Mercurial > emacs
annotate src/coding.c @ 87178:81d86af942c9
Add minimal Gnus item.
author | Reiner Steib <Reiner.Steib@gmx.de> |
---|---|
date | Sat, 08 Dec 2007 14:29:18 +0000 |
parents | 8e5b337fea59 |
children | 107ccd98fa12 |
rev | line source |
---|---|
17052 | 1 /* Coding system handler (conversion, detection, and etc). |
68651
3bd95f4f2941
Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
68567
diff
changeset
|
2 Copyright (C) 2001, 2002, 2003, 2004, 2005, |
75348 | 3 2006, 2007 Free Software Foundation, Inc. |
74605
6ee41fdd69ff
Update AIST copyright years.
Kenichi Handa <handa@m17n.org>
parents:
73995
diff
changeset
|
4 Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, |
75348 | 5 2005, 2006, 2007 |
67658 | 6 National Institute of Advanced Industrial Science and Technology (AIST) |
7 Registration Number H14PRO021 | |
17052 | 8 |
17071 | 9 This file is part of GNU Emacs. |
10 | |
11 GNU Emacs is free software; you can redistribute it and/or modify | |
12 it under the terms of the GNU General Public License as published by | |
78313
2b9404c2f01f
Remove license from trivial file.
Glenn Morris <rgm@gnu.org>
parents:
78152
diff
changeset
|
13 the Free Software Foundation; either version 3, or (at your option) |
17071 | 14 any later version. |
15 | |
16 GNU Emacs is distributed in the hope that it will be useful, | |
17 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
19 GNU General Public License for more details. | |
20 | |
21 You should have received a copy of the GNU General Public License | |
22 along with GNU Emacs; see the file COPYING. If not, write to | |
64084 | 23 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
24 Boston, MA 02110-1301, USA. */ | |
17052 | 25 |
26 /*** TABLE OF CONTENTS *** | |
27 | |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
28 0. General comments |
17052 | 29 1. Preamble |
17835
f36ffb6f1208
Name change through the code:
Kenichi Handa <handa@m17n.org>
parents:
17725
diff
changeset
|
30 2. Emacs' internal format (emacs-mule) handlers |
17052 | 31 3. ISO2022 handlers |
32 4. Shift-JIS and BIG5 handlers | |
22874
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
33 5. CCL handlers |
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
34 6. End-of-line handlers |
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
35 7. C library functions |
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
36 8. Emacs Lisp library functions |
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
37 9. Post-amble |
17052 | 38 |
39 */ | |
40 | |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
41 /*** 0. General comments ***/ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
42 |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
43 |
35053 | 44 /*** GENERAL NOTE on CODING SYSTEMS *** |
45 | |
46 A coding system is an encoding mechanism for one or more character | |
17052 | 47 sets. Here's a list of coding systems which Emacs can handle. When |
48 we say "decode", it means converting some other coding system to | |
35053 | 49 Emacs' internal format (emacs-mule), and when we say "encode", |
17835
f36ffb6f1208
Name change through the code:
Kenichi Handa <handa@m17n.org>
parents:
17725
diff
changeset
|
50 it means converting the coding system emacs-mule to some other |
f36ffb6f1208
Name change through the code:
Kenichi Handa <handa@m17n.org>
parents:
17725
diff
changeset
|
51 coding system. |
f36ffb6f1208
Name change through the code:
Kenichi Handa <handa@m17n.org>
parents:
17725
diff
changeset
|
52 |
f36ffb6f1208
Name change through the code:
Kenichi Handa <handa@m17n.org>
parents:
17725
diff
changeset
|
53 0. Emacs' internal format (emacs-mule) |
17052 | 54 |
35053 | 55 Emacs itself holds a multi-lingual character in buffers and strings |
18766 | 56 in a special format. Details are described in section 2. |
17052 | 57 |
58 1. ISO2022 | |
59 | |
60 The most famous coding system for multiple character sets. X's | |
18766 | 61 Compound Text, various EUCs (Extended Unix Code), and coding |
62 systems used in Internet communication such as ISO-2022-JP are | |
63 all variants of ISO2022. Details are described in section 3. | |
17052 | 64 |
65 2. SJIS (or Shift-JIS or MS-Kanji-Code) | |
42104
d69c2368e549
(DECODE_COMPOSITION_END): Fixed a typo in the last
Sam Steingold <sds@gnu.org>
parents:
42103
diff
changeset
|
66 |
17052 | 67 A coding system to encode character sets: ASCII, JISX0201, and |
68 JISX0208. Widely used for PC's in Japan. Details are described in | |
18766 | 69 section 4. |
17052 | 70 |
71 3. BIG5 | |
72 | |
35053 | 73 A coding system to encode the character sets ASCII and Big5. Widely |
74 used for Chinese (mainly in Taiwan and Hong Kong). Details are | |
18766 | 75 described in section 4. In this file, when we write "BIG5" |
76 (all uppercase), we mean the coding system, and when we write | |
77 "Big5" (capitalized), we mean the character set. | |
78 | |
19612
783efd6c7c1e
(Qno_conversion, Qundecided): New variables.
Kenichi Handa <handa@m17n.org>
parents:
19546
diff
changeset
|
79 4. Raw text |
783efd6c7c1e
(Qno_conversion, Qundecided): New variables.
Kenichi Handa <handa@m17n.org>
parents:
19546
diff
changeset
|
80 |
35053 | 81 A coding system for text containing random 8-bit code. Emacs does |
82 no code conversion on such text except for end-of-line format. | |
19612
783efd6c7c1e
(Qno_conversion, Qundecided): New variables.
Kenichi Handa <handa@m17n.org>
parents:
19546
diff
changeset
|
83 |
783efd6c7c1e
(Qno_conversion, Qundecided): New variables.
Kenichi Handa <handa@m17n.org>
parents:
19546
diff
changeset
|
84 5. Other |
18766 | 85 |
35053 | 86 If a user wants to read/write text encoded in a coding system not |
87 listed above, he can supply a decoder and an encoder for it as CCL | |
17052 | 88 (Code Conversion Language) programs. Emacs executes the CCL program |
89 while reading/writing. | |
90 | |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
91 Emacs represents a coding system by a Lisp symbol that has a property |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
92 `coding-system'. But, before actually using the coding system, the |
17052 | 93 information about it is set in a structure of type `struct |
18766 | 94 coding_system' for rapid processing. See section 6 for more details. |
17052 | 95 |
96 */ | |
97 | |
98 /*** GENERAL NOTES on END-OF-LINE FORMAT *** | |
99 | |
35053 | 100 How end-of-line of text is encoded depends on the operating system. |
101 For instance, Unix's format is just one byte of `line-feed' code, | |
18766 | 102 whereas DOS's format is two-byte sequence of `carriage-return' and |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
103 `line-feed' codes. MacOS's format is usually one byte of |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
104 `carriage-return'. |
17052 | 105 |
35053 | 106 Since text character encoding and end-of-line encoding are |
107 independent, any coding system described above can have any | |
108 end-of-line format. So Emacs has information about end-of-line | |
109 format in each coding-system. See section 6 for more details. | |
17052 | 110 |
111 */ | |
112 | |
113 /*** GENERAL NOTES on `detect_coding_XXX ()' functions *** | |
114 | |
115 These functions check if a text between SRC and SRC_END is encoded | |
116 in the coding system category XXX. Each returns an integer value in | |
35053 | 117 which appropriate flag bits for the category XXX are set. The flag |
17052 | 118 bits are defined in macros CODING_CATEGORY_MASK_XXX. Below is the |
35053 | 119 template for these functions. If MULTIBYTEP is nonzero, 8-bit codes |
34531
37f85e931855
(ONE_MORE_BYTE_CHECK_MULTIBYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34197
diff
changeset
|
120 of the range 0x80..0x9F are in multibyte form. */ |
17052 | 121 #if 0 |
122 int | |
34531
37f85e931855
(ONE_MORE_BYTE_CHECK_MULTIBYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34197
diff
changeset
|
123 detect_coding_emacs_mule (src, src_end, multibytep) |
17052 | 124 unsigned char *src, *src_end; |
34531
37f85e931855
(ONE_MORE_BYTE_CHECK_MULTIBYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34197
diff
changeset
|
125 int multibytep; |
17052 | 126 { |
127 ... | |
128 } | |
129 #endif | |
130 | |
131 /*** GENERAL NOTES on `decode_coding_XXX ()' functions *** | |
132 | |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
133 These functions decode SRC_BYTES length of unibyte text at SOURCE |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
134 encoded in CODING to Emacs' internal format. The resulting |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
135 multibyte text goes to a place pointed to by DESTINATION, the length |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
136 of which should not exceed DST_BYTES. |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
137 |
35053 | 138 These functions set the information about original and decoded texts |
139 in the members `produced', `produced_char', `consumed', and | |
140 `consumed_char' of the structure *CODING. They also set the member | |
141 `result' to one of CODING_FINISH_XXX indicating how the decoding | |
142 finished. | |
143 | |
144 DST_BYTES zero means that the source area and destination area are | |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
145 overlapped, which means that we can produce a decoded text until it |
35053 | 146 reaches the head of the not-yet-decoded source text. |
147 | |
148 Below is a template for these functions. */ | |
17052 | 149 #if 0 |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
150 static void |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
151 decode_coding_XXX (coding, source, destination, src_bytes, dst_bytes) |
17052 | 152 struct coding_system *coding; |
59168
0345f2b10f1d
(decode_coding_XXX, decode_composition_emacs_mule)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
59095
diff
changeset
|
153 const unsigned char *source; |
0345f2b10f1d
(decode_coding_XXX, decode_composition_emacs_mule)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
59095
diff
changeset
|
154 unsigned char *destination; |
17052 | 155 int src_bytes, dst_bytes; |
156 { | |
157 ... | |
158 } | |
159 #endif | |
160 | |
161 /*** GENERAL NOTES on `encode_coding_XXX ()' functions *** | |
162 | |
35053 | 163 These functions encode SRC_BYTES length text at SOURCE from Emacs' |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
164 internal multibyte format to CODING. The resulting unibyte text |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
165 goes to a place pointed to by DESTINATION, the length of which |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
166 should not exceed DST_BYTES. |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
167 |
35053 | 168 These functions set the information about original and encoded texts |
169 in the members `produced', `produced_char', `consumed', and | |
170 `consumed_char' of the structure *CODING. They also set the member | |
171 `result' to one of CODING_FINISH_XXX indicating how the encoding | |
172 finished. | |
173 | |
174 DST_BYTES zero means that the source area and destination area are | |
175 overlapped, which means that we can produce encoded text until it | |
176 reaches at the head of the not-yet-encoded source text. | |
177 | |
178 Below is a template for these functions. */ | |
17052 | 179 #if 0 |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
180 static void |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
181 encode_coding_XXX (coding, source, destination, src_bytes, dst_bytes) |
17052 | 182 struct coding_system *coding; |
183 unsigned char *source, *destination; | |
184 int src_bytes, dst_bytes; | |
185 { | |
186 ... | |
187 } | |
188 #endif | |
189 | |
190 /*** COMMONLY USED MACROS ***/ | |
191 | |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
192 /* The following two macros ONE_MORE_BYTE and TWO_MORE_BYTES safely |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
193 get one, two, and three bytes from the source text respectively. |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
194 If there are not enough bytes in the source, they jump to |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
195 `label_end_of_loop'. The caller should set variables `coding', |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
196 `src' and `src_end' to appropriate pointer in advance. These |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
197 macros are called from decoding routines `decode_coding_XXX', thus |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
198 it is assumed that the source text is unibyte. */ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
199 |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
200 #define ONE_MORE_BYTE(c1) \ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
201 do { \ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
202 if (src >= src_end) \ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
203 { \ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
204 coding->result = CODING_FINISH_INSUFFICIENT_SRC; \ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
205 goto label_end_of_loop; \ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
206 } \ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
207 c1 = *src++; \ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
208 } while (0) |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
209 |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
210 #define TWO_MORE_BYTES(c1, c2) \ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
211 do { \ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
212 if (src + 1 >= src_end) \ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
213 { \ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
214 coding->result = CODING_FINISH_INSUFFICIENT_SRC; \ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
215 goto label_end_of_loop; \ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
216 } \ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
217 c1 = *src++; \ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
218 c2 = *src++; \ |
17052 | 219 } while (0) |
220 | |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
221 |
34531
37f85e931855
(ONE_MORE_BYTE_CHECK_MULTIBYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34197
diff
changeset
|
222 /* Like ONE_MORE_BYTE, but 8-bit bytes of data at SRC are in multibyte |
72395
94e4795b333d
(ONE_MORE_BYTE_CHECK_MULTIBYTE): New arg RET. If SRC
Kenichi Handa <handa@m17n.org>
parents:
72323
diff
changeset
|
223 form if MULTIBYTEP is nonzero. In addition, if SRC is not less |
94e4795b333d
(ONE_MORE_BYTE_CHECK_MULTIBYTE): New arg RET. If SRC
Kenichi Handa <handa@m17n.org>
parents:
72323
diff
changeset
|
224 than SRC_END, return with RET. */ |
94e4795b333d
(ONE_MORE_BYTE_CHECK_MULTIBYTE): New arg RET. If SRC
Kenichi Handa <handa@m17n.org>
parents:
72323
diff
changeset
|
225 |
94e4795b333d
(ONE_MORE_BYTE_CHECK_MULTIBYTE): New arg RET. If SRC
Kenichi Handa <handa@m17n.org>
parents:
72323
diff
changeset
|
226 #define ONE_MORE_BYTE_CHECK_MULTIBYTE(c1, multibytep, ret) \ |
34531
37f85e931855
(ONE_MORE_BYTE_CHECK_MULTIBYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34197
diff
changeset
|
227 do { \ |
37f85e931855
(ONE_MORE_BYTE_CHECK_MULTIBYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34197
diff
changeset
|
228 if (src >= src_end) \ |
37f85e931855
(ONE_MORE_BYTE_CHECK_MULTIBYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34197
diff
changeset
|
229 { \ |
37f85e931855
(ONE_MORE_BYTE_CHECK_MULTIBYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34197
diff
changeset
|
230 coding->result = CODING_FINISH_INSUFFICIENT_SRC; \ |
72395
94e4795b333d
(ONE_MORE_BYTE_CHECK_MULTIBYTE): New arg RET. If SRC
Kenichi Handa <handa@m17n.org>
parents:
72323
diff
changeset
|
231 return ret; \ |
34531
37f85e931855
(ONE_MORE_BYTE_CHECK_MULTIBYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34197
diff
changeset
|
232 } \ |
37f85e931855
(ONE_MORE_BYTE_CHECK_MULTIBYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34197
diff
changeset
|
233 c1 = *src++; \ |
37f85e931855
(ONE_MORE_BYTE_CHECK_MULTIBYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34197
diff
changeset
|
234 if (multibytep && c1 == LEADING_CODE_8_BIT_CONTROL) \ |
37f85e931855
(ONE_MORE_BYTE_CHECK_MULTIBYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34197
diff
changeset
|
235 c1 = *src++ - 0x20; \ |
37f85e931855
(ONE_MORE_BYTE_CHECK_MULTIBYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34197
diff
changeset
|
236 } while (0) |
37f85e931855
(ONE_MORE_BYTE_CHECK_MULTIBYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34197
diff
changeset
|
237 |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
238 /* Set C to the next character at the source text pointed by `src'. |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
239 If there are not enough characters in the source, jump to |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
240 `label_end_of_loop'. The caller should set variables `coding' |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
241 `src', `src_end', and `translation_table' to appropriate pointers |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
242 in advance. This macro is used in encoding routines |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
243 `encode_coding_XXX', thus it assumes that the source text is in |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
244 multibyte form except for 8-bit characters. 8-bit characters are |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
245 in multibyte form if coding->src_multibyte is nonzero, else they |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
246 are represented by a single byte. */ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
247 |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
248 #define ONE_MORE_CHAR(c) \ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
249 do { \ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
250 int len = src_end - src; \ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
251 int bytes; \ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
252 if (len <= 0) \ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
253 { \ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
254 coding->result = CODING_FINISH_INSUFFICIENT_SRC; \ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
255 goto label_end_of_loop; \ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
256 } \ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
257 if (coding->src_multibyte \ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
258 || UNIBYTE_STR_AS_MULTIBYTE_P (src, len, bytes)) \ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
259 c = STRING_CHAR_AND_LENGTH (src, len, bytes); \ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
260 else \ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
261 c = *src, bytes = 1; \ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
262 if (!NILP (translation_table)) \ |
31455
0b33b8c5d16e
(encode_coding_sjis_big5): Use translation table for
Kenichi Handa <handa@m17n.org>
parents:
31123
diff
changeset
|
263 c = translate_char (translation_table, c, -1, 0, 0); \ |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
264 src += bytes; \ |
17052 | 265 } while (0) |
266 | |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
267 |
36087 | 268 /* Produce a multibyte form of character C to `dst'. Jump to |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
269 `label_end_of_loop' if there's not enough space at `dst'. |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
270 |
35053 | 271 If we are now in the middle of a composition sequence, the decoded |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
272 character may be ALTCHAR (for the current composition). In that |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
273 case, the character goes to coding->cmp_data->data instead of |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
274 `dst'. |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
275 |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
276 This macro is used in decoding routines. */ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
277 |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
278 #define EMIT_CHAR(c) \ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
279 do { \ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
280 if (! COMPOSING_P (coding) \ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
281 || coding->composing == COMPOSITION_RELATIVE \ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
282 || coding->composing == COMPOSITION_WITH_RULE) \ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
283 { \ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
284 int bytes = CHAR_BYTES (c); \ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
285 if ((dst + bytes) > (dst_bytes ? dst_end : src)) \ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
286 { \ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
287 coding->result = CODING_FINISH_INSUFFICIENT_DST; \ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
288 goto label_end_of_loop; \ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
289 } \ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
290 dst += CHAR_STRING (c, dst); \ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
291 coding->produced_char++; \ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
292 } \ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
293 \ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
294 if (COMPOSING_P (coding) \ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
295 && coding->composing != COMPOSITION_RELATIVE) \ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
296 { \ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
297 CODING_ADD_COMPOSITION_COMPONENT (coding, c); \ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
298 coding->composition_rule_follows \ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
299 = coding->composing != COMPOSITION_WITH_ALTCHARS; \ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
300 } \ |
17052 | 301 } while (0) |
302 | |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
303 |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
304 #define EMIT_ONE_BYTE(c) \ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
305 do { \ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
306 if (dst >= (dst_bytes ? dst_end : src)) \ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
307 { \ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
308 coding->result = CODING_FINISH_INSUFFICIENT_DST; \ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
309 goto label_end_of_loop; \ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
310 } \ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
311 *dst++ = c; \ |
17052 | 312 } while (0) |
313 | |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
314 #define EMIT_TWO_BYTES(c1, c2) \ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
315 do { \ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
316 if (dst + 2 > (dst_bytes ? dst_end : src)) \ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
317 { \ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
318 coding->result = CODING_FINISH_INSUFFICIENT_DST; \ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
319 goto label_end_of_loop; \ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
320 } \ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
321 *dst++ = c1, *dst++ = c2; \ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
322 } while (0) |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
323 |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
324 #define EMIT_BYTES(from, to) \ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
325 do { \ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
326 if (dst + (to - from) > (dst_bytes ? dst_end : src)) \ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
327 { \ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
328 coding->result = CODING_FINISH_INSUFFICIENT_DST; \ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
329 goto label_end_of_loop; \ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
330 } \ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
331 while (from < to) \ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
332 *dst++ = *from++; \ |
17052 | 333 } while (0) |
334 | |
335 | |
336 /*** 1. Preamble ***/ | |
337 | |
26088
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
26067
diff
changeset
|
338 #ifdef emacs |
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
26067
diff
changeset
|
339 #include <config.h> |
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
26067
diff
changeset
|
340 #endif |
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
26067
diff
changeset
|
341 |
17052 | 342 #include <stdio.h> |
343 | |
344 #ifdef emacs | |
345 | |
346 #include "lisp.h" | |
347 #include "buffer.h" | |
348 #include "charset.h" | |
26847 | 349 #include "composite.h" |
17052 | 350 #include "ccl.h" |
351 #include "coding.h" | |
352 #include "window.h" | |
51855
1d29dcb76e2b
Include intervals.h for Fset_text_properties.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51842
diff
changeset
|
353 #include "intervals.h" |
83127
5182815e0ee1
Make terminal_coding and keyboard_coding display-local.
Karoly Lorentey <lorentey@elte.hu>
parents:
54320
diff
changeset
|
354 #include "frame.h" |
5182815e0ee1
Make terminal_coding and keyboard_coding display-local.
Karoly Lorentey <lorentey@elte.hu>
parents:
54320
diff
changeset
|
355 #include "termhooks.h" |
17052 | 356 |
357 #else /* not emacs */ | |
358 | |
359 #include "mulelib.h" | |
360 | |
361 #endif /* not emacs */ | |
362 | |
363 Lisp_Object Qcoding_system, Qeol_type; | |
364 Lisp_Object Qbuffer_file_coding_system; | |
365 Lisp_Object Qpost_read_conversion, Qpre_write_conversion; | |
19612
783efd6c7c1e
(Qno_conversion, Qundecided): New variables.
Kenichi Handa <handa@m17n.org>
parents:
19546
diff
changeset
|
366 Lisp_Object Qno_conversion, Qundecided; |
19750
95e4e1cba6ac
(Qcoding_system_history): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
19747
diff
changeset
|
367 Lisp_Object Qcoding_system_history; |
30487
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
368 Lisp_Object Qsafe_chars; |
22874
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
369 Lisp_Object Qvalid_codes; |
70704
576f5c8ea6e4
(Qascii_incompatible): New variable.
Kenichi Handa <handa@m17n.org>
parents:
70520
diff
changeset
|
370 Lisp_Object Qascii_incompatible; |
17052 | 371 |
372 extern Lisp_Object Qinsert_file_contents, Qwrite_region; | |
64251
3de1b955c31a
* coding.c (Qprocess_argument):
Kim F. Storm <storm@cua.dk>
parents:
64084
diff
changeset
|
373 Lisp_Object Qcall_process, Qcall_process_region; |
17052 | 374 Lisp_Object Qstart_process, Qopen_network_stream; |
375 Lisp_Object Qtarget_idx; | |
376 | |
85332
bb808ca35bd9
(Qcompletion_ignore_case): New external Lisp_Object.
Glenn Morris <rgm@gnu.org>
parents:
85330
diff
changeset
|
377 extern Lisp_Object Qcompletion_ignore_case; |
bb808ca35bd9
(Qcompletion_ignore_case): New external Lisp_Object.
Glenn Morris <rgm@gnu.org>
parents:
85330
diff
changeset
|
378 |
52794
f4d906e31662
(Qcoding_system_define_form): New variable.
Kenichi Handa <handa@m17n.org>
parents:
52401
diff
changeset
|
379 /* If a symbol has this property, evaluate the value to define the |
f4d906e31662
(Qcoding_system_define_form): New variable.
Kenichi Handa <handa@m17n.org>
parents:
52401
diff
changeset
|
380 symbol as a coding system. */ |
f4d906e31662
(Qcoding_system_define_form): New variable.
Kenichi Handa <handa@m17n.org>
parents:
52401
diff
changeset
|
381 Lisp_Object Qcoding_system_define_form; |
f4d906e31662
(Qcoding_system_define_form): New variable.
Kenichi Handa <handa@m17n.org>
parents:
52401
diff
changeset
|
382 |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
383 Lisp_Object Vselect_safe_coding_system_function; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
384 |
48874
3002a87cc629
(coding_system_require_warning): New variable.
Kenichi Handa <handa@m17n.org>
parents:
48829
diff
changeset
|
385 int coding_system_require_warning; |
3002a87cc629
(coding_system_require_warning): New variable.
Kenichi Handa <handa@m17n.org>
parents:
48829
diff
changeset
|
386 |
24200
b9d9fccad516
(syms_of_coding): eol-mnemonic-* variables are now
Eli Zaretskii <eliz@gnu.org>
parents:
24178
diff
changeset
|
387 /* Mnemonic string for each format of end-of-line. */ |
b9d9fccad516
(syms_of_coding): eol-mnemonic-* variables are now
Eli Zaretskii <eliz@gnu.org>
parents:
24178
diff
changeset
|
388 Lisp_Object eol_mnemonic_unix, eol_mnemonic_dos, eol_mnemonic_mac; |
b9d9fccad516
(syms_of_coding): eol-mnemonic-* variables are now
Eli Zaretskii <eliz@gnu.org>
parents:
24178
diff
changeset
|
389 /* Mnemonic string to indicate format of end-of-line is not yet |
17052 | 390 decided. */ |
24200
b9d9fccad516
(syms_of_coding): eol-mnemonic-* variables are now
Eli Zaretskii <eliz@gnu.org>
parents:
24178
diff
changeset
|
391 Lisp_Object eol_mnemonic_undecided; |
17052 | 392 |
18650
aa3f2820e2ac
(Qemacs_mule, inhibit_eol_conversion): New variables.
Kenichi Handa <handa@m17n.org>
parents:
18613
diff
changeset
|
393 /* Format of end-of-line decided by system. This is CODING_EOL_LF on |
70520
b6740a317343
(setup_coding_system): For invalid coding-system, set
Kenichi Handa <handa@m17n.org>
parents:
69995
diff
changeset
|
394 Unix, CODING_EOL_CRLF on DOS/Windows, and CODING_EOL_CR on Mac. |
b6740a317343
(setup_coding_system): For invalid coding-system, set
Kenichi Handa <handa@m17n.org>
parents:
69995
diff
changeset
|
395 This has an effect only for external encoding (i.e. for output to |
b6740a317343
(setup_coding_system): For invalid coding-system, set
Kenichi Handa <handa@m17n.org>
parents:
69995
diff
changeset
|
396 file and process), not for in-buffer or Lisp string encoding. */ |
18650
aa3f2820e2ac
(Qemacs_mule, inhibit_eol_conversion): New variables.
Kenichi Handa <handa@m17n.org>
parents:
18613
diff
changeset
|
397 int system_eol_type; |
aa3f2820e2ac
(Qemacs_mule, inhibit_eol_conversion): New variables.
Kenichi Handa <handa@m17n.org>
parents:
18613
diff
changeset
|
398 |
17052 | 399 #ifdef emacs |
400 | |
49539
1ad5bfbb831a
(syms_of_coding): Add `...' for symbols in the docstring of
Kenichi Handa <handa@m17n.org>
parents:
48874
diff
changeset
|
401 /* Information about which coding system is safe for which chars. |
1ad5bfbb831a
(syms_of_coding): Add `...' for symbols in the docstring of
Kenichi Handa <handa@m17n.org>
parents:
48874
diff
changeset
|
402 The value has the form (GENERIC-LIST . NON-GENERIC-ALIST). |
1ad5bfbb831a
(syms_of_coding): Add `...' for symbols in the docstring of
Kenichi Handa <handa@m17n.org>
parents:
48874
diff
changeset
|
403 |
1ad5bfbb831a
(syms_of_coding): Add `...' for symbols in the docstring of
Kenichi Handa <handa@m17n.org>
parents:
48874
diff
changeset
|
404 GENERIC-LIST is a list of generic coding systems which can encode |
1ad5bfbb831a
(syms_of_coding): Add `...' for symbols in the docstring of
Kenichi Handa <handa@m17n.org>
parents:
48874
diff
changeset
|
405 any characters. |
1ad5bfbb831a
(syms_of_coding): Add `...' for symbols in the docstring of
Kenichi Handa <handa@m17n.org>
parents:
48874
diff
changeset
|
406 |
1ad5bfbb831a
(syms_of_coding): Add `...' for symbols in the docstring of
Kenichi Handa <handa@m17n.org>
parents:
48874
diff
changeset
|
407 NON-GENERIC-ALIST is an alist of non generic coding systems vs the |
1ad5bfbb831a
(syms_of_coding): Add `...' for symbols in the docstring of
Kenichi Handa <handa@m17n.org>
parents:
48874
diff
changeset
|
408 corresponding char table that contains safe chars. */ |
1ad5bfbb831a
(syms_of_coding): Add `...' for symbols in the docstring of
Kenichi Handa <handa@m17n.org>
parents:
48874
diff
changeset
|
409 Lisp_Object Vcoding_system_safe_chars; |
1ad5bfbb831a
(syms_of_coding): Add `...' for symbols in the docstring of
Kenichi Handa <handa@m17n.org>
parents:
48874
diff
changeset
|
410 |
20105
c017642863c2
(Qcoding_system_spec): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
19824
diff
changeset
|
411 Lisp_Object Vcoding_system_list, Vcoding_system_alist; |
c017642863c2
(Qcoding_system_spec): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
19824
diff
changeset
|
412 |
c017642863c2
(Qcoding_system_spec): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
19824
diff
changeset
|
413 Lisp_Object Qcoding_system_p, Qcoding_system_error; |
17052 | 414 |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
415 /* Coding system emacs-mule and raw-text are for converting only |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
416 end-of-line format. */ |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
417 Lisp_Object Qemacs_mule, Qraw_text; |
18650
aa3f2820e2ac
(Qemacs_mule, inhibit_eol_conversion): New variables.
Kenichi Handa <handa@m17n.org>
parents:
18613
diff
changeset
|
418 |
51406 | 419 Lisp_Object Qutf_8; |
420 | |
17052 | 421 /* Coding-systems are handed between Emacs Lisp programs and C internal |
422 routines by the following three variables. */ | |
423 /* Coding-system for reading files and receiving data from process. */ | |
424 Lisp_Object Vcoding_system_for_read; | |
425 /* Coding-system for writing files and sending data to process. */ | |
426 Lisp_Object Vcoding_system_for_write; | |
427 /* Coding-system actually used in the latest I/O. */ | |
428 Lisp_Object Vlast_coding_system_used; | |
429 | |
19280
e755044718ee
(ENCODE_ISO_CHARACTER_DIMENSION1): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
19193
diff
changeset
|
430 /* A vector of length 256 which contains information about special |
22529 | 431 Latin codes (especially for dealing with Microsoft codes). */ |
19365
d9374f5ebd3a
(CODING_FLAG_ISO_LATIN_EXTRA): New macro.
Kenichi Handa <handa@m17n.org>
parents:
19285
diff
changeset
|
432 Lisp_Object Vlatin_extra_code_table; |
19280
e755044718ee
(ENCODE_ISO_CHARACTER_DIMENSION1): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
19193
diff
changeset
|
433 |
18650
aa3f2820e2ac
(Qemacs_mule, inhibit_eol_conversion): New variables.
Kenichi Handa <handa@m17n.org>
parents:
18613
diff
changeset
|
434 /* Flag to inhibit code conversion of end-of-line format. */ |
aa3f2820e2ac
(Qemacs_mule, inhibit_eol_conversion): New variables.
Kenichi Handa <handa@m17n.org>
parents:
18613
diff
changeset
|
435 int inhibit_eol_conversion; |
aa3f2820e2ac
(Qemacs_mule, inhibit_eol_conversion): New variables.
Kenichi Handa <handa@m17n.org>
parents:
18613
diff
changeset
|
436 |
30204
35aec8514228
(inhibit_iso_escape_detection): New variable.
Kenichi Handa <handa@m17n.org>
parents:
29985
diff
changeset
|
437 /* Flag to inhibit ISO2022 escape sequence detection. */ |
35aec8514228
(inhibit_iso_escape_detection): New variable.
Kenichi Handa <handa@m17n.org>
parents:
29985
diff
changeset
|
438 int inhibit_iso_escape_detection; |
35aec8514228
(inhibit_iso_escape_detection): New variable.
Kenichi Handa <handa@m17n.org>
parents:
29985
diff
changeset
|
439 |
21574
30394e3ae7f8
(syms_of_coding): Declare and define inherit-process-coding-system.
Eli Zaretskii <eliz@gnu.org>
parents:
21520
diff
changeset
|
440 /* Flag to make buffer-file-coding-system inherit from process-coding. */ |
30394e3ae7f8
(syms_of_coding): Declare and define inherit-process-coding-system.
Eli Zaretskii <eliz@gnu.org>
parents:
21520
diff
changeset
|
441 int inherit_process_coding_system; |
30394e3ae7f8
(syms_of_coding): Declare and define inherit-process-coding-system.
Eli Zaretskii <eliz@gnu.org>
parents:
21520
diff
changeset
|
442 |
19280
e755044718ee
(ENCODE_ISO_CHARACTER_DIMENSION1): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
19193
diff
changeset
|
443 /* Coding system to be used to encode text for terminal display when |
e755044718ee
(ENCODE_ISO_CHARACTER_DIMENSION1): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
19193
diff
changeset
|
444 terminal coding system is nil. */ |
e755044718ee
(ENCODE_ISO_CHARACTER_DIMENSION1): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
19193
diff
changeset
|
445 struct coding_system safe_terminal_coding; |
e755044718ee
(ENCODE_ISO_CHARACTER_DIMENSION1): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
19193
diff
changeset
|
446 |
22979
ceb8e4a89a32
(default_buffer_file_coding): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22964
diff
changeset
|
447 /* Default coding system to be used to write a file. */ |
ceb8e4a89a32
(default_buffer_file_coding): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22964
diff
changeset
|
448 struct coding_system default_buffer_file_coding; |
ceb8e4a89a32
(default_buffer_file_coding): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22964
diff
changeset
|
449 |
18180
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
450 Lisp_Object Vfile_coding_system_alist; |
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
451 Lisp_Object Vprocess_coding_system_alist; |
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
452 Lisp_Object Vnetwork_coding_system_alist; |
17052 | 453 |
26088
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
26067
diff
changeset
|
454 Lisp_Object Vlocale_coding_system; |
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
26067
diff
changeset
|
455 |
17052 | 456 #endif /* emacs */ |
457 | |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
458 Lisp_Object Qcoding_category, Qcoding_category_index; |
17052 | 459 |
460 /* List of symbols `coding-category-xxx' ordered by priority. */ | |
461 Lisp_Object Vcoding_category_list; | |
462 | |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
463 /* Table of coding categories (Lisp symbols). */ |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
464 Lisp_Object Vcoding_category_table; |
17052 | 465 |
466 /* Table of names of symbol for each coding-category. */ | |
467 char *coding_category_name[CODING_CATEGORY_IDX_MAX] = { | |
17835
f36ffb6f1208
Name change through the code:
Kenichi Handa <handa@m17n.org>
parents:
17725
diff
changeset
|
468 "coding-category-emacs-mule", |
17052 | 469 "coding-category-sjis", |
470 "coding-category-iso-7", | |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
471 "coding-category-iso-7-tight", |
17052 | 472 "coding-category-iso-8-1", |
473 "coding-category-iso-8-2", | |
18787
954e6be0a757
(detect_coding_iso2022): Distinguish coding-category-iso-7-else and
Kenichi Handa <handa@m17n.org>
parents:
18766
diff
changeset
|
474 "coding-category-iso-7-else", |
954e6be0a757
(detect_coding_iso2022): Distinguish coding-category-iso-7-else and
Kenichi Handa <handa@m17n.org>
parents:
18766
diff
changeset
|
475 "coding-category-iso-8-else", |
23027
0dc823b2335f
(coding_category_name): Fix the order of initial
Kenichi Handa <handa@m17n.org>
parents:
22979
diff
changeset
|
476 "coding-category-ccl", |
17052 | 477 "coding-category-big5", |
28022
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
478 "coding-category-utf-8", |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
479 "coding-category-utf-16-be", |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
480 "coding-category-utf-16-le", |
19612
783efd6c7c1e
(Qno_conversion, Qundecided): New variables.
Kenichi Handa <handa@m17n.org>
parents:
19546
diff
changeset
|
481 "coding-category-raw-text", |
23027
0dc823b2335f
(coding_category_name): Fix the order of initial
Kenichi Handa <handa@m17n.org>
parents:
22979
diff
changeset
|
482 "coding-category-binary" |
17052 | 483 }; |
484 | |
22226
557fac086b1b
(ascii_skip_code): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22186
diff
changeset
|
485 /* Table of pointers to coding systems corresponding to each coding |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
486 categories. */ |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
487 struct coding_system *coding_system_table[CODING_CATEGORY_IDX_MAX]; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
488 |
22226
557fac086b1b
(ascii_skip_code): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22186
diff
changeset
|
489 /* Table of coding category masks. Nth element is a mask for a coding |
36087 | 490 category of which priority is Nth. */ |
22226
557fac086b1b
(ascii_skip_code): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22186
diff
changeset
|
491 static |
557fac086b1b
(ascii_skip_code): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22186
diff
changeset
|
492 int coding_priorities[CODING_CATEGORY_IDX_MAX]; |
557fac086b1b
(ascii_skip_code): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22186
diff
changeset
|
493 |
22186
fc4aaf1b1772
Change term "character translation table" to "translation table".
Kenichi Handa <handa@m17n.org>
parents:
22166
diff
changeset
|
494 /* Flag to tell if we look up translation table on character code |
fc4aaf1b1772
Change term "character translation table" to "translation table".
Kenichi Handa <handa@m17n.org>
parents:
22166
diff
changeset
|
495 conversion. */ |
22119
592bb8b9bcfd
Change terms unify/unification to
Kenichi Handa <handa@m17n.org>
parents:
22020
diff
changeset
|
496 Lisp_Object Venable_character_translation; |
22186
fc4aaf1b1772
Change term "character translation table" to "translation table".
Kenichi Handa <handa@m17n.org>
parents:
22166
diff
changeset
|
497 /* Standard translation table to look up on decoding (reading). */ |
fc4aaf1b1772
Change term "character translation table" to "translation table".
Kenichi Handa <handa@m17n.org>
parents:
22166
diff
changeset
|
498 Lisp_Object Vstandard_translation_table_for_decode; |
fc4aaf1b1772
Change term "character translation table" to "translation table".
Kenichi Handa <handa@m17n.org>
parents:
22166
diff
changeset
|
499 /* Standard translation table to look up on encoding (writing). */ |
fc4aaf1b1772
Change term "character translation table" to "translation table".
Kenichi Handa <handa@m17n.org>
parents:
22166
diff
changeset
|
500 Lisp_Object Vstandard_translation_table_for_encode; |
fc4aaf1b1772
Change term "character translation table" to "translation table".
Kenichi Handa <handa@m17n.org>
parents:
22166
diff
changeset
|
501 |
fc4aaf1b1772
Change term "character translation table" to "translation table".
Kenichi Handa <handa@m17n.org>
parents:
22166
diff
changeset
|
502 Lisp_Object Qtranslation_table; |
fc4aaf1b1772
Change term "character translation table" to "translation table".
Kenichi Handa <handa@m17n.org>
parents:
22166
diff
changeset
|
503 Lisp_Object Qtranslation_table_id; |
fc4aaf1b1772
Change term "character translation table" to "translation table".
Kenichi Handa <handa@m17n.org>
parents:
22166
diff
changeset
|
504 Lisp_Object Qtranslation_table_for_decode; |
fc4aaf1b1772
Change term "character translation table" to "translation table".
Kenichi Handa <handa@m17n.org>
parents:
22166
diff
changeset
|
505 Lisp_Object Qtranslation_table_for_encode; |
17052 | 506 |
507 /* Alist of charsets vs revision number. */ | |
508 Lisp_Object Vcharset_revision_alist; | |
509 | |
18180
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
510 /* Default coding systems used for process I/O. */ |
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
511 Lisp_Object Vdefault_process_coding_system; |
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
512 |
48182
9474e269efd1
Reformat some DEFUNs so that etags works.
Dave Love <fx@gnu.org>
parents:
48125
diff
changeset
|
513 /* Char table for translating Quail and self-inserting input. */ |
9474e269efd1
Reformat some DEFUNs so that etags works.
Dave Love <fx@gnu.org>
parents:
48125
diff
changeset
|
514 Lisp_Object Vtranslation_table_for_input; |
9474e269efd1
Reformat some DEFUNs so that etags works.
Dave Love <fx@gnu.org>
parents:
48125
diff
changeset
|
515 |
26067
f54ca66e2571
(code_convert_string): Add record_unwind_protect to
Kenichi Handa <handa@m17n.org>
parents:
25860
diff
changeset
|
516 /* Global flag to tell that we can't call post-read-conversion and |
f54ca66e2571
(code_convert_string): Add record_unwind_protect to
Kenichi Handa <handa@m17n.org>
parents:
25860
diff
changeset
|
517 pre-write-conversion functions. Usually the value is zero, but it |
f54ca66e2571
(code_convert_string): Add record_unwind_protect to
Kenichi Handa <handa@m17n.org>
parents:
25860
diff
changeset
|
518 is set to 1 temporarily while such functions are running. This is |
f54ca66e2571
(code_convert_string): Add record_unwind_protect to
Kenichi Handa <handa@m17n.org>
parents:
25860
diff
changeset
|
519 to avoid infinite recursive call. */ |
f54ca66e2571
(code_convert_string): Add record_unwind_protect to
Kenichi Handa <handa@m17n.org>
parents:
25860
diff
changeset
|
520 static int inhibit_pre_post_conversion; |
f54ca66e2571
(code_convert_string): Add record_unwind_protect to
Kenichi Handa <handa@m17n.org>
parents:
25860
diff
changeset
|
521 |
30487
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
522 Lisp_Object Qchar_coding_system; |
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
523 |
49539
1ad5bfbb831a
(syms_of_coding): Add `...' for symbols in the docstring of
Kenichi Handa <handa@m17n.org>
parents:
48874
diff
changeset
|
524 /* Return `safe-chars' property of CODING_SYSTEM (symbol). Don't check |
1ad5bfbb831a
(syms_of_coding): Add `...' for symbols in the docstring of
Kenichi Handa <handa@m17n.org>
parents:
48874
diff
changeset
|
525 its validity. */ |
30487
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
526 |
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
527 Lisp_Object |
49539
1ad5bfbb831a
(syms_of_coding): Add `...' for symbols in the docstring of
Kenichi Handa <handa@m17n.org>
parents:
48874
diff
changeset
|
528 coding_safe_chars (coding_system) |
1ad5bfbb831a
(syms_of_coding): Add `...' for symbols in the docstring of
Kenichi Handa <handa@m17n.org>
parents:
48874
diff
changeset
|
529 Lisp_Object coding_system; |
30487
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
530 { |
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
531 Lisp_Object coding_spec, plist, safe_chars; |
42104
d69c2368e549
(DECODE_COMPOSITION_END): Fixed a typo in the last
Sam Steingold <sds@gnu.org>
parents:
42103
diff
changeset
|
532 |
49539
1ad5bfbb831a
(syms_of_coding): Add `...' for symbols in the docstring of
Kenichi Handa <handa@m17n.org>
parents:
48874
diff
changeset
|
533 coding_spec = Fget (coding_system, Qcoding_system); |
30487
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
534 plist = XVECTOR (coding_spec)->contents[3]; |
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
535 safe_chars = Fplist_get (XVECTOR (coding_spec)->contents[3], Qsafe_chars); |
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
536 return (CHAR_TABLE_P (safe_chars) ? safe_chars : Qt); |
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
537 } |
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
538 |
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
539 #define CODING_SAFE_CHAR_P(safe_chars, c) \ |
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
540 (EQ (safe_chars, Qt) || !NILP (CHAR_TABLE_REF (safe_chars, c))) |
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
541 |
17052 | 542 |
17835
f36ffb6f1208
Name change through the code:
Kenichi Handa <handa@m17n.org>
parents:
17725
diff
changeset
|
543 /*** 2. Emacs internal format (emacs-mule) handlers ***/ |
17052 | 544 |
34888
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
545 /* Emacs' internal format for representation of multiple character |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
546 sets is a kind of multi-byte encoding, i.e. characters are |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
547 represented by variable-length sequences of one-byte codes. |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
548 |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
549 ASCII characters and control characters (e.g. `tab', `newline') are |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
550 represented by one-byte sequences which are their ASCII codes, in |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
551 the range 0x00 through 0x7F. |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
552 |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
553 8-bit characters of the range 0x80..0x9F are represented by |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
554 two-byte sequences of LEADING_CODE_8_BIT_CONTROL and (their 8-bit |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
555 code + 0x20). |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
556 |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
557 8-bit characters of the range 0xA0..0xFF are represented by |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
558 one-byte sequences which are their 8-bit code. |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
559 |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
560 The other characters are represented by a sequence of `base |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
561 leading-code', optional `extended leading-code', and one or two |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
562 `position-code's. The length of the sequence is determined by the |
34888
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
563 base leading-code. Leading-code takes the range 0x81 through 0x9D, |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
564 whereas extended leading-code and position-code take the range 0xA0 |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
565 through 0xFF. See `charset.h' for more details about leading-code |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
566 and position-code. |
18766 | 567 |
17052 | 568 --- CODE RANGE of Emacs' internal format --- |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
569 character set range |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
570 ------------- ----- |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
571 ascii 0x00..0x7F |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
572 eight-bit-control LEADING_CODE_8_BIT_CONTROL + 0xA0..0xBF |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
573 eight-bit-graphic 0xA0..0xBF |
34888
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
574 ELSE 0x81..0x9D + [0xA0..0xFF]+ |
17052 | 575 --------------------------------------------- |
576 | |
34888
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
577 As this is the internal character representation, the format is |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
578 usually not used externally (i.e. in a file or in a data sent to a |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
579 process). But, it is possible to have a text externally in this |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
580 format (i.e. by encoding by the coding system `emacs-mule'). |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
581 |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
582 In that case, a sequence of one-byte codes has a slightly different |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
583 form. |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
584 |
37231 | 585 Firstly, all characters in eight-bit-control are represented by |
34888
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
586 one-byte sequences which are their 8-bit code. |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
587 |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
588 Next, character composition data are represented by the byte |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
589 sequence of the form: 0x80 METHOD BYTES CHARS COMPONENT ..., |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
590 where, |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
591 METHOD is 0xF0 plus one of composition method (enum |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
592 composition_method), |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
593 |
37231 | 594 BYTES is 0xA0 plus the byte length of these composition data, |
595 | |
596 CHARS is 0xA0 plus the number of characters composed by these | |
34888
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
597 data, |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
598 |
36087 | 599 COMPONENTs are characters of multibyte form or composition |
34888
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
600 rules encoded by two-byte of ASCII codes. |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
601 |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
602 In addition, for backward compatibility, the following formats are |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
603 also recognized as composition data on decoding. |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
604 |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
605 0x80 MSEQ ... |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
606 0x80 0xFF MSEQ RULE MSEQ RULE ... MSEQ |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
607 |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
608 Here, |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
609 MSEQ is a multibyte form but in these special format: |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
610 ASCII: 0xA0 ASCII_CODE+0x80, |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
611 other: LEADING_CODE+0x20 FOLLOWING-BYTE ..., |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
612 RULE is a one byte code of the range 0xA0..0xF0 that |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
613 represents a composition rule. |
17052 | 614 */ |
615 | |
616 enum emacs_code_class_type emacs_code_class[256]; | |
617 | |
618 /* See the above "GENERAL NOTES on `detect_coding_XXX ()' functions". | |
619 Check if a text is encoded in Emacs' internal format. If it is, | |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
620 return CODING_CATEGORY_MASK_EMACS_MULE, else return 0. */ |
17052 | 621 |
34531
37f85e931855
(ONE_MORE_BYTE_CHECK_MULTIBYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34197
diff
changeset
|
622 static int |
37f85e931855
(ONE_MORE_BYTE_CHECK_MULTIBYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34197
diff
changeset
|
623 detect_coding_emacs_mule (src, src_end, multibytep) |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
624 unsigned char *src, *src_end; |
34531
37f85e931855
(ONE_MORE_BYTE_CHECK_MULTIBYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34197
diff
changeset
|
625 int multibytep; |
17052 | 626 { |
627 unsigned char c; | |
628 int composing = 0; | |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
629 /* Dummy for ONE_MORE_BYTE. */ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
630 struct coding_system dummy_coding; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
631 struct coding_system *coding = &dummy_coding; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
632 |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
633 while (1) |
17052 | 634 { |
72395
94e4795b333d
(ONE_MORE_BYTE_CHECK_MULTIBYTE): New arg RET. If SRC
Kenichi Handa <handa@m17n.org>
parents:
72323
diff
changeset
|
635 ONE_MORE_BYTE_CHECK_MULTIBYTE (c, multibytep, |
94e4795b333d
(ONE_MORE_BYTE_CHECK_MULTIBYTE): New arg RET. If SRC
Kenichi Handa <handa@m17n.org>
parents:
72323
diff
changeset
|
636 CODING_CATEGORY_MASK_EMACS_MULE); |
17052 | 637 if (composing) |
638 { | |
639 if (c < 0xA0) | |
640 composing = 0; | |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
641 else if (c == 0xA0) |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
642 { |
72395
94e4795b333d
(ONE_MORE_BYTE_CHECK_MULTIBYTE): New arg RET. If SRC
Kenichi Handa <handa@m17n.org>
parents:
72323
diff
changeset
|
643 ONE_MORE_BYTE_CHECK_MULTIBYTE (c, multibytep, 0); |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
644 c &= 0x7F; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
645 } |
17052 | 646 else |
647 c -= 0x20; | |
648 } | |
649 | |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
650 if (c < 0x20) |
17052 | 651 { |
652 if (c == ISO_CODE_ESC || c == ISO_CODE_SI || c == ISO_CODE_SO) | |
653 return 0; | |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
654 } |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
655 else if (c >= 0x80 && c < 0xA0) |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
656 { |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
657 if (c == 0x80) |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
658 /* Old leading code for a composite character. */ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
659 composing = 1; |
26847 | 660 else |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
661 { |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
662 unsigned char *src_base = src - 1; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
663 int bytes; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
664 |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
665 if (!UNIBYTE_STR_AS_MULTIBYTE_P (src_base, src_end - src_base, |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
666 bytes)) |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
667 return 0; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
668 src = src_base + bytes; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
669 } |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
670 } |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
671 } |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
672 } |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
673 |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
674 |
34888
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
675 /* Record the starting position START and METHOD of one composition. */ |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
676 |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
677 #define CODING_ADD_COMPOSITION_START(coding, start, method) \ |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
678 do { \ |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
679 struct composition_data *cmp_data = coding->cmp_data; \ |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
680 int *data = cmp_data->data + cmp_data->used; \ |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
681 coding->cmp_data_start = cmp_data->used; \ |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
682 data[0] = -1; \ |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
683 data[1] = cmp_data->char_offset + start; \ |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
684 data[3] = (int) method; \ |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
685 cmp_data->used += 4; \ |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
686 } while (0) |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
687 |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
688 /* Record the ending position END of the current composition. */ |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
689 |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
690 #define CODING_ADD_COMPOSITION_END(coding, end) \ |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
691 do { \ |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
692 struct composition_data *cmp_data = coding->cmp_data; \ |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
693 int *data = cmp_data->data + coding->cmp_data_start; \ |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
694 data[0] = cmp_data->used - coding->cmp_data_start; \ |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
695 data[2] = cmp_data->char_offset + end; \ |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
696 } while (0) |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
697 |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
698 /* Record one COMPONENT (alternate character or composition rule). */ |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
699 |
50047
8e17fbb2ac77
(CODING_ADD_COMPOSITION_COMPONENT): If the number of
Kenichi Handa <handa@m17n.org>
parents:
49600
diff
changeset
|
700 #define CODING_ADD_COMPOSITION_COMPONENT(coding, component) \ |
8e17fbb2ac77
(CODING_ADD_COMPOSITION_COMPONENT): If the number of
Kenichi Handa <handa@m17n.org>
parents:
49600
diff
changeset
|
701 do { \ |
8e17fbb2ac77
(CODING_ADD_COMPOSITION_COMPONENT): If the number of
Kenichi Handa <handa@m17n.org>
parents:
49600
diff
changeset
|
702 coding->cmp_data->data[coding->cmp_data->used++] = component; \ |
8e17fbb2ac77
(CODING_ADD_COMPOSITION_COMPONENT): If the number of
Kenichi Handa <handa@m17n.org>
parents:
49600
diff
changeset
|
703 if (coding->cmp_data->used - coding->cmp_data_start \ |
8e17fbb2ac77
(CODING_ADD_COMPOSITION_COMPONENT): If the number of
Kenichi Handa <handa@m17n.org>
parents:
49600
diff
changeset
|
704 == COMPOSITION_DATA_MAX_BUNCH_LENGTH) \ |
8e17fbb2ac77
(CODING_ADD_COMPOSITION_COMPONENT): If the number of
Kenichi Handa <handa@m17n.org>
parents:
49600
diff
changeset
|
705 { \ |
8e17fbb2ac77
(CODING_ADD_COMPOSITION_COMPONENT): If the number of
Kenichi Handa <handa@m17n.org>
parents:
49600
diff
changeset
|
706 CODING_ADD_COMPOSITION_END (coding, coding->produced_char); \ |
8e17fbb2ac77
(CODING_ADD_COMPOSITION_COMPONENT): If the number of
Kenichi Handa <handa@m17n.org>
parents:
49600
diff
changeset
|
707 coding->composing = COMPOSITION_NO; \ |
8e17fbb2ac77
(CODING_ADD_COMPOSITION_COMPONENT): If the number of
Kenichi Handa <handa@m17n.org>
parents:
49600
diff
changeset
|
708 } \ |
8e17fbb2ac77
(CODING_ADD_COMPOSITION_COMPONENT): If the number of
Kenichi Handa <handa@m17n.org>
parents:
49600
diff
changeset
|
709 } while (0) |
34888
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
710 |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
711 |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
712 /* Get one byte from a data pointed by SRC and increment SRC. If SRC |
36087 | 713 is not less than SRC_END, return -1 without incrementing Src. */ |
34888
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
714 |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
715 #define SAFE_ONE_MORE_BYTE() (src >= src_end ? -1 : *src++) |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
716 |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
717 |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
718 /* Decode a character represented as a component of composition |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
719 sequence of Emacs 20 style at SRC. Set C to that character, store |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
720 its multibyte form sequence at P, and set P to the end of that |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
721 sequence. If no valid character is found, set C to -1. */ |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
722 |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
723 #define DECODE_EMACS_MULE_COMPOSITION_CHAR(c, p) \ |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
724 do { \ |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
725 int bytes; \ |
51356
8da3b8a0ca4f
(DECODE_EMACS_MULE_COMPOSITION_CHAR): If coding->flags
Kenichi Handa <handa@m17n.org>
parents:
51327
diff
changeset
|
726 \ |
34888
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
727 c = SAFE_ONE_MORE_BYTE (); \ |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
728 if (c < 0) \ |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
729 break; \ |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
730 if (CHAR_HEAD_P (c)) \ |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
731 c = -1; \ |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
732 else if (c == 0xA0) \ |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
733 { \ |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
734 c = SAFE_ONE_MORE_BYTE (); \ |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
735 if (c < 0xA0) \ |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
736 c = -1; \ |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
737 else \ |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
738 { \ |
69344
be24f5428cef
(DECODE_EMACS_MULE_COMPOSITION_CHAR): Fix decoding
Kenichi Handa <handa@m17n.org>
parents:
68651
diff
changeset
|
739 c -= 0x80; \ |
34888
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
740 *p++ = c; \ |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
741 } \ |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
742 } \ |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
743 else if (BASE_LEADING_CODE_P (c - 0x20)) \ |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
744 { \ |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
745 unsigned char *p0 = p; \ |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
746 \ |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
747 c -= 0x20; \ |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
748 *p++ = c; \ |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
749 bytes = BYTES_BY_CHAR_HEAD (c); \ |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
750 while (--bytes) \ |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
751 { \ |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
752 c = SAFE_ONE_MORE_BYTE (); \ |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
753 if (c < 0) \ |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
754 break; \ |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
755 *p++ = c; \ |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
756 } \ |
51356
8da3b8a0ca4f
(DECODE_EMACS_MULE_COMPOSITION_CHAR): If coding->flags
Kenichi Handa <handa@m17n.org>
parents:
51327
diff
changeset
|
757 if (UNIBYTE_STR_AS_MULTIBYTE_P (p0, p - p0, bytes) \ |
8da3b8a0ca4f
(DECODE_EMACS_MULE_COMPOSITION_CHAR): If coding->flags
Kenichi Handa <handa@m17n.org>
parents:
51327
diff
changeset
|
758 || (coding->flags /* We are recovering a file. */ \ |
8da3b8a0ca4f
(DECODE_EMACS_MULE_COMPOSITION_CHAR): If coding->flags
Kenichi Handa <handa@m17n.org>
parents:
51327
diff
changeset
|
759 && p0[0] == LEADING_CODE_8_BIT_CONTROL \ |
8da3b8a0ca4f
(DECODE_EMACS_MULE_COMPOSITION_CHAR): If coding->flags
Kenichi Handa <handa@m17n.org>
parents:
51327
diff
changeset
|
760 && ! CHAR_HEAD_P (p0[1]))) \ |
34888
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
761 c = STRING_CHAR (p0, bytes); \ |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
762 else \ |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
763 c = -1; \ |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
764 } \ |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
765 else \ |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
766 c = -1; \ |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
767 } while (0) |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
768 |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
769 |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
770 /* Decode a composition rule represented as a component of composition |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
771 sequence of Emacs 20 style at SRC. Set C to the rule. If not |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
772 valid rule is found, set C to -1. */ |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
773 |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
774 #define DECODE_EMACS_MULE_COMPOSITION_RULE(c) \ |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
775 do { \ |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
776 c = SAFE_ONE_MORE_BYTE (); \ |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
777 c -= 0xA0; \ |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
778 if (c < 0 || c >= 81) \ |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
779 c = -1; \ |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
780 else \ |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
781 { \ |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
782 gref = c / 9, nref = c % 9; \ |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
783 c = COMPOSITION_ENCODE_RULE (gref, nref); \ |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
784 } \ |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
785 } while (0) |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
786 |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
787 |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
788 /* Decode composition sequence encoded by `emacs-mule' at the source |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
789 pointed by SRC. SRC_END is the end of source. Store information |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
790 of the composition in CODING->cmp_data. |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
791 |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
792 For backward compatibility, decode also a composition sequence of |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
793 Emacs 20 style. In that case, the composition sequence contains |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
794 characters that should be extracted into a buffer or string. Store |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
795 those characters at *DESTINATION in multibyte form. |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
796 |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
797 If we encounter an invalid byte sequence, return 0. |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
798 If we encounter an insufficient source or destination, or |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
799 insufficient space in CODING->cmp_data, return 1. |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
800 Otherwise, return consumed bytes in the source. |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
801 |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
802 */ |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
803 static INLINE int |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
804 decode_composition_emacs_mule (coding, src, src_end, |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
805 destination, dst_end, dst_bytes) |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
806 struct coding_system *coding; |
59168
0345f2b10f1d
(decode_coding_XXX, decode_composition_emacs_mule)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
59095
diff
changeset
|
807 const unsigned char *src, *src_end; |
0345f2b10f1d
(decode_coding_XXX, decode_composition_emacs_mule)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
59095
diff
changeset
|
808 unsigned char **destination, *dst_end; |
34888
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
809 int dst_bytes; |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
810 { |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
811 unsigned char *dst = *destination; |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
812 int method, data_len, nchars; |
59168
0345f2b10f1d
(decode_coding_XXX, decode_composition_emacs_mule)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
59095
diff
changeset
|
813 const unsigned char *src_base = src++; |
36087 | 814 /* Store components of composition. */ |
34888
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
815 int component[COMPOSITION_DATA_MAX_BUNCH_LENGTH]; |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
816 int ncomponent; |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
817 /* Store multibyte form of characters to be composed. This is for |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
818 Emacs 20 style composition sequence. */ |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
819 unsigned char buf[MAX_COMPOSITION_COMPONENTS * MAX_MULTIBYTE_LENGTH]; |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
820 unsigned char *bufp = buf; |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
821 int c, i, gref, nref; |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
822 |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
823 if (coding->cmp_data->used + COMPOSITION_DATA_MAX_BUNCH_LENGTH |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
824 >= COMPOSITION_DATA_SIZE) |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
825 { |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
826 coding->result = CODING_FINISH_INSUFFICIENT_CMP; |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
827 return -1; |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
828 } |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
829 |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
830 ONE_MORE_BYTE (c); |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
831 if (c - 0xF0 >= COMPOSITION_RELATIVE |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
832 && c - 0xF0 <= COMPOSITION_WITH_RULE_ALTCHARS) |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
833 { |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
834 int with_rule; |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
835 |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
836 method = c - 0xF0; |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
837 with_rule = (method == COMPOSITION_WITH_RULE |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
838 || method == COMPOSITION_WITH_RULE_ALTCHARS); |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
839 ONE_MORE_BYTE (c); |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
840 data_len = c - 0xA0; |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
841 if (data_len < 4 |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
842 || src_base + data_len > src_end) |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
843 return 0; |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
844 ONE_MORE_BYTE (c); |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
845 nchars = c - 0xA0; |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
846 if (c < 1) |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
847 return 0; |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
848 for (ncomponent = 0; src < src_base + data_len; ncomponent++) |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
849 { |
43041
983767b5ccc0
(decode_composition_emacs_mule):
Richard M. Stallman <rms@gnu.org>
parents:
42661
diff
changeset
|
850 /* If it is longer than this, it can't be valid. */ |
983767b5ccc0
(decode_composition_emacs_mule):
Richard M. Stallman <rms@gnu.org>
parents:
42661
diff
changeset
|
851 if (ncomponent >= COMPOSITION_DATA_MAX_BUNCH_LENGTH) |
983767b5ccc0
(decode_composition_emacs_mule):
Richard M. Stallman <rms@gnu.org>
parents:
42661
diff
changeset
|
852 return 0; |
983767b5ccc0
(decode_composition_emacs_mule):
Richard M. Stallman <rms@gnu.org>
parents:
42661
diff
changeset
|
853 |
34888
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
854 if (ncomponent % 2 && with_rule) |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
855 { |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
856 ONE_MORE_BYTE (gref); |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
857 gref -= 32; |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
858 ONE_MORE_BYTE (nref); |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
859 nref -= 32; |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
860 c = COMPOSITION_ENCODE_RULE (gref, nref); |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
861 } |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
862 else |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
863 { |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
864 int bytes; |
51356
8da3b8a0ca4f
(DECODE_EMACS_MULE_COMPOSITION_CHAR): If coding->flags
Kenichi Handa <handa@m17n.org>
parents:
51327
diff
changeset
|
865 if (UNIBYTE_STR_AS_MULTIBYTE_P (src, src_end - src, bytes) |
8da3b8a0ca4f
(DECODE_EMACS_MULE_COMPOSITION_CHAR): If coding->flags
Kenichi Handa <handa@m17n.org>
parents:
51327
diff
changeset
|
866 || (coding->flags /* We are recovering a file. */ |
8da3b8a0ca4f
(DECODE_EMACS_MULE_COMPOSITION_CHAR): If coding->flags
Kenichi Handa <handa@m17n.org>
parents:
51327
diff
changeset
|
867 && src[0] == LEADING_CODE_8_BIT_CONTROL |
8da3b8a0ca4f
(DECODE_EMACS_MULE_COMPOSITION_CHAR): If coding->flags
Kenichi Handa <handa@m17n.org>
parents:
51327
diff
changeset
|
868 && ! CHAR_HEAD_P (src[1]))) |
34888
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
869 c = STRING_CHAR (src, bytes); |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
870 else |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
871 c = *src, bytes = 1; |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
872 src += bytes; |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
873 } |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
874 component[ncomponent] = c; |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
875 } |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
876 } |
68567
ae0affba29c8
(decode_composition_emacs_mule): Fix handling of
Kenichi Handa <handa@m17n.org>
parents:
67658
diff
changeset
|
877 else if (c >= 0x80) |
34888
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
878 { |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
879 /* This may be an old Emacs 20 style format. See the comment at |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
880 the section 2 of this file. */ |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
881 while (src < src_end && !CHAR_HEAD_P (*src)) src++; |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
882 if (src == src_end |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
883 && !(coding->mode & CODING_MODE_LAST_BLOCK)) |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
884 goto label_end_of_loop; |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
885 |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
886 src_end = src; |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
887 src = src_base + 1; |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
888 if (c < 0xC0) |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
889 { |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
890 method = COMPOSITION_RELATIVE; |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
891 for (ncomponent = 0; ncomponent < MAX_COMPOSITION_COMPONENTS;) |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
892 { |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
893 DECODE_EMACS_MULE_COMPOSITION_CHAR (c, bufp); |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
894 if (c < 0) |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
895 break; |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
896 component[ncomponent++] = c; |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
897 } |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
898 if (ncomponent < 2) |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
899 return 0; |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
900 nchars = ncomponent; |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
901 } |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
902 else if (c == 0xFF) |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
903 { |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
904 method = COMPOSITION_WITH_RULE; |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
905 src++; |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
906 DECODE_EMACS_MULE_COMPOSITION_CHAR (c, bufp); |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
907 if (c < 0) |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
908 return 0; |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
909 component[0] = c; |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
910 for (ncomponent = 1; |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
911 ncomponent < MAX_COMPOSITION_COMPONENTS * 2 - 1;) |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
912 { |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
913 DECODE_EMACS_MULE_COMPOSITION_RULE (c); |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
914 if (c < 0) |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
915 break; |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
916 component[ncomponent++] = c; |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
917 DECODE_EMACS_MULE_COMPOSITION_CHAR (c, bufp); |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
918 if (c < 0) |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
919 break; |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
920 component[ncomponent++] = c; |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
921 } |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
922 if (ncomponent < 3) |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
923 return 0; |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
924 nchars = (ncomponent + 1) / 2; |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
925 } |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
926 else |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
927 return 0; |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
928 } |
68567
ae0affba29c8
(decode_composition_emacs_mule): Fix handling of
Kenichi Handa <handa@m17n.org>
parents:
67658
diff
changeset
|
929 else |
ae0affba29c8
(decode_composition_emacs_mule): Fix handling of
Kenichi Handa <handa@m17n.org>
parents:
67658
diff
changeset
|
930 return 0; |
34888
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
931 |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
932 if (buf == bufp || dst + (bufp - buf) <= (dst_bytes ? dst_end : src)) |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
933 { |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
934 CODING_ADD_COMPOSITION_START (coding, coding->produced_char, method); |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
935 for (i = 0; i < ncomponent; i++) |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
936 CODING_ADD_COMPOSITION_COMPONENT (coding, component[i]); |
42104
d69c2368e549
(DECODE_COMPOSITION_END): Fixed a typo in the last
Sam Steingold <sds@gnu.org>
parents:
42103
diff
changeset
|
937 CODING_ADD_COMPOSITION_END (coding, coding->produced_char + nchars); |
34888
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
938 if (buf < bufp) |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
939 { |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
940 unsigned char *p = buf; |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
941 EMIT_BYTES (p, bufp); |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
942 *destination += bufp - buf; |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
943 coding->produced_char += nchars; |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
944 } |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
945 return (src - src_base); |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
946 } |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
947 label_end_of_loop: |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
948 return -1; |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
949 } |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
950 |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
951 /* See the above "GENERAL NOTES on `decode_coding_XXX ()' functions". */ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
952 |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
953 static void |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
954 decode_coding_emacs_mule (coding, source, destination, src_bytes, dst_bytes) |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
955 struct coding_system *coding; |
59168
0345f2b10f1d
(decode_coding_XXX, decode_composition_emacs_mule)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
59095
diff
changeset
|
956 const unsigned char *source; |
0345f2b10f1d
(decode_coding_XXX, decode_composition_emacs_mule)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
59095
diff
changeset
|
957 unsigned char *destination; |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
958 int src_bytes, dst_bytes; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
959 { |
59168
0345f2b10f1d
(decode_coding_XXX, decode_composition_emacs_mule)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
59095
diff
changeset
|
960 const unsigned char *src = source; |
0345f2b10f1d
(decode_coding_XXX, decode_composition_emacs_mule)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
59095
diff
changeset
|
961 const unsigned char *src_end = source + src_bytes; |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
962 unsigned char *dst = destination; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
963 unsigned char *dst_end = destination + dst_bytes; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
964 /* SRC_BASE remembers the start position in source in each loop. |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
965 The loop will be exited when there's not enough source code, or |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
966 when there's not enough destination area to produce a |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
967 character. */ |
59168
0345f2b10f1d
(decode_coding_XXX, decode_composition_emacs_mule)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
59095
diff
changeset
|
968 const unsigned char *src_base; |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
969 |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
970 coding->produced_char = 0; |
29663
ebf778ab6b42
(decode_coding_emacs_mule): Always set src_base at the
Kenichi Handa <handa@m17n.org>
parents:
29299
diff
changeset
|
971 while ((src_base = src) < src_end) |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
972 { |
59168
0345f2b10f1d
(decode_coding_XXX, decode_composition_emacs_mule)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
59095
diff
changeset
|
973 unsigned char tmp[MAX_MULTIBYTE_LENGTH]; |
0345f2b10f1d
(decode_coding_XXX, decode_composition_emacs_mule)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
59095
diff
changeset
|
974 const unsigned char *p; |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
975 int bytes; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
976 |
32806
9502d0a5b2ad
(decode_coding_emacs_mule): If coding->eol_type is CR
Eli Zaretskii <eliz@gnu.org>
parents:
32745
diff
changeset
|
977 if (*src == '\r') |
9502d0a5b2ad
(decode_coding_emacs_mule): If coding->eol_type is CR
Eli Zaretskii <eliz@gnu.org>
parents:
32745
diff
changeset
|
978 { |
33828
ef38af5ee8d2
(decode_coding_emacs_mule): Fix the case of
Eli Zaretskii <eliz@gnu.org>
parents:
32896
diff
changeset
|
979 int c = *src++; |
ef38af5ee8d2
(decode_coding_emacs_mule): Fix the case of
Eli Zaretskii <eliz@gnu.org>
parents:
32896
diff
changeset
|
980 |
32806
9502d0a5b2ad
(decode_coding_emacs_mule): If coding->eol_type is CR
Eli Zaretskii <eliz@gnu.org>
parents:
32745
diff
changeset
|
981 if (coding->eol_type == CODING_EOL_CR) |
9502d0a5b2ad
(decode_coding_emacs_mule): If coding->eol_type is CR
Eli Zaretskii <eliz@gnu.org>
parents:
32745
diff
changeset
|
982 c = '\n'; |
9502d0a5b2ad
(decode_coding_emacs_mule): If coding->eol_type is CR
Eli Zaretskii <eliz@gnu.org>
parents:
32745
diff
changeset
|
983 else if (coding->eol_type == CODING_EOL_CRLF) |
9502d0a5b2ad
(decode_coding_emacs_mule): If coding->eol_type is CR
Eli Zaretskii <eliz@gnu.org>
parents:
32745
diff
changeset
|
984 { |
9502d0a5b2ad
(decode_coding_emacs_mule): If coding->eol_type is CR
Eli Zaretskii <eliz@gnu.org>
parents:
32745
diff
changeset
|
985 ONE_MORE_BYTE (c); |
9502d0a5b2ad
(decode_coding_emacs_mule): If coding->eol_type is CR
Eli Zaretskii <eliz@gnu.org>
parents:
32745
diff
changeset
|
986 if (c != '\n') |
9502d0a5b2ad
(decode_coding_emacs_mule): If coding->eol_type is CR
Eli Zaretskii <eliz@gnu.org>
parents:
32745
diff
changeset
|
987 { |
9502d0a5b2ad
(decode_coding_emacs_mule): If coding->eol_type is CR
Eli Zaretskii <eliz@gnu.org>
parents:
32745
diff
changeset
|
988 src--; |
9502d0a5b2ad
(decode_coding_emacs_mule): If coding->eol_type is CR
Eli Zaretskii <eliz@gnu.org>
parents:
32745
diff
changeset
|
989 c = '\r'; |
9502d0a5b2ad
(decode_coding_emacs_mule): If coding->eol_type is CR
Eli Zaretskii <eliz@gnu.org>
parents:
32745
diff
changeset
|
990 } |
9502d0a5b2ad
(decode_coding_emacs_mule): If coding->eol_type is CR
Eli Zaretskii <eliz@gnu.org>
parents:
32745
diff
changeset
|
991 } |
9502d0a5b2ad
(decode_coding_emacs_mule): If coding->eol_type is CR
Eli Zaretskii <eliz@gnu.org>
parents:
32745
diff
changeset
|
992 *dst++ = c; |
9502d0a5b2ad
(decode_coding_emacs_mule): If coding->eol_type is CR
Eli Zaretskii <eliz@gnu.org>
parents:
32745
diff
changeset
|
993 coding->produced_char++; |
9502d0a5b2ad
(decode_coding_emacs_mule): If coding->eol_type is CR
Eli Zaretskii <eliz@gnu.org>
parents:
32745
diff
changeset
|
994 continue; |
9502d0a5b2ad
(decode_coding_emacs_mule): If coding->eol_type is CR
Eli Zaretskii <eliz@gnu.org>
parents:
32745
diff
changeset
|
995 } |
9502d0a5b2ad
(decode_coding_emacs_mule): If coding->eol_type is CR
Eli Zaretskii <eliz@gnu.org>
parents:
32745
diff
changeset
|
996 else if (*src == '\n') |
9502d0a5b2ad
(decode_coding_emacs_mule): If coding->eol_type is CR
Eli Zaretskii <eliz@gnu.org>
parents:
32745
diff
changeset
|
997 { |
9502d0a5b2ad
(decode_coding_emacs_mule): If coding->eol_type is CR
Eli Zaretskii <eliz@gnu.org>
parents:
32745
diff
changeset
|
998 if ((coding->eol_type == CODING_EOL_CR |
9502d0a5b2ad
(decode_coding_emacs_mule): If coding->eol_type is CR
Eli Zaretskii <eliz@gnu.org>
parents:
32745
diff
changeset
|
999 || coding->eol_type == CODING_EOL_CRLF) |
9502d0a5b2ad
(decode_coding_emacs_mule): If coding->eol_type is CR
Eli Zaretskii <eliz@gnu.org>
parents:
32745
diff
changeset
|
1000 && coding->mode & CODING_MODE_INHIBIT_INCONSISTENT_EOL) |
9502d0a5b2ad
(decode_coding_emacs_mule): If coding->eol_type is CR
Eli Zaretskii <eliz@gnu.org>
parents:
32745
diff
changeset
|
1001 { |
9502d0a5b2ad
(decode_coding_emacs_mule): If coding->eol_type is CR
Eli Zaretskii <eliz@gnu.org>
parents:
32745
diff
changeset
|
1002 coding->result = CODING_FINISH_INCONSISTENT_EOL; |
9502d0a5b2ad
(decode_coding_emacs_mule): If coding->eol_type is CR
Eli Zaretskii <eliz@gnu.org>
parents:
32745
diff
changeset
|
1003 goto label_end_of_loop; |
9502d0a5b2ad
(decode_coding_emacs_mule): If coding->eol_type is CR
Eli Zaretskii <eliz@gnu.org>
parents:
32745
diff
changeset
|
1004 } |
9502d0a5b2ad
(decode_coding_emacs_mule): If coding->eol_type is CR
Eli Zaretskii <eliz@gnu.org>
parents:
32745
diff
changeset
|
1005 *dst++ = *src++; |
9502d0a5b2ad
(decode_coding_emacs_mule): If coding->eol_type is CR
Eli Zaretskii <eliz@gnu.org>
parents:
32745
diff
changeset
|
1006 coding->produced_char++; |
9502d0a5b2ad
(decode_coding_emacs_mule): If coding->eol_type is CR
Eli Zaretskii <eliz@gnu.org>
parents:
32745
diff
changeset
|
1007 continue; |
9502d0a5b2ad
(decode_coding_emacs_mule): If coding->eol_type is CR
Eli Zaretskii <eliz@gnu.org>
parents:
32745
diff
changeset
|
1008 } |
47698
77511decc5ff
(decode_coding_emacs_mule): Check coding->cmp_data.
Kenichi Handa <handa@m17n.org>
parents:
47632
diff
changeset
|
1009 else if (*src == 0x80 && coding->cmp_data) |
34888
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1010 { |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1011 /* Start of composition data. */ |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1012 int consumed = decode_composition_emacs_mule (coding, src, src_end, |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1013 &dst, dst_end, |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1014 dst_bytes); |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1015 if (consumed < 0) |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1016 goto label_end_of_loop; |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1017 else if (consumed > 0) |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1018 { |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1019 src += consumed; |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1020 continue; |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1021 } |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1022 bytes = CHAR_STRING (*src, tmp); |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1023 p = tmp; |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1024 src++; |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1025 } |
51356
8da3b8a0ca4f
(DECODE_EMACS_MULE_COMPOSITION_CHAR): If coding->flags
Kenichi Handa <handa@m17n.org>
parents:
51327
diff
changeset
|
1026 else if (UNIBYTE_STR_AS_MULTIBYTE_P (src, src_end - src, bytes) |
8da3b8a0ca4f
(DECODE_EMACS_MULE_COMPOSITION_CHAR): If coding->flags
Kenichi Handa <handa@m17n.org>
parents:
51327
diff
changeset
|
1027 || (coding->flags /* We are recovering a file. */ |
8da3b8a0ca4f
(DECODE_EMACS_MULE_COMPOSITION_CHAR): If coding->flags
Kenichi Handa <handa@m17n.org>
parents:
51327
diff
changeset
|
1028 && src[0] == LEADING_CODE_8_BIT_CONTROL |
8da3b8a0ca4f
(DECODE_EMACS_MULE_COMPOSITION_CHAR): If coding->flags
Kenichi Handa <handa@m17n.org>
parents:
51327
diff
changeset
|
1029 && ! CHAR_HEAD_P (src[1]))) |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1030 { |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1031 p = src; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1032 src += bytes; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1033 } |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1034 else |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1035 { |
54320
a7e59b39de35
(decode_coding_emacs_mule): Handle insufficent source correctly.
Kenichi Handa <handa@m17n.org>
parents:
54303
diff
changeset
|
1036 int i, c; |
a7e59b39de35
(decode_coding_emacs_mule): Handle insufficent source correctly.
Kenichi Handa <handa@m17n.org>
parents:
54303
diff
changeset
|
1037 |
a7e59b39de35
(decode_coding_emacs_mule): Handle insufficent source correctly.
Kenichi Handa <handa@m17n.org>
parents:
54303
diff
changeset
|
1038 bytes = BYTES_BY_CHAR_HEAD (*src); |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1039 src++; |
54320
a7e59b39de35
(decode_coding_emacs_mule): Handle insufficent source correctly.
Kenichi Handa <handa@m17n.org>
parents:
54303
diff
changeset
|
1040 for (i = 1; i < bytes; i++) |
a7e59b39de35
(decode_coding_emacs_mule): Handle insufficent source correctly.
Kenichi Handa <handa@m17n.org>
parents:
54303
diff
changeset
|
1041 { |
a7e59b39de35
(decode_coding_emacs_mule): Handle insufficent source correctly.
Kenichi Handa <handa@m17n.org>
parents:
54303
diff
changeset
|
1042 ONE_MORE_BYTE (c); |
a7e59b39de35
(decode_coding_emacs_mule): Handle insufficent source correctly.
Kenichi Handa <handa@m17n.org>
parents:
54303
diff
changeset
|
1043 if (CHAR_HEAD_P (c)) |
a7e59b39de35
(decode_coding_emacs_mule): Handle insufficent source correctly.
Kenichi Handa <handa@m17n.org>
parents:
54303
diff
changeset
|
1044 break; |
a7e59b39de35
(decode_coding_emacs_mule): Handle insufficent source correctly.
Kenichi Handa <handa@m17n.org>
parents:
54303
diff
changeset
|
1045 } |
a7e59b39de35
(decode_coding_emacs_mule): Handle insufficent source correctly.
Kenichi Handa <handa@m17n.org>
parents:
54303
diff
changeset
|
1046 if (i < bytes) |
a7e59b39de35
(decode_coding_emacs_mule): Handle insufficent source correctly.
Kenichi Handa <handa@m17n.org>
parents:
54303
diff
changeset
|
1047 { |
a7e59b39de35
(decode_coding_emacs_mule): Handle insufficent source correctly.
Kenichi Handa <handa@m17n.org>
parents:
54303
diff
changeset
|
1048 bytes = CHAR_STRING (*src_base, tmp); |
a7e59b39de35
(decode_coding_emacs_mule): Handle insufficent source correctly.
Kenichi Handa <handa@m17n.org>
parents:
54303
diff
changeset
|
1049 p = tmp; |
a7e59b39de35
(decode_coding_emacs_mule): Handle insufficent source correctly.
Kenichi Handa <handa@m17n.org>
parents:
54303
diff
changeset
|
1050 src = src_base + 1; |
a7e59b39de35
(decode_coding_emacs_mule): Handle insufficent source correctly.
Kenichi Handa <handa@m17n.org>
parents:
54303
diff
changeset
|
1051 } |
a7e59b39de35
(decode_coding_emacs_mule): Handle insufficent source correctly.
Kenichi Handa <handa@m17n.org>
parents:
54303
diff
changeset
|
1052 else |
a7e59b39de35
(decode_coding_emacs_mule): Handle insufficent source correctly.
Kenichi Handa <handa@m17n.org>
parents:
54303
diff
changeset
|
1053 { |
a7e59b39de35
(decode_coding_emacs_mule): Handle insufficent source correctly.
Kenichi Handa <handa@m17n.org>
parents:
54303
diff
changeset
|
1054 p = src_base; |
a7e59b39de35
(decode_coding_emacs_mule): Handle insufficent source correctly.
Kenichi Handa <handa@m17n.org>
parents:
54303
diff
changeset
|
1055 } |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1056 } |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1057 if (dst + bytes >= (dst_bytes ? dst_end : src)) |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1058 { |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1059 coding->result = CODING_FINISH_INSUFFICIENT_DST; |
17052 | 1060 break; |
1061 } | |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1062 while (bytes--) *dst++ = *p++; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1063 coding->produced_char++; |
17052 | 1064 } |
32806
9502d0a5b2ad
(decode_coding_emacs_mule): If coding->eol_type is CR
Eli Zaretskii <eliz@gnu.org>
parents:
32745
diff
changeset
|
1065 label_end_of_loop: |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1066 coding->consumed = coding->consumed_char = src_base - source; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1067 coding->produced = dst - destination; |
17052 | 1068 } |
1069 | |
34888
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1070 |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1071 /* Encode composition data stored at DATA into a special byte sequence |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1072 starting by 0x80. Update CODING->cmp_data_start and maybe |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1073 CODING->cmp_data for the next call. */ |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1074 |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1075 #define ENCODE_COMPOSITION_EMACS_MULE(coding, data) \ |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1076 do { \ |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1077 unsigned char buf[1024], *p0 = buf, *p; \ |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1078 int len = data[0]; \ |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1079 int i; \ |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1080 \ |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1081 buf[0] = 0x80; \ |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1082 buf[1] = 0xF0 + data[3]; /* METHOD */ \ |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1083 buf[3] = 0xA0 + (data[2] - data[1]); /* COMPOSED-CHARS */ \ |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1084 p = buf + 4; \ |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1085 if (data[3] == COMPOSITION_WITH_RULE \ |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1086 || data[3] == COMPOSITION_WITH_RULE_ALTCHARS) \ |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1087 { \ |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1088 p += CHAR_STRING (data[4], p); \ |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1089 for (i = 5; i < len; i += 2) \ |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1090 { \ |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1091 int gref, nref; \ |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1092 COMPOSITION_DECODE_RULE (data[i], gref, nref); \ |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1093 *p++ = 0x20 + gref; \ |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1094 *p++ = 0x20 + nref; \ |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1095 p += CHAR_STRING (data[i + 1], p); \ |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1096 } \ |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1097 } \ |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1098 else \ |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1099 { \ |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1100 for (i = 4; i < len; i++) \ |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1101 p += CHAR_STRING (data[i], p); \ |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1102 } \ |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1103 buf[2] = 0xA0 + (p - buf); /* COMPONENTS-BYTES */ \ |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1104 \ |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1105 if (dst + (p - buf) + 4 > (dst_bytes ? dst_end : src)) \ |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1106 { \ |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1107 coding->result = CODING_FINISH_INSUFFICIENT_DST; \ |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1108 goto label_end_of_loop; \ |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1109 } \ |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1110 while (p0 < p) \ |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1111 *dst++ = *p0++; \ |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1112 coding->cmp_data_start += data[0]; \ |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1113 if (coding->cmp_data_start == coding->cmp_data->used \ |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1114 && coding->cmp_data->next) \ |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1115 { \ |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1116 coding->cmp_data = coding->cmp_data->next; \ |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1117 coding->cmp_data_start = 0; \ |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1118 } \ |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1119 } while (0) |
42104
d69c2368e549
(DECODE_COMPOSITION_END): Fixed a typo in the last
Sam Steingold <sds@gnu.org>
parents:
42103
diff
changeset
|
1120 |
34888
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1121 |
46548
cb1914307488
(encode_eol, detect_coding, detect_eol):
Ken Raeburn <raeburn@raeburn.org>
parents:
46462
diff
changeset
|
1122 static void encode_eol P_ ((struct coding_system *, const unsigned char *, |
34888
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1123 unsigned char *, int, int)); |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1124 |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1125 static void |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1126 encode_coding_emacs_mule (coding, source, destination, src_bytes, dst_bytes) |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1127 struct coding_system *coding; |
59168
0345f2b10f1d
(decode_coding_XXX, decode_composition_emacs_mule)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
59095
diff
changeset
|
1128 const unsigned char *source; |
0345f2b10f1d
(decode_coding_XXX, decode_composition_emacs_mule)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
59095
diff
changeset
|
1129 unsigned char *destination; |
34888
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1130 int src_bytes, dst_bytes; |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1131 { |
59168
0345f2b10f1d
(decode_coding_XXX, decode_composition_emacs_mule)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
59095
diff
changeset
|
1132 const unsigned char *src = source; |
0345f2b10f1d
(decode_coding_XXX, decode_composition_emacs_mule)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
59095
diff
changeset
|
1133 const unsigned char *src_end = source + src_bytes; |
34888
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1134 unsigned char *dst = destination; |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1135 unsigned char *dst_end = destination + dst_bytes; |
59168
0345f2b10f1d
(decode_coding_XXX, decode_composition_emacs_mule)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
59095
diff
changeset
|
1136 const unsigned char *src_base; |
34888
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1137 int c; |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1138 int char_offset; |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1139 int *data; |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1140 |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1141 Lisp_Object translation_table; |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1142 |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1143 translation_table = Qnil; |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1144 |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1145 /* Optimization for the case that there's no composition. */ |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1146 if (!coding->cmp_data || coding->cmp_data->used == 0) |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1147 { |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1148 encode_eol (coding, source, destination, src_bytes, dst_bytes); |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1149 return; |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1150 } |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1151 |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1152 char_offset = coding->cmp_data->char_offset; |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1153 data = coding->cmp_data->data + coding->cmp_data_start; |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1154 while (1) |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1155 { |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1156 src_base = src; |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1157 |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1158 /* If SRC starts a composition, encode the information about the |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1159 composition in advance. */ |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1160 if (coding->cmp_data_start < coding->cmp_data->used |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1161 && char_offset + coding->consumed_char == data[1]) |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1162 { |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1163 ENCODE_COMPOSITION_EMACS_MULE (coding, data); |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1164 char_offset = coding->cmp_data->char_offset; |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1165 data = coding->cmp_data->data + coding->cmp_data_start; |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1166 } |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1167 |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1168 ONE_MORE_CHAR (c); |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1169 if (c == '\n' && (coding->eol_type == CODING_EOL_CRLF |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1170 || coding->eol_type == CODING_EOL_CR)) |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1171 { |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1172 if (coding->eol_type == CODING_EOL_CRLF) |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1173 EMIT_TWO_BYTES ('\r', c); |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1174 else |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1175 EMIT_ONE_BYTE ('\r'); |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1176 } |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1177 else if (SINGLE_BYTE_CHAR_P (c)) |
51356
8da3b8a0ca4f
(DECODE_EMACS_MULE_COMPOSITION_CHAR): If coding->flags
Kenichi Handa <handa@m17n.org>
parents:
51327
diff
changeset
|
1178 { |
8da3b8a0ca4f
(DECODE_EMACS_MULE_COMPOSITION_CHAR): If coding->flags
Kenichi Handa <handa@m17n.org>
parents:
51327
diff
changeset
|
1179 if (coding->flags && ! ASCII_BYTE_P (c)) |
8da3b8a0ca4f
(DECODE_EMACS_MULE_COMPOSITION_CHAR): If coding->flags
Kenichi Handa <handa@m17n.org>
parents:
51327
diff
changeset
|
1180 { |
8da3b8a0ca4f
(DECODE_EMACS_MULE_COMPOSITION_CHAR): If coding->flags
Kenichi Handa <handa@m17n.org>
parents:
51327
diff
changeset
|
1181 /* As we are auto saving, retain the multibyte form for |
8da3b8a0ca4f
(DECODE_EMACS_MULE_COMPOSITION_CHAR): If coding->flags
Kenichi Handa <handa@m17n.org>
parents:
51327
diff
changeset
|
1182 8-bit chars. */ |
8da3b8a0ca4f
(DECODE_EMACS_MULE_COMPOSITION_CHAR): If coding->flags
Kenichi Handa <handa@m17n.org>
parents:
51327
diff
changeset
|
1183 unsigned char buf[MAX_MULTIBYTE_LENGTH]; |
8da3b8a0ca4f
(DECODE_EMACS_MULE_COMPOSITION_CHAR): If coding->flags
Kenichi Handa <handa@m17n.org>
parents:
51327
diff
changeset
|
1184 int bytes = CHAR_STRING (c, buf); |
8da3b8a0ca4f
(DECODE_EMACS_MULE_COMPOSITION_CHAR): If coding->flags
Kenichi Handa <handa@m17n.org>
parents:
51327
diff
changeset
|
1185 |
8da3b8a0ca4f
(DECODE_EMACS_MULE_COMPOSITION_CHAR): If coding->flags
Kenichi Handa <handa@m17n.org>
parents:
51327
diff
changeset
|
1186 if (bytes == 1) |
8da3b8a0ca4f
(DECODE_EMACS_MULE_COMPOSITION_CHAR): If coding->flags
Kenichi Handa <handa@m17n.org>
parents:
51327
diff
changeset
|
1187 EMIT_ONE_BYTE (buf[0]); |
8da3b8a0ca4f
(DECODE_EMACS_MULE_COMPOSITION_CHAR): If coding->flags
Kenichi Handa <handa@m17n.org>
parents:
51327
diff
changeset
|
1188 else |
8da3b8a0ca4f
(DECODE_EMACS_MULE_COMPOSITION_CHAR): If coding->flags
Kenichi Handa <handa@m17n.org>
parents:
51327
diff
changeset
|
1189 EMIT_TWO_BYTES (buf[0], buf[1]); |
8da3b8a0ca4f
(DECODE_EMACS_MULE_COMPOSITION_CHAR): If coding->flags
Kenichi Handa <handa@m17n.org>
parents:
51327
diff
changeset
|
1190 } |
8da3b8a0ca4f
(DECODE_EMACS_MULE_COMPOSITION_CHAR): If coding->flags
Kenichi Handa <handa@m17n.org>
parents:
51327
diff
changeset
|
1191 else |
8da3b8a0ca4f
(DECODE_EMACS_MULE_COMPOSITION_CHAR): If coding->flags
Kenichi Handa <handa@m17n.org>
parents:
51327
diff
changeset
|
1192 EMIT_ONE_BYTE (c); |
8da3b8a0ca4f
(DECODE_EMACS_MULE_COMPOSITION_CHAR): If coding->flags
Kenichi Handa <handa@m17n.org>
parents:
51327
diff
changeset
|
1193 } |
34888
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1194 else |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1195 EMIT_BYTES (src_base, src); |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1196 coding->consumed_char++; |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1197 } |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1198 label_end_of_loop: |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1199 coding->consumed = src_base - source; |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1200 coding->produced = coding->produced_char = dst - destination; |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1201 return; |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1202 } |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1203 |
17052 | 1204 |
1205 /*** 3. ISO2022 handlers ***/ | |
1206 | |
1207 /* The following note describes the coding system ISO2022 briefly. | |
24425
61c6b3be1d51
Comment for ISO 2022 encoding mechanism modified.
Kenichi Handa <handa@m17n.org>
parents:
24344
diff
changeset
|
1208 Since the intention of this note is to help understand the |
35053 | 1209 functions in this file, some parts are NOT ACCURATE or are OVERLY |
24425
61c6b3be1d51
Comment for ISO 2022 encoding mechanism modified.
Kenichi Handa <handa@m17n.org>
parents:
24344
diff
changeset
|
1210 SIMPLIFIED. For thorough understanding, please refer to the |
35053 | 1211 original document of ISO2022. This is equivalent to the standard |
1212 ECMA-35, obtainable from <URL:http://www.ecma.ch/> (*). | |
17052 | 1213 |
1214 ISO2022 provides many mechanisms to encode several character sets | |
35053 | 1215 in 7-bit and 8-bit environments. For 7-bit environments, all text |
24425
61c6b3be1d51
Comment for ISO 2022 encoding mechanism modified.
Kenichi Handa <handa@m17n.org>
parents:
24344
diff
changeset
|
1216 is encoded using bytes less than 128. This may make the encoded |
61c6b3be1d51
Comment for ISO 2022 encoding mechanism modified.
Kenichi Handa <handa@m17n.org>
parents:
24344
diff
changeset
|
1217 text a little bit longer, but the text passes more easily through |
35053 | 1218 several types of gateway, some of which strip off the MSB (Most |
36087 | 1219 Significant Bit). |
35053 | 1220 |
1221 There are two kinds of character sets: control character sets and | |
1222 graphic character sets. The former contain control characters such | |
17052 | 1223 as `newline' and `escape' to provide control functions (control |
24425
61c6b3be1d51
Comment for ISO 2022 encoding mechanism modified.
Kenichi Handa <handa@m17n.org>
parents:
24344
diff
changeset
|
1224 functions are also provided by escape sequences). The latter |
35053 | 1225 contain graphic characters such as 'A' and '-'. Emacs recognizes |
17052 | 1226 two control character sets and many graphic character sets. |
1227 | |
1228 Graphic character sets are classified into one of the following | |
24425
61c6b3be1d51
Comment for ISO 2022 encoding mechanism modified.
Kenichi Handa <handa@m17n.org>
parents:
24344
diff
changeset
|
1229 four classes, according to the number of bytes (DIMENSION) and |
61c6b3be1d51
Comment for ISO 2022 encoding mechanism modified.
Kenichi Handa <handa@m17n.org>
parents:
24344
diff
changeset
|
1230 number of characters in one dimension (CHARS) of the set: |
61c6b3be1d51
Comment for ISO 2022 encoding mechanism modified.
Kenichi Handa <handa@m17n.org>
parents:
24344
diff
changeset
|
1231 - DIMENSION1_CHARS94 |
61c6b3be1d51
Comment for ISO 2022 encoding mechanism modified.
Kenichi Handa <handa@m17n.org>
parents:
24344
diff
changeset
|
1232 - DIMENSION1_CHARS96 |
61c6b3be1d51
Comment for ISO 2022 encoding mechanism modified.
Kenichi Handa <handa@m17n.org>
parents:
24344
diff
changeset
|
1233 - DIMENSION2_CHARS94 |
61c6b3be1d51
Comment for ISO 2022 encoding mechanism modified.
Kenichi Handa <handa@m17n.org>
parents:
24344
diff
changeset
|
1234 - DIMENSION2_CHARS96 |
61c6b3be1d51
Comment for ISO 2022 encoding mechanism modified.
Kenichi Handa <handa@m17n.org>
parents:
24344
diff
changeset
|
1235 |
61c6b3be1d51
Comment for ISO 2022 encoding mechanism modified.
Kenichi Handa <handa@m17n.org>
parents:
24344
diff
changeset
|
1236 In addition, each character set is assigned an identification tag, |
35053 | 1237 unique for each set, called the "final character" (denoted as <F> |
24425
61c6b3be1d51
Comment for ISO 2022 encoding mechanism modified.
Kenichi Handa <handa@m17n.org>
parents:
24344
diff
changeset
|
1238 hereafter). The <F> of each character set is decided by ECMA(*) |
61c6b3be1d51
Comment for ISO 2022 encoding mechanism modified.
Kenichi Handa <handa@m17n.org>
parents:
24344
diff
changeset
|
1239 when it is registered in ISO. The code range of <F> is 0x30..0x7F |
61c6b3be1d51
Comment for ISO 2022 encoding mechanism modified.
Kenichi Handa <handa@m17n.org>
parents:
24344
diff
changeset
|
1240 (0x30..0x3F are for private use only). |
17052 | 1241 |
1242 Note (*): ECMA = European Computer Manufacturers Association | |
1243 | |
35053 | 1244 Here are examples of graphic character sets [NAME(<F>)]: |
17052 | 1245 o DIMENSION1_CHARS94 -- ASCII('B'), right-half-of-JISX0201('I'), ... |
1246 o DIMENSION1_CHARS96 -- right-half-of-ISO8859-1('A'), ... | |
1247 o DIMENSION2_CHARS94 -- GB2312('A'), JISX0208('B'), ... | |
1248 o DIMENSION2_CHARS96 -- none for the moment | |
1249 | |
24425
61c6b3be1d51
Comment for ISO 2022 encoding mechanism modified.
Kenichi Handa <handa@m17n.org>
parents:
24344
diff
changeset
|
1250 A code area (1 byte=8 bits) is divided into 4 areas, C0, GL, C1, and GR. |
17052 | 1251 C0 [0x00..0x1F] -- control character plane 0 |
1252 GL [0x20..0x7F] -- graphic character plane 0 | |
1253 C1 [0x80..0x9F] -- control character plane 1 | |
1254 GR [0xA0..0xFF] -- graphic character plane 1 | |
1255 | |
1256 A control character set is directly designated and invoked to C0 or | |
24425
61c6b3be1d51
Comment for ISO 2022 encoding mechanism modified.
Kenichi Handa <handa@m17n.org>
parents:
24344
diff
changeset
|
1257 C1 by an escape sequence. The most common case is that: |
61c6b3be1d51
Comment for ISO 2022 encoding mechanism modified.
Kenichi Handa <handa@m17n.org>
parents:
24344
diff
changeset
|
1258 - ISO646's control character set is designated/invoked to C0, and |
61c6b3be1d51
Comment for ISO 2022 encoding mechanism modified.
Kenichi Handa <handa@m17n.org>
parents:
24344
diff
changeset
|
1259 - ISO6429's control character set is designated/invoked to C1, |
61c6b3be1d51
Comment for ISO 2022 encoding mechanism modified.
Kenichi Handa <handa@m17n.org>
parents:
24344
diff
changeset
|
1260 and usually these designations/invocations are omitted in encoded |
61c6b3be1d51
Comment for ISO 2022 encoding mechanism modified.
Kenichi Handa <handa@m17n.org>
parents:
24344
diff
changeset
|
1261 text. In a 7-bit environment, only C0 can be used, and a control |
61c6b3be1d51
Comment for ISO 2022 encoding mechanism modified.
Kenichi Handa <handa@m17n.org>
parents:
24344
diff
changeset
|
1262 character for C1 is encoded by an appropriate escape sequence to |
61c6b3be1d51
Comment for ISO 2022 encoding mechanism modified.
Kenichi Handa <handa@m17n.org>
parents:
24344
diff
changeset
|
1263 fit into the environment. All control characters for C1 are |
61c6b3be1d51
Comment for ISO 2022 encoding mechanism modified.
Kenichi Handa <handa@m17n.org>
parents:
24344
diff
changeset
|
1264 defined to have corresponding escape sequences. |
17052 | 1265 |
1266 A graphic character set is at first designated to one of four | |
1267 graphic registers (G0 through G3), then these graphic registers are | |
1268 invoked to GL or GR. These designations and invocations can be | |
1269 done independently. The most common case is that G0 is invoked to | |
24425
61c6b3be1d51
Comment for ISO 2022 encoding mechanism modified.
Kenichi Handa <handa@m17n.org>
parents:
24344
diff
changeset
|
1270 GL, G1 is invoked to GR, and ASCII is designated to G0. Usually |
61c6b3be1d51
Comment for ISO 2022 encoding mechanism modified.
Kenichi Handa <handa@m17n.org>
parents:
24344
diff
changeset
|
1271 these invocations and designations are omitted in encoded text. |
61c6b3be1d51
Comment for ISO 2022 encoding mechanism modified.
Kenichi Handa <handa@m17n.org>
parents:
24344
diff
changeset
|
1272 In a 7-bit environment, only GL can be used. |
61c6b3be1d51
Comment for ISO 2022 encoding mechanism modified.
Kenichi Handa <handa@m17n.org>
parents:
24344
diff
changeset
|
1273 |
61c6b3be1d51
Comment for ISO 2022 encoding mechanism modified.
Kenichi Handa <handa@m17n.org>
parents:
24344
diff
changeset
|
1274 When a graphic character set of CHARS94 is invoked to GL, codes |
61c6b3be1d51
Comment for ISO 2022 encoding mechanism modified.
Kenichi Handa <handa@m17n.org>
parents:
24344
diff
changeset
|
1275 0x20 and 0x7F of the GL area work as control characters SPACE and |
61c6b3be1d51
Comment for ISO 2022 encoding mechanism modified.
Kenichi Handa <handa@m17n.org>
parents:
24344
diff
changeset
|
1276 DEL respectively, and codes 0xA0 and 0xFF of the GR area should not |
61c6b3be1d51
Comment for ISO 2022 encoding mechanism modified.
Kenichi Handa <handa@m17n.org>
parents:
24344
diff
changeset
|
1277 be used. |
17052 | 1278 |
1279 There are two ways of invocation: locking-shift and single-shift. | |
1280 With locking-shift, the invocation lasts until the next different | |
24425
61c6b3be1d51
Comment for ISO 2022 encoding mechanism modified.
Kenichi Handa <handa@m17n.org>
parents:
24344
diff
changeset
|
1281 invocation, whereas with single-shift, the invocation affects the |
61c6b3be1d51
Comment for ISO 2022 encoding mechanism modified.
Kenichi Handa <handa@m17n.org>
parents:
24344
diff
changeset
|
1282 following character only and doesn't affect the locking-shift |
61c6b3be1d51
Comment for ISO 2022 encoding mechanism modified.
Kenichi Handa <handa@m17n.org>
parents:
24344
diff
changeset
|
1283 state. Invocations are done by the following control characters or |
61c6b3be1d51
Comment for ISO 2022 encoding mechanism modified.
Kenichi Handa <handa@m17n.org>
parents:
24344
diff
changeset
|
1284 escape sequences: |
17052 | 1285 |
1286 ---------------------------------------------------------------------- | |
24425
61c6b3be1d51
Comment for ISO 2022 encoding mechanism modified.
Kenichi Handa <handa@m17n.org>
parents:
24344
diff
changeset
|
1287 abbrev function cntrl escape seq description |
17052 | 1288 ---------------------------------------------------------------------- |
24425
61c6b3be1d51
Comment for ISO 2022 encoding mechanism modified.
Kenichi Handa <handa@m17n.org>
parents:
24344
diff
changeset
|
1289 SI/LS0 (shift-in) 0x0F none invoke G0 into GL |
61c6b3be1d51
Comment for ISO 2022 encoding mechanism modified.
Kenichi Handa <handa@m17n.org>
parents:
24344
diff
changeset
|
1290 SO/LS1 (shift-out) 0x0E none invoke G1 into GL |
61c6b3be1d51
Comment for ISO 2022 encoding mechanism modified.
Kenichi Handa <handa@m17n.org>
parents:
24344
diff
changeset
|
1291 LS2 (locking-shift-2) none ESC 'n' invoke G2 into GL |
61c6b3be1d51
Comment for ISO 2022 encoding mechanism modified.
Kenichi Handa <handa@m17n.org>
parents:
24344
diff
changeset
|
1292 LS3 (locking-shift-3) none ESC 'o' invoke G3 into GL |
61c6b3be1d51
Comment for ISO 2022 encoding mechanism modified.
Kenichi Handa <handa@m17n.org>
parents:
24344
diff
changeset
|
1293 LS1R (locking-shift-1 right) none ESC '~' invoke G1 into GR (*) |
61c6b3be1d51
Comment for ISO 2022 encoding mechanism modified.
Kenichi Handa <handa@m17n.org>
parents:
24344
diff
changeset
|
1294 LS2R (locking-shift-2 right) none ESC '}' invoke G2 into GR (*) |
61c6b3be1d51
Comment for ISO 2022 encoding mechanism modified.
Kenichi Handa <handa@m17n.org>
parents:
24344
diff
changeset
|
1295 LS3R (locking-shift 3 right) none ESC '|' invoke G3 into GR (*) |
61c6b3be1d51
Comment for ISO 2022 encoding mechanism modified.
Kenichi Handa <handa@m17n.org>
parents:
24344
diff
changeset
|
1296 SS2 (single-shift-2) 0x8E ESC 'N' invoke G2 for one char |
61c6b3be1d51
Comment for ISO 2022 encoding mechanism modified.
Kenichi Handa <handa@m17n.org>
parents:
24344
diff
changeset
|
1297 SS3 (single-shift-3) 0x8F ESC 'O' invoke G3 for one char |
17052 | 1298 ---------------------------------------------------------------------- |
24425
61c6b3be1d51
Comment for ISO 2022 encoding mechanism modified.
Kenichi Handa <handa@m17n.org>
parents:
24344
diff
changeset
|
1299 (*) These are not used by any known coding system. |
61c6b3be1d51
Comment for ISO 2022 encoding mechanism modified.
Kenichi Handa <handa@m17n.org>
parents:
24344
diff
changeset
|
1300 |
61c6b3be1d51
Comment for ISO 2022 encoding mechanism modified.
Kenichi Handa <handa@m17n.org>
parents:
24344
diff
changeset
|
1301 Control characters for these functions are defined by macros |
61c6b3be1d51
Comment for ISO 2022 encoding mechanism modified.
Kenichi Handa <handa@m17n.org>
parents:
24344
diff
changeset
|
1302 ISO_CODE_XXX in `coding.h'. |
61c6b3be1d51
Comment for ISO 2022 encoding mechanism modified.
Kenichi Handa <handa@m17n.org>
parents:
24344
diff
changeset
|
1303 |
61c6b3be1d51
Comment for ISO 2022 encoding mechanism modified.
Kenichi Handa <handa@m17n.org>
parents:
24344
diff
changeset
|
1304 Designations are done by the following escape sequences: |
17052 | 1305 ---------------------------------------------------------------------- |
1306 escape sequence description | |
1307 ---------------------------------------------------------------------- | |
1308 ESC '(' <F> designate DIMENSION1_CHARS94<F> to G0 | |
1309 ESC ')' <F> designate DIMENSION1_CHARS94<F> to G1 | |
1310 ESC '*' <F> designate DIMENSION1_CHARS94<F> to G2 | |
1311 ESC '+' <F> designate DIMENSION1_CHARS94<F> to G3 | |
1312 ESC ',' <F> designate DIMENSION1_CHARS96<F> to G0 (*) | |
1313 ESC '-' <F> designate DIMENSION1_CHARS96<F> to G1 | |
1314 ESC '.' <F> designate DIMENSION1_CHARS96<F> to G2 | |
1315 ESC '/' <F> designate DIMENSION1_CHARS96<F> to G3 | |
1316 ESC '$' '(' <F> designate DIMENSION2_CHARS94<F> to G0 (**) | |
1317 ESC '$' ')' <F> designate DIMENSION2_CHARS94<F> to G1 | |
1318 ESC '$' '*' <F> designate DIMENSION2_CHARS94<F> to G2 | |
1319 ESC '$' '+' <F> designate DIMENSION2_CHARS94<F> to G3 | |
1320 ESC '$' ',' <F> designate DIMENSION2_CHARS96<F> to G0 (*) | |
1321 ESC '$' '-' <F> designate DIMENSION2_CHARS96<F> to G1 | |
1322 ESC '$' '.' <F> designate DIMENSION2_CHARS96<F> to G2 | |
1323 ESC '$' '/' <F> designate DIMENSION2_CHARS96<F> to G3 | |
1324 ---------------------------------------------------------------------- | |
1325 | |
1326 In this list, "DIMENSION1_CHARS94<F>" means a graphic character set | |
24425
61c6b3be1d51
Comment for ISO 2022 encoding mechanism modified.
Kenichi Handa <handa@m17n.org>
parents:
24344
diff
changeset
|
1327 of dimension 1, chars 94, and final character <F>, etc... |
17052 | 1328 |
1329 Note (*): Although these designations are not allowed in ISO2022, | |
1330 Emacs accepts them on decoding, and produces them on encoding | |
24425
61c6b3be1d51
Comment for ISO 2022 encoding mechanism modified.
Kenichi Handa <handa@m17n.org>
parents:
24344
diff
changeset
|
1331 CHARS96 character sets in a coding system which is characterized as |
17052 | 1332 7-bit environment, non-locking-shift, and non-single-shift. |
1333 | |
1334 Note (**): If <F> is '@', 'A', or 'B', the intermediate character | |
24425
61c6b3be1d51
Comment for ISO 2022 encoding mechanism modified.
Kenichi Handa <handa@m17n.org>
parents:
24344
diff
changeset
|
1335 '(' can be omitted. We refer to this as "short-form" hereafter. |
17052 | 1336 |
35053 | 1337 Now you may notice that there are a lot of ways of encoding the |
24425
61c6b3be1d51
Comment for ISO 2022 encoding mechanism modified.
Kenichi Handa <handa@m17n.org>
parents:
24344
diff
changeset
|
1338 same multilingual text in ISO2022. Actually, there exist many |
61c6b3be1d51
Comment for ISO 2022 encoding mechanism modified.
Kenichi Handa <handa@m17n.org>
parents:
24344
diff
changeset
|
1339 coding systems such as Compound Text (used in X11's inter client |
36087 | 1340 communication, ISO-2022-JP (used in Japanese Internet), ISO-2022-KR |
1341 (used in Korean Internet), EUC (Extended UNIX Code, used in Asian | |
17052 | 1342 localized platforms), and all of these are variants of ISO2022. |
1343 | |
1344 In addition to the above, Emacs handles two more kinds of escape | |
1345 sequences: ISO6429's direction specification and Emacs' private | |
1346 sequence for specifying character composition. | |
1347 | |
24425
61c6b3be1d51
Comment for ISO 2022 encoding mechanism modified.
Kenichi Handa <handa@m17n.org>
parents:
24344
diff
changeset
|
1348 ISO6429's direction specification takes the following form: |
17052 | 1349 o CSI ']' -- end of the current direction |
1350 o CSI '0' ']' -- end of the current direction | |
1351 o CSI '1' ']' -- start of left-to-right text | |
1352 o CSI '2' ']' -- start of right-to-left text | |
1353 The control character CSI (0x9B: control sequence introducer) is | |
24425
61c6b3be1d51
Comment for ISO 2022 encoding mechanism modified.
Kenichi Handa <handa@m17n.org>
parents:
24344
diff
changeset
|
1354 abbreviated to the escape sequence ESC '[' in a 7-bit environment. |
61c6b3be1d51
Comment for ISO 2022 encoding mechanism modified.
Kenichi Handa <handa@m17n.org>
parents:
24344
diff
changeset
|
1355 |
61c6b3be1d51
Comment for ISO 2022 encoding mechanism modified.
Kenichi Handa <handa@m17n.org>
parents:
24344
diff
changeset
|
1356 Character composition specification takes the following form: |
26847 | 1357 o ESC '0' -- start relative composition |
1358 o ESC '1' -- end composition | |
1359 o ESC '2' -- start rule-base composition (*) | |
1360 o ESC '3' -- start relative composition with alternate chars (**) | |
1361 o ESC '4' -- start rule-base composition with alternate chars (**) | |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1362 Since these are not standard escape sequences of any ISO standard, |
35053 | 1363 the use of them with these meanings is restricted to Emacs only. |
1364 | |
1365 (*) This form is used only in Emacs 20.5 and older versions, | |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1366 but the newer versions can safely decode it. |
35053 | 1367 (**) This form is used only in Emacs 21.1 and newer versions, |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1368 and the older versions can't decode it. |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1369 |
35053 | 1370 Here's a list of example usages of these composition escape |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1371 sequences (categorized by `enum composition_method'). |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1372 |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1373 COMPOSITION_RELATIVE: |
26847 | 1374 ESC 0 CHAR [ CHAR ] ESC 1 |
36087 | 1375 COMPOSITION_WITH_RULE: |
26847 | 1376 ESC 2 CHAR [ RULE CHAR ] ESC 1 |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1377 COMPOSITION_WITH_ALTCHARS: |
26847 | 1378 ESC 3 ALTCHAR [ ALTCHAR ] ESC 0 CHAR [ CHAR ] ESC 1 |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1379 COMPOSITION_WITH_RULE_ALTCHARS: |
26847 | 1380 ESC 4 ALTCHAR [ RULE ALTCHAR ] ESC 0 CHAR [ CHAR ] ESC 1 */ |
17052 | 1381 |
1382 enum iso_code_class_type iso_code_class[256]; | |
1383 | |
30487
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
1384 #define CHARSET_OK(idx, charset, c) \ |
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
1385 (coding_system_table[idx] \ |
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
1386 && (charset == CHARSET_ASCII \ |
49539
1ad5bfbb831a
(syms_of_coding): Add `...' for symbols in the docstring of
Kenichi Handa <handa@m17n.org>
parents:
48874
diff
changeset
|
1387 || (safe_chars = coding_safe_chars (coding_system_table[idx]->symbol), \ |
30487
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
1388 CODING_SAFE_CHAR_P (safe_chars, c))) \ |
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
1389 && (CODING_SPEC_ISO_REQUESTED_DESIGNATION (coding_system_table[idx], \ |
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
1390 charset) \ |
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
1391 != CODING_SPEC_ISO_NO_REQUESTED_DESIGNATION)) |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
1392 |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
1393 #define SHIFT_OUT_OK(idx) \ |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
1394 (CODING_SPEC_ISO_INITIAL_DESIGNATION (coding_system_table[idx], 1) >= 0) |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
1395 |
50047
8e17fbb2ac77
(CODING_ADD_COMPOSITION_COMPONENT): If the number of
Kenichi Handa <handa@m17n.org>
parents:
49600
diff
changeset
|
1396 #define COMPOSITION_OK(idx) \ |
8e17fbb2ac77
(CODING_ADD_COMPOSITION_COMPONENT): If the number of
Kenichi Handa <handa@m17n.org>
parents:
49600
diff
changeset
|
1397 (coding_system_table[idx]->composing != COMPOSITION_DISABLED) |
8e17fbb2ac77
(CODING_ADD_COMPOSITION_COMPONENT): If the number of
Kenichi Handa <handa@m17n.org>
parents:
49600
diff
changeset
|
1398 |
17052 | 1399 /* See the above "GENERAL NOTES on `detect_coding_XXX ()' functions". |
35053 | 1400 Check if a text is encoded in ISO2022. If it is, return an |
17052 | 1401 integer in which appropriate flag bits any of: |
1402 CODING_CATEGORY_MASK_ISO_7 | |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
1403 CODING_CATEGORY_MASK_ISO_7_TIGHT |
17052 | 1404 CODING_CATEGORY_MASK_ISO_8_1 |
1405 CODING_CATEGORY_MASK_ISO_8_2 | |
18787
954e6be0a757
(detect_coding_iso2022): Distinguish coding-category-iso-7-else and
Kenichi Handa <handa@m17n.org>
parents:
18766
diff
changeset
|
1406 CODING_CATEGORY_MASK_ISO_7_ELSE |
954e6be0a757
(detect_coding_iso2022): Distinguish coding-category-iso-7-else and
Kenichi Handa <handa@m17n.org>
parents:
18766
diff
changeset
|
1407 CODING_CATEGORY_MASK_ISO_8_ELSE |
17052 | 1408 are set. If a code which should never appear in ISO2022 is found, |
1409 returns 0. */ | |
1410 | |
34531
37f85e931855
(ONE_MORE_BYTE_CHECK_MULTIBYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34197
diff
changeset
|
1411 static int |
37f85e931855
(ONE_MORE_BYTE_CHECK_MULTIBYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34197
diff
changeset
|
1412 detect_coding_iso2022 (src, src_end, multibytep) |
17052 | 1413 unsigned char *src, *src_end; |
34531
37f85e931855
(ONE_MORE_BYTE_CHECK_MULTIBYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34197
diff
changeset
|
1414 int multibytep; |
17052 | 1415 { |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
1416 int mask = CODING_CATEGORY_MASK_ISO; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
1417 int mask_found = 0; |
23088
45c36d636f66
(detect_coding_iso2022): Don't check the byte length of
Kenichi Handa <handa@m17n.org>
parents:
23082
diff
changeset
|
1418 int reg[4], shift_out = 0, single_shifting = 0; |
34988
8cd5e6ad71a2
(detect_coding_iso2022, setup_coding_system): Remove
Eli Zaretskii <eliz@gnu.org>
parents:
34892
diff
changeset
|
1419 int c, c1, charset; |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1420 /* Dummy for ONE_MORE_BYTE. */ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1421 struct coding_system dummy_coding; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1422 struct coding_system *coding = &dummy_coding; |
30487
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
1423 Lisp_Object safe_chars; |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
1424 |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
1425 reg[0] = CHARSET_ASCII, reg[1] = reg[2] = reg[3] = -1; |
72395
94e4795b333d
(ONE_MORE_BYTE_CHECK_MULTIBYTE): New arg RET. If SRC
Kenichi Handa <handa@m17n.org>
parents:
72323
diff
changeset
|
1426 while (mask) |
94e4795b333d
(ONE_MORE_BYTE_CHECK_MULTIBYTE): New arg RET. If SRC
Kenichi Handa <handa@m17n.org>
parents:
72323
diff
changeset
|
1427 { |
94e4795b333d
(ONE_MORE_BYTE_CHECK_MULTIBYTE): New arg RET. If SRC
Kenichi Handa <handa@m17n.org>
parents:
72323
diff
changeset
|
1428 ONE_MORE_BYTE_CHECK_MULTIBYTE (c, multibytep, mask & mask_found); |
46702
2673ae55a6f9
(detect_coding_iso2022): While checking a byte sequence
Kenichi Handa <handa@m17n.org>
parents:
46548
diff
changeset
|
1429 retry: |
17052 | 1430 switch (c) |
1431 { | |
1432 case ISO_CODE_ESC: | |
30204
35aec8514228
(inhibit_iso_escape_detection): New variable.
Kenichi Handa <handa@m17n.org>
parents:
29985
diff
changeset
|
1433 if (inhibit_iso_escape_detection) |
35aec8514228
(inhibit_iso_escape_detection): New variable.
Kenichi Handa <handa@m17n.org>
parents:
29985
diff
changeset
|
1434 break; |
23088
45c36d636f66
(detect_coding_iso2022): Don't check the byte length of
Kenichi Handa <handa@m17n.org>
parents:
23082
diff
changeset
|
1435 single_shifting = 0; |
72395
94e4795b333d
(ONE_MORE_BYTE_CHECK_MULTIBYTE): New arg RET. If SRC
Kenichi Handa <handa@m17n.org>
parents:
72323
diff
changeset
|
1436 ONE_MORE_BYTE_CHECK_MULTIBYTE (c, multibytep, mask & mask_found); |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
1437 if (c >= '(' && c <= '/') |
19134
8fa6e23f8d22
(detect_coding_iso2022): Do not exclude posibility of
Kenichi Handa <handa@m17n.org>
parents:
19118
diff
changeset
|
1438 { |
8fa6e23f8d22
(detect_coding_iso2022): Do not exclude posibility of
Kenichi Handa <handa@m17n.org>
parents:
19118
diff
changeset
|
1439 /* Designation sequence for a charset of dimension 1. */ |
72395
94e4795b333d
(ONE_MORE_BYTE_CHECK_MULTIBYTE): New arg RET. If SRC
Kenichi Handa <handa@m17n.org>
parents:
72323
diff
changeset
|
1440 ONE_MORE_BYTE_CHECK_MULTIBYTE (c1, multibytep, mask & mask_found); |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
1441 if (c1 < ' ' || c1 >= 0x80 |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
1442 || (charset = iso_charset_table[0][c >= ','][c1]) < 0) |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
1443 /* Invalid designation sequence. Just ignore. */ |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
1444 break; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
1445 reg[(c - '(') % 4] = charset; |
19134
8fa6e23f8d22
(detect_coding_iso2022): Do not exclude posibility of
Kenichi Handa <handa@m17n.org>
parents:
19118
diff
changeset
|
1446 } |
8fa6e23f8d22
(detect_coding_iso2022): Do not exclude posibility of
Kenichi Handa <handa@m17n.org>
parents:
19118
diff
changeset
|
1447 else if (c == '$') |
17052 | 1448 { |
19134
8fa6e23f8d22
(detect_coding_iso2022): Do not exclude posibility of
Kenichi Handa <handa@m17n.org>
parents:
19118
diff
changeset
|
1449 /* Designation sequence for a charset of dimension 2. */ |
72395
94e4795b333d
(ONE_MORE_BYTE_CHECK_MULTIBYTE): New arg RET. If SRC
Kenichi Handa <handa@m17n.org>
parents:
72323
diff
changeset
|
1450 ONE_MORE_BYTE_CHECK_MULTIBYTE (c, multibytep, mask & mask_found); |
19134
8fa6e23f8d22
(detect_coding_iso2022): Do not exclude posibility of
Kenichi Handa <handa@m17n.org>
parents:
19118
diff
changeset
|
1451 if (c >= '@' && c <= 'B') |
8fa6e23f8d22
(detect_coding_iso2022): Do not exclude posibility of
Kenichi Handa <handa@m17n.org>
parents:
19118
diff
changeset
|
1452 /* Designation for JISX0208.1978, GB2312, or JISX0208. */ |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
1453 reg[0] = charset = iso_charset_table[1][0][c]; |
19134
8fa6e23f8d22
(detect_coding_iso2022): Do not exclude posibility of
Kenichi Handa <handa@m17n.org>
parents:
19118
diff
changeset
|
1454 else if (c >= '(' && c <= '/') |
17320
9d15bec5f47e
(detect_coding_iso2022, detect_coding_mask): Ignore
Kenichi Handa <handa@m17n.org>
parents:
17304
diff
changeset
|
1455 { |
72395
94e4795b333d
(ONE_MORE_BYTE_CHECK_MULTIBYTE): New arg RET. If SRC
Kenichi Handa <handa@m17n.org>
parents:
72323
diff
changeset
|
1456 ONE_MORE_BYTE_CHECK_MULTIBYTE (c1, multibytep, |
94e4795b333d
(ONE_MORE_BYTE_CHECK_MULTIBYTE): New arg RET. If SRC
Kenichi Handa <handa@m17n.org>
parents:
72323
diff
changeset
|
1457 mask & mask_found); |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
1458 if (c1 < ' ' || c1 >= 0x80 |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
1459 || (charset = iso_charset_table[1][c >= ','][c1]) < 0) |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
1460 /* Invalid designation sequence. Just ignore. */ |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
1461 break; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
1462 reg[(c - '(') % 4] = charset; |
17320
9d15bec5f47e
(detect_coding_iso2022, detect_coding_mask): Ignore
Kenichi Handa <handa@m17n.org>
parents:
17304
diff
changeset
|
1463 } |
19134
8fa6e23f8d22
(detect_coding_iso2022): Do not exclude posibility of
Kenichi Handa <handa@m17n.org>
parents:
19118
diff
changeset
|
1464 else |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
1465 /* Invalid designation sequence. Just ignore. */ |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
1466 break; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
1467 } |
23116
6736da064f4a
(detect_coding_iso2022): Handle ESC N and ESC O
Kenichi Handa <handa@m17n.org>
parents:
23089
diff
changeset
|
1468 else if (c == 'N' || c == 'O') |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
1469 { |
23116
6736da064f4a
(detect_coding_iso2022): Handle ESC N and ESC O
Kenichi Handa <handa@m17n.org>
parents:
23089
diff
changeset
|
1470 /* ESC <Fe> for SS2 or SS3. */ |
6736da064f4a
(detect_coding_iso2022): Handle ESC N and ESC O
Kenichi Handa <handa@m17n.org>
parents:
23089
diff
changeset
|
1471 mask &= CODING_CATEGORY_MASK_ISO_7_ELSE; |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
1472 break; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
1473 } |
26847 | 1474 else if (c >= '0' && c <= '4') |
1475 { | |
1476 /* ESC <Fp> for start/end composition. */ | |
50047
8e17fbb2ac77
(CODING_ADD_COMPOSITION_COMPONENT): If the number of
Kenichi Handa <handa@m17n.org>
parents:
49600
diff
changeset
|
1477 if (COMPOSITION_OK (CODING_CATEGORY_IDX_ISO_7)) |
8e17fbb2ac77
(CODING_ADD_COMPOSITION_COMPONENT): If the number of
Kenichi Handa <handa@m17n.org>
parents:
49600
diff
changeset
|
1478 mask_found |= CODING_CATEGORY_MASK_ISO_7; |
8e17fbb2ac77
(CODING_ADD_COMPOSITION_COMPONENT): If the number of
Kenichi Handa <handa@m17n.org>
parents:
49600
diff
changeset
|
1479 else |
8e17fbb2ac77
(CODING_ADD_COMPOSITION_COMPONENT): If the number of
Kenichi Handa <handa@m17n.org>
parents:
49600
diff
changeset
|
1480 mask &= ~CODING_CATEGORY_MASK_ISO_7; |
8e17fbb2ac77
(CODING_ADD_COMPOSITION_COMPONENT): If the number of
Kenichi Handa <handa@m17n.org>
parents:
49600
diff
changeset
|
1481 if (COMPOSITION_OK (CODING_CATEGORY_IDX_ISO_7_TIGHT)) |
8e17fbb2ac77
(CODING_ADD_COMPOSITION_COMPONENT): If the number of
Kenichi Handa <handa@m17n.org>
parents:
49600
diff
changeset
|
1482 mask_found |= CODING_CATEGORY_MASK_ISO_7_TIGHT; |
8e17fbb2ac77
(CODING_ADD_COMPOSITION_COMPONENT): If the number of
Kenichi Handa <handa@m17n.org>
parents:
49600
diff
changeset
|
1483 else |
8e17fbb2ac77
(CODING_ADD_COMPOSITION_COMPONENT): If the number of
Kenichi Handa <handa@m17n.org>
parents:
49600
diff
changeset
|
1484 mask &= ~CODING_CATEGORY_MASK_ISO_7_TIGHT; |
8e17fbb2ac77
(CODING_ADD_COMPOSITION_COMPONENT): If the number of
Kenichi Handa <handa@m17n.org>
parents:
49600
diff
changeset
|
1485 if (COMPOSITION_OK (CODING_CATEGORY_IDX_ISO_8_1)) |
8e17fbb2ac77
(CODING_ADD_COMPOSITION_COMPONENT): If the number of
Kenichi Handa <handa@m17n.org>
parents:
49600
diff
changeset
|
1486 mask_found |= CODING_CATEGORY_MASK_ISO_8_1; |
8e17fbb2ac77
(CODING_ADD_COMPOSITION_COMPONENT): If the number of
Kenichi Handa <handa@m17n.org>
parents:
49600
diff
changeset
|
1487 else |
8e17fbb2ac77
(CODING_ADD_COMPOSITION_COMPONENT): If the number of
Kenichi Handa <handa@m17n.org>
parents:
49600
diff
changeset
|
1488 mask &= ~CODING_CATEGORY_MASK_ISO_8_1; |
8e17fbb2ac77
(CODING_ADD_COMPOSITION_COMPONENT): If the number of
Kenichi Handa <handa@m17n.org>
parents:
49600
diff
changeset
|
1489 if (COMPOSITION_OK (CODING_CATEGORY_IDX_ISO_8_2)) |
8e17fbb2ac77
(CODING_ADD_COMPOSITION_COMPONENT): If the number of
Kenichi Handa <handa@m17n.org>
parents:
49600
diff
changeset
|
1490 mask_found |= CODING_CATEGORY_MASK_ISO_8_2; |
8e17fbb2ac77
(CODING_ADD_COMPOSITION_COMPONENT): If the number of
Kenichi Handa <handa@m17n.org>
parents:
49600
diff
changeset
|
1491 else |
8e17fbb2ac77
(CODING_ADD_COMPOSITION_COMPONENT): If the number of
Kenichi Handa <handa@m17n.org>
parents:
49600
diff
changeset
|
1492 mask &= ~CODING_CATEGORY_MASK_ISO_8_2; |
8e17fbb2ac77
(CODING_ADD_COMPOSITION_COMPONENT): If the number of
Kenichi Handa <handa@m17n.org>
parents:
49600
diff
changeset
|
1493 if (COMPOSITION_OK (CODING_CATEGORY_IDX_ISO_7_ELSE)) |
8e17fbb2ac77
(CODING_ADD_COMPOSITION_COMPONENT): If the number of
Kenichi Handa <handa@m17n.org>
parents:
49600
diff
changeset
|
1494 mask_found |= CODING_CATEGORY_MASK_ISO_7_ELSE; |
8e17fbb2ac77
(CODING_ADD_COMPOSITION_COMPONENT): If the number of
Kenichi Handa <handa@m17n.org>
parents:
49600
diff
changeset
|
1495 else |
8e17fbb2ac77
(CODING_ADD_COMPOSITION_COMPONENT): If the number of
Kenichi Handa <handa@m17n.org>
parents:
49600
diff
changeset
|
1496 mask &= ~CODING_CATEGORY_MASK_ISO_7_ELSE; |
8e17fbb2ac77
(CODING_ADD_COMPOSITION_COMPONENT): If the number of
Kenichi Handa <handa@m17n.org>
parents:
49600
diff
changeset
|
1497 if (COMPOSITION_OK (CODING_CATEGORY_IDX_ISO_8_ELSE)) |
8e17fbb2ac77
(CODING_ADD_COMPOSITION_COMPONENT): If the number of
Kenichi Handa <handa@m17n.org>
parents:
49600
diff
changeset
|
1498 mask_found |= CODING_CATEGORY_MASK_ISO_8_ELSE; |
8e17fbb2ac77
(CODING_ADD_COMPOSITION_COMPONENT): If the number of
Kenichi Handa <handa@m17n.org>
parents:
49600
diff
changeset
|
1499 else |
8e17fbb2ac77
(CODING_ADD_COMPOSITION_COMPONENT): If the number of
Kenichi Handa <handa@m17n.org>
parents:
49600
diff
changeset
|
1500 mask &= ~CODING_CATEGORY_MASK_ISO_8_ELSE; |
26847 | 1501 break; |
1502 } | |
19134
8fa6e23f8d22
(detect_coding_iso2022): Do not exclude posibility of
Kenichi Handa <handa@m17n.org>
parents:
19118
diff
changeset
|
1503 else |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
1504 /* Invalid escape sequence. Just ignore. */ |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
1505 break; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
1506 |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
1507 /* We found a valid designation sequence for CHARSET. */ |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
1508 mask &= ~CODING_CATEGORY_MASK_ISO_8BIT; |
30487
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
1509 c = MAKE_CHAR (charset, 0, 0); |
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
1510 if (CHARSET_OK (CODING_CATEGORY_IDX_ISO_7, charset, c)) |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
1511 mask_found |= CODING_CATEGORY_MASK_ISO_7; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
1512 else |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
1513 mask &= ~CODING_CATEGORY_MASK_ISO_7; |
30487
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
1514 if (CHARSET_OK (CODING_CATEGORY_IDX_ISO_7_TIGHT, charset, c)) |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
1515 mask_found |= CODING_CATEGORY_MASK_ISO_7_TIGHT; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
1516 else |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
1517 mask &= ~CODING_CATEGORY_MASK_ISO_7_TIGHT; |
30487
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
1518 if (CHARSET_OK (CODING_CATEGORY_IDX_ISO_7_ELSE, charset, c)) |
23116
6736da064f4a
(detect_coding_iso2022): Handle ESC N and ESC O
Kenichi Handa <handa@m17n.org>
parents:
23089
diff
changeset
|
1519 mask_found |= CODING_CATEGORY_MASK_ISO_7_ELSE; |
6736da064f4a
(detect_coding_iso2022): Handle ESC N and ESC O
Kenichi Handa <handa@m17n.org>
parents:
23089
diff
changeset
|
1520 else |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
1521 mask &= ~CODING_CATEGORY_MASK_ISO_7_ELSE; |
30487
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
1522 if (CHARSET_OK (CODING_CATEGORY_IDX_ISO_8_ELSE, charset, c)) |
23116
6736da064f4a
(detect_coding_iso2022): Handle ESC N and ESC O
Kenichi Handa <handa@m17n.org>
parents:
23089
diff
changeset
|
1523 mask_found |= CODING_CATEGORY_MASK_ISO_8_ELSE; |
6736da064f4a
(detect_coding_iso2022): Handle ESC N and ESC O
Kenichi Handa <handa@m17n.org>
parents:
23089
diff
changeset
|
1524 else |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
1525 mask &= ~CODING_CATEGORY_MASK_ISO_8_ELSE; |
17052 | 1526 break; |
1527 | |
1528 case ISO_CODE_SO: | |
30204
35aec8514228
(inhibit_iso_escape_detection): New variable.
Kenichi Handa <handa@m17n.org>
parents:
29985
diff
changeset
|
1529 if (inhibit_iso_escape_detection) |
35aec8514228
(inhibit_iso_escape_detection): New variable.
Kenichi Handa <handa@m17n.org>
parents:
29985
diff
changeset
|
1530 break; |
23088
45c36d636f66
(detect_coding_iso2022): Don't check the byte length of
Kenichi Handa <handa@m17n.org>
parents:
23082
diff
changeset
|
1531 single_shifting = 0; |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
1532 if (shift_out == 0 |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
1533 && (reg[1] >= 0 |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
1534 || SHIFT_OUT_OK (CODING_CATEGORY_IDX_ISO_7_ELSE) |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
1535 || SHIFT_OUT_OK (CODING_CATEGORY_IDX_ISO_8_ELSE))) |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
1536 { |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
1537 /* Locking shift out. */ |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
1538 mask &= ~CODING_CATEGORY_MASK_ISO_7BIT; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
1539 mask_found |= CODING_CATEGORY_MASK_ISO_SHIFT; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
1540 } |
17119
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
1541 break; |
42104
d69c2368e549
(DECODE_COMPOSITION_END): Fixed a typo in the last
Sam Steingold <sds@gnu.org>
parents:
42103
diff
changeset
|
1542 |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
1543 case ISO_CODE_SI: |
30204
35aec8514228
(inhibit_iso_escape_detection): New variable.
Kenichi Handa <handa@m17n.org>
parents:
29985
diff
changeset
|
1544 if (inhibit_iso_escape_detection) |
35aec8514228
(inhibit_iso_escape_detection): New variable.
Kenichi Handa <handa@m17n.org>
parents:
29985
diff
changeset
|
1545 break; |
23088
45c36d636f66
(detect_coding_iso2022): Don't check the byte length of
Kenichi Handa <handa@m17n.org>
parents:
23082
diff
changeset
|
1546 single_shifting = 0; |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
1547 if (shift_out == 1) |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
1548 { |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
1549 /* Locking shift in. */ |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
1550 mask &= ~CODING_CATEGORY_MASK_ISO_7BIT; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
1551 mask_found |= CODING_CATEGORY_MASK_ISO_SHIFT; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
1552 } |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
1553 break; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
1554 |
17052 | 1555 case ISO_CODE_CSI: |
23088
45c36d636f66
(detect_coding_iso2022): Don't check the byte length of
Kenichi Handa <handa@m17n.org>
parents:
23082
diff
changeset
|
1556 single_shifting = 0; |
17052 | 1557 case ISO_CODE_SS2: |
1558 case ISO_CODE_SS3: | |
19365
d9374f5ebd3a
(CODING_FLAG_ISO_LATIN_EXTRA): New macro.
Kenichi Handa <handa@m17n.org>
parents:
19285
diff
changeset
|
1559 { |
d9374f5ebd3a
(CODING_FLAG_ISO_LATIN_EXTRA): New macro.
Kenichi Handa <handa@m17n.org>
parents:
19285
diff
changeset
|
1560 int newmask = CODING_CATEGORY_MASK_ISO_8_ELSE; |
d9374f5ebd3a
(CODING_FLAG_ISO_LATIN_EXTRA): New macro.
Kenichi Handa <handa@m17n.org>
parents:
19285
diff
changeset
|
1561 |
30204
35aec8514228
(inhibit_iso_escape_detection): New variable.
Kenichi Handa <handa@m17n.org>
parents:
29985
diff
changeset
|
1562 if (inhibit_iso_escape_detection) |
35aec8514228
(inhibit_iso_escape_detection): New variable.
Kenichi Handa <handa@m17n.org>
parents:
29985
diff
changeset
|
1563 break; |
20150
402b6e5f4b58
(encode_designation_at_bol): Fix bug of finding graphic
Kenichi Handa <handa@m17n.org>
parents:
20105
diff
changeset
|
1564 if (c != ISO_CODE_CSI) |
402b6e5f4b58
(encode_designation_at_bol): Fix bug of finding graphic
Kenichi Handa <handa@m17n.org>
parents:
20105
diff
changeset
|
1565 { |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
1566 if (coding_system_table[CODING_CATEGORY_IDX_ISO_8_1]->flags |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
1567 & CODING_FLAG_ISO_SINGLE_SHIFT) |
20150
402b6e5f4b58
(encode_designation_at_bol): Fix bug of finding graphic
Kenichi Handa <handa@m17n.org>
parents:
20105
diff
changeset
|
1568 newmask |= CODING_CATEGORY_MASK_ISO_8_1; |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
1569 if (coding_system_table[CODING_CATEGORY_IDX_ISO_8_2]->flags |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
1570 & CODING_FLAG_ISO_SINGLE_SHIFT) |
20150
402b6e5f4b58
(encode_designation_at_bol): Fix bug of finding graphic
Kenichi Handa <handa@m17n.org>
parents:
20105
diff
changeset
|
1571 newmask |= CODING_CATEGORY_MASK_ISO_8_2; |
23088
45c36d636f66
(detect_coding_iso2022): Don't check the byte length of
Kenichi Handa <handa@m17n.org>
parents:
23082
diff
changeset
|
1572 single_shifting = 1; |
20150
402b6e5f4b58
(encode_designation_at_bol): Fix bug of finding graphic
Kenichi Handa <handa@m17n.org>
parents:
20105
diff
changeset
|
1573 } |
19365
d9374f5ebd3a
(CODING_FLAG_ISO_LATIN_EXTRA): New macro.
Kenichi Handa <handa@m17n.org>
parents:
19285
diff
changeset
|
1574 if (VECTORP (Vlatin_extra_code_table) |
d9374f5ebd3a
(CODING_FLAG_ISO_LATIN_EXTRA): New macro.
Kenichi Handa <handa@m17n.org>
parents:
19285
diff
changeset
|
1575 && !NILP (XVECTOR (Vlatin_extra_code_table)->contents[c])) |
d9374f5ebd3a
(CODING_FLAG_ISO_LATIN_EXTRA): New macro.
Kenichi Handa <handa@m17n.org>
parents:
19285
diff
changeset
|
1576 { |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
1577 if (coding_system_table[CODING_CATEGORY_IDX_ISO_8_1]->flags |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
1578 & CODING_FLAG_ISO_LATIN_EXTRA) |
19365
d9374f5ebd3a
(CODING_FLAG_ISO_LATIN_EXTRA): New macro.
Kenichi Handa <handa@m17n.org>
parents:
19285
diff
changeset
|
1579 newmask |= CODING_CATEGORY_MASK_ISO_8_1; |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
1580 if (coding_system_table[CODING_CATEGORY_IDX_ISO_8_2]->flags |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
1581 & CODING_FLAG_ISO_LATIN_EXTRA) |
19365
d9374f5ebd3a
(CODING_FLAG_ISO_LATIN_EXTRA): New macro.
Kenichi Handa <handa@m17n.org>
parents:
19285
diff
changeset
|
1582 newmask |= CODING_CATEGORY_MASK_ISO_8_2; |
d9374f5ebd3a
(CODING_FLAG_ISO_LATIN_EXTRA): New macro.
Kenichi Handa <handa@m17n.org>
parents:
19285
diff
changeset
|
1583 } |
d9374f5ebd3a
(CODING_FLAG_ISO_LATIN_EXTRA): New macro.
Kenichi Handa <handa@m17n.org>
parents:
19285
diff
changeset
|
1584 mask &= newmask; |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
1585 mask_found |= newmask; |
19365
d9374f5ebd3a
(CODING_FLAG_ISO_LATIN_EXTRA): New macro.
Kenichi Handa <handa@m17n.org>
parents:
19285
diff
changeset
|
1586 } |
d9374f5ebd3a
(CODING_FLAG_ISO_LATIN_EXTRA): New macro.
Kenichi Handa <handa@m17n.org>
parents:
19285
diff
changeset
|
1587 break; |
17052 | 1588 |
1589 default: | |
1590 if (c < 0x80) | |
23088
45c36d636f66
(detect_coding_iso2022): Don't check the byte length of
Kenichi Handa <handa@m17n.org>
parents:
23082
diff
changeset
|
1591 { |
45c36d636f66
(detect_coding_iso2022): Don't check the byte length of
Kenichi Handa <handa@m17n.org>
parents:
23082
diff
changeset
|
1592 single_shifting = 0; |
45c36d636f66
(detect_coding_iso2022): Don't check the byte length of
Kenichi Handa <handa@m17n.org>
parents:
23082
diff
changeset
|
1593 break; |
45c36d636f66
(detect_coding_iso2022): Don't check the byte length of
Kenichi Handa <handa@m17n.org>
parents:
23082
diff
changeset
|
1594 } |
17052 | 1595 else if (c < 0xA0) |
19280
e755044718ee
(ENCODE_ISO_CHARACTER_DIMENSION1): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
19193
diff
changeset
|
1596 { |
23088
45c36d636f66
(detect_coding_iso2022): Don't check the byte length of
Kenichi Handa <handa@m17n.org>
parents:
23082
diff
changeset
|
1597 single_shifting = 0; |
19365
d9374f5ebd3a
(CODING_FLAG_ISO_LATIN_EXTRA): New macro.
Kenichi Handa <handa@m17n.org>
parents:
19285
diff
changeset
|
1598 if (VECTORP (Vlatin_extra_code_table) |
d9374f5ebd3a
(CODING_FLAG_ISO_LATIN_EXTRA): New macro.
Kenichi Handa <handa@m17n.org>
parents:
19285
diff
changeset
|
1599 && !NILP (XVECTOR (Vlatin_extra_code_table)->contents[c])) |
19280
e755044718ee
(ENCODE_ISO_CHARACTER_DIMENSION1): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
19193
diff
changeset
|
1600 { |
19365
d9374f5ebd3a
(CODING_FLAG_ISO_LATIN_EXTRA): New macro.
Kenichi Handa <handa@m17n.org>
parents:
19285
diff
changeset
|
1601 int newmask = 0; |
d9374f5ebd3a
(CODING_FLAG_ISO_LATIN_EXTRA): New macro.
Kenichi Handa <handa@m17n.org>
parents:
19285
diff
changeset
|
1602 |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
1603 if (coding_system_table[CODING_CATEGORY_IDX_ISO_8_1]->flags |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
1604 & CODING_FLAG_ISO_LATIN_EXTRA) |
19365
d9374f5ebd3a
(CODING_FLAG_ISO_LATIN_EXTRA): New macro.
Kenichi Handa <handa@m17n.org>
parents:
19285
diff
changeset
|
1605 newmask |= CODING_CATEGORY_MASK_ISO_8_1; |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
1606 if (coding_system_table[CODING_CATEGORY_IDX_ISO_8_2]->flags |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
1607 & CODING_FLAG_ISO_LATIN_EXTRA) |
19365
d9374f5ebd3a
(CODING_FLAG_ISO_LATIN_EXTRA): New macro.
Kenichi Handa <handa@m17n.org>
parents:
19285
diff
changeset
|
1608 newmask |= CODING_CATEGORY_MASK_ISO_8_2; |
d9374f5ebd3a
(CODING_FLAG_ISO_LATIN_EXTRA): New macro.
Kenichi Handa <handa@m17n.org>
parents:
19285
diff
changeset
|
1609 mask &= newmask; |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
1610 mask_found |= newmask; |
19280
e755044718ee
(ENCODE_ISO_CHARACTER_DIMENSION1): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
19193
diff
changeset
|
1611 } |
19365
d9374f5ebd3a
(CODING_FLAG_ISO_LATIN_EXTRA): New macro.
Kenichi Handa <handa@m17n.org>
parents:
19285
diff
changeset
|
1612 else |
d9374f5ebd3a
(CODING_FLAG_ISO_LATIN_EXTRA): New macro.
Kenichi Handa <handa@m17n.org>
parents:
19285
diff
changeset
|
1613 return 0; |
19280
e755044718ee
(ENCODE_ISO_CHARACTER_DIMENSION1): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
19193
diff
changeset
|
1614 } |
17052 | 1615 else |
1616 { | |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
1617 mask &= ~(CODING_CATEGORY_MASK_ISO_7BIT |
18787
954e6be0a757
(detect_coding_iso2022): Distinguish coding-category-iso-7-else and
Kenichi Handa <handa@m17n.org>
parents:
18766
diff
changeset
|
1618 | CODING_CATEGORY_MASK_ISO_7_ELSE); |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
1619 mask_found |= CODING_CATEGORY_MASK_ISO_8_1; |
23088
45c36d636f66
(detect_coding_iso2022): Don't check the byte length of
Kenichi Handa <handa@m17n.org>
parents:
23082
diff
changeset
|
1620 /* Check the length of succeeding codes of the range |
45c36d636f66
(detect_coding_iso2022): Don't check the byte length of
Kenichi Handa <handa@m17n.org>
parents:
23082
diff
changeset
|
1621 0xA0..0FF. If the byte length is odd, we exclude |
45c36d636f66
(detect_coding_iso2022): Don't check the byte length of
Kenichi Handa <handa@m17n.org>
parents:
23082
diff
changeset
|
1622 CODING_CATEGORY_MASK_ISO_8_2. We can check this only |
45c36d636f66
(detect_coding_iso2022): Don't check the byte length of
Kenichi Handa <handa@m17n.org>
parents:
23082
diff
changeset
|
1623 when we are not single shifting. */ |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1624 if (!single_shifting |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1625 && mask & CODING_CATEGORY_MASK_ISO_8_2) |
23088
45c36d636f66
(detect_coding_iso2022): Don't check the byte length of
Kenichi Handa <handa@m17n.org>
parents:
23082
diff
changeset
|
1626 { |
29299
b33b38d81020
(detect_coding_iso2022): Fix code for checking
Kenichi Handa <handa@m17n.org>
parents:
29275
diff
changeset
|
1627 int i = 1; |
46702
2673ae55a6f9
(detect_coding_iso2022): While checking a byte sequence
Kenichi Handa <handa@m17n.org>
parents:
46548
diff
changeset
|
1628 |
2673ae55a6f9
(detect_coding_iso2022): While checking a byte sequence
Kenichi Handa <handa@m17n.org>
parents:
46548
diff
changeset
|
1629 c = -1; |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1630 while (src < src_end) |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1631 { |
72395
94e4795b333d
(ONE_MORE_BYTE_CHECK_MULTIBYTE): New arg RET. If SRC
Kenichi Handa <handa@m17n.org>
parents:
72323
diff
changeset
|
1632 ONE_MORE_BYTE_CHECK_MULTIBYTE (c, multibytep, |
94e4795b333d
(ONE_MORE_BYTE_CHECK_MULTIBYTE): New arg RET. If SRC
Kenichi Handa <handa@m17n.org>
parents:
72323
diff
changeset
|
1633 mask & mask_found); |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1634 if (c < 0xA0) |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1635 break; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1636 i++; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1637 } |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1638 |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1639 if (i & 1 && src < src_end) |
23088
45c36d636f66
(detect_coding_iso2022): Don't check the byte length of
Kenichi Handa <handa@m17n.org>
parents:
23082
diff
changeset
|
1640 mask &= ~CODING_CATEGORY_MASK_ISO_8_2; |
45c36d636f66
(detect_coding_iso2022): Don't check the byte length of
Kenichi Handa <handa@m17n.org>
parents:
23082
diff
changeset
|
1641 else |
45c36d636f66
(detect_coding_iso2022): Don't check the byte length of
Kenichi Handa <handa@m17n.org>
parents:
23082
diff
changeset
|
1642 mask_found |= CODING_CATEGORY_MASK_ISO_8_2; |
46702
2673ae55a6f9
(detect_coding_iso2022): While checking a byte sequence
Kenichi Handa <handa@m17n.org>
parents:
46548
diff
changeset
|
1643 if (c >= 0) |
2673ae55a6f9
(detect_coding_iso2022): While checking a byte sequence
Kenichi Handa <handa@m17n.org>
parents:
46548
diff
changeset
|
1644 /* This means that we have read one extra byte. */ |
2673ae55a6f9
(detect_coding_iso2022): While checking a byte sequence
Kenichi Handa <handa@m17n.org>
parents:
46548
diff
changeset
|
1645 goto retry; |
23088
45c36d636f66
(detect_coding_iso2022): Don't check the byte length of
Kenichi Handa <handa@m17n.org>
parents:
23082
diff
changeset
|
1646 } |
17052 | 1647 } |
1648 break; | |
1649 } | |
1650 } | |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
1651 return (mask & mask_found); |
17052 | 1652 } |
1653 | |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1654 /* Decode a character of which charset is CHARSET, the 1st position |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1655 code is C1, the 2nd position code is C2, and return the decoded |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1656 character code. If the variable `translation_table' is non-nil, |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1657 returned the translated code. */ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1658 |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1659 #define DECODE_ISO_CHARACTER(charset, c1, c2) \ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1660 (NILP (translation_table) \ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1661 ? MAKE_CHAR (charset, c1, c2) \ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1662 : translate_char (translation_table, -1, charset, c1, c2)) |
17052 | 1663 |
1664 /* Set designation state into CODING. */ | |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
1665 #define DECODE_DESIGNATION(reg, dimension, chars, final_char) \ |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
1666 do { \ |
30487
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
1667 int charset, c; \ |
23881
20d595402dea
(DECODE_DESIGNATION): Jump to label_invalid_code if
Kenichi Handa <handa@m17n.org>
parents:
23564
diff
changeset
|
1668 \ |
20d595402dea
(DECODE_DESIGNATION): Jump to label_invalid_code if
Kenichi Handa <handa@m17n.org>
parents:
23564
diff
changeset
|
1669 if (final_char < '0' || final_char >= 128) \ |
20d595402dea
(DECODE_DESIGNATION): Jump to label_invalid_code if
Kenichi Handa <handa@m17n.org>
parents:
23564
diff
changeset
|
1670 goto label_invalid_code; \ |
20d595402dea
(DECODE_DESIGNATION): Jump to label_invalid_code if
Kenichi Handa <handa@m17n.org>
parents:
23564
diff
changeset
|
1671 charset = ISO_CHARSET_TABLE (make_number (dimension), \ |
20d595402dea
(DECODE_DESIGNATION): Jump to label_invalid_code if
Kenichi Handa <handa@m17n.org>
parents:
23564
diff
changeset
|
1672 make_number (chars), \ |
20d595402dea
(DECODE_DESIGNATION): Jump to label_invalid_code if
Kenichi Handa <handa@m17n.org>
parents:
23564
diff
changeset
|
1673 make_number (final_char)); \ |
30487
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
1674 c = MAKE_CHAR (charset, 0, 0); \ |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
1675 if (charset >= 0 \ |
21331
4c89837392b3
(CHARSET_OK): Don't reject safe charsets.
Kenichi Handa <handa@m17n.org>
parents:
21321
diff
changeset
|
1676 && (CODING_SPEC_ISO_REQUESTED_DESIGNATION (coding, charset) == reg \ |
30487
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
1677 || CODING_SAFE_CHAR_P (safe_chars, c))) \ |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
1678 { \ |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
1679 if (coding->spec.iso2022.last_invalid_designation_register == 0 \ |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
1680 && reg == 0 \ |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
1681 && charset == CHARSET_ASCII) \ |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
1682 { \ |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
1683 /* We should insert this designation sequence as is so \ |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
1684 that it is surely written back to a file. */ \ |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
1685 coding->spec.iso2022.last_invalid_designation_register = -1; \ |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
1686 goto label_invalid_code; \ |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
1687 } \ |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
1688 coding->spec.iso2022.last_invalid_designation_register = -1; \ |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
1689 if ((coding->mode & CODING_MODE_DIRECTION) \ |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
1690 && CHARSET_REVERSE_CHARSET (charset) >= 0) \ |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
1691 charset = CHARSET_REVERSE_CHARSET (charset); \ |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
1692 CODING_SPEC_ISO_DESIGNATION (coding, reg) = charset; \ |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
1693 } \ |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
1694 else \ |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
1695 { \ |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
1696 coding->spec.iso2022.last_invalid_designation_register = reg; \ |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
1697 goto label_invalid_code; \ |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
1698 } \ |
17052 | 1699 } while (0) |
1700 | |
26847 | 1701 /* Allocate a memory block for storing information about compositions. |
1702 The block is chained to the already allocated blocks. */ | |
1703 | |
29275
b4ea9178e480
(DECODE_COMPOSITION_START): If coding->cmp_data is not
Kenichi Handa <handa@m17n.org>
parents:
29247
diff
changeset
|
1704 void |
26847 | 1705 coding_allocate_composition_data (coding, char_offset) |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
1706 struct coding_system *coding; |
26847 | 1707 int char_offset; |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
1708 { |
26847 | 1709 struct composition_data *cmp_data |
1710 = (struct composition_data *) xmalloc (sizeof *cmp_data); | |
1711 | |
1712 cmp_data->char_offset = char_offset; | |
1713 cmp_data->used = 0; | |
1714 cmp_data->prev = coding->cmp_data; | |
1715 cmp_data->next = NULL; | |
1716 if (coding->cmp_data) | |
1717 coding->cmp_data->next = cmp_data; | |
1718 coding->cmp_data = cmp_data; | |
1719 coding->cmp_data_start = 0; | |
53007
36796e056954
(coding_allocate_composition_data): Reset
Kenichi Handa <handa@m17n.org>
parents:
52806
diff
changeset
|
1720 coding->composing = COMPOSITION_NO; |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
1721 } |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
1722 |
34888
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1723 /* Handle composition start sequence ESC 0, ESC 2, ESC 3, or ESC 4. |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1724 ESC 0 : relative composition : ESC 0 CHAR ... ESC 1 |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1725 ESC 2 : rulebase composition : ESC 2 CHAR RULE CHAR RULE ... CHAR ESC 1 |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1726 ESC 3 : altchar composition : ESC 3 ALT ... ESC 0 CHAR ... ESC 1 |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1727 ESC 4 : alt&rule composition : ESC 4 ALT RULE .. ALT ESC 0 CHAR ... ESC 1 |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1728 */ |
26847 | 1729 |
29275
b4ea9178e480
(DECODE_COMPOSITION_START): If coding->cmp_data is not
Kenichi Handa <handa@m17n.org>
parents:
29247
diff
changeset
|
1730 #define DECODE_COMPOSITION_START(c1) \ |
b4ea9178e480
(DECODE_COMPOSITION_START): If coding->cmp_data is not
Kenichi Handa <handa@m17n.org>
parents:
29247
diff
changeset
|
1731 do { \ |
b4ea9178e480
(DECODE_COMPOSITION_START): If coding->cmp_data is not
Kenichi Handa <handa@m17n.org>
parents:
29247
diff
changeset
|
1732 if (coding->composing == COMPOSITION_DISABLED) \ |
b4ea9178e480
(DECODE_COMPOSITION_START): If coding->cmp_data is not
Kenichi Handa <handa@m17n.org>
parents:
29247
diff
changeset
|
1733 { \ |
b4ea9178e480
(DECODE_COMPOSITION_START): If coding->cmp_data is not
Kenichi Handa <handa@m17n.org>
parents:
29247
diff
changeset
|
1734 *dst++ = ISO_CODE_ESC; \ |
b4ea9178e480
(DECODE_COMPOSITION_START): If coding->cmp_data is not
Kenichi Handa <handa@m17n.org>
parents:
29247
diff
changeset
|
1735 *dst++ = c1 & 0x7f; \ |
b4ea9178e480
(DECODE_COMPOSITION_START): If coding->cmp_data is not
Kenichi Handa <handa@m17n.org>
parents:
29247
diff
changeset
|
1736 coding->produced_char += 2; \ |
b4ea9178e480
(DECODE_COMPOSITION_START): If coding->cmp_data is not
Kenichi Handa <handa@m17n.org>
parents:
29247
diff
changeset
|
1737 } \ |
b4ea9178e480
(DECODE_COMPOSITION_START): If coding->cmp_data is not
Kenichi Handa <handa@m17n.org>
parents:
29247
diff
changeset
|
1738 else if (!COMPOSING_P (coding)) \ |
b4ea9178e480
(DECODE_COMPOSITION_START): If coding->cmp_data is not
Kenichi Handa <handa@m17n.org>
parents:
29247
diff
changeset
|
1739 { \ |
b4ea9178e480
(DECODE_COMPOSITION_START): If coding->cmp_data is not
Kenichi Handa <handa@m17n.org>
parents:
29247
diff
changeset
|
1740 /* This is surely the start of a composition. We must be sure \ |
b4ea9178e480
(DECODE_COMPOSITION_START): If coding->cmp_data is not
Kenichi Handa <handa@m17n.org>
parents:
29247
diff
changeset
|
1741 that coding->cmp_data has enough space to store the \ |
b4ea9178e480
(DECODE_COMPOSITION_START): If coding->cmp_data is not
Kenichi Handa <handa@m17n.org>
parents:
29247
diff
changeset
|
1742 information about the composition. If not, terminate the \ |
b4ea9178e480
(DECODE_COMPOSITION_START): If coding->cmp_data is not
Kenichi Handa <handa@m17n.org>
parents:
29247
diff
changeset
|
1743 current decoding loop, allocate one more memory block for \ |
36087 | 1744 coding->cmp_data in the caller, then start the decoding \ |
29275
b4ea9178e480
(DECODE_COMPOSITION_START): If coding->cmp_data is not
Kenichi Handa <handa@m17n.org>
parents:
29247
diff
changeset
|
1745 loop again. We can't allocate memory here directly because \ |
b4ea9178e480
(DECODE_COMPOSITION_START): If coding->cmp_data is not
Kenichi Handa <handa@m17n.org>
parents:
29247
diff
changeset
|
1746 it may cause buffer/string relocation. */ \ |
b4ea9178e480
(DECODE_COMPOSITION_START): If coding->cmp_data is not
Kenichi Handa <handa@m17n.org>
parents:
29247
diff
changeset
|
1747 if (!coding->cmp_data \ |
b4ea9178e480
(DECODE_COMPOSITION_START): If coding->cmp_data is not
Kenichi Handa <handa@m17n.org>
parents:
29247
diff
changeset
|
1748 || (coding->cmp_data->used + COMPOSITION_DATA_MAX_BUNCH_LENGTH \ |
b4ea9178e480
(DECODE_COMPOSITION_START): If coding->cmp_data is not
Kenichi Handa <handa@m17n.org>
parents:
29247
diff
changeset
|
1749 >= COMPOSITION_DATA_SIZE)) \ |
b4ea9178e480
(DECODE_COMPOSITION_START): If coding->cmp_data is not
Kenichi Handa <handa@m17n.org>
parents:
29247
diff
changeset
|
1750 { \ |
b4ea9178e480
(DECODE_COMPOSITION_START): If coding->cmp_data is not
Kenichi Handa <handa@m17n.org>
parents:
29247
diff
changeset
|
1751 coding->result = CODING_FINISH_INSUFFICIENT_CMP; \ |
b4ea9178e480
(DECODE_COMPOSITION_START): If coding->cmp_data is not
Kenichi Handa <handa@m17n.org>
parents:
29247
diff
changeset
|
1752 goto label_end_of_loop; \ |
b4ea9178e480
(DECODE_COMPOSITION_START): If coding->cmp_data is not
Kenichi Handa <handa@m17n.org>
parents:
29247
diff
changeset
|
1753 } \ |
b4ea9178e480
(DECODE_COMPOSITION_START): If coding->cmp_data is not
Kenichi Handa <handa@m17n.org>
parents:
29247
diff
changeset
|
1754 coding->composing = (c1 == '0' ? COMPOSITION_RELATIVE \ |
b4ea9178e480
(DECODE_COMPOSITION_START): If coding->cmp_data is not
Kenichi Handa <handa@m17n.org>
parents:
29247
diff
changeset
|
1755 : c1 == '2' ? COMPOSITION_WITH_RULE \ |
b4ea9178e480
(DECODE_COMPOSITION_START): If coding->cmp_data is not
Kenichi Handa <handa@m17n.org>
parents:
29247
diff
changeset
|
1756 : c1 == '3' ? COMPOSITION_WITH_ALTCHARS \ |
b4ea9178e480
(DECODE_COMPOSITION_START): If coding->cmp_data is not
Kenichi Handa <handa@m17n.org>
parents:
29247
diff
changeset
|
1757 : COMPOSITION_WITH_RULE_ALTCHARS); \ |
b4ea9178e480
(DECODE_COMPOSITION_START): If coding->cmp_data is not
Kenichi Handa <handa@m17n.org>
parents:
29247
diff
changeset
|
1758 CODING_ADD_COMPOSITION_START (coding, coding->produced_char, \ |
b4ea9178e480
(DECODE_COMPOSITION_START): If coding->cmp_data is not
Kenichi Handa <handa@m17n.org>
parents:
29247
diff
changeset
|
1759 coding->composing); \ |
b4ea9178e480
(DECODE_COMPOSITION_START): If coding->cmp_data is not
Kenichi Handa <handa@m17n.org>
parents:
29247
diff
changeset
|
1760 coding->composition_rule_follows = 0; \ |
b4ea9178e480
(DECODE_COMPOSITION_START): If coding->cmp_data is not
Kenichi Handa <handa@m17n.org>
parents:
29247
diff
changeset
|
1761 } \ |
b4ea9178e480
(DECODE_COMPOSITION_START): If coding->cmp_data is not
Kenichi Handa <handa@m17n.org>
parents:
29247
diff
changeset
|
1762 else \ |
b4ea9178e480
(DECODE_COMPOSITION_START): If coding->cmp_data is not
Kenichi Handa <handa@m17n.org>
parents:
29247
diff
changeset
|
1763 { \ |
b4ea9178e480
(DECODE_COMPOSITION_START): If coding->cmp_data is not
Kenichi Handa <handa@m17n.org>
parents:
29247
diff
changeset
|
1764 /* We are already handling a composition. If the method is \ |
b4ea9178e480
(DECODE_COMPOSITION_START): If coding->cmp_data is not
Kenichi Handa <handa@m17n.org>
parents:
29247
diff
changeset
|
1765 the following two, the codes following the current escape \ |
b4ea9178e480
(DECODE_COMPOSITION_START): If coding->cmp_data is not
Kenichi Handa <handa@m17n.org>
parents:
29247
diff
changeset
|
1766 sequence are actual characters stored in a buffer. */ \ |
b4ea9178e480
(DECODE_COMPOSITION_START): If coding->cmp_data is not
Kenichi Handa <handa@m17n.org>
parents:
29247
diff
changeset
|
1767 if (coding->composing == COMPOSITION_WITH_ALTCHARS \ |
b4ea9178e480
(DECODE_COMPOSITION_START): If coding->cmp_data is not
Kenichi Handa <handa@m17n.org>
parents:
29247
diff
changeset
|
1768 || coding->composing == COMPOSITION_WITH_RULE_ALTCHARS) \ |
b4ea9178e480
(DECODE_COMPOSITION_START): If coding->cmp_data is not
Kenichi Handa <handa@m17n.org>
parents:
29247
diff
changeset
|
1769 { \ |
b4ea9178e480
(DECODE_COMPOSITION_START): If coding->cmp_data is not
Kenichi Handa <handa@m17n.org>
parents:
29247
diff
changeset
|
1770 coding->composing = COMPOSITION_RELATIVE; \ |
b4ea9178e480
(DECODE_COMPOSITION_START): If coding->cmp_data is not
Kenichi Handa <handa@m17n.org>
parents:
29247
diff
changeset
|
1771 coding->composition_rule_follows = 0; \ |
b4ea9178e480
(DECODE_COMPOSITION_START): If coding->cmp_data is not
Kenichi Handa <handa@m17n.org>
parents:
29247
diff
changeset
|
1772 } \ |
b4ea9178e480
(DECODE_COMPOSITION_START): If coding->cmp_data is not
Kenichi Handa <handa@m17n.org>
parents:
29247
diff
changeset
|
1773 } \ |
26847 | 1774 } while (0) |
1775 | |
36087 | 1776 /* Handle composition end sequence ESC 1. */ |
26847 | 1777 |
1778 #define DECODE_COMPOSITION_END(c1) \ | |
1779 do { \ | |
42104
d69c2368e549
(DECODE_COMPOSITION_END): Fixed a typo in the last
Sam Steingold <sds@gnu.org>
parents:
42103
diff
changeset
|
1780 if (! COMPOSING_P (coding)) \ |
26847 | 1781 { \ |
1782 *dst++ = ISO_CODE_ESC; \ | |
1783 *dst++ = c1; \ | |
1784 coding->produced_char += 2; \ | |
1785 } \ | |
1786 else \ | |
1787 { \ | |
1788 CODING_ADD_COMPOSITION_END (coding, coding->produced_char); \ | |
1789 coding->composing = COMPOSITION_NO; \ | |
1790 } \ | |
1791 } while (0) | |
1792 | |
1793 /* Decode a composition rule from the byte C1 (and maybe one more byte | |
1794 from SRC) and store one encoded composition rule in | |
1795 coding->cmp_data. */ | |
1796 | |
1797 #define DECODE_COMPOSITION_RULE(c1) \ | |
1798 do { \ | |
1799 int rule = 0; \ | |
1800 (c1) -= 32; \ | |
1801 if (c1 < 81) /* old format (before ver.21) */ \ | |
1802 { \ | |
1803 int gref = (c1) / 9; \ | |
1804 int nref = (c1) % 9; \ | |
1805 if (gref == 4) gref = 10; \ | |
1806 if (nref == 4) nref = 10; \ | |
1807 rule = COMPOSITION_ENCODE_RULE (gref, nref); \ | |
1808 } \ | |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1809 else if (c1 < 93) /* new format (after ver.21) */ \ |
26847 | 1810 { \ |
1811 ONE_MORE_BYTE (c2); \ | |
1812 rule = COMPOSITION_ENCODE_RULE (c1 - 81, c2 - 32); \ | |
1813 } \ | |
1814 CODING_ADD_COMPOSITION_COMPONENT (coding, rule); \ | |
1815 coding->composition_rule_follows = 0; \ | |
1816 } while (0) | |
1817 | |
1818 | |
17052 | 1819 /* See the above "GENERAL NOTES on `decode_coding_XXX ()' functions". */ |
1820 | |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1821 static void |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
1822 decode_coding_iso2022 (coding, source, destination, src_bytes, dst_bytes) |
17052 | 1823 struct coding_system *coding; |
59168
0345f2b10f1d
(decode_coding_XXX, decode_composition_emacs_mule)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
59095
diff
changeset
|
1824 const unsigned char *source; |
0345f2b10f1d
(decode_coding_XXX, decode_composition_emacs_mule)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
59095
diff
changeset
|
1825 unsigned char *destination; |
17052 | 1826 int src_bytes, dst_bytes; |
1827 { | |
59168
0345f2b10f1d
(decode_coding_XXX, decode_composition_emacs_mule)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
59095
diff
changeset
|
1828 const unsigned char *src = source; |
0345f2b10f1d
(decode_coding_XXX, decode_composition_emacs_mule)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
59095
diff
changeset
|
1829 const unsigned char *src_end = source + src_bytes; |
17052 | 1830 unsigned char *dst = destination; |
1831 unsigned char *dst_end = destination + dst_bytes; | |
1832 /* Charsets invoked to graphic plane 0 and 1 respectively. */ | |
1833 int charset0 = CODING_SPEC_ISO_PLANE_CHARSET (coding, 0); | |
1834 int charset1 = CODING_SPEC_ISO_PLANE_CHARSET (coding, 1); | |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1835 /* SRC_BASE remembers the start position in source in each loop. |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1836 The loop will be exited when there's not enough source code |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1837 (within macro ONE_MORE_BYTE), or when there's not enough |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1838 destination area to produce a character (within macro |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1839 EMIT_CHAR). */ |
59168
0345f2b10f1d
(decode_coding_XXX, decode_composition_emacs_mule)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
59095
diff
changeset
|
1840 const unsigned char *src_base; |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1841 int c, charset; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1842 Lisp_Object translation_table; |
30487
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
1843 Lisp_Object safe_chars; |
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
1844 |
49539
1ad5bfbb831a
(syms_of_coding): Add `...' for symbols in the docstring of
Kenichi Handa <handa@m17n.org>
parents:
48874
diff
changeset
|
1845 safe_chars = coding_safe_chars (coding->symbol); |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1846 |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1847 if (NILP (Venable_character_translation)) |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1848 translation_table = Qnil; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1849 else |
17052 | 1850 { |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1851 translation_table = coding->translation_table_for_decode; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1852 if (NILP (translation_table)) |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1853 translation_table = Vstandard_translation_table_for_decode; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1854 } |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1855 |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1856 coding->result = CODING_FINISH_NORMAL; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1857 |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1858 while (1) |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1859 { |
52354
5480186284b2
(decode_coding_iso2022): Initialized local variable c2.
Kenichi Handa <handa@m17n.org>
parents:
52016
diff
changeset
|
1860 int c1, c2 = 0; |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1861 |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1862 src_base = src; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1863 ONE_MORE_BYTE (c1); |
17052 | 1864 |
26847 | 1865 /* We produce no character or one character. */ |
17052 | 1866 switch (iso_code_class [c1]) |
1867 { | |
1868 case ISO_0x20_or_0x7F: | |
26847 | 1869 if (COMPOSING_P (coding) && coding->composition_rule_follows) |
1870 { | |
1871 DECODE_COMPOSITION_RULE (c1); | |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1872 continue; |
26847 | 1873 } |
1874 if (charset0 < 0 || CHARSET_CHARS (charset0) == 94) | |
17052 | 1875 { |
1876 /* This is SPACE or DEL. */ | |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1877 charset = CHARSET_ASCII; |
17052 | 1878 break; |
1879 } | |
1880 /* This is a graphic character, we fall down ... */ | |
1881 | |
1882 case ISO_graphic_plane_0: | |
26847 | 1883 if (COMPOSING_P (coding) && coding->composition_rule_follows) |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1884 { |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1885 DECODE_COMPOSITION_RULE (c1); |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1886 continue; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1887 } |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1888 charset = charset0; |
17052 | 1889 break; |
1890 | |
1891 case ISO_0xA0_or_0xFF: | |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
1892 if (charset1 < 0 || CHARSET_CHARS (charset1) == 94 |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
1893 || coding->flags & CODING_FLAG_ISO_SEVEN_BITS) |
20931
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
1894 goto label_invalid_code; |
17052 | 1895 /* This is a graphic character, we fall down ... */ |
1896 | |
1897 case ISO_graphic_plane_1: | |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1898 if (charset1 < 0) |
20931
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
1899 goto label_invalid_code; |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1900 charset = charset1; |
17052 | 1901 break; |
1902 | |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1903 case ISO_control_0: |
26847 | 1904 if (COMPOSING_P (coding)) |
1905 DECODE_COMPOSITION_END ('1'); | |
1906 | |
17052 | 1907 /* All ISO2022 control characters in this class have the |
1908 same representation in Emacs internal format. */ | |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
1909 if (c1 == '\n' |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
1910 && (coding->mode & CODING_MODE_INHIBIT_INCONSISTENT_EOL) |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
1911 && (coding->eol_type == CODING_EOL_CR |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
1912 || coding->eol_type == CODING_EOL_CRLF)) |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
1913 { |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1914 coding->result = CODING_FINISH_INCONSISTENT_EOL; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1915 goto label_end_of_loop; |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
1916 } |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1917 charset = CHARSET_ASCII; |
17052 | 1918 break; |
1919 | |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1920 case ISO_control_1: |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1921 if (COMPOSING_P (coding)) |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1922 DECODE_COMPOSITION_END ('1'); |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1923 goto label_invalid_code; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1924 |
17052 | 1925 case ISO_carriage_return: |
26847 | 1926 if (COMPOSING_P (coding)) |
1927 DECODE_COMPOSITION_END ('1'); | |
1928 | |
17052 | 1929 if (coding->eol_type == CODING_EOL_CR) |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1930 c1 = '\n'; |
17052 | 1931 else if (coding->eol_type == CODING_EOL_CRLF) |
1932 { | |
1933 ONE_MORE_BYTE (c1); | |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1934 if (c1 != ISO_CODE_LF) |
17052 | 1935 { |
1936 src--; | |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1937 c1 = '\r'; |
17052 | 1938 } |
1939 } | |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1940 charset = CHARSET_ASCII; |
17052 | 1941 break; |
1942 | |
1943 case ISO_shift_out: | |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
1944 if (! (coding->flags & CODING_FLAG_ISO_LOCKING_SHIFT) |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
1945 || CODING_SPEC_ISO_DESIGNATION (coding, 1) < 0) |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
1946 goto label_invalid_code; |
17052 | 1947 CODING_SPEC_ISO_INVOCATION (coding, 0) = 1; |
1948 charset0 = CODING_SPEC_ISO_PLANE_CHARSET (coding, 0); | |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1949 continue; |
17052 | 1950 |
1951 case ISO_shift_in: | |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
1952 if (! (coding->flags & CODING_FLAG_ISO_LOCKING_SHIFT)) |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
1953 goto label_invalid_code; |
17052 | 1954 CODING_SPEC_ISO_INVOCATION (coding, 0) = 0; |
1955 charset0 = CODING_SPEC_ISO_PLANE_CHARSET (coding, 0); | |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1956 continue; |
17052 | 1957 |
1958 case ISO_single_shift_2_7: | |
1959 case ISO_single_shift_2: | |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
1960 if (! (coding->flags & CODING_FLAG_ISO_SINGLE_SHIFT)) |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
1961 goto label_invalid_code; |
17052 | 1962 /* SS2 is handled as an escape sequence of ESC 'N' */ |
1963 c1 = 'N'; | |
1964 goto label_escape_sequence; | |
1965 | |
1966 case ISO_single_shift_3: | |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
1967 if (! (coding->flags & CODING_FLAG_ISO_SINGLE_SHIFT)) |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
1968 goto label_invalid_code; |
17052 | 1969 /* SS2 is handled as an escape sequence of ESC 'O' */ |
1970 c1 = 'O'; | |
1971 goto label_escape_sequence; | |
1972 | |
1973 case ISO_control_sequence_introducer: | |
1974 /* CSI is handled as an escape sequence of ESC '[' ... */ | |
1975 c1 = '['; | |
1976 goto label_escape_sequence; | |
1977 | |
1978 case ISO_escape: | |
1979 ONE_MORE_BYTE (c1); | |
1980 label_escape_sequence: | |
1981 /* Escape sequences handled by Emacs are invocation, | |
1982 designation, direction specification, and character | |
1983 composition specification. */ | |
1984 switch (c1) | |
1985 { | |
1986 case '&': /* revision of following character set */ | |
1987 ONE_MORE_BYTE (c1); | |
1988 if (!(c1 >= '@' && c1 <= '~')) | |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
1989 goto label_invalid_code; |
17052 | 1990 ONE_MORE_BYTE (c1); |
1991 if (c1 != ISO_CODE_ESC) | |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
1992 goto label_invalid_code; |
17052 | 1993 ONE_MORE_BYTE (c1); |
1994 goto label_escape_sequence; | |
1995 | |
1996 case '$': /* designation of 2-byte character set */ | |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
1997 if (! (coding->flags & CODING_FLAG_ISO_DESIGNATION)) |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
1998 goto label_invalid_code; |
17052 | 1999 ONE_MORE_BYTE (c1); |
2000 if (c1 >= '@' && c1 <= 'B') | |
2001 { /* designation of JISX0208.1978, GB2312.1980, | |
23339
2da87b489590
(check_composing_code): Fix previous change. Now it
Kenichi Handa <handa@m17n.org>
parents:
23325
diff
changeset
|
2002 or JISX0208.1980 */ |
17052 | 2003 DECODE_DESIGNATION (0, 2, 94, c1); |
2004 } | |
2005 else if (c1 >= 0x28 && c1 <= 0x2B) | |
2006 { /* designation of DIMENSION2_CHARS94 character set */ | |
2007 ONE_MORE_BYTE (c2); | |
2008 DECODE_DESIGNATION (c1 - 0x28, 2, 94, c2); | |
2009 } | |
2010 else if (c1 >= 0x2C && c1 <= 0x2F) | |
2011 { /* designation of DIMENSION2_CHARS96 character set */ | |
2012 ONE_MORE_BYTE (c2); | |
2013 DECODE_DESIGNATION (c1 - 0x2C, 2, 96, c2); | |
2014 } | |
2015 else | |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
2016 goto label_invalid_code; |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2017 /* We must update these variables now. */ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2018 charset0 = CODING_SPEC_ISO_PLANE_CHARSET (coding, 0); |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2019 charset1 = CODING_SPEC_ISO_PLANE_CHARSET (coding, 1); |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2020 continue; |
17052 | 2021 |
2022 case 'n': /* invocation of locking-shift-2 */ | |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
2023 if (! (coding->flags & CODING_FLAG_ISO_LOCKING_SHIFT) |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
2024 || CODING_SPEC_ISO_DESIGNATION (coding, 2) < 0) |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
2025 goto label_invalid_code; |
17052 | 2026 CODING_SPEC_ISO_INVOCATION (coding, 0) = 2; |
17119
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
2027 charset0 = CODING_SPEC_ISO_PLANE_CHARSET (coding, 0); |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2028 continue; |
17052 | 2029 |
2030 case 'o': /* invocation of locking-shift-3 */ | |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
2031 if (! (coding->flags & CODING_FLAG_ISO_LOCKING_SHIFT) |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
2032 || CODING_SPEC_ISO_DESIGNATION (coding, 3) < 0) |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
2033 goto label_invalid_code; |
17052 | 2034 CODING_SPEC_ISO_INVOCATION (coding, 0) = 3; |
17119
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
2035 charset0 = CODING_SPEC_ISO_PLANE_CHARSET (coding, 0); |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2036 continue; |
17052 | 2037 |
2038 case 'N': /* invocation of single-shift-2 */ | |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
2039 if (! (coding->flags & CODING_FLAG_ISO_SINGLE_SHIFT) |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
2040 || CODING_SPEC_ISO_DESIGNATION (coding, 2) < 0) |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
2041 goto label_invalid_code; |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2042 charset = CODING_SPEC_ISO_DESIGNATION (coding, 2); |
17052 | 2043 ONE_MORE_BYTE (c1); |
30578
705b94e152b1
(decode_coding_iso2022): More strict check for handling single
Kenichi Handa <handa@m17n.org>
parents:
30487
diff
changeset
|
2044 if (c1 < 0x20 || (c1 >= 0x80 && c1 < 0xA0)) |
705b94e152b1
(decode_coding_iso2022): More strict check for handling single
Kenichi Handa <handa@m17n.org>
parents:
30487
diff
changeset
|
2045 goto label_invalid_code; |
17052 | 2046 break; |
2047 | |
2048 case 'O': /* invocation of single-shift-3 */ | |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
2049 if (! (coding->flags & CODING_FLAG_ISO_SINGLE_SHIFT) |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
2050 || CODING_SPEC_ISO_DESIGNATION (coding, 3) < 0) |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
2051 goto label_invalid_code; |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2052 charset = CODING_SPEC_ISO_DESIGNATION (coding, 3); |
17052 | 2053 ONE_MORE_BYTE (c1); |
30578
705b94e152b1
(decode_coding_iso2022): More strict check for handling single
Kenichi Handa <handa@m17n.org>
parents:
30487
diff
changeset
|
2054 if (c1 < 0x20 || (c1 >= 0x80 && c1 < 0xA0)) |
705b94e152b1
(decode_coding_iso2022): More strict check for handling single
Kenichi Handa <handa@m17n.org>
parents:
30487
diff
changeset
|
2055 goto label_invalid_code; |
17052 | 2056 break; |
2057 | |
26847 | 2058 case '0': case '2': case '3': case '4': /* start composition */ |
2059 DECODE_COMPOSITION_START (c1); | |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2060 continue; |
17052 | 2061 |
26847 | 2062 case '1': /* end composition */ |
2063 DECODE_COMPOSITION_END (c1); | |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2064 continue; |
17052 | 2065 |
2066 case '[': /* specification of direction */ | |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
2067 if (coding->flags & CODING_FLAG_ISO_NO_DIRECTION) |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
2068 goto label_invalid_code; |
17052 | 2069 /* For the moment, nested direction is not supported. |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
2070 So, `coding->mode & CODING_MODE_DIRECTION' zero means |
36087 | 2071 left-to-right, and nonzero means right-to-left. */ |
17052 | 2072 ONE_MORE_BYTE (c1); |
2073 switch (c1) | |
2074 { | |
2075 case ']': /* end of the current direction */ | |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
2076 coding->mode &= ~CODING_MODE_DIRECTION; |
17052 | 2077 |
2078 case '0': /* end of the current direction */ | |
2079 case '1': /* start of left-to-right direction */ | |
2080 ONE_MORE_BYTE (c1); | |
2081 if (c1 == ']') | |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
2082 coding->mode &= ~CODING_MODE_DIRECTION; |
17052 | 2083 else |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
2084 goto label_invalid_code; |
17052 | 2085 break; |
2086 | |
2087 case '2': /* start of right-to-left direction */ | |
2088 ONE_MORE_BYTE (c1); | |
2089 if (c1 == ']') | |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
2090 coding->mode |= CODING_MODE_DIRECTION; |
17052 | 2091 else |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
2092 goto label_invalid_code; |
17052 | 2093 break; |
2094 | |
2095 default: | |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
2096 goto label_invalid_code; |
17052 | 2097 } |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2098 continue; |
17052 | 2099 |
51311 | 2100 case '%': |
2101 if (COMPOSING_P (coding)) | |
2102 DECODE_COMPOSITION_END ('1'); | |
2103 ONE_MORE_BYTE (c1); | |
2104 if (c1 == '/') | |
2105 { | |
2106 /* CTEXT extended segment: | |
2107 ESC % / [0-4] M L --ENCODING-NAME-- \002 --BYTES-- | |
2108 We keep these bytes as is for the moment. | |
2109 They may be decoded by post-read-conversion. */ | |
2110 int dim, M, L; | |
2111 int size, required; | |
2112 int produced_chars; | |
56191 | 2113 |
51311 | 2114 ONE_MORE_BYTE (dim); |
2115 ONE_MORE_BYTE (M); | |
2116 ONE_MORE_BYTE (L); | |
2117 size = ((M - 128) * 128) + (L - 128); | |
2118 required = 8 + size * 2; | |
2119 if (dst + required > (dst_bytes ? dst_end : src)) | |
2120 goto label_end_of_loop; | |
2121 *dst++ = ISO_CODE_ESC; | |
2122 *dst++ = '%'; | |
2123 *dst++ = '/'; | |
2124 *dst++ = dim; | |
2125 produced_chars = 4; | |
2126 dst += CHAR_STRING (M, dst), produced_chars++; | |
2127 dst += CHAR_STRING (L, dst), produced_chars++; | |
2128 while (size-- > 0) | |
2129 { | |
2130 ONE_MORE_BYTE (c1); | |
2131 dst += CHAR_STRING (c1, dst), produced_chars++; | |
2132 } | |
2133 coding->produced_char += produced_chars; | |
2134 } | |
2135 else if (c1 == 'G') | |
2136 { | |
2137 unsigned char *d = dst; | |
2138 int produced_chars; | |
2139 | |
2140 /* XFree86 extension for embedding UTF-8 in CTEXT: | |
2141 ESC % G --UTF-8-BYTES-- ESC % @ | |
2142 We keep these bytes as is for the moment. | |
2143 They may be decoded by post-read-conversion. */ | |
2144 if (d + 6 > (dst_bytes ? dst_end : src)) | |
2145 goto label_end_of_loop; | |
2146 *d++ = ISO_CODE_ESC; | |
2147 *d++ = '%'; | |
2148 *d++ = 'G'; | |
2149 produced_chars = 3; | |
2150 while (d + 1 < (dst_bytes ? dst_end : src)) | |
2151 { | |
2152 ONE_MORE_BYTE (c1); | |
2153 if (c1 == ISO_CODE_ESC | |
2154 && src + 1 < src_end | |
2155 && src[0] == '%' | |
2156 && src[1] == '@') | |
53239
82690620d562
(decode_coding_iso2022): Fix for preserving UTF-8
Kenichi Handa <handa@m17n.org>
parents:
53087
diff
changeset
|
2157 { |
82690620d562
(decode_coding_iso2022): Fix for preserving UTF-8
Kenichi Handa <handa@m17n.org>
parents:
53087
diff
changeset
|
2158 src += 2; |
82690620d562
(decode_coding_iso2022): Fix for preserving UTF-8
Kenichi Handa <handa@m17n.org>
parents:
53087
diff
changeset
|
2159 break; |
82690620d562
(decode_coding_iso2022): Fix for preserving UTF-8
Kenichi Handa <handa@m17n.org>
parents:
53087
diff
changeset
|
2160 } |
51311 | 2161 d += CHAR_STRING (c1, d), produced_chars++; |
2162 } | |
2163 if (d + 3 > (dst_bytes ? dst_end : src)) | |
2164 goto label_end_of_loop; | |
2165 *d++ = ISO_CODE_ESC; | |
2166 *d++ = '%'; | |
2167 *d++ = '@'; | |
2168 dst = d; | |
2169 coding->produced_char += produced_chars + 3; | |
2170 } | |
2171 else | |
2172 goto label_invalid_code; | |
2173 continue; | |
2174 | |
17052 | 2175 default: |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
2176 if (! (coding->flags & CODING_FLAG_ISO_DESIGNATION)) |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
2177 goto label_invalid_code; |
17052 | 2178 if (c1 >= 0x28 && c1 <= 0x2B) |
2179 { /* designation of DIMENSION1_CHARS94 character set */ | |
2180 ONE_MORE_BYTE (c2); | |
2181 DECODE_DESIGNATION (c1 - 0x28, 1, 94, c2); | |
2182 } | |
2183 else if (c1 >= 0x2C && c1 <= 0x2F) | |
2184 { /* designation of DIMENSION1_CHARS96 character set */ | |
2185 ONE_MORE_BYTE (c2); | |
2186 DECODE_DESIGNATION (c1 - 0x2C, 1, 96, c2); | |
2187 } | |
2188 else | |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2189 goto label_invalid_code; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2190 /* We must update these variables now. */ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2191 charset0 = CODING_SPEC_ISO_PLANE_CHARSET (coding, 0); |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2192 charset1 = CODING_SPEC_ISO_PLANE_CHARSET (coding, 1); |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2193 continue; |
17052 | 2194 } |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2195 } |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2196 |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2197 /* Now we know CHARSET and 1st position code C1 of a character. |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2198 Produce a multibyte sequence for that character while getting |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2199 2nd position code C2 if necessary. */ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2200 if (CHARSET_DIMENSION (charset) == 2) |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2201 { |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2202 ONE_MORE_BYTE (c2); |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2203 if (c1 < 0x80 ? c2 < 0x20 || c2 >= 0x80 : c2 < 0xA0) |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2204 /* C2 is not in a valid range. */ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2205 goto label_invalid_code; |
17052 | 2206 } |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2207 c = DECODE_ISO_CHARACTER (charset, c1, c2); |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2208 EMIT_CHAR (c); |
17052 | 2209 continue; |
2210 | |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2211 label_invalid_code: |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2212 coding->errors++; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2213 if (COMPOSING_P (coding)) |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2214 DECODE_COMPOSITION_END ('1'); |
17052 | 2215 src = src_base; |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2216 c = *src++; |
59608
a691d3c9971a
(decode_coding_iso2022): Translate invalid codes if
Kenichi Handa <handa@m17n.org>
parents:
59173
diff
changeset
|
2217 if (! NILP (translation_table)) |
a691d3c9971a
(decode_coding_iso2022): Translate invalid codes if
Kenichi Handa <handa@m17n.org>
parents:
59173
diff
changeset
|
2218 c = translate_char (translation_table, c, 0, 0, 0); |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2219 EMIT_CHAR (c); |
17052 | 2220 } |
2221 | |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2222 label_end_of_loop: |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2223 coding->consumed = coding->consumed_char = src_base - source; |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
2224 coding->produced = dst - destination; |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2225 return; |
17052 | 2226 } |
2227 | |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2228 |
18766 | 2229 /* ISO2022 encoding stuff. */ |
17052 | 2230 |
2231 /* | |
18766 | 2232 It is not enough to say just "ISO2022" on encoding, we have to |
35053 | 2233 specify more details. In Emacs, each ISO2022 coding system |
17052 | 2234 variant has the following specifications: |
36087 | 2235 1. Initial designation to G0 through G3. |
17052 | 2236 2. Allows short-form designation? |
2237 3. ASCII should be designated to G0 before control characters? | |
2238 4. ASCII should be designated to G0 at end of line? | |
2239 5. 7-bit environment or 8-bit environment? | |
2240 6. Use locking-shift? | |
2241 7. Use Single-shift? | |
2242 And the following two are only for Japanese: | |
2243 8. Use ASCII in place of JIS0201-1976-Roman? | |
2244 9. Use JISX0208-1983 in place of JISX0208-1978? | |
2245 These specifications are encoded in `coding->flags' as flag bits | |
2246 defined by macros CODING_FLAG_ISO_XXX. See `coding.h' for more | |
18766 | 2247 details. |
17052 | 2248 */ |
2249 | |
2250 /* Produce codes (escape sequence) for designating CHARSET to graphic | |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2251 register REG at DST, and increment DST. If <final-char> of CHARSET is |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2252 '@', 'A', or 'B' and the coding system CODING allows, produce |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2253 designation sequence of short-form. */ |
17052 | 2254 |
2255 #define ENCODE_DESIGNATION(charset, reg, coding) \ | |
2256 do { \ | |
2257 unsigned char final_char = CHARSET_ISO_FINAL_CHAR (charset); \ | |
2258 char *intermediate_char_94 = "()*+"; \ | |
2259 char *intermediate_char_96 = ",-./"; \ | |
20150
402b6e5f4b58
(encode_designation_at_bol): Fix bug of finding graphic
Kenichi Handa <handa@m17n.org>
parents:
20105
diff
changeset
|
2260 int revision = CODING_SPEC_ISO_REVISION_NUMBER(coding, charset); \ |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2261 \ |
20150
402b6e5f4b58
(encode_designation_at_bol): Fix bug of finding graphic
Kenichi Handa <handa@m17n.org>
parents:
20105
diff
changeset
|
2262 if (revision < 255) \ |
402b6e5f4b58
(encode_designation_at_bol): Fix bug of finding graphic
Kenichi Handa <handa@m17n.org>
parents:
20105
diff
changeset
|
2263 { \ |
17052 | 2264 *dst++ = ISO_CODE_ESC; \ |
2265 *dst++ = '&'; \ | |
20150
402b6e5f4b58
(encode_designation_at_bol): Fix bug of finding graphic
Kenichi Handa <handa@m17n.org>
parents:
20105
diff
changeset
|
2266 *dst++ = '@' + revision; \ |
17052 | 2267 } \ |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2268 *dst++ = ISO_CODE_ESC; \ |
17052 | 2269 if (CHARSET_DIMENSION (charset) == 1) \ |
2270 { \ | |
2271 if (CHARSET_CHARS (charset) == 94) \ | |
2272 *dst++ = (unsigned char) (intermediate_char_94[reg]); \ | |
2273 else \ | |
2274 *dst++ = (unsigned char) (intermediate_char_96[reg]); \ | |
2275 } \ | |
2276 else \ | |
2277 { \ | |
2278 *dst++ = '$'; \ | |
2279 if (CHARSET_CHARS (charset) == 94) \ | |
2280 { \ | |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2281 if (! (coding->flags & CODING_FLAG_ISO_SHORT_FORM) \ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2282 || reg != 0 \ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2283 || final_char < '@' || final_char > 'B') \ |
17052 | 2284 *dst++ = (unsigned char) (intermediate_char_94[reg]); \ |
2285 } \ | |
2286 else \ | |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2287 *dst++ = (unsigned char) (intermediate_char_96[reg]); \ |
17052 | 2288 } \ |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2289 *dst++ = final_char; \ |
17052 | 2290 CODING_SPEC_ISO_DESIGNATION (coding, reg) = charset; \ |
2291 } while (0) | |
2292 | |
2293 /* The following two macros produce codes (control character or escape | |
2294 sequence) for ISO2022 single-shift functions (single-shift-2 and | |
2295 single-shift-3). */ | |
2296 | |
2297 #define ENCODE_SINGLE_SHIFT_2 \ | |
2298 do { \ | |
2299 if (coding->flags & CODING_FLAG_ISO_SEVEN_BITS) \ | |
2300 *dst++ = ISO_CODE_ESC, *dst++ = 'N'; \ | |
2301 else \ | |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2302 *dst++ = ISO_CODE_SS2; \ |
17052 | 2303 CODING_SPEC_ISO_SINGLE_SHIFTING (coding) = 1; \ |
2304 } while (0) | |
2305 | |
20931
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
2306 #define ENCODE_SINGLE_SHIFT_3 \ |
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
2307 do { \ |
17052 | 2308 if (coding->flags & CODING_FLAG_ISO_SEVEN_BITS) \ |
20931
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
2309 *dst++ = ISO_CODE_ESC, *dst++ = 'O'; \ |
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
2310 else \ |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2311 *dst++ = ISO_CODE_SS3; \ |
17052 | 2312 CODING_SPEC_ISO_SINGLE_SHIFTING (coding) = 1; \ |
2313 } while (0) | |
2314 | |
2315 /* The following four macros produce codes (control character or | |
2316 escape sequence) for ISO2022 locking-shift functions (shift-in, | |
2317 shift-out, locking-shift-2, and locking-shift-3). */ | |
2318 | |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2319 #define ENCODE_SHIFT_IN \ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2320 do { \ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2321 *dst++ = ISO_CODE_SI; \ |
17052 | 2322 CODING_SPEC_ISO_INVOCATION (coding, 0) = 0; \ |
2323 } while (0) | |
2324 | |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2325 #define ENCODE_SHIFT_OUT \ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2326 do { \ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2327 *dst++ = ISO_CODE_SO; \ |
17052 | 2328 CODING_SPEC_ISO_INVOCATION (coding, 0) = 1; \ |
2329 } while (0) | |
2330 | |
2331 #define ENCODE_LOCKING_SHIFT_2 \ | |
2332 do { \ | |
2333 *dst++ = ISO_CODE_ESC, *dst++ = 'n'; \ | |
2334 CODING_SPEC_ISO_INVOCATION (coding, 0) = 2; \ | |
2335 } while (0) | |
2336 | |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2337 #define ENCODE_LOCKING_SHIFT_3 \ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2338 do { \ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2339 *dst++ = ISO_CODE_ESC, *dst++ = 'o'; \ |
17052 | 2340 CODING_SPEC_ISO_INVOCATION (coding, 0) = 3; \ |
2341 } while (0) | |
2342 | |
18766 | 2343 /* Produce codes for a DIMENSION1 character whose character set is |
2344 CHARSET and whose position-code is C1. Designation and invocation | |
17052 | 2345 sequences are also produced in advance if necessary. */ |
2346 | |
19285
af3d00fde172
(Fset_terminal_coding_system_internal): Set
Kenichi Handa <handa@m17n.org>
parents:
19280
diff
changeset
|
2347 #define ENCODE_ISO_CHARACTER_DIMENSION1(charset, c1) \ |
af3d00fde172
(Fset_terminal_coding_system_internal): Set
Kenichi Handa <handa@m17n.org>
parents:
19280
diff
changeset
|
2348 do { \ |
af3d00fde172
(Fset_terminal_coding_system_internal): Set
Kenichi Handa <handa@m17n.org>
parents:
19280
diff
changeset
|
2349 if (CODING_SPEC_ISO_SINGLE_SHIFTING (coding)) \ |
af3d00fde172
(Fset_terminal_coding_system_internal): Set
Kenichi Handa <handa@m17n.org>
parents:
19280
diff
changeset
|
2350 { \ |
af3d00fde172
(Fset_terminal_coding_system_internal): Set
Kenichi Handa <handa@m17n.org>
parents:
19280
diff
changeset
|
2351 if (coding->flags & CODING_FLAG_ISO_SEVEN_BITS) \ |
af3d00fde172
(Fset_terminal_coding_system_internal): Set
Kenichi Handa <handa@m17n.org>
parents:
19280
diff
changeset
|
2352 *dst++ = c1 & 0x7F; \ |
af3d00fde172
(Fset_terminal_coding_system_internal): Set
Kenichi Handa <handa@m17n.org>
parents:
19280
diff
changeset
|
2353 else \ |
af3d00fde172
(Fset_terminal_coding_system_internal): Set
Kenichi Handa <handa@m17n.org>
parents:
19280
diff
changeset
|
2354 *dst++ = c1 | 0x80; \ |
af3d00fde172
(Fset_terminal_coding_system_internal): Set
Kenichi Handa <handa@m17n.org>
parents:
19280
diff
changeset
|
2355 CODING_SPEC_ISO_SINGLE_SHIFTING (coding) = 0; \ |
af3d00fde172
(Fset_terminal_coding_system_internal): Set
Kenichi Handa <handa@m17n.org>
parents:
19280
diff
changeset
|
2356 break; \ |
af3d00fde172
(Fset_terminal_coding_system_internal): Set
Kenichi Handa <handa@m17n.org>
parents:
19280
diff
changeset
|
2357 } \ |
af3d00fde172
(Fset_terminal_coding_system_internal): Set
Kenichi Handa <handa@m17n.org>
parents:
19280
diff
changeset
|
2358 else if (charset == CODING_SPEC_ISO_PLANE_CHARSET (coding, 0)) \ |
af3d00fde172
(Fset_terminal_coding_system_internal): Set
Kenichi Handa <handa@m17n.org>
parents:
19280
diff
changeset
|
2359 { \ |
af3d00fde172
(Fset_terminal_coding_system_internal): Set
Kenichi Handa <handa@m17n.org>
parents:
19280
diff
changeset
|
2360 *dst++ = c1 & 0x7F; \ |
af3d00fde172
(Fset_terminal_coding_system_internal): Set
Kenichi Handa <handa@m17n.org>
parents:
19280
diff
changeset
|
2361 break; \ |
af3d00fde172
(Fset_terminal_coding_system_internal): Set
Kenichi Handa <handa@m17n.org>
parents:
19280
diff
changeset
|
2362 } \ |
af3d00fde172
(Fset_terminal_coding_system_internal): Set
Kenichi Handa <handa@m17n.org>
parents:
19280
diff
changeset
|
2363 else if (charset == CODING_SPEC_ISO_PLANE_CHARSET (coding, 1)) \ |
af3d00fde172
(Fset_terminal_coding_system_internal): Set
Kenichi Handa <handa@m17n.org>
parents:
19280
diff
changeset
|
2364 { \ |
af3d00fde172
(Fset_terminal_coding_system_internal): Set
Kenichi Handa <handa@m17n.org>
parents:
19280
diff
changeset
|
2365 *dst++ = c1 | 0x80; \ |
af3d00fde172
(Fset_terminal_coding_system_internal): Set
Kenichi Handa <handa@m17n.org>
parents:
19280
diff
changeset
|
2366 break; \ |
af3d00fde172
(Fset_terminal_coding_system_internal): Set
Kenichi Handa <handa@m17n.org>
parents:
19280
diff
changeset
|
2367 } \ |
af3d00fde172
(Fset_terminal_coding_system_internal): Set
Kenichi Handa <handa@m17n.org>
parents:
19280
diff
changeset
|
2368 else \ |
af3d00fde172
(Fset_terminal_coding_system_internal): Set
Kenichi Handa <handa@m17n.org>
parents:
19280
diff
changeset
|
2369 /* Since CHARSET is not yet invoked to any graphic planes, we \ |
af3d00fde172
(Fset_terminal_coding_system_internal): Set
Kenichi Handa <handa@m17n.org>
parents:
19280
diff
changeset
|
2370 must invoke it, or, at first, designate it to some graphic \ |
af3d00fde172
(Fset_terminal_coding_system_internal): Set
Kenichi Handa <handa@m17n.org>
parents:
19280
diff
changeset
|
2371 register. Then repeat the loop to actually produce the \ |
af3d00fde172
(Fset_terminal_coding_system_internal): Set
Kenichi Handa <handa@m17n.org>
parents:
19280
diff
changeset
|
2372 character. */ \ |
af3d00fde172
(Fset_terminal_coding_system_internal): Set
Kenichi Handa <handa@m17n.org>
parents:
19280
diff
changeset
|
2373 dst = encode_invocation_designation (charset, coding, dst); \ |
17052 | 2374 } while (1) |
2375 | |
18766 | 2376 /* Produce codes for a DIMENSION2 character whose character set is |
2377 CHARSET and whose position-codes are C1 and C2. Designation and | |
17052 | 2378 invocation codes are also produced in advance if necessary. */ |
2379 | |
19285
af3d00fde172
(Fset_terminal_coding_system_internal): Set
Kenichi Handa <handa@m17n.org>
parents:
19280
diff
changeset
|
2380 #define ENCODE_ISO_CHARACTER_DIMENSION2(charset, c1, c2) \ |
af3d00fde172
(Fset_terminal_coding_system_internal): Set
Kenichi Handa <handa@m17n.org>
parents:
19280
diff
changeset
|
2381 do { \ |
af3d00fde172
(Fset_terminal_coding_system_internal): Set
Kenichi Handa <handa@m17n.org>
parents:
19280
diff
changeset
|
2382 if (CODING_SPEC_ISO_SINGLE_SHIFTING (coding)) \ |
af3d00fde172
(Fset_terminal_coding_system_internal): Set
Kenichi Handa <handa@m17n.org>
parents:
19280
diff
changeset
|
2383 { \ |
af3d00fde172
(Fset_terminal_coding_system_internal): Set
Kenichi Handa <handa@m17n.org>
parents:
19280
diff
changeset
|
2384 if (coding->flags & CODING_FLAG_ISO_SEVEN_BITS) \ |
af3d00fde172
(Fset_terminal_coding_system_internal): Set
Kenichi Handa <handa@m17n.org>
parents:
19280
diff
changeset
|
2385 *dst++ = c1 & 0x7F, *dst++ = c2 & 0x7F; \ |
af3d00fde172
(Fset_terminal_coding_system_internal): Set
Kenichi Handa <handa@m17n.org>
parents:
19280
diff
changeset
|
2386 else \ |
af3d00fde172
(Fset_terminal_coding_system_internal): Set
Kenichi Handa <handa@m17n.org>
parents:
19280
diff
changeset
|
2387 *dst++ = c1 | 0x80, *dst++ = c2 | 0x80; \ |
af3d00fde172
(Fset_terminal_coding_system_internal): Set
Kenichi Handa <handa@m17n.org>
parents:
19280
diff
changeset
|
2388 CODING_SPEC_ISO_SINGLE_SHIFTING (coding) = 0; \ |
af3d00fde172
(Fset_terminal_coding_system_internal): Set
Kenichi Handa <handa@m17n.org>
parents:
19280
diff
changeset
|
2389 break; \ |
af3d00fde172
(Fset_terminal_coding_system_internal): Set
Kenichi Handa <handa@m17n.org>
parents:
19280
diff
changeset
|
2390 } \ |
af3d00fde172
(Fset_terminal_coding_system_internal): Set
Kenichi Handa <handa@m17n.org>
parents:
19280
diff
changeset
|
2391 else if (charset == CODING_SPEC_ISO_PLANE_CHARSET (coding, 0)) \ |
af3d00fde172
(Fset_terminal_coding_system_internal): Set
Kenichi Handa <handa@m17n.org>
parents:
19280
diff
changeset
|
2392 { \ |
af3d00fde172
(Fset_terminal_coding_system_internal): Set
Kenichi Handa <handa@m17n.org>
parents:
19280
diff
changeset
|
2393 *dst++ = c1 & 0x7F, *dst++= c2 & 0x7F; \ |
af3d00fde172
(Fset_terminal_coding_system_internal): Set
Kenichi Handa <handa@m17n.org>
parents:
19280
diff
changeset
|
2394 break; \ |
af3d00fde172
(Fset_terminal_coding_system_internal): Set
Kenichi Handa <handa@m17n.org>
parents:
19280
diff
changeset
|
2395 } \ |
af3d00fde172
(Fset_terminal_coding_system_internal): Set
Kenichi Handa <handa@m17n.org>
parents:
19280
diff
changeset
|
2396 else if (charset == CODING_SPEC_ISO_PLANE_CHARSET (coding, 1)) \ |
af3d00fde172
(Fset_terminal_coding_system_internal): Set
Kenichi Handa <handa@m17n.org>
parents:
19280
diff
changeset
|
2397 { \ |
af3d00fde172
(Fset_terminal_coding_system_internal): Set
Kenichi Handa <handa@m17n.org>
parents:
19280
diff
changeset
|
2398 *dst++ = c1 | 0x80, *dst++= c2 | 0x80; \ |
af3d00fde172
(Fset_terminal_coding_system_internal): Set
Kenichi Handa <handa@m17n.org>
parents:
19280
diff
changeset
|
2399 break; \ |
af3d00fde172
(Fset_terminal_coding_system_internal): Set
Kenichi Handa <handa@m17n.org>
parents:
19280
diff
changeset
|
2400 } \ |
af3d00fde172
(Fset_terminal_coding_system_internal): Set
Kenichi Handa <handa@m17n.org>
parents:
19280
diff
changeset
|
2401 else \ |
af3d00fde172
(Fset_terminal_coding_system_internal): Set
Kenichi Handa <handa@m17n.org>
parents:
19280
diff
changeset
|
2402 /* Since CHARSET is not yet invoked to any graphic planes, we \ |
af3d00fde172
(Fset_terminal_coding_system_internal): Set
Kenichi Handa <handa@m17n.org>
parents:
19280
diff
changeset
|
2403 must invoke it, or, at first, designate it to some graphic \ |
af3d00fde172
(Fset_terminal_coding_system_internal): Set
Kenichi Handa <handa@m17n.org>
parents:
19280
diff
changeset
|
2404 register. Then repeat the loop to actually produce the \ |
af3d00fde172
(Fset_terminal_coding_system_internal): Set
Kenichi Handa <handa@m17n.org>
parents:
19280
diff
changeset
|
2405 character. */ \ |
af3d00fde172
(Fset_terminal_coding_system_internal): Set
Kenichi Handa <handa@m17n.org>
parents:
19280
diff
changeset
|
2406 dst = encode_invocation_designation (charset, coding, dst); \ |
17052 | 2407 } while (1) |
2408 | |
30487
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
2409 #define ENCODE_ISO_CHARACTER(c) \ |
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
2410 do { \ |
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
2411 int charset, c1, c2; \ |
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
2412 \ |
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
2413 SPLIT_CHAR (c, charset, c1, c2); \ |
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
2414 if (CHARSET_DEFINED_P (charset)) \ |
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
2415 { \ |
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
2416 if (CHARSET_DIMENSION (charset) == 1) \ |
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
2417 { \ |
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
2418 if (charset == CHARSET_ASCII \ |
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
2419 && coding->flags & CODING_FLAG_ISO_USE_ROMAN) \ |
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
2420 charset = charset_latin_jisx0201; \ |
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
2421 ENCODE_ISO_CHARACTER_DIMENSION1 (charset, c1); \ |
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
2422 } \ |
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
2423 else \ |
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
2424 { \ |
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
2425 if (charset == charset_jisx0208 \ |
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
2426 && coding->flags & CODING_FLAG_ISO_USE_OLDJIS) \ |
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
2427 charset = charset_jisx0208_1978; \ |
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
2428 ENCODE_ISO_CHARACTER_DIMENSION2 (charset, c1, c2); \ |
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
2429 } \ |
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
2430 } \ |
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
2431 else \ |
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
2432 { \ |
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
2433 *dst++ = c1; \ |
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
2434 if (c2 >= 0) \ |
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
2435 *dst++ = c2; \ |
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
2436 } \ |
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
2437 } while (0) |
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
2438 |
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
2439 |
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
2440 /* Instead of encoding character C, produce one or two `?'s. */ |
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
2441 |
51140
94d903190cee
(ENCODE_UNSAFE_CHARACTER): Adjusted for the name change
Kenichi Handa <handa@m17n.org>
parents:
51090
diff
changeset
|
2442 #define ENCODE_UNSAFE_CHARACTER(c) \ |
94d903190cee
(ENCODE_UNSAFE_CHARACTER): Adjusted for the name change
Kenichi Handa <handa@m17n.org>
parents:
51090
diff
changeset
|
2443 do { \ |
94d903190cee
(ENCODE_UNSAFE_CHARACTER): Adjusted for the name change
Kenichi Handa <handa@m17n.org>
parents:
51090
diff
changeset
|
2444 ENCODE_ISO_CHARACTER (CODING_REPLACEMENT_CHARACTER); \ |
94d903190cee
(ENCODE_UNSAFE_CHARACTER): Adjusted for the name change
Kenichi Handa <handa@m17n.org>
parents:
51090
diff
changeset
|
2445 if (CHARSET_WIDTH (CHAR_CHARSET (c)) > 1) \ |
94d903190cee
(ENCODE_UNSAFE_CHARACTER): Adjusted for the name change
Kenichi Handa <handa@m17n.org>
parents:
51090
diff
changeset
|
2446 ENCODE_ISO_CHARACTER (CODING_REPLACEMENT_CHARACTER); \ |
22119
592bb8b9bcfd
Change terms unify/unification to
Kenichi Handa <handa@m17n.org>
parents:
22020
diff
changeset
|
2447 } while (0) |
17725
92f042f73be2
(Valternate_charset_table): The valiable deleted.
Kenichi Handa <handa@m17n.org>
parents:
17717
diff
changeset
|
2448 |
30487
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
2449 |
17052 | 2450 /* Produce designation and invocation codes at a place pointed by DST |
2451 to use CHARSET. The element `spec.iso2022' of *CODING is updated. | |
2452 Return new DST. */ | |
2453 | |
2454 unsigned char * | |
2455 encode_invocation_designation (charset, coding, dst) | |
2456 int charset; | |
2457 struct coding_system *coding; | |
2458 unsigned char *dst; | |
2459 { | |
2460 int reg; /* graphic register number */ | |
2461 | |
2462 /* At first, check designations. */ | |
2463 for (reg = 0; reg < 4; reg++) | |
2464 if (charset == CODING_SPEC_ISO_DESIGNATION (coding, reg)) | |
2465 break; | |
2466 | |
2467 if (reg >= 4) | |
2468 { | |
2469 /* CHARSET is not yet designated to any graphic registers. */ | |
2470 /* At first check the requested designation. */ | |
2471 reg = CODING_SPEC_ISO_REQUESTED_DESIGNATION (coding, charset); | |
18002
a14261786239
(encode_invocation_designation): Use macro
Kenichi Handa <handa@m17n.org>
parents:
17835
diff
changeset
|
2472 if (reg == CODING_SPEC_ISO_NO_REQUESTED_DESIGNATION) |
a14261786239
(encode_invocation_designation): Use macro
Kenichi Handa <handa@m17n.org>
parents:
17835
diff
changeset
|
2473 /* Since CHARSET requests no special designation, designate it |
a14261786239
(encode_invocation_designation): Use macro
Kenichi Handa <handa@m17n.org>
parents:
17835
diff
changeset
|
2474 to graphic register 0. */ |
17052 | 2475 reg = 0; |
2476 | |
2477 ENCODE_DESIGNATION (charset, reg, coding); | |
2478 } | |
2479 | |
2480 if (CODING_SPEC_ISO_INVOCATION (coding, 0) != reg | |
2481 && CODING_SPEC_ISO_INVOCATION (coding, 1) != reg) | |
2482 { | |
2483 /* Since the graphic register REG is not invoked to any graphic | |
2484 planes, invoke it to graphic plane 0. */ | |
2485 switch (reg) | |
2486 { | |
2487 case 0: /* graphic register 0 */ | |
2488 ENCODE_SHIFT_IN; | |
2489 break; | |
2490 | |
2491 case 1: /* graphic register 1 */ | |
2492 ENCODE_SHIFT_OUT; | |
2493 break; | |
2494 | |
2495 case 2: /* graphic register 2 */ | |
2496 if (coding->flags & CODING_FLAG_ISO_SINGLE_SHIFT) | |
2497 ENCODE_SINGLE_SHIFT_2; | |
2498 else | |
2499 ENCODE_LOCKING_SHIFT_2; | |
2500 break; | |
2501 | |
2502 case 3: /* graphic register 3 */ | |
2503 if (coding->flags & CODING_FLAG_ISO_SINGLE_SHIFT) | |
2504 ENCODE_SINGLE_SHIFT_3; | |
2505 else | |
2506 ENCODE_LOCKING_SHIFT_3; | |
2507 break; | |
2508 } | |
2509 } | |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2510 |
17052 | 2511 return dst; |
2512 } | |
2513 | |
26847 | 2514 /* Produce 2-byte codes for encoded composition rule RULE. */ |
2515 | |
2516 #define ENCODE_COMPOSITION_RULE(rule) \ | |
2517 do { \ | |
2518 int gref, nref; \ | |
2519 COMPOSITION_DECODE_RULE (rule, gref, nref); \ | |
2520 *dst++ = 32 + 81 + gref; \ | |
2521 *dst++ = 32 + nref; \ | |
2522 } while (0) | |
2523 | |
2524 /* Produce codes for indicating the start of a composition sequence | |
2525 (ESC 0, ESC 3, or ESC 4). DATA points to an array of integers | |
2526 which specify information about the composition. See the comment | |
2527 in coding.h for the format of DATA. */ | |
2528 | |
2529 #define ENCODE_COMPOSITION_START(coding, data) \ | |
2530 do { \ | |
2531 coding->composing = data[3]; \ | |
2532 *dst++ = ISO_CODE_ESC; \ | |
2533 if (coding->composing == COMPOSITION_RELATIVE) \ | |
2534 *dst++ = '0'; \ | |
2535 else \ | |
2536 { \ | |
2537 *dst++ = (coding->composing == COMPOSITION_WITH_ALTCHARS \ | |
2538 ? '3' : '4'); \ | |
2539 coding->cmp_data_index = coding->cmp_data_start + 4; \ | |
2540 coding->composition_rule_follows = 0; \ | |
2541 } \ | |
2542 } while (0) | |
2543 | |
2544 /* Produce codes for indicating the end of the current composition. */ | |
2545 | |
2546 #define ENCODE_COMPOSITION_END(coding, data) \ | |
2547 do { \ | |
2548 *dst++ = ISO_CODE_ESC; \ | |
2549 *dst++ = '1'; \ | |
2550 coding->cmp_data_start += data[0]; \ | |
2551 coding->composing = COMPOSITION_NO; \ | |
2552 if (coding->cmp_data_start == coding->cmp_data->used \ | |
2553 && coding->cmp_data->next) \ | |
2554 { \ | |
2555 coding->cmp_data = coding->cmp_data->next; \ | |
2556 coding->cmp_data_start = 0; \ | |
2557 } \ | |
2558 } while (0) | |
2559 | |
2560 /* Produce composition start sequence ESC 0. Here, this sequence | |
2561 doesn't mean the start of a new composition but means that we have | |
2562 just produced components (alternate chars and composition rules) of | |
2563 the composition and the actual text follows in SRC. */ | |
2564 | |
2565 #define ENCODE_COMPOSITION_FAKE_START(coding) \ | |
2566 do { \ | |
2567 *dst++ = ISO_CODE_ESC; \ | |
2568 *dst++ = '0'; \ | |
2569 coding->composing = COMPOSITION_RELATIVE; \ | |
2570 } while (0) | |
17052 | 2571 |
2572 /* The following three macros produce codes for indicating direction | |
2573 of text. */ | |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2574 #define ENCODE_CONTROL_SEQUENCE_INTRODUCER \ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2575 do { \ |
17052 | 2576 if (coding->flags == CODING_FLAG_ISO_SEVEN_BITS) \ |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2577 *dst++ = ISO_CODE_ESC, *dst++ = '['; \ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2578 else \ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2579 *dst++ = ISO_CODE_CSI; \ |
17052 | 2580 } while (0) |
2581 | |
2582 #define ENCODE_DIRECTION_R2L \ | |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2583 ENCODE_CONTROL_SEQUENCE_INTRODUCER (dst), *dst++ = '2', *dst++ = ']' |
17052 | 2584 |
2585 #define ENCODE_DIRECTION_L2R \ | |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2586 ENCODE_CONTROL_SEQUENCE_INTRODUCER (dst), *dst++ = '0', *dst++ = ']' |
17052 | 2587 |
2588 /* Produce codes for designation and invocation to reset the graphic | |
2589 planes and registers to initial state. */ | |
17119
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
2590 #define ENCODE_RESET_PLANE_AND_REGISTER \ |
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
2591 do { \ |
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
2592 int reg; \ |
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
2593 if (CODING_SPEC_ISO_INVOCATION (coding, 0) != 0) \ |
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
2594 ENCODE_SHIFT_IN; \ |
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
2595 for (reg = 0; reg < 4; reg++) \ |
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
2596 if (CODING_SPEC_ISO_INITIAL_DESIGNATION (coding, reg) >= 0 \ |
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
2597 && (CODING_SPEC_ISO_DESIGNATION (coding, reg) \ |
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
2598 != CODING_SPEC_ISO_INITIAL_DESIGNATION (coding, reg))) \ |
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
2599 ENCODE_DESIGNATION \ |
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
2600 (CODING_SPEC_ISO_INITIAL_DESIGNATION (coding, reg), reg, coding); \ |
17052 | 2601 } while (0) |
2602 | |
17725
92f042f73be2
(Valternate_charset_table): The valiable deleted.
Kenichi Handa <handa@m17n.org>
parents:
17717
diff
changeset
|
2603 /* Produce designation sequences of charsets in the line started from |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2604 SRC to a place pointed by DST, and return updated DST. |
17725
92f042f73be2
(Valternate_charset_table): The valiable deleted.
Kenichi Handa <handa@m17n.org>
parents:
17717
diff
changeset
|
2605 |
92f042f73be2
(Valternate_charset_table): The valiable deleted.
Kenichi Handa <handa@m17n.org>
parents:
17717
diff
changeset
|
2606 If the current block ends before any end-of-line, we may fail to |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
2607 find all the necessary designations. */ |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
2608 |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2609 static unsigned char * |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2610 encode_designation_at_bol (coding, translation_table, src, src_end, dst) |
17119
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
2611 struct coding_system *coding; |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2612 Lisp_Object translation_table; |
59168
0345f2b10f1d
(decode_coding_XXX, decode_composition_emacs_mule)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
59095
diff
changeset
|
2613 const unsigned char *src, *src_end; |
0345f2b10f1d
(decode_coding_XXX, decode_composition_emacs_mule)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
59095
diff
changeset
|
2614 unsigned char *dst; |
17119
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
2615 { |
17725
92f042f73be2
(Valternate_charset_table): The valiable deleted.
Kenichi Handa <handa@m17n.org>
parents:
17717
diff
changeset
|
2616 int charset, c, found = 0, reg; |
92f042f73be2
(Valternate_charset_table): The valiable deleted.
Kenichi Handa <handa@m17n.org>
parents:
17717
diff
changeset
|
2617 /* Table of charsets to be designated to each graphic register. */ |
92f042f73be2
(Valternate_charset_table): The valiable deleted.
Kenichi Handa <handa@m17n.org>
parents:
17717
diff
changeset
|
2618 int r[4]; |
92f042f73be2
(Valternate_charset_table): The valiable deleted.
Kenichi Handa <handa@m17n.org>
parents:
17717
diff
changeset
|
2619 |
92f042f73be2
(Valternate_charset_table): The valiable deleted.
Kenichi Handa <handa@m17n.org>
parents:
17717
diff
changeset
|
2620 for (reg = 0; reg < 4; reg++) |
92f042f73be2
(Valternate_charset_table): The valiable deleted.
Kenichi Handa <handa@m17n.org>
parents:
17717
diff
changeset
|
2621 r[reg] = -1; |
92f042f73be2
(Valternate_charset_table): The valiable deleted.
Kenichi Handa <handa@m17n.org>
parents:
17717
diff
changeset
|
2622 |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2623 while (found < 4) |
17119
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
2624 { |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2625 ONE_MORE_CHAR (c); |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2626 if (c == '\n') |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2627 break; |
42104
d69c2368e549
(DECODE_COMPOSITION_END): Fixed a typo in the last
Sam Steingold <sds@gnu.org>
parents:
42103
diff
changeset
|
2628 |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2629 charset = CHAR_CHARSET (c); |
17725
92f042f73be2
(Valternate_charset_table): The valiable deleted.
Kenichi Handa <handa@m17n.org>
parents:
17717
diff
changeset
|
2630 reg = CODING_SPEC_ISO_REQUESTED_DESIGNATION (coding, charset); |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
2631 if (reg != CODING_SPEC_ISO_NO_REQUESTED_DESIGNATION && r[reg] < 0) |
17725
92f042f73be2
(Valternate_charset_table): The valiable deleted.
Kenichi Handa <handa@m17n.org>
parents:
17717
diff
changeset
|
2632 { |
92f042f73be2
(Valternate_charset_table): The valiable deleted.
Kenichi Handa <handa@m17n.org>
parents:
17717
diff
changeset
|
2633 found++; |
92f042f73be2
(Valternate_charset_table): The valiable deleted.
Kenichi Handa <handa@m17n.org>
parents:
17717
diff
changeset
|
2634 r[reg] = charset; |
17119
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
2635 } |
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
2636 } |
17725
92f042f73be2
(Valternate_charset_table): The valiable deleted.
Kenichi Handa <handa@m17n.org>
parents:
17717
diff
changeset
|
2637 |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2638 label_end_of_loop: |
17725
92f042f73be2
(Valternate_charset_table): The valiable deleted.
Kenichi Handa <handa@m17n.org>
parents:
17717
diff
changeset
|
2639 if (found) |
92f042f73be2
(Valternate_charset_table): The valiable deleted.
Kenichi Handa <handa@m17n.org>
parents:
17717
diff
changeset
|
2640 { |
92f042f73be2
(Valternate_charset_table): The valiable deleted.
Kenichi Handa <handa@m17n.org>
parents:
17717
diff
changeset
|
2641 for (reg = 0; reg < 4; reg++) |
92f042f73be2
(Valternate_charset_table): The valiable deleted.
Kenichi Handa <handa@m17n.org>
parents:
17717
diff
changeset
|
2642 if (r[reg] >= 0 |
92f042f73be2
(Valternate_charset_table): The valiable deleted.
Kenichi Handa <handa@m17n.org>
parents:
17717
diff
changeset
|
2643 && CODING_SPEC_ISO_DESIGNATION (coding, reg) != r[reg]) |
92f042f73be2
(Valternate_charset_table): The valiable deleted.
Kenichi Handa <handa@m17n.org>
parents:
17717
diff
changeset
|
2644 ENCODE_DESIGNATION (r[reg], reg, coding); |
92f042f73be2
(Valternate_charset_table): The valiable deleted.
Kenichi Handa <handa@m17n.org>
parents:
17717
diff
changeset
|
2645 } |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2646 |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2647 return dst; |
17119
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
2648 } |
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
2649 |
17052 | 2650 /* See the above "GENERAL NOTES on `encode_coding_XXX ()' functions". */ |
2651 | |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2652 static void |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
2653 encode_coding_iso2022 (coding, source, destination, src_bytes, dst_bytes) |
17052 | 2654 struct coding_system *coding; |
59168
0345f2b10f1d
(decode_coding_XXX, decode_composition_emacs_mule)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
59095
diff
changeset
|
2655 const unsigned char *source; |
0345f2b10f1d
(decode_coding_XXX, decode_composition_emacs_mule)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
59095
diff
changeset
|
2656 unsigned char *destination; |
17052 | 2657 int src_bytes, dst_bytes; |
2658 { | |
59168
0345f2b10f1d
(decode_coding_XXX, decode_composition_emacs_mule)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
59095
diff
changeset
|
2659 const unsigned char *src = source; |
0345f2b10f1d
(decode_coding_XXX, decode_composition_emacs_mule)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
59095
diff
changeset
|
2660 const unsigned char *src_end = source + src_bytes; |
17052 | 2661 unsigned char *dst = destination; |
2662 unsigned char *dst_end = destination + dst_bytes; | |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2663 /* Since the maximum bytes produced by each loop is 20, we subtract 19 |
17052 | 2664 from DST_END to assure overflow checking is necessary only at the |
2665 head of loop. */ | |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2666 unsigned char *adjusted_dst_end = dst_end - 19; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2667 /* SRC_BASE remembers the start position in source in each loop. |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2668 The loop will be exited when there's not enough source text to |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2669 analyze multi-byte codes (within macro ONE_MORE_CHAR), or when |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2670 there's not enough destination area to produce encoded codes |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2671 (within macro EMIT_BYTES). */ |
59168
0345f2b10f1d
(decode_coding_XXX, decode_composition_emacs_mule)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
59095
diff
changeset
|
2672 const unsigned char *src_base; |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2673 int c; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2674 Lisp_Object translation_table; |
30487
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
2675 Lisp_Object safe_chars; |
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
2676 |
51140
94d903190cee
(ENCODE_UNSAFE_CHARACTER): Adjusted for the name change
Kenichi Handa <handa@m17n.org>
parents:
51090
diff
changeset
|
2677 if (coding->flags & CODING_FLAG_ISO_SAFE) |
94d903190cee
(ENCODE_UNSAFE_CHARACTER): Adjusted for the name change
Kenichi Handa <handa@m17n.org>
parents:
51090
diff
changeset
|
2678 coding->mode |= CODING_MODE_INHIBIT_UNENCODABLE_CHAR; |
94d903190cee
(ENCODE_UNSAFE_CHARACTER): Adjusted for the name change
Kenichi Handa <handa@m17n.org>
parents:
51090
diff
changeset
|
2679 |
49539
1ad5bfbb831a
(syms_of_coding): Add `...' for symbols in the docstring of
Kenichi Handa <handa@m17n.org>
parents:
48874
diff
changeset
|
2680 safe_chars = coding_safe_chars (coding->symbol); |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2681 |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2682 if (NILP (Venable_character_translation)) |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2683 translation_table = Qnil; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2684 else |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2685 { |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2686 translation_table = coding->translation_table_for_encode; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2687 if (NILP (translation_table)) |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2688 translation_table = Vstandard_translation_table_for_encode; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2689 } |
17052 | 2690 |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
2691 coding->consumed_char = 0; |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2692 coding->errors = 0; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2693 while (1) |
17052 | 2694 { |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2695 src_base = src; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2696 |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2697 if (dst >= (dst_bytes ? adjusted_dst_end : (src - 19))) |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2698 { |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2699 coding->result = CODING_FINISH_INSUFFICIENT_DST; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2700 break; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2701 } |
17052 | 2702 |
17119
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
2703 if (coding->flags & CODING_FLAG_ISO_DESIGNATE_AT_BOL |
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
2704 && CODING_SPEC_ISO_BOL (coding)) |
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
2705 { |
17725
92f042f73be2
(Valternate_charset_table): The valiable deleted.
Kenichi Handa <handa@m17n.org>
parents:
17717
diff
changeset
|
2706 /* We have to produce designation sequences if any now. */ |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2707 dst = encode_designation_at_bol (coding, translation_table, |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2708 src, src_end, dst); |
17119
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
2709 CODING_SPEC_ISO_BOL (coding) = 0; |
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
2710 } |
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
2711 |
26847 | 2712 /* Check composition start and end. */ |
2713 if (coding->composing != COMPOSITION_DISABLED | |
2714 && coding->cmp_data_start < coding->cmp_data->used) | |
17052 | 2715 { |
26847 | 2716 struct composition_data *cmp_data = coding->cmp_data; |
2717 int *data = cmp_data->data + coding->cmp_data_start; | |
2718 int this_pos = cmp_data->char_offset + coding->consumed_char; | |
2719 | |
2720 if (coding->composing == COMPOSITION_RELATIVE) | |
2721 { | |
2722 if (this_pos == data[2]) | |
2723 { | |
2724 ENCODE_COMPOSITION_END (coding, data); | |
2725 cmp_data = coding->cmp_data; | |
2726 data = cmp_data->data + coding->cmp_data_start; | |
2727 } | |
2728 } | |
2729 else if (COMPOSING_P (coding)) | |
17052 | 2730 { |
26847 | 2731 /* COMPOSITION_WITH_ALTCHARS or COMPOSITION_WITH_RULE_ALTCHAR */ |
2732 if (coding->cmp_data_index == coding->cmp_data_start + data[0]) | |
2733 /* We have consumed components of the composition. | |
36087 | 2734 What follows in SRC is the composition's base |
26847 | 2735 text. */ |
2736 ENCODE_COMPOSITION_FAKE_START (coding); | |
2737 else | |
17052 | 2738 { |
26847 | 2739 int c = cmp_data->data[coding->cmp_data_index++]; |
2740 if (coding->composition_rule_follows) | |
2741 { | |
2742 ENCODE_COMPOSITION_RULE (c); | |
2743 coding->composition_rule_follows = 0; | |
2744 } | |
2745 else | |
2746 { | |
51140
94d903190cee
(ENCODE_UNSAFE_CHARACTER): Adjusted for the name change
Kenichi Handa <handa@m17n.org>
parents:
51090
diff
changeset
|
2747 if (coding->mode & CODING_MODE_INHIBIT_UNENCODABLE_CHAR |
30487
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
2748 && ! CODING_SAFE_CHAR_P (safe_chars, c)) |
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
2749 ENCODE_UNSAFE_CHARACTER (c); |
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
2750 else |
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
2751 ENCODE_ISO_CHARACTER (c); |
26847 | 2752 if (coding->composing == COMPOSITION_WITH_RULE_ALTCHARS) |
2753 coding->composition_rule_follows = 1; | |
2754 } | |
17052 | 2755 continue; |
2756 } | |
26847 | 2757 } |
2758 if (!COMPOSING_P (coding)) | |
2759 { | |
2760 if (this_pos == data[1]) | |
17052 | 2761 { |
26847 | 2762 ENCODE_COMPOSITION_START (coding, data); |
2763 continue; | |
17052 | 2764 } |
2765 } | |
2766 } | |
26847 | 2767 |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2768 ONE_MORE_CHAR (c); |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2769 |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2770 /* Now encode the character C. */ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2771 if (c < 0x20 || c == 0x7F) |
17052 | 2772 { |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2773 if (c == '\r') |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2774 { |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2775 if (! (coding->mode & CODING_MODE_SELECTIVE_DISPLAY)) |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2776 { |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2777 if (coding->flags & CODING_FLAG_ISO_RESET_AT_CNTL) |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2778 ENCODE_RESET_PLANE_AND_REGISTER; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2779 *dst++ = c; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2780 continue; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2781 } |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2782 /* fall down to treat '\r' as '\n' ... */ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2783 c = '\n'; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2784 } |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2785 if (c == '\n') |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2786 { |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2787 if (coding->flags & CODING_FLAG_ISO_RESET_AT_EOL) |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2788 ENCODE_RESET_PLANE_AND_REGISTER; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2789 if (coding->flags & CODING_FLAG_ISO_INIT_AT_BOL) |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2790 bcopy (coding->spec.iso2022.initial_designation, |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2791 coding->spec.iso2022.current_designation, |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2792 sizeof coding->spec.iso2022.initial_designation); |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2793 if (coding->eol_type == CODING_EOL_LF |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2794 || coding->eol_type == CODING_EOL_UNDECIDED) |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2795 *dst++ = ISO_CODE_LF; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2796 else if (coding->eol_type == CODING_EOL_CRLF) |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2797 *dst++ = ISO_CODE_CR, *dst++ = ISO_CODE_LF; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2798 else |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2799 *dst++ = ISO_CODE_CR; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2800 CODING_SPEC_ISO_BOL (coding) = 1; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2801 } |
42104
d69c2368e549
(DECODE_COMPOSITION_END): Fixed a typo in the last
Sam Steingold <sds@gnu.org>
parents:
42103
diff
changeset
|
2802 else |
17052 | 2803 { |
2804 if (coding->flags & CODING_FLAG_ISO_RESET_AT_CNTL) | |
17119
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
2805 ENCODE_RESET_PLANE_AND_REGISTER; |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2806 *dst++ = c; |
19052
302a7b2a6948
(encode_coding_iso2022): Write out invalid multibyte
Kenichi Handa <handa@m17n.org>
parents:
18910
diff
changeset
|
2807 } |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2808 } |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2809 else if (ASCII_BYTE_P (c)) |
30487
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
2810 ENCODE_ISO_CHARACTER (c); |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2811 else if (SINGLE_BYTE_CHAR_P (c)) |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2812 { |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2813 *dst++ = c; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2814 coding->errors++; |
17052 | 2815 } |
51140
94d903190cee
(ENCODE_UNSAFE_CHARACTER): Adjusted for the name change
Kenichi Handa <handa@m17n.org>
parents:
51090
diff
changeset
|
2816 else if (coding->mode & CODING_MODE_INHIBIT_UNENCODABLE_CHAR |
30487
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
2817 && ! CODING_SAFE_CHAR_P (safe_chars, c)) |
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
2818 ENCODE_UNSAFE_CHARACTER (c); |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2819 else |
30487
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
2820 ENCODE_ISO_CHARACTER (c); |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2821 |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2822 coding->consumed_char++; |
17052 | 2823 } |
2824 | |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2825 label_end_of_loop: |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2826 coding->consumed = src_base - source; |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
2827 coding->produced = coding->produced_char = dst - destination; |
17052 | 2828 } |
2829 | |
2830 | |
2831 /*** 4. SJIS and BIG5 handlers ***/ | |
2832 | |
35053 | 2833 /* Although SJIS and BIG5 are not ISO coding systems, they are used |
17052 | 2834 quite widely. So, for the moment, Emacs supports them in the bare |
2835 C code. But, in the future, they may be supported only by CCL. */ | |
2836 | |
2837 /* SJIS is a coding system encoding three character sets: ASCII, right | |
2838 half of JISX0201-Kana, and JISX0208. An ASCII character is encoded | |
2839 as is. A character of charset katakana-jisx0201 is encoded by | |
2840 "position-code + 0x80". A character of charset japanese-jisx0208 | |
2841 is encoded in 2-byte but two position-codes are divided and shifted | |
35053 | 2842 so that it fits in the range below. |
17052 | 2843 |
2844 --- CODE RANGE of SJIS --- | |
2845 (character set) (range) | |
2846 ASCII 0x00 .. 0x7F | |
36647
0a75ccbe42b2
(detect_coding_sjis): Do more rigid check.
Kenichi Handa <handa@m17n.org>
parents:
36520
diff
changeset
|
2847 KATAKANA-JISX0201 0xA1 .. 0xDF |
24324
2eec590faf26
(Fdecode_sjis_char, Fencode_sjis_char): Hanlde
Kenichi Handa <handa@m17n.org>
parents:
24316
diff
changeset
|
2848 JISX0208 (1st byte) 0x81 .. 0x9F and 0xE0 .. 0xEF |
23564
6eb3e346d1fd
(DECODE_CHARACTER_ASCII): Check validity of inserted
Kenichi Handa <handa@m17n.org>
parents:
23542
diff
changeset
|
2849 (2nd byte) 0x40 .. 0x7E and 0x80 .. 0xFC |
17052 | 2850 ------------------------------- |
2851 | |
2852 */ | |
2853 | |
2854 /* BIG5 is a coding system encoding two character sets: ASCII and | |
2855 Big5. An ASCII character is encoded as is. Big5 is a two-byte | |
35053 | 2856 character set and is encoded in two bytes. |
17052 | 2857 |
2858 --- CODE RANGE of BIG5 --- | |
2859 (character set) (range) | |
2860 ASCII 0x00 .. 0x7F | |
2861 Big5 (1st byte) 0xA1 .. 0xFE | |
2862 (2nd byte) 0x40 .. 0x7E and 0xA1 .. 0xFE | |
2863 -------------------------- | |
2864 | |
2865 Since the number of characters in Big5 is larger than maximum | |
2866 characters in Emacs' charset (96x96), it can't be handled as one | |
2867 charset. So, in Emacs, Big5 is divided into two: `charset-big5-1' | |
2868 and `charset-big5-2'. Both are DIMENSION2 and CHARS94. The former | |
2869 contains frequently used characters and the latter contains less | |
2870 frequently used characters. */ | |
2871 | |
2872 /* Macros to decode or encode a character of Big5 in BIG5. B1 and B2 | |
2873 are the 1st and 2nd position-codes of Big5 in BIG5 coding system. | |
46150 | 2874 C1 and C2 are the 1st and 2nd position-codes of Emacs' internal |
17052 | 2875 format. CHARSET is `charset_big5_1' or `charset_big5_2'. */ |
2876 | |
2877 /* Number of Big5 characters which have the same code in 1st byte. */ | |
2878 #define BIG5_SAME_ROW (0xFF - 0xA1 + 0x7F - 0x40) | |
2879 | |
2880 #define DECODE_BIG5(b1, b2, charset, c1, c2) \ | |
2881 do { \ | |
2882 unsigned int temp \ | |
2883 = (b1 - 0xA1) * BIG5_SAME_ROW + b2 - (b2 < 0x7F ? 0x40 : 0x62); \ | |
2884 if (b1 < 0xC9) \ | |
2885 charset = charset_big5_1; \ | |
2886 else \ | |
2887 { \ | |
2888 charset = charset_big5_2; \ | |
2889 temp -= (0xC9 - 0xA1) * BIG5_SAME_ROW; \ | |
2890 } \ | |
2891 c1 = temp / (0xFF - 0xA1) + 0x21; \ | |
2892 c2 = temp % (0xFF - 0xA1) + 0x21; \ | |
2893 } while (0) | |
2894 | |
2895 #define ENCODE_BIG5(charset, c1, c2, b1, b2) \ | |
2896 do { \ | |
2897 unsigned int temp = (c1 - 0x21) * (0xFF - 0xA1) + (c2 - 0x21); \ | |
2898 if (charset == charset_big5_2) \ | |
2899 temp += BIG5_SAME_ROW * (0xC9 - 0xA1); \ | |
2900 b1 = temp / BIG5_SAME_ROW + 0xA1; \ | |
2901 b2 = temp % BIG5_SAME_ROW; \ | |
2902 b2 += b2 < 0x3F ? 0x40 : 0x62; \ | |
2903 } while (0) | |
2904 | |
2905 /* See the above "GENERAL NOTES on `detect_coding_XXX ()' functions". | |
2906 Check if a text is encoded in SJIS. If it is, return | |
2907 CODING_CATEGORY_MASK_SJIS, else return 0. */ | |
2908 | |
34531
37f85e931855
(ONE_MORE_BYTE_CHECK_MULTIBYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34197
diff
changeset
|
2909 static int |
37f85e931855
(ONE_MORE_BYTE_CHECK_MULTIBYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34197
diff
changeset
|
2910 detect_coding_sjis (src, src_end, multibytep) |
17052 | 2911 unsigned char *src, *src_end; |
34531
37f85e931855
(ONE_MORE_BYTE_CHECK_MULTIBYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34197
diff
changeset
|
2912 int multibytep; |
17052 | 2913 { |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2914 int c; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2915 /* Dummy for ONE_MORE_BYTE. */ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2916 struct coding_system dummy_coding; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2917 struct coding_system *coding = &dummy_coding; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2918 |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2919 while (1) |
17052 | 2920 { |
72395
94e4795b333d
(ONE_MORE_BYTE_CHECK_MULTIBYTE): New arg RET. If SRC
Kenichi Handa <handa@m17n.org>
parents:
72323
diff
changeset
|
2921 ONE_MORE_BYTE_CHECK_MULTIBYTE (c, multibytep, CODING_CATEGORY_MASK_SJIS); |
36647
0a75ccbe42b2
(detect_coding_sjis): Do more rigid check.
Kenichi Handa <handa@m17n.org>
parents:
36520
diff
changeset
|
2922 if (c < 0x80) |
0a75ccbe42b2
(detect_coding_sjis): Do more rigid check.
Kenichi Handa <handa@m17n.org>
parents:
36520
diff
changeset
|
2923 continue; |
0a75ccbe42b2
(detect_coding_sjis): Do more rigid check.
Kenichi Handa <handa@m17n.org>
parents:
36520
diff
changeset
|
2924 if (c == 0x80 || c == 0xA0 || c > 0xEF) |
0a75ccbe42b2
(detect_coding_sjis): Do more rigid check.
Kenichi Handa <handa@m17n.org>
parents:
36520
diff
changeset
|
2925 return 0; |
0a75ccbe42b2
(detect_coding_sjis): Do more rigid check.
Kenichi Handa <handa@m17n.org>
parents:
36520
diff
changeset
|
2926 if (c <= 0x9F || c >= 0xE0) |
17052 | 2927 { |
72395
94e4795b333d
(ONE_MORE_BYTE_CHECK_MULTIBYTE): New arg RET. If SRC
Kenichi Handa <handa@m17n.org>
parents:
72323
diff
changeset
|
2928 ONE_MORE_BYTE_CHECK_MULTIBYTE (c, multibytep, 0); |
36647
0a75ccbe42b2
(detect_coding_sjis): Do more rigid check.
Kenichi Handa <handa@m17n.org>
parents:
36520
diff
changeset
|
2929 if (c < 0x40 || c == 0x7F || c > 0xFC) |
17052 | 2930 return 0; |
2931 } | |
2932 } | |
2933 } | |
2934 | |
2935 /* See the above "GENERAL NOTES on `detect_coding_XXX ()' functions". | |
2936 Check if a text is encoded in BIG5. If it is, return | |
2937 CODING_CATEGORY_MASK_BIG5, else return 0. */ | |
2938 | |
34531
37f85e931855
(ONE_MORE_BYTE_CHECK_MULTIBYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34197
diff
changeset
|
2939 static int |
37f85e931855
(ONE_MORE_BYTE_CHECK_MULTIBYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34197
diff
changeset
|
2940 detect_coding_big5 (src, src_end, multibytep) |
17052 | 2941 unsigned char *src, *src_end; |
34531
37f85e931855
(ONE_MORE_BYTE_CHECK_MULTIBYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34197
diff
changeset
|
2942 int multibytep; |
17052 | 2943 { |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2944 int c; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2945 /* Dummy for ONE_MORE_BYTE. */ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2946 struct coding_system dummy_coding; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2947 struct coding_system *coding = &dummy_coding; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2948 |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2949 while (1) |
17052 | 2950 { |
72395
94e4795b333d
(ONE_MORE_BYTE_CHECK_MULTIBYTE): New arg RET. If SRC
Kenichi Handa <handa@m17n.org>
parents:
72323
diff
changeset
|
2951 ONE_MORE_BYTE_CHECK_MULTIBYTE (c, multibytep, CODING_CATEGORY_MASK_BIG5); |
36647
0a75ccbe42b2
(detect_coding_sjis): Do more rigid check.
Kenichi Handa <handa@m17n.org>
parents:
36520
diff
changeset
|
2952 if (c < 0x80) |
0a75ccbe42b2
(detect_coding_sjis): Do more rigid check.
Kenichi Handa <handa@m17n.org>
parents:
36520
diff
changeset
|
2953 continue; |
0a75ccbe42b2
(detect_coding_sjis): Do more rigid check.
Kenichi Handa <handa@m17n.org>
parents:
36520
diff
changeset
|
2954 if (c < 0xA1 || c > 0xFE) |
0a75ccbe42b2
(detect_coding_sjis): Do more rigid check.
Kenichi Handa <handa@m17n.org>
parents:
36520
diff
changeset
|
2955 return 0; |
72395
94e4795b333d
(ONE_MORE_BYTE_CHECK_MULTIBYTE): New arg RET. If SRC
Kenichi Handa <handa@m17n.org>
parents:
72323
diff
changeset
|
2956 ONE_MORE_BYTE_CHECK_MULTIBYTE (c, multibytep, 0); |
36647
0a75ccbe42b2
(detect_coding_sjis): Do more rigid check.
Kenichi Handa <handa@m17n.org>
parents:
36520
diff
changeset
|
2957 if (c < 0x40 || (c > 0x7F && c < 0xA1) || c > 0xFE) |
0a75ccbe42b2
(detect_coding_sjis): Do more rigid check.
Kenichi Handa <handa@m17n.org>
parents:
36520
diff
changeset
|
2958 return 0; |
17052 | 2959 } |
2960 } | |
2961 | |
28022
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
2962 /* See the above "GENERAL NOTES on `detect_coding_XXX ()' functions". |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
2963 Check if a text is encoded in UTF-8. If it is, return |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
2964 CODING_CATEGORY_MASK_UTF_8, else return 0. */ |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
2965 |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
2966 #define UTF_8_1_OCTET_P(c) ((c) < 0x80) |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
2967 #define UTF_8_EXTRA_OCTET_P(c) (((c) & 0xC0) == 0x80) |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
2968 #define UTF_8_2_OCTET_LEADING_P(c) (((c) & 0xE0) == 0xC0) |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
2969 #define UTF_8_3_OCTET_LEADING_P(c) (((c) & 0xF0) == 0xE0) |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
2970 #define UTF_8_4_OCTET_LEADING_P(c) (((c) & 0xF8) == 0xF0) |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
2971 #define UTF_8_5_OCTET_LEADING_P(c) (((c) & 0xFC) == 0xF8) |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
2972 #define UTF_8_6_OCTET_LEADING_P(c) (((c) & 0xFE) == 0xFC) |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
2973 |
34531
37f85e931855
(ONE_MORE_BYTE_CHECK_MULTIBYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34197
diff
changeset
|
2974 static int |
37f85e931855
(ONE_MORE_BYTE_CHECK_MULTIBYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34197
diff
changeset
|
2975 detect_coding_utf_8 (src, src_end, multibytep) |
28022
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
2976 unsigned char *src, *src_end; |
34531
37f85e931855
(ONE_MORE_BYTE_CHECK_MULTIBYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34197
diff
changeset
|
2977 int multibytep; |
28022
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
2978 { |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
2979 unsigned char c; |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
2980 int seq_maybe_bytes; |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2981 /* Dummy for ONE_MORE_BYTE. */ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2982 struct coding_system dummy_coding; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2983 struct coding_system *coding = &dummy_coding; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2984 |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2985 while (1) |
28022
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
2986 { |
72395
94e4795b333d
(ONE_MORE_BYTE_CHECK_MULTIBYTE): New arg RET. If SRC
Kenichi Handa <handa@m17n.org>
parents:
72323
diff
changeset
|
2987 ONE_MORE_BYTE_CHECK_MULTIBYTE (c, multibytep, CODING_CATEGORY_MASK_UTF_8); |
28022
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
2988 if (UTF_8_1_OCTET_P (c)) |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
2989 continue; |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
2990 else if (UTF_8_2_OCTET_LEADING_P (c)) |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
2991 seq_maybe_bytes = 1; |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
2992 else if (UTF_8_3_OCTET_LEADING_P (c)) |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
2993 seq_maybe_bytes = 2; |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
2994 else if (UTF_8_4_OCTET_LEADING_P (c)) |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
2995 seq_maybe_bytes = 3; |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
2996 else if (UTF_8_5_OCTET_LEADING_P (c)) |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
2997 seq_maybe_bytes = 4; |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
2998 else if (UTF_8_6_OCTET_LEADING_P (c)) |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
2999 seq_maybe_bytes = 5; |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
3000 else |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
3001 return 0; |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
3002 |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
3003 do |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
3004 { |
72395
94e4795b333d
(ONE_MORE_BYTE_CHECK_MULTIBYTE): New arg RET. If SRC
Kenichi Handa <handa@m17n.org>
parents:
72323
diff
changeset
|
3005 ONE_MORE_BYTE_CHECK_MULTIBYTE (c, multibytep, 0); |
28022
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
3006 if (!UTF_8_EXTRA_OCTET_P (c)) |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
3007 return 0; |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
3008 seq_maybe_bytes--; |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
3009 } |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
3010 while (seq_maybe_bytes > 0); |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
3011 } |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
3012 } |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
3013 |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
3014 /* See the above "GENERAL NOTES on `detect_coding_XXX ()' functions". |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
3015 Check if a text is encoded in UTF-16 Big Endian (endian == 1) or |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
3016 Little Endian (otherwise). If it is, return |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
3017 CODING_CATEGORY_MASK_UTF_16_BE or CODING_CATEGORY_MASK_UTF_16_LE, |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
3018 else return 0. */ |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
3019 |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
3020 #define UTF_16_INVALID_P(val) \ |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
3021 (((val) == 0xFFFE) \ |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
3022 || ((val) == 0xFFFF)) |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
3023 |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
3024 #define UTF_16_HIGH_SURROGATE_P(val) \ |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
3025 (((val) & 0xD800) == 0xD800) |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
3026 |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
3027 #define UTF_16_LOW_SURROGATE_P(val) \ |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
3028 (((val) & 0xDC00) == 0xDC00) |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
3029 |
34531
37f85e931855
(ONE_MORE_BYTE_CHECK_MULTIBYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34197
diff
changeset
|
3030 static int |
37f85e931855
(ONE_MORE_BYTE_CHECK_MULTIBYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34197
diff
changeset
|
3031 detect_coding_utf_16 (src, src_end, multibytep) |
28022
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
3032 unsigned char *src, *src_end; |
34531
37f85e931855
(ONE_MORE_BYTE_CHECK_MULTIBYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34197
diff
changeset
|
3033 int multibytep; |
28022
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
3034 { |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3035 unsigned char c1, c2; |
50484
6818550bfbc7
(code_convert_region_unwind): Set
Kenichi Handa <handa@m17n.org>
parents:
50185
diff
changeset
|
3036 /* Dummy for ONE_MORE_BYTE_CHECK_MULTIBYTE. */ |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3037 struct coding_system dummy_coding; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3038 struct coding_system *coding = &dummy_coding; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3039 |
72395
94e4795b333d
(ONE_MORE_BYTE_CHECK_MULTIBYTE): New arg RET. If SRC
Kenichi Handa <handa@m17n.org>
parents:
72323
diff
changeset
|
3040 ONE_MORE_BYTE_CHECK_MULTIBYTE (c1, multibytep, 0); |
94e4795b333d
(ONE_MORE_BYTE_CHECK_MULTIBYTE): New arg RET. If SRC
Kenichi Handa <handa@m17n.org>
parents:
72323
diff
changeset
|
3041 ONE_MORE_BYTE_CHECK_MULTIBYTE (c2, multibytep, 0); |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3042 |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3043 if ((c1 == 0xFF) && (c2 == 0xFE)) |
28022
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
3044 return CODING_CATEGORY_MASK_UTF_16_LE; |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3045 else if ((c1 == 0xFE) && (c2 == 0xFF)) |
28022
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
3046 return CODING_CATEGORY_MASK_UTF_16_BE; |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
3047 return 0; |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
3048 } |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
3049 |
17052 | 3050 /* See the above "GENERAL NOTES on `decode_coding_XXX ()' functions". |
3051 If SJIS_P is 1, decode SJIS text, else decode BIG5 test. */ | |
3052 | |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3053 static void |
17052 | 3054 decode_coding_sjis_big5 (coding, source, destination, |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3055 src_bytes, dst_bytes, sjis_p) |
17052 | 3056 struct coding_system *coding; |
59168
0345f2b10f1d
(decode_coding_XXX, decode_composition_emacs_mule)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
59095
diff
changeset
|
3057 const unsigned char *source; |
0345f2b10f1d
(decode_coding_XXX, decode_composition_emacs_mule)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
59095
diff
changeset
|
3058 unsigned char *destination; |
17052 | 3059 int src_bytes, dst_bytes; |
3060 int sjis_p; | |
3061 { | |
59168
0345f2b10f1d
(decode_coding_XXX, decode_composition_emacs_mule)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
59095
diff
changeset
|
3062 const unsigned char *src = source; |
0345f2b10f1d
(decode_coding_XXX, decode_composition_emacs_mule)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
59095
diff
changeset
|
3063 const unsigned char *src_end = source + src_bytes; |
17052 | 3064 unsigned char *dst = destination; |
3065 unsigned char *dst_end = destination + dst_bytes; | |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3066 /* SRC_BASE remembers the start position in source in each loop. |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3067 The loop will be exited when there's not enough source code |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3068 (within macro ONE_MORE_BYTE), or when there's not enough |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3069 destination area to produce a character (within macro |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3070 EMIT_CHAR). */ |
59168
0345f2b10f1d
(decode_coding_XXX, decode_composition_emacs_mule)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
59095
diff
changeset
|
3071 const unsigned char *src_base; |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3072 Lisp_Object translation_table; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3073 |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3074 if (NILP (Venable_character_translation)) |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3075 translation_table = Qnil; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3076 else |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3077 { |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3078 translation_table = coding->translation_table_for_decode; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3079 if (NILP (translation_table)) |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3080 translation_table = Vstandard_translation_table_for_decode; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3081 } |
17052 | 3082 |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3083 coding->produced_char = 0; |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3084 while (1) |
17052 | 3085 { |
52354
5480186284b2
(decode_coding_iso2022): Initialized local variable c2.
Kenichi Handa <handa@m17n.org>
parents:
52016
diff
changeset
|
3086 int c, charset, c1, c2 = 0; |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3087 |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3088 src_base = src; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3089 ONE_MORE_BYTE (c1); |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3090 |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3091 if (c1 < 0x80) |
17052 | 3092 { |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3093 charset = CHARSET_ASCII; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3094 if (c1 < 0x20) |
17052 | 3095 { |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3096 if (c1 == '\r') |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3097 { |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3098 if (coding->eol_type == CODING_EOL_CRLF) |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3099 { |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3100 ONE_MORE_BYTE (c2); |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3101 if (c2 == '\n') |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3102 c1 = c2; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3103 else |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3104 /* To process C2 again, SRC is subtracted by 1. */ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3105 src--; |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3106 } |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3107 else if (coding->eol_type == CODING_EOL_CR) |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3108 c1 = '\n'; |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3109 } |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3110 else if (c1 == '\n' |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3111 && (coding->mode & CODING_MODE_INHIBIT_INCONSISTENT_EOL) |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3112 && (coding->eol_type == CODING_EOL_CR |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3113 || coding->eol_type == CODING_EOL_CRLF)) |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3114 { |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3115 coding->result = CODING_FINISH_INCONSISTENT_EOL; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3116 goto label_end_of_loop; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3117 } |
17052 | 3118 } |
3119 } | |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3120 else |
24870
b0f6eab5deeb
(decode_coding_sjis_big5): Avoid compiler warning.
Kenichi Handa <handa@m17n.org>
parents:
24822
diff
changeset
|
3121 { |
17052 | 3122 if (sjis_p) |
3123 { | |
36647
0a75ccbe42b2
(detect_coding_sjis): Do more rigid check.
Kenichi Handa <handa@m17n.org>
parents:
36520
diff
changeset
|
3124 if (c1 == 0x80 || c1 == 0xA0 || c1 > 0xEF) |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3125 goto label_invalid_code; |
36647
0a75ccbe42b2
(detect_coding_sjis): Do more rigid check.
Kenichi Handa <handa@m17n.org>
parents:
36520
diff
changeset
|
3126 if (c1 <= 0x9F || c1 >= 0xE0) |
20931
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
3127 { |
22616
c493ce6a31e4
(setup_raw_text_coding_system): New function.
Kenichi Handa <handa@m17n.org>
parents:
22529
diff
changeset
|
3128 /* SJIS -> JISX0208 */ |
c493ce6a31e4
(setup_raw_text_coding_system): New function.
Kenichi Handa <handa@m17n.org>
parents:
22529
diff
changeset
|
3129 ONE_MORE_BYTE (c2); |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3130 if (c2 < 0x40 || c2 == 0x7F || c2 > 0xFC) |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3131 goto label_invalid_code; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3132 DECODE_SJIS (c1, c2, c1, c2); |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3133 charset = charset_jisx0208; |
24870
b0f6eab5deeb
(decode_coding_sjis_big5): Avoid compiler warning.
Kenichi Handa <handa@m17n.org>
parents:
24822
diff
changeset
|
3134 } |
20931
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
3135 else |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3136 /* SJIS -> JISX0201-Kana */ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3137 charset = charset_katakana_jisx0201; |
20931
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
3138 } |
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
3139 else |
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
3140 { |
22616
c493ce6a31e4
(setup_raw_text_coding_system): New function.
Kenichi Handa <handa@m17n.org>
parents:
22529
diff
changeset
|
3141 /* BIG5 -> Big5 */ |
36647
0a75ccbe42b2
(detect_coding_sjis): Do more rigid check.
Kenichi Handa <handa@m17n.org>
parents:
36520
diff
changeset
|
3142 if (c1 < 0xA0 || c1 > 0xFE) |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3143 goto label_invalid_code; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3144 ONE_MORE_BYTE (c2); |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3145 if (c2 < 0x40 || (c2 > 0x7E && c2 < 0xA1) || c2 > 0xFE) |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3146 goto label_invalid_code; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3147 DECODE_BIG5 (c1, c2, charset, c1, c2); |
20931
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
3148 } |
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
3149 } |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3150 |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3151 c = DECODE_ISO_CHARACTER (charset, c1, c2); |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3152 EMIT_CHAR (c); |
20931
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
3153 continue; |
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
3154 |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3155 label_invalid_code: |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3156 coding->errors++; |
17052 | 3157 src = src_base; |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3158 c = *src++; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3159 EMIT_CHAR (c); |
17052 | 3160 } |
3161 | |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3162 label_end_of_loop: |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3163 coding->consumed = coding->consumed_char = src_base - source; |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3164 coding->produced = dst - destination; |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3165 return; |
17052 | 3166 } |
3167 | |
3168 /* See the above "GENERAL NOTES on `encode_coding_XXX ()' functions". | |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3169 This function can encode charsets `ascii', `katakana-jisx0201', |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3170 `japanese-jisx0208', `chinese-big5-1', and `chinese-big5-2'. We |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3171 are sure that all these charsets are registered as official charset |
17052 | 3172 (i.e. do not have extended leading-codes). Characters of other |
3173 charsets are produced without any encoding. If SJIS_P is 1, encode | |
3174 SJIS text, else encode BIG5 text. */ | |
3175 | |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3176 static void |
17052 | 3177 encode_coding_sjis_big5 (coding, source, destination, |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3178 src_bytes, dst_bytes, sjis_p) |
17052 | 3179 struct coding_system *coding; |
3180 unsigned char *source, *destination; | |
3181 int src_bytes, dst_bytes; | |
3182 int sjis_p; | |
3183 { | |
3184 unsigned char *src = source; | |
3185 unsigned char *src_end = source + src_bytes; | |
3186 unsigned char *dst = destination; | |
3187 unsigned char *dst_end = destination + dst_bytes; | |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3188 /* SRC_BASE remembers the start position in source in each loop. |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3189 The loop will be exited when there's not enough source text to |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3190 analyze multi-byte codes (within macro ONE_MORE_CHAR), or when |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3191 there's not enough destination area to produce encoded codes |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3192 (within macro EMIT_BYTES). */ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3193 unsigned char *src_base; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3194 Lisp_Object translation_table; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3195 |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3196 if (NILP (Venable_character_translation)) |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3197 translation_table = Qnil; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3198 else |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3199 { |
31455
0b33b8c5d16e
(encode_coding_sjis_big5): Use translation table for
Kenichi Handa <handa@m17n.org>
parents:
31123
diff
changeset
|
3200 translation_table = coding->translation_table_for_encode; |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3201 if (NILP (translation_table)) |
31455
0b33b8c5d16e
(encode_coding_sjis_big5): Use translation table for
Kenichi Handa <handa@m17n.org>
parents:
31123
diff
changeset
|
3202 translation_table = Vstandard_translation_table_for_encode; |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3203 } |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3204 |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3205 while (1) |
17052 | 3206 { |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3207 int c, charset, c1, c2; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3208 |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3209 src_base = src; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3210 ONE_MORE_CHAR (c); |
42104
d69c2368e549
(DECODE_COMPOSITION_END): Fixed a typo in the last
Sam Steingold <sds@gnu.org>
parents:
42103
diff
changeset
|
3211 |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3212 /* Now encode the character C. */ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3213 if (SINGLE_BYTE_CHAR_P (c)) |
17052 | 3214 { |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3215 switch (c) |
17052 | 3216 { |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3217 case '\r': |
45227
6ce63e0a93f1
(encode_coding_sjis_big5): Enclose bitwise AND in
Eli Zaretskii <eliz@gnu.org>
parents:
44562
diff
changeset
|
3218 if (!(coding->mode & CODING_MODE_SELECTIVE_DISPLAY)) |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3219 { |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3220 EMIT_ONE_BYTE (c); |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3221 break; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3222 } |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3223 c = '\n'; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3224 case '\n': |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3225 if (coding->eol_type == CODING_EOL_CRLF) |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3226 { |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3227 EMIT_TWO_BYTES ('\r', c); |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3228 break; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3229 } |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3230 else if (coding->eol_type == CODING_EOL_CR) |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3231 c = '\r'; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3232 default: |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3233 EMIT_ONE_BYTE (c); |
17052 | 3234 } |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3235 } |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3236 else |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3237 { |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3238 SPLIT_CHAR (c, charset, c1, c2); |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3239 if (sjis_p) |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3240 { |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3241 if (charset == charset_jisx0208 |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3242 || charset == charset_jisx0208_1978) |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3243 { |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3244 ENCODE_SJIS (c1, c2, c1, c2); |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3245 EMIT_TWO_BYTES (c1, c2); |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3246 } |
31455
0b33b8c5d16e
(encode_coding_sjis_big5): Use translation table for
Kenichi Handa <handa@m17n.org>
parents:
31123
diff
changeset
|
3247 else if (charset == charset_katakana_jisx0201) |
0b33b8c5d16e
(encode_coding_sjis_big5): Use translation table for
Kenichi Handa <handa@m17n.org>
parents:
31123
diff
changeset
|
3248 EMIT_ONE_BYTE (c1 | 0x80); |
31457
b1c66af9aba5
(encode_coding_sjis_big5): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
31455
diff
changeset
|
3249 else if (charset == charset_latin_jisx0201) |
b1c66af9aba5
(encode_coding_sjis_big5): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
31455
diff
changeset
|
3250 EMIT_ONE_BYTE (c1); |
51140
94d903190cee
(ENCODE_UNSAFE_CHARACTER): Adjusted for the name change
Kenichi Handa <handa@m17n.org>
parents:
51090
diff
changeset
|
3251 else if (coding->mode & CODING_MODE_INHIBIT_UNENCODABLE_CHAR) |
94d903190cee
(ENCODE_UNSAFE_CHARACTER): Adjusted for the name change
Kenichi Handa <handa@m17n.org>
parents:
51090
diff
changeset
|
3252 { |
94d903190cee
(ENCODE_UNSAFE_CHARACTER): Adjusted for the name change
Kenichi Handa <handa@m17n.org>
parents:
51090
diff
changeset
|
3253 EMIT_ONE_BYTE (CODING_REPLACEMENT_CHARACTER); |
94d903190cee
(ENCODE_UNSAFE_CHARACTER): Adjusted for the name change
Kenichi Handa <handa@m17n.org>
parents:
51090
diff
changeset
|
3254 if (CHARSET_WIDTH (charset) > 1) |
94d903190cee
(ENCODE_UNSAFE_CHARACTER): Adjusted for the name change
Kenichi Handa <handa@m17n.org>
parents:
51090
diff
changeset
|
3255 EMIT_ONE_BYTE (CODING_REPLACEMENT_CHARACTER); |
94d903190cee
(ENCODE_UNSAFE_CHARACTER): Adjusted for the name change
Kenichi Handa <handa@m17n.org>
parents:
51090
diff
changeset
|
3256 } |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3257 else |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3258 /* There's no way other than producing the internal |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3259 codes as is. */ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3260 EMIT_BYTES (src_base, src); |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3261 } |
17052 | 3262 else |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3263 { |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3264 if (charset == charset_big5_1 || charset == charset_big5_2) |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3265 { |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3266 ENCODE_BIG5 (charset, c1, c2, c1, c2); |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3267 EMIT_TWO_BYTES (c1, c2); |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3268 } |
51140
94d903190cee
(ENCODE_UNSAFE_CHARACTER): Adjusted for the name change
Kenichi Handa <handa@m17n.org>
parents:
51090
diff
changeset
|
3269 else if (coding->mode & CODING_MODE_INHIBIT_UNENCODABLE_CHAR) |
94d903190cee
(ENCODE_UNSAFE_CHARACTER): Adjusted for the name change
Kenichi Handa <handa@m17n.org>
parents:
51090
diff
changeset
|
3270 { |
94d903190cee
(ENCODE_UNSAFE_CHARACTER): Adjusted for the name change
Kenichi Handa <handa@m17n.org>
parents:
51090
diff
changeset
|
3271 EMIT_ONE_BYTE (CODING_REPLACEMENT_CHARACTER); |
94d903190cee
(ENCODE_UNSAFE_CHARACTER): Adjusted for the name change
Kenichi Handa <handa@m17n.org>
parents:
51090
diff
changeset
|
3272 if (CHARSET_WIDTH (charset) > 1) |
94d903190cee
(ENCODE_UNSAFE_CHARACTER): Adjusted for the name change
Kenichi Handa <handa@m17n.org>
parents:
51090
diff
changeset
|
3273 EMIT_ONE_BYTE (CODING_REPLACEMENT_CHARACTER); |
94d903190cee
(ENCODE_UNSAFE_CHARACTER): Adjusted for the name change
Kenichi Handa <handa@m17n.org>
parents:
51090
diff
changeset
|
3274 } |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3275 else |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3276 /* There's no way other than producing the internal |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3277 codes as is. */ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3278 EMIT_BYTES (src_base, src); |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3279 } |
17052 | 3280 } |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3281 coding->consumed_char++; |
17052 | 3282 } |
3283 | |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3284 label_end_of_loop: |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3285 coding->consumed = src_base - source; |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3286 coding->produced = coding->produced_char = dst - destination; |
17052 | 3287 } |
3288 | |
3289 | |
22874
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
3290 /*** 5. CCL handlers ***/ |
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
3291 |
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
3292 /* See the above "GENERAL NOTES on `detect_coding_XXX ()' functions". |
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
3293 Check if a text is encoded in a coding system of which |
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
3294 encoder/decoder are written in CCL program. If it is, return |
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
3295 CODING_CATEGORY_MASK_CCL, else return 0. */ |
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
3296 |
34531
37f85e931855
(ONE_MORE_BYTE_CHECK_MULTIBYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34197
diff
changeset
|
3297 static int |
37f85e931855
(ONE_MORE_BYTE_CHECK_MULTIBYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34197
diff
changeset
|
3298 detect_coding_ccl (src, src_end, multibytep) |
22874
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
3299 unsigned char *src, *src_end; |
34531
37f85e931855
(ONE_MORE_BYTE_CHECK_MULTIBYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34197
diff
changeset
|
3300 int multibytep; |
22874
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
3301 { |
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
3302 unsigned char *valid; |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3303 int c; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3304 /* Dummy for ONE_MORE_BYTE. */ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3305 struct coding_system dummy_coding; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3306 struct coding_system *coding = &dummy_coding; |
22874
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
3307 |
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
3308 /* No coding system is assigned to coding-category-ccl. */ |
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
3309 if (!coding_system_table[CODING_CATEGORY_IDX_CCL]) |
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
3310 return 0; |
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
3311 |
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
3312 valid = coding_system_table[CODING_CATEGORY_IDX_CCL]->spec.ccl.valid_codes; |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3313 while (1) |
22874
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
3314 { |
72395
94e4795b333d
(ONE_MORE_BYTE_CHECK_MULTIBYTE): New arg RET. If SRC
Kenichi Handa <handa@m17n.org>
parents:
72323
diff
changeset
|
3315 ONE_MORE_BYTE_CHECK_MULTIBYTE (c, multibytep, CODING_CATEGORY_MASK_CCL); |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3316 if (! valid[c]) |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3317 return 0; |
22874
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
3318 } |
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
3319 } |
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
3320 |
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
3321 |
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
3322 /*** 6. End-of-line handlers ***/ |
17052 | 3323 |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3324 /* See the above "GENERAL NOTES on `decode_coding_XXX ()' functions". */ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3325 |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3326 static void |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3327 decode_eol (coding, source, destination, src_bytes, dst_bytes) |
17052 | 3328 struct coding_system *coding; |
59168
0345f2b10f1d
(decode_coding_XXX, decode_composition_emacs_mule)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
59095
diff
changeset
|
3329 const unsigned char *source; |
0345f2b10f1d
(decode_coding_XXX, decode_composition_emacs_mule)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
59095
diff
changeset
|
3330 unsigned char *destination; |
17052 | 3331 int src_bytes, dst_bytes; |
3332 { | |
59168
0345f2b10f1d
(decode_coding_XXX, decode_composition_emacs_mule)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
59095
diff
changeset
|
3333 const unsigned char *src = source; |
17052 | 3334 unsigned char *dst = destination; |
59168
0345f2b10f1d
(decode_coding_XXX, decode_composition_emacs_mule)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
59095
diff
changeset
|
3335 const unsigned char *src_end = src + src_bytes; |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3336 unsigned char *dst_end = dst + dst_bytes; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3337 Lisp_Object translation_table; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3338 /* SRC_BASE remembers the start position in source in each loop. |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3339 The loop will be exited when there's not enough source code |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3340 (within macro ONE_MORE_BYTE), or when there's not enough |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3341 destination area to produce a character (within macro |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3342 EMIT_CHAR). */ |
59168
0345f2b10f1d
(decode_coding_XXX, decode_composition_emacs_mule)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
59095
diff
changeset
|
3343 const unsigned char *src_base; |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3344 int c; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3345 |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3346 translation_table = Qnil; |
17052 | 3347 switch (coding->eol_type) |
3348 { | |
3349 case CODING_EOL_CRLF: | |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3350 while (1) |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3351 { |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3352 src_base = src; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3353 ONE_MORE_BYTE (c); |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3354 if (c == '\r') |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3355 { |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3356 ONE_MORE_BYTE (c); |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3357 if (c != '\n') |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3358 { |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3359 src--; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3360 c = '\r'; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3361 } |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3362 } |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3363 else if (c == '\n' |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3364 && (coding->mode & CODING_MODE_INHIBIT_INCONSISTENT_EOL)) |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3365 { |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3366 coding->result = CODING_FINISH_INCONSISTENT_EOL; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3367 goto label_end_of_loop; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3368 } |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3369 EMIT_CHAR (c); |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3370 } |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3371 break; |
17052 | 3372 |
3373 case CODING_EOL_CR: | |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3374 while (1) |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3375 { |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3376 src_base = src; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3377 ONE_MORE_BYTE (c); |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3378 if (c == '\n') |
20931
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
3379 { |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3380 if (coding->mode & CODING_MODE_INHIBIT_INCONSISTENT_EOL) |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3381 { |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3382 coding->result = CODING_FINISH_INCONSISTENT_EOL; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3383 goto label_end_of_loop; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3384 } |
20931
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
3385 } |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3386 else if (c == '\r') |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3387 c = '\n'; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3388 EMIT_CHAR (c); |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3389 } |
17052 | 3390 break; |
3391 | |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3392 default: /* no need for EOL handling */ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3393 while (1) |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3394 { |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3395 src_base = src; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3396 ONE_MORE_BYTE (c); |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3397 EMIT_CHAR (c); |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3398 } |
17052 | 3399 } |
3400 | |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3401 label_end_of_loop: |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3402 coding->consumed = coding->consumed_char = src_base - source; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3403 coding->produced = dst - destination; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3404 return; |
17052 | 3405 } |
3406 | |
3407 /* See "GENERAL NOTES about `encode_coding_XXX ()' functions". Encode | |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3408 format of end-of-line according to `coding->eol_type'. It also |
36087 | 3409 convert multibyte form 8-bit characters to unibyte if |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3410 CODING->src_multibyte is nonzero. If `coding->mode & |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3411 CODING_MODE_SELECTIVE_DISPLAY' is nonzero, code '\r' in source text |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3412 also means end-of-line. */ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3413 |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3414 static void |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3415 encode_eol (coding, source, destination, src_bytes, dst_bytes) |
17052 | 3416 struct coding_system *coding; |
46548
cb1914307488
(encode_eol, detect_coding, detect_eol):
Ken Raeburn <raeburn@raeburn.org>
parents:
46462
diff
changeset
|
3417 const unsigned char *source; |
cb1914307488
(encode_eol, detect_coding, detect_eol):
Ken Raeburn <raeburn@raeburn.org>
parents:
46462
diff
changeset
|
3418 unsigned char *destination; |
17052 | 3419 int src_bytes, dst_bytes; |
3420 { | |
46548
cb1914307488
(encode_eol, detect_coding, detect_eol):
Ken Raeburn <raeburn@raeburn.org>
parents:
46462
diff
changeset
|
3421 const unsigned char *src = source; |
17052 | 3422 unsigned char *dst = destination; |
46548
cb1914307488
(encode_eol, detect_coding, detect_eol):
Ken Raeburn <raeburn@raeburn.org>
parents:
46462
diff
changeset
|
3423 const unsigned char *src_end = src + src_bytes; |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3424 unsigned char *dst_end = dst + dst_bytes; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3425 Lisp_Object translation_table; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3426 /* SRC_BASE remembers the start position in source in each loop. |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3427 The loop will be exited when there's not enough source text to |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3428 analyze multi-byte codes (within macro ONE_MORE_CHAR), or when |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3429 there's not enough destination area to produce encoded codes |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3430 (within macro EMIT_BYTES). */ |
46548
cb1914307488
(encode_eol, detect_coding, detect_eol):
Ken Raeburn <raeburn@raeburn.org>
parents:
46462
diff
changeset
|
3431 const unsigned char *src_base; |
cb1914307488
(encode_eol, detect_coding, detect_eol):
Ken Raeburn <raeburn@raeburn.org>
parents:
46462
diff
changeset
|
3432 unsigned char *tmp; |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3433 int c; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3434 int selective_display = coding->mode & CODING_MODE_SELECTIVE_DISPLAY; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3435 |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3436 translation_table = Qnil; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3437 if (coding->src_multibyte |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3438 && *(src_end - 1) == LEADING_CODE_8_BIT_CONTROL) |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3439 { |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3440 src_end--; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3441 src_bytes--; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3442 coding->result = CODING_FINISH_INSUFFICIENT_SRC; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3443 } |
20931
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
3444 |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3445 if (coding->eol_type == CODING_EOL_CRLF) |
17052 | 3446 { |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3447 while (src < src_end) |
17052 | 3448 { |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3449 src_base = src; |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3450 c = *src++; |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3451 if (c >= 0x20) |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3452 EMIT_ONE_BYTE (c); |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3453 else if (c == '\n' || (c == '\r' && selective_display)) |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3454 EMIT_TWO_BYTES ('\r', '\n'); |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3455 else |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3456 EMIT_ONE_BYTE (c); |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3457 } |
29093
176708661b08
(encode_eol): Fix a bug of DOS style EOL encoding.
Kenichi Handa <handa@m17n.org>
parents:
29005
diff
changeset
|
3458 src_base = src; |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3459 label_end_of_loop: |
29182
1d1c27067af4
(encode_eol): Add null statement after label.
Dave Love <fx@gnu.org>
parents:
29172
diff
changeset
|
3460 ; |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3461 } |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3462 else |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3463 { |
31123
097593e77185
(encode_eol): Fix bug for the case of dst_bytes being zero. Set
Kenichi Handa <handa@m17n.org>
parents:
30951
diff
changeset
|
3464 if (!dst_bytes || src_bytes <= dst_bytes) |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3465 { |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3466 safe_bcopy (src, dst, src_bytes); |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3467 src_base = src_end; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3468 dst += src_bytes; |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3469 } |
20931
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
3470 else |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3471 { |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3472 if (coding->src_multibyte |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3473 && *(src + dst_bytes - 1) == LEADING_CODE_8_BIT_CONTROL) |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3474 dst_bytes--; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3475 safe_bcopy (src, dst, dst_bytes); |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3476 src_base = src + dst_bytes; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3477 dst = destination + dst_bytes; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3478 coding->result = CODING_FINISH_INSUFFICIENT_DST; |
17052 | 3479 } |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3480 if (coding->eol_type == CODING_EOL_CR) |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3481 { |
46548
cb1914307488
(encode_eol, detect_coding, detect_eol):
Ken Raeburn <raeburn@raeburn.org>
parents:
46462
diff
changeset
|
3482 for (tmp = destination; tmp < dst; tmp++) |
cb1914307488
(encode_eol, detect_coding, detect_eol):
Ken Raeburn <raeburn@raeburn.org>
parents:
46462
diff
changeset
|
3483 if (*tmp == '\n') *tmp = '\r'; |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3484 } |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3485 else if (selective_display) |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3486 { |
46548
cb1914307488
(encode_eol, detect_coding, detect_eol):
Ken Raeburn <raeburn@raeburn.org>
parents:
46462
diff
changeset
|
3487 for (tmp = destination; tmp < dst; tmp++) |
cb1914307488
(encode_eol, detect_coding, detect_eol):
Ken Raeburn <raeburn@raeburn.org>
parents:
46462
diff
changeset
|
3488 if (*tmp == '\r') *tmp = '\n'; |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3489 } |
17052 | 3490 } |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3491 if (coding->src_multibyte) |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3492 dst = destination + str_as_unibyte (destination, dst - destination); |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3493 |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3494 coding->consumed = src_base - source; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3495 coding->produced = dst - destination; |
31123
097593e77185
(encode_eol): Fix bug for the case of dst_bytes being zero. Set
Kenichi Handa <handa@m17n.org>
parents:
30951
diff
changeset
|
3496 coding->produced_char = coding->produced; |
17052 | 3497 } |
3498 | |
3499 | |
22874
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
3500 /*** 7. C library functions ***/ |
17052 | 3501 |
35053 | 3502 /* In Emacs Lisp, a coding system is represented by a Lisp symbol which |
17052 | 3503 has a property `coding-system'. The value of this property is a |
35053 | 3504 vector of length 5 (called the coding-vector). Among elements of |
17052 | 3505 this vector, the first (element[0]) and the fifth (element[4]) |
3506 carry important information for decoding/encoding. Before | |
3507 decoding/encoding, this information should be set in fields of a | |
3508 structure of type `coding_system'. | |
3509 | |
35053 | 3510 The value of the property `coding-system' can be a symbol of another |
17052 | 3511 subsidiary coding-system. In that case, Emacs gets coding-vector |
3512 from that symbol. | |
3513 | |
3514 `element[0]' contains information to be set in `coding->type'. The | |
3515 value and its meaning is as follows: | |
3516 | |
17835
f36ffb6f1208
Name change through the code:
Kenichi Handa <handa@m17n.org>
parents:
17725
diff
changeset
|
3517 0 -- coding_type_emacs_mule |
f36ffb6f1208
Name change through the code:
Kenichi Handa <handa@m17n.org>
parents:
17725
diff
changeset
|
3518 1 -- coding_type_sjis |
f36ffb6f1208
Name change through the code:
Kenichi Handa <handa@m17n.org>
parents:
17725
diff
changeset
|
3519 2 -- coding_type_iso2022 |
f36ffb6f1208
Name change through the code:
Kenichi Handa <handa@m17n.org>
parents:
17725
diff
changeset
|
3520 3 -- coding_type_big5 |
f36ffb6f1208
Name change through the code:
Kenichi Handa <handa@m17n.org>
parents:
17725
diff
changeset
|
3521 4 -- coding_type_ccl encoder/decoder written in CCL |
f36ffb6f1208
Name change through the code:
Kenichi Handa <handa@m17n.org>
parents:
17725
diff
changeset
|
3522 nil -- coding_type_no_conversion |
f36ffb6f1208
Name change through the code:
Kenichi Handa <handa@m17n.org>
parents:
17725
diff
changeset
|
3523 t -- coding_type_undecided (automatic conversion on decoding, |
f36ffb6f1208
Name change through the code:
Kenichi Handa <handa@m17n.org>
parents:
17725
diff
changeset
|
3524 no-conversion on encoding) |
17052 | 3525 |
3526 `element[4]' contains information to be set in `coding->flags' and | |
3527 `coding->spec'. The meaning varies by `coding->type'. | |
3528 | |
3529 If `coding->type' is `coding_type_iso2022', element[4] is a vector | |
3530 of length 32 (of which the first 13 sub-elements are used now). | |
3531 Meanings of these sub-elements are: | |
3532 | |
3533 sub-element[N] where N is 0 through 3: to be set in `coding->spec.iso2022' | |
3534 If the value is an integer of valid charset, the charset is | |
3535 assumed to be designated to graphic register N initially. | |
3536 | |
3537 If the value is minus, it is a minus value of charset which | |
3538 reserves graphic register N, which means that the charset is | |
3539 not designated initially but should be designated to graphic | |
3540 register N just before encoding a character in that charset. | |
3541 | |
3542 If the value is nil, graphic register N is never used on | |
3543 encoding. | |
42104
d69c2368e549
(DECODE_COMPOSITION_END): Fixed a typo in the last
Sam Steingold <sds@gnu.org>
parents:
42103
diff
changeset
|
3544 |
17052 | 3545 sub-element[N] where N is 4 through 11: to be set in `coding->flags' |
3546 Each value takes t or nil. See the section ISO2022 of | |
3547 `coding.h' for more information. | |
3548 | |
3549 If `coding->type' is `coding_type_big5', element[4] is t to denote | |
3550 BIG5-ETen or nil to denote BIG5-HKU. | |
3551 | |
3552 If `coding->type' takes the other value, element[4] is ignored. | |
3553 | |
35053 | 3554 Emacs Lisp's coding systems also carry information about format of |
17052 | 3555 end-of-line in a value of property `eol-type'. If the value is |
3556 integer, 0 means CODING_EOL_LF, 1 means CODING_EOL_CRLF, and 2 | |
3557 means CODING_EOL_CR. If it is not integer, it should be a vector | |
3558 of subsidiary coding systems of which property `eol-type' has one | |
35053 | 3559 of the above values. |
17052 | 3560 |
3561 */ | |
3562 | |
3563 /* Extract information for decoding/encoding from CODING_SYSTEM_SYMBOL | |
3564 and set it in CODING. If CODING_SYSTEM_SYMBOL is invalid, CODING | |
3565 is setup so that no conversion is necessary and return -1, else | |
3566 return 0. */ | |
3567 | |
3568 int | |
17119
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
3569 setup_coding_system (coding_system, coding) |
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
3570 Lisp_Object coding_system; |
17052 | 3571 struct coding_system *coding; |
3572 { | |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3573 Lisp_Object coding_spec, coding_type, eol_type, plist; |
20105
c017642863c2
(Qcoding_system_spec): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
19824
diff
changeset
|
3574 Lisp_Object val; |
17052 | 3575 |
34591
9d5d795f9315
(setup_coding_system): Clear all members of the struct
Kenichi Handa <handa@m17n.org>
parents:
34536
diff
changeset
|
3576 /* At first, zero clear all members. */ |
9d5d795f9315
(setup_coding_system): Clear all members of the struct
Kenichi Handa <handa@m17n.org>
parents:
34536
diff
changeset
|
3577 bzero (coding, sizeof (struct coding_system)); |
9d5d795f9315
(setup_coding_system): Clear all members of the struct
Kenichi Handa <handa@m17n.org>
parents:
34536
diff
changeset
|
3578 |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3579 /* Initialize some fields required for all kinds of coding systems. */ |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3580 coding->symbol = coding_system; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3581 coding->heading_ascii = -1; |
17052 | 3582 coding->post_read_conversion = coding->pre_write_conversion = Qnil; |
26847 | 3583 coding->composing = COMPOSITION_DISABLED; |
3584 coding->cmp_data = NULL; | |
24460
be35d27a4bfb
(setup_coding_system): Check for CODING_SYSTEM = nil.
Kenichi Handa <handa@m17n.org>
parents:
24425
diff
changeset
|
3585 |
be35d27a4bfb
(setup_coding_system): Check for CODING_SYSTEM = nil.
Kenichi Handa <handa@m17n.org>
parents:
24425
diff
changeset
|
3586 if (NILP (coding_system)) |
be35d27a4bfb
(setup_coding_system): Check for CODING_SYSTEM = nil.
Kenichi Handa <handa@m17n.org>
parents:
24425
diff
changeset
|
3587 goto label_invalid_coding_system; |
be35d27a4bfb
(setup_coding_system): Check for CODING_SYSTEM = nil.
Kenichi Handa <handa@m17n.org>
parents:
24425
diff
changeset
|
3588 |
20105
c017642863c2
(Qcoding_system_spec): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
19824
diff
changeset
|
3589 coding_spec = Fget (coding_system, Qcoding_system); |
24460
be35d27a4bfb
(setup_coding_system): Check for CODING_SYSTEM = nil.
Kenichi Handa <handa@m17n.org>
parents:
24425
diff
changeset
|
3590 |
20105
c017642863c2
(Qcoding_system_spec): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
19824
diff
changeset
|
3591 if (!VECTORP (coding_spec) |
c017642863c2
(Qcoding_system_spec): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
19824
diff
changeset
|
3592 || XVECTOR (coding_spec)->size != 5 |
c017642863c2
(Qcoding_system_spec): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
19824
diff
changeset
|
3593 || !CONSP (XVECTOR (coding_spec)->contents[3])) |
17052 | 3594 goto label_invalid_coding_system; |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3595 |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3596 eol_type = inhibit_eol_conversion ? Qnil : Fget (coding_system, Qeol_type); |
17052 | 3597 if (VECTORP (eol_type)) |
20227
71008f909642
(setup_coding_system): Initialize common_flags member
Kenichi Handa <handa@m17n.org>
parents:
20150
diff
changeset
|
3598 { |
71008f909642
(setup_coding_system): Initialize common_flags member
Kenichi Handa <handa@m17n.org>
parents:
20150
diff
changeset
|
3599 coding->eol_type = CODING_EOL_UNDECIDED; |
71008f909642
(setup_coding_system): Initialize common_flags member
Kenichi Handa <handa@m17n.org>
parents:
20150
diff
changeset
|
3600 coding->common_flags = CODING_REQUIRE_DETECTION_MASK; |
69995
d4a5619e5025
(setup_coding_system): If eol-type is not yet decided
Kenichi Handa <handa@m17n.org>
parents:
69993
diff
changeset
|
3601 if (system_eol_type != CODING_EOL_LF) |
d4a5619e5025
(setup_coding_system): If eol-type is not yet decided
Kenichi Handa <handa@m17n.org>
parents:
69993
diff
changeset
|
3602 coding->common_flags |= CODING_REQUIRE_ENCODING_MASK; |
20227
71008f909642
(setup_coding_system): Initialize common_flags member
Kenichi Handa <handa@m17n.org>
parents:
20150
diff
changeset
|
3603 } |
17052 | 3604 else if (XFASTINT (eol_type) == 1) |
20227
71008f909642
(setup_coding_system): Initialize common_flags member
Kenichi Handa <handa@m17n.org>
parents:
20150
diff
changeset
|
3605 { |
71008f909642
(setup_coding_system): Initialize common_flags member
Kenichi Handa <handa@m17n.org>
parents:
20150
diff
changeset
|
3606 coding->eol_type = CODING_EOL_CRLF; |
71008f909642
(setup_coding_system): Initialize common_flags member
Kenichi Handa <handa@m17n.org>
parents:
20150
diff
changeset
|
3607 coding->common_flags |
71008f909642
(setup_coding_system): Initialize common_flags member
Kenichi Handa <handa@m17n.org>
parents:
20150
diff
changeset
|
3608 = CODING_REQUIRE_DECODING_MASK | CODING_REQUIRE_ENCODING_MASK; |
71008f909642
(setup_coding_system): Initialize common_flags member
Kenichi Handa <handa@m17n.org>
parents:
20150
diff
changeset
|
3609 } |
17052 | 3610 else if (XFASTINT (eol_type) == 2) |
20227
71008f909642
(setup_coding_system): Initialize common_flags member
Kenichi Handa <handa@m17n.org>
parents:
20150
diff
changeset
|
3611 { |
71008f909642
(setup_coding_system): Initialize common_flags member
Kenichi Handa <handa@m17n.org>
parents:
20150
diff
changeset
|
3612 coding->eol_type = CODING_EOL_CR; |
71008f909642
(setup_coding_system): Initialize common_flags member
Kenichi Handa <handa@m17n.org>
parents:
20150
diff
changeset
|
3613 coding->common_flags |
71008f909642
(setup_coding_system): Initialize common_flags member
Kenichi Handa <handa@m17n.org>
parents:
20150
diff
changeset
|
3614 = CODING_REQUIRE_DECODING_MASK | CODING_REQUIRE_ENCODING_MASK; |
71008f909642
(setup_coding_system): Initialize common_flags member
Kenichi Handa <handa@m17n.org>
parents:
20150
diff
changeset
|
3615 } |
17052 | 3616 else |
70704
576f5c8ea6e4
(Qascii_incompatible): New variable.
Kenichi Handa <handa@m17n.org>
parents:
70520
diff
changeset
|
3617 { |
576f5c8ea6e4
(Qascii_incompatible): New variable.
Kenichi Handa <handa@m17n.org>
parents:
70520
diff
changeset
|
3618 coding->common_flags = 0; |
576f5c8ea6e4
(Qascii_incompatible): New variable.
Kenichi Handa <handa@m17n.org>
parents:
70520
diff
changeset
|
3619 coding->eol_type = CODING_EOL_LF; |
576f5c8ea6e4
(Qascii_incompatible): New variable.
Kenichi Handa <handa@m17n.org>
parents:
70520
diff
changeset
|
3620 } |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3621 |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3622 coding_type = XVECTOR (coding_spec)->contents[0]; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3623 /* Try short cut. */ |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3624 if (SYMBOLP (coding_type)) |
20227
71008f909642
(setup_coding_system): Initialize common_flags member
Kenichi Handa <handa@m17n.org>
parents:
20150
diff
changeset
|
3625 { |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3626 if (EQ (coding_type, Qt)) |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3627 { |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3628 coding->type = coding_type_undecided; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3629 coding->common_flags |= CODING_REQUIRE_DETECTION_MASK; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3630 } |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3631 else |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3632 coding->type = coding_type_no_conversion; |
34197
78561a43cdd1
(setup_coding_system): Be sure to initialize coding->category_idx.
Kenichi Handa <handa@m17n.org>
parents:
33931
diff
changeset
|
3633 /* Initialize this member. Any thing other than |
78561a43cdd1
(setup_coding_system): Be sure to initialize coding->category_idx.
Kenichi Handa <handa@m17n.org>
parents:
33931
diff
changeset
|
3634 CODING_CATEGORY_IDX_UTF_16_BE and |
78561a43cdd1
(setup_coding_system): Be sure to initialize coding->category_idx.
Kenichi Handa <handa@m17n.org>
parents:
33931
diff
changeset
|
3635 CODING_CATEGORY_IDX_UTF_16_LE are ok because they have |
78561a43cdd1
(setup_coding_system): Be sure to initialize coding->category_idx.
Kenichi Handa <handa@m17n.org>
parents:
33931
diff
changeset
|
3636 special treatment in detect_eol. */ |
78561a43cdd1
(setup_coding_system): Be sure to initialize coding->category_idx.
Kenichi Handa <handa@m17n.org>
parents:
33931
diff
changeset
|
3637 coding->category_idx = CODING_CATEGORY_IDX_EMACS_MULE; |
78561a43cdd1
(setup_coding_system): Be sure to initialize coding->category_idx.
Kenichi Handa <handa@m17n.org>
parents:
33931
diff
changeset
|
3638 |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3639 return 0; |
20227
71008f909642
(setup_coding_system): Initialize common_flags member
Kenichi Handa <handa@m17n.org>
parents:
20150
diff
changeset
|
3640 } |
17052 | 3641 |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3642 /* Get values of coding system properties: |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3643 `post-read-conversion', `pre-write-conversion', |
22186
fc4aaf1b1772
Change term "character translation table" to "translation table".
Kenichi Handa <handa@m17n.org>
parents:
22166
diff
changeset
|
3644 `translation-table-for-decode', `translation-table-for-encode'. */ |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3645 plist = XVECTOR (coding_spec)->contents[3]; |
26067
f54ca66e2571
(code_convert_string): Add record_unwind_protect to
Kenichi Handa <handa@m17n.org>
parents:
25860
diff
changeset
|
3646 /* Pre & post conversion functions should be disabled if |
36087 | 3647 inhibit_eol_conversion is nonzero. This is the case that a code |
26067
f54ca66e2571
(code_convert_string): Add record_unwind_protect to
Kenichi Handa <handa@m17n.org>
parents:
25860
diff
changeset
|
3648 conversion function is called while those functions are running. */ |
f54ca66e2571
(code_convert_string): Add record_unwind_protect to
Kenichi Handa <handa@m17n.org>
parents:
25860
diff
changeset
|
3649 if (! inhibit_pre_post_conversion) |
f54ca66e2571
(code_convert_string): Add record_unwind_protect to
Kenichi Handa <handa@m17n.org>
parents:
25860
diff
changeset
|
3650 { |
f54ca66e2571
(code_convert_string): Add record_unwind_protect to
Kenichi Handa <handa@m17n.org>
parents:
25860
diff
changeset
|
3651 coding->post_read_conversion = Fplist_get (plist, Qpost_read_conversion); |
f54ca66e2571
(code_convert_string): Add record_unwind_protect to
Kenichi Handa <handa@m17n.org>
parents:
25860
diff
changeset
|
3652 coding->pre_write_conversion = Fplist_get (plist, Qpre_write_conversion); |
f54ca66e2571
(code_convert_string): Add record_unwind_protect to
Kenichi Handa <handa@m17n.org>
parents:
25860
diff
changeset
|
3653 } |
22186
fc4aaf1b1772
Change term "character translation table" to "translation table".
Kenichi Handa <handa@m17n.org>
parents:
22166
diff
changeset
|
3654 val = Fplist_get (plist, Qtranslation_table_for_decode); |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3655 if (SYMBOLP (val)) |
22186
fc4aaf1b1772
Change term "character translation table" to "translation table".
Kenichi Handa <handa@m17n.org>
parents:
22166
diff
changeset
|
3656 val = Fget (val, Qtranslation_table_for_decode); |
fc4aaf1b1772
Change term "character translation table" to "translation table".
Kenichi Handa <handa@m17n.org>
parents:
22166
diff
changeset
|
3657 coding->translation_table_for_decode = CHAR_TABLE_P (val) ? val : Qnil; |
fc4aaf1b1772
Change term "character translation table" to "translation table".
Kenichi Handa <handa@m17n.org>
parents:
22166
diff
changeset
|
3658 val = Fplist_get (plist, Qtranslation_table_for_encode); |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3659 if (SYMBOLP (val)) |
22186
fc4aaf1b1772
Change term "character translation table" to "translation table".
Kenichi Handa <handa@m17n.org>
parents:
22166
diff
changeset
|
3660 val = Fget (val, Qtranslation_table_for_encode); |
fc4aaf1b1772
Change term "character translation table" to "translation table".
Kenichi Handa <handa@m17n.org>
parents:
22166
diff
changeset
|
3661 coding->translation_table_for_encode = CHAR_TABLE_P (val) ? val : Qnil; |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3662 val = Fplist_get (plist, Qcoding_category); |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3663 if (!NILP (val)) |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3664 { |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3665 val = Fget (val, Qcoding_category_index); |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3666 if (INTEGERP (val)) |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3667 coding->category_idx = XINT (val); |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3668 else |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3669 goto label_invalid_coding_system; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3670 } |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3671 else |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3672 goto label_invalid_coding_system; |
42104
d69c2368e549
(DECODE_COMPOSITION_END): Fixed a typo in the last
Sam Steingold <sds@gnu.org>
parents:
42103
diff
changeset
|
3673 |
26847 | 3674 /* If the coding system has non-nil `composition' property, enable |
3675 composition handling. */ | |
3676 val = Fplist_get (plist, Qcomposition); | |
3677 if (!NILP (val)) | |
3678 coding->composing = COMPOSITION_NO; | |
3679 | |
70704
576f5c8ea6e4
(Qascii_incompatible): New variable.
Kenichi Handa <handa@m17n.org>
parents:
70520
diff
changeset
|
3680 /* If the coding system is ascii-incompatible, record it in |
576f5c8ea6e4
(Qascii_incompatible): New variable.
Kenichi Handa <handa@m17n.org>
parents:
70520
diff
changeset
|
3681 common_flags. */ |
576f5c8ea6e4
(Qascii_incompatible): New variable.
Kenichi Handa <handa@m17n.org>
parents:
70520
diff
changeset
|
3682 val = Fplist_get (plist, Qascii_incompatible); |
576f5c8ea6e4
(Qascii_incompatible): New variable.
Kenichi Handa <handa@m17n.org>
parents:
70520
diff
changeset
|
3683 if (! NILP (val)) |
576f5c8ea6e4
(Qascii_incompatible): New variable.
Kenichi Handa <handa@m17n.org>
parents:
70520
diff
changeset
|
3684 coding->common_flags |= CODING_ASCII_INCOMPATIBLE_MASK; |
576f5c8ea6e4
(Qascii_incompatible): New variable.
Kenichi Handa <handa@m17n.org>
parents:
70520
diff
changeset
|
3685 |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3686 switch (XFASTINT (coding_type)) |
17052 | 3687 { |
3688 case 0: | |
17835
f36ffb6f1208
Name change through the code:
Kenichi Handa <handa@m17n.org>
parents:
17725
diff
changeset
|
3689 coding->type = coding_type_emacs_mule; |
34888
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
3690 coding->common_flags |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
3691 |= CODING_REQUIRE_DECODING_MASK | CODING_REQUIRE_ENCODING_MASK; |
20227
71008f909642
(setup_coding_system): Initialize common_flags member
Kenichi Handa <handa@m17n.org>
parents:
20150
diff
changeset
|
3692 if (!NILP (coding->post_read_conversion)) |
71008f909642
(setup_coding_system): Initialize common_flags member
Kenichi Handa <handa@m17n.org>
parents:
20150
diff
changeset
|
3693 coding->common_flags |= CODING_REQUIRE_DECODING_MASK; |
71008f909642
(setup_coding_system): Initialize common_flags member
Kenichi Handa <handa@m17n.org>
parents:
20150
diff
changeset
|
3694 if (!NILP (coding->pre_write_conversion)) |
71008f909642
(setup_coding_system): Initialize common_flags member
Kenichi Handa <handa@m17n.org>
parents:
20150
diff
changeset
|
3695 coding->common_flags |= CODING_REQUIRE_ENCODING_MASK; |
17052 | 3696 break; |
3697 | |
3698 case 1: | |
3699 coding->type = coding_type_sjis; | |
20227
71008f909642
(setup_coding_system): Initialize common_flags member
Kenichi Handa <handa@m17n.org>
parents:
20150
diff
changeset
|
3700 coding->common_flags |
71008f909642
(setup_coding_system): Initialize common_flags member
Kenichi Handa <handa@m17n.org>
parents:
20150
diff
changeset
|
3701 |= CODING_REQUIRE_DECODING_MASK | CODING_REQUIRE_ENCODING_MASK; |
17052 | 3702 break; |
3703 | |
3704 case 2: | |
3705 coding->type = coding_type_iso2022; | |
20227
71008f909642
(setup_coding_system): Initialize common_flags member
Kenichi Handa <handa@m17n.org>
parents:
20150
diff
changeset
|
3706 coding->common_flags |
71008f909642
(setup_coding_system): Initialize common_flags member
Kenichi Handa <handa@m17n.org>
parents:
20150
diff
changeset
|
3707 |= CODING_REQUIRE_DECODING_MASK | CODING_REQUIRE_ENCODING_MASK; |
17052 | 3708 { |
20150
402b6e5f4b58
(encode_designation_at_bol): Fix bug of finding graphic
Kenichi Handa <handa@m17n.org>
parents:
20105
diff
changeset
|
3709 Lisp_Object val, temp; |
17052 | 3710 Lisp_Object *flags; |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3711 int i, charset, reg_bits = 0; |
17052 | 3712 |
20105
c017642863c2
(Qcoding_system_spec): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
19824
diff
changeset
|
3713 val = XVECTOR (coding_spec)->contents[4]; |
19747
bed06df9cbc5
(setup_coding_system, Ffind_operation_coding_system)
Richard M. Stallman <rms@gnu.org>
parents:
19743
diff
changeset
|
3714 |
17052 | 3715 if (!VECTORP (val) || XVECTOR (val)->size != 32) |
3716 goto label_invalid_coding_system; | |
3717 | |
3718 flags = XVECTOR (val)->contents; | |
3719 coding->flags | |
3720 = ((NILP (flags[4]) ? 0 : CODING_FLAG_ISO_SHORT_FORM) | |
3721 | (NILP (flags[5]) ? 0 : CODING_FLAG_ISO_RESET_AT_EOL) | |
3722 | (NILP (flags[6]) ? 0 : CODING_FLAG_ISO_RESET_AT_CNTL) | |
3723 | (NILP (flags[7]) ? 0 : CODING_FLAG_ISO_SEVEN_BITS) | |
3724 | (NILP (flags[8]) ? 0 : CODING_FLAG_ISO_LOCKING_SHIFT) | |
3725 | (NILP (flags[9]) ? 0 : CODING_FLAG_ISO_SINGLE_SHIFT) | |
3726 | (NILP (flags[10]) ? 0 : CODING_FLAG_ISO_USE_ROMAN) | |
3727 | (NILP (flags[11]) ? 0 : CODING_FLAG_ISO_USE_OLDJIS) | |
17119
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
3728 | (NILP (flags[12]) ? 0 : CODING_FLAG_ISO_NO_DIRECTION) |
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
3729 | (NILP (flags[13]) ? 0 : CODING_FLAG_ISO_INIT_AT_BOL) |
19280
e755044718ee
(ENCODE_ISO_CHARACTER_DIMENSION1): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
19193
diff
changeset
|
3730 | (NILP (flags[14]) ? 0 : CODING_FLAG_ISO_DESIGNATE_AT_BOL) |
e755044718ee
(ENCODE_ISO_CHARACTER_DIMENSION1): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
19193
diff
changeset
|
3731 | (NILP (flags[15]) ? 0 : CODING_FLAG_ISO_SAFE) |
19365
d9374f5ebd3a
(CODING_FLAG_ISO_LATIN_EXTRA): New macro.
Kenichi Handa <handa@m17n.org>
parents:
19285
diff
changeset
|
3732 | (NILP (flags[16]) ? 0 : CODING_FLAG_ISO_LATIN_EXTRA) |
19280
e755044718ee
(ENCODE_ISO_CHARACTER_DIMENSION1): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
19193
diff
changeset
|
3733 ); |
17052 | 3734 |
3735 /* Invoke graphic register 0 to plane 0. */ | |
3736 CODING_SPEC_ISO_INVOCATION (coding, 0) = 0; | |
3737 /* Invoke graphic register 1 to plane 1 if we can use full 8-bit. */ | |
3738 CODING_SPEC_ISO_INVOCATION (coding, 1) | |
3739 = (coding->flags & CODING_FLAG_ISO_SEVEN_BITS ? -1 : 1); | |
3740 /* Not single shifting at first. */ | |
19285
af3d00fde172
(Fset_terminal_coding_system_internal): Set
Kenichi Handa <handa@m17n.org>
parents:
19280
diff
changeset
|
3741 CODING_SPEC_ISO_SINGLE_SHIFTING (coding) = 0; |
17119
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
3742 /* Beginning of buffer should also be regarded as bol. */ |
19285
af3d00fde172
(Fset_terminal_coding_system_internal): Set
Kenichi Handa <handa@m17n.org>
parents:
19280
diff
changeset
|
3743 CODING_SPEC_ISO_BOL (coding) = 1; |
17052 | 3744 |
20150
402b6e5f4b58
(encode_designation_at_bol): Fix bug of finding graphic
Kenichi Handa <handa@m17n.org>
parents:
20105
diff
changeset
|
3745 for (charset = 0; charset <= MAX_CHARSET; charset++) |
402b6e5f4b58
(encode_designation_at_bol): Fix bug of finding graphic
Kenichi Handa <handa@m17n.org>
parents:
20105
diff
changeset
|
3746 CODING_SPEC_ISO_REVISION_NUMBER (coding, charset) = 255; |
402b6e5f4b58
(encode_designation_at_bol): Fix bug of finding graphic
Kenichi Handa <handa@m17n.org>
parents:
20105
diff
changeset
|
3747 val = Vcharset_revision_alist; |
402b6e5f4b58
(encode_designation_at_bol): Fix bug of finding graphic
Kenichi Handa <handa@m17n.org>
parents:
20105
diff
changeset
|
3748 while (CONSP (val)) |
402b6e5f4b58
(encode_designation_at_bol): Fix bug of finding graphic
Kenichi Handa <handa@m17n.org>
parents:
20105
diff
changeset
|
3749 { |
25662
0a7261c1d487
Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25370
diff
changeset
|
3750 charset = get_charset_id (Fcar_safe (XCAR (val))); |
20150
402b6e5f4b58
(encode_designation_at_bol): Fix bug of finding graphic
Kenichi Handa <handa@m17n.org>
parents:
20105
diff
changeset
|
3751 if (charset >= 0 |
25662
0a7261c1d487
Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25370
diff
changeset
|
3752 && (temp = Fcdr_safe (XCAR (val)), INTEGERP (temp)) |
20150
402b6e5f4b58
(encode_designation_at_bol): Fix bug of finding graphic
Kenichi Handa <handa@m17n.org>
parents:
20105
diff
changeset
|
3753 && (i = XINT (temp), (i >= 0 && (i + '@') < 128))) |
402b6e5f4b58
(encode_designation_at_bol): Fix bug of finding graphic
Kenichi Handa <handa@m17n.org>
parents:
20105
diff
changeset
|
3754 CODING_SPEC_ISO_REVISION_NUMBER (coding, charset) = i; |
25662
0a7261c1d487
Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25370
diff
changeset
|
3755 val = XCDR (val); |
20150
402b6e5f4b58
(encode_designation_at_bol): Fix bug of finding graphic
Kenichi Handa <handa@m17n.org>
parents:
20105
diff
changeset
|
3756 } |
402b6e5f4b58
(encode_designation_at_bol): Fix bug of finding graphic
Kenichi Handa <handa@m17n.org>
parents:
20105
diff
changeset
|
3757 |
17052 | 3758 /* Checks FLAGS[REG] (REG = 0, 1, 2 3) and decide designations. |
3759 FLAGS[REG] can be one of below: | |
3760 integer CHARSET: CHARSET occupies register I, | |
3761 t: designate nothing to REG initially, but can be used | |
3762 by any charsets, | |
3763 list of integer, nil, or t: designate the first | |
3764 element (if integer) to REG initially, the remaining | |
3765 elements (if integer) is designated to REG on request, | |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3766 if an element is t, REG can be used by any charsets, |
17052 | 3767 nil: REG is never used. */ |
17190
6637001cdb4b
Adjusted for the change of MAX_CHARSET.
Kenichi Handa <handa@m17n.org>
parents:
17137
diff
changeset
|
3768 for (charset = 0; charset <= MAX_CHARSET; charset++) |
18002
a14261786239
(encode_invocation_designation): Use macro
Kenichi Handa <handa@m17n.org>
parents:
17835
diff
changeset
|
3769 CODING_SPEC_ISO_REQUESTED_DESIGNATION (coding, charset) |
a14261786239
(encode_invocation_designation): Use macro
Kenichi Handa <handa@m17n.org>
parents:
17835
diff
changeset
|
3770 = CODING_SPEC_ISO_NO_REQUESTED_DESIGNATION; |
17052 | 3771 for (i = 0; i < 4; i++) |
3772 { | |
41899
5c01da9c8604
(setup_coding_system, shrink_encoding_region)
Pavel Janík <Pavel@Janik.cz>
parents:
41678
diff
changeset
|
3773 if ((INTEGERP (flags[i]) |
5c01da9c8604
(setup_coding_system, shrink_encoding_region)
Pavel Janík <Pavel@Janik.cz>
parents:
41678
diff
changeset
|
3774 && (charset = XINT (flags[i]), CHARSET_VALID_P (charset))) |
17119
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
3775 || (charset = get_charset_id (flags[i])) >= 0) |
17052 | 3776 { |
3777 CODING_SPEC_ISO_INITIAL_DESIGNATION (coding, i) = charset; | |
3778 CODING_SPEC_ISO_REQUESTED_DESIGNATION (coding, charset) = i; | |
3779 } | |
3780 else if (EQ (flags[i], Qt)) | |
3781 { | |
3782 CODING_SPEC_ISO_INITIAL_DESIGNATION (coding, i) = -1; | |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3783 reg_bits |= 1 << i; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3784 coding->flags |= CODING_FLAG_ISO_DESIGNATION; |
17052 | 3785 } |
3786 else if (CONSP (flags[i])) | |
3787 { | |
22954
928b337d953b
Avoid using initializers for Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents:
22874
diff
changeset
|
3788 Lisp_Object tail; |
928b337d953b
Avoid using initializers for Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents:
22874
diff
changeset
|
3789 tail = flags[i]; |
17052 | 3790 |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3791 coding->flags |= CODING_FLAG_ISO_DESIGNATION; |
41899
5c01da9c8604
(setup_coding_system, shrink_encoding_region)
Pavel Janík <Pavel@Janik.cz>
parents:
41678
diff
changeset
|
3792 if ((INTEGERP (XCAR (tail)) |
5c01da9c8604
(setup_coding_system, shrink_encoding_region)
Pavel Janík <Pavel@Janik.cz>
parents:
41678
diff
changeset
|
3793 && (charset = XINT (XCAR (tail)), |
5c01da9c8604
(setup_coding_system, shrink_encoding_region)
Pavel Janík <Pavel@Janik.cz>
parents:
41678
diff
changeset
|
3794 CHARSET_VALID_P (charset))) |
25662
0a7261c1d487
Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25370
diff
changeset
|
3795 || (charset = get_charset_id (XCAR (tail))) >= 0) |
17052 | 3796 { |
3797 CODING_SPEC_ISO_INITIAL_DESIGNATION (coding, i) = charset; | |
3798 CODING_SPEC_ISO_REQUESTED_DESIGNATION (coding, charset) =i; | |
3799 } | |
3800 else | |
3801 CODING_SPEC_ISO_INITIAL_DESIGNATION (coding, i) = -1; | |
25662
0a7261c1d487
Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25370
diff
changeset
|
3802 tail = XCDR (tail); |
17052 | 3803 while (CONSP (tail)) |
3804 { | |
41899
5c01da9c8604
(setup_coding_system, shrink_encoding_region)
Pavel Janík <Pavel@Janik.cz>
parents:
41678
diff
changeset
|
3805 if ((INTEGERP (XCAR (tail)) |
5c01da9c8604
(setup_coding_system, shrink_encoding_region)
Pavel Janík <Pavel@Janik.cz>
parents:
41678
diff
changeset
|
3806 && (charset = XINT (XCAR (tail)), |
5c01da9c8604
(setup_coding_system, shrink_encoding_region)
Pavel Janík <Pavel@Janik.cz>
parents:
41678
diff
changeset
|
3807 CHARSET_VALID_P (charset))) |
25662
0a7261c1d487
Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25370
diff
changeset
|
3808 || (charset = get_charset_id (XCAR (tail))) >= 0) |
20150
402b6e5f4b58
(encode_designation_at_bol): Fix bug of finding graphic
Kenichi Handa <handa@m17n.org>
parents:
20105
diff
changeset
|
3809 CODING_SPEC_ISO_REQUESTED_DESIGNATION (coding, charset) |
402b6e5f4b58
(encode_designation_at_bol): Fix bug of finding graphic
Kenichi Handa <handa@m17n.org>
parents:
20105
diff
changeset
|
3810 = i; |
25662
0a7261c1d487
Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25370
diff
changeset
|
3811 else if (EQ (XCAR (tail), Qt)) |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3812 reg_bits |= 1 << i; |
25662
0a7261c1d487
Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25370
diff
changeset
|
3813 tail = XCDR (tail); |
17052 | 3814 } |
3815 } | |
3816 else | |
3817 CODING_SPEC_ISO_INITIAL_DESIGNATION (coding, i) = -1; | |
42104
d69c2368e549
(DECODE_COMPOSITION_END): Fixed a typo in the last
Sam Steingold <sds@gnu.org>
parents:
42103
diff
changeset
|
3818 |
17052 | 3819 CODING_SPEC_ISO_DESIGNATION (coding, i) |
3820 = CODING_SPEC_ISO_INITIAL_DESIGNATION (coding, i); | |
3821 } | |
3822 | |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3823 if (reg_bits && ! (coding->flags & CODING_FLAG_ISO_LOCKING_SHIFT)) |
17052 | 3824 { |
3825 /* REG 1 can be used only by locking shift in 7-bit env. */ | |
3826 if (coding->flags & CODING_FLAG_ISO_SEVEN_BITS) | |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3827 reg_bits &= ~2; |
17052 | 3828 if (! (coding->flags & CODING_FLAG_ISO_SINGLE_SHIFT)) |
3829 /* Without any shifting, only REG 0 and 1 can be used. */ | |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3830 reg_bits &= 3; |
17052 | 3831 } |
3832 | |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3833 if (reg_bits) |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3834 for (charset = 0; charset <= MAX_CHARSET; charset++) |
19285
af3d00fde172
(Fset_terminal_coding_system_internal): Set
Kenichi Handa <handa@m17n.org>
parents:
19280
diff
changeset
|
3835 { |
38473
f5a9d9707da5
* coding.c (setup_coding_system): Don't do any designation based on reg_bits if
Ken Raeburn <raeburn@raeburn.org>
parents:
38391
diff
changeset
|
3836 if (CHARSET_DEFINED_P (charset) |
30263
b8083f5b4b7c
(setup_coding_system): Don't override the explicitly specified
Kenichi Handa <handa@m17n.org>
parents:
30204
diff
changeset
|
3837 && (CODING_SPEC_ISO_REQUESTED_DESIGNATION (coding, charset) |
b8083f5b4b7c
(setup_coding_system): Don't override the explicitly specified
Kenichi Handa <handa@m17n.org>
parents:
30204
diff
changeset
|
3838 == CODING_SPEC_ISO_NO_REQUESTED_DESIGNATION)) |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3839 { |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3840 /* There exist some default graphic registers to be |
30263
b8083f5b4b7c
(setup_coding_system): Don't override the explicitly specified
Kenichi Handa <handa@m17n.org>
parents:
30204
diff
changeset
|
3841 used by CHARSET. */ |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3842 |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3843 /* We had better avoid designating a charset of |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3844 CHARS96 to REG 0 as far as possible. */ |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3845 if (CHARSET_CHARS (charset) == 96) |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3846 CODING_SPEC_ISO_REQUESTED_DESIGNATION (coding, charset) |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3847 = (reg_bits & 2 |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3848 ? 1 : (reg_bits & 4 ? 2 : (reg_bits & 8 ? 3 : 0))); |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3849 else |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3850 CODING_SPEC_ISO_REQUESTED_DESIGNATION (coding, charset) |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3851 = (reg_bits & 1 |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3852 ? 0 : (reg_bits & 2 ? 1 : (reg_bits & 4 ? 2 : 3))); |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3853 } |
19285
af3d00fde172
(Fset_terminal_coding_system_internal): Set
Kenichi Handa <handa@m17n.org>
parents:
19280
diff
changeset
|
3854 } |
17052 | 3855 } |
20227
71008f909642
(setup_coding_system): Initialize common_flags member
Kenichi Handa <handa@m17n.org>
parents:
20150
diff
changeset
|
3856 coding->common_flags |= CODING_REQUIRE_FLUSHING_MASK; |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3857 coding->spec.iso2022.last_invalid_designation_register = -1; |
17052 | 3858 break; |
3859 | |
3860 case 3: | |
3861 coding->type = coding_type_big5; | |
20227
71008f909642
(setup_coding_system): Initialize common_flags member
Kenichi Handa <handa@m17n.org>
parents:
20150
diff
changeset
|
3862 coding->common_flags |
71008f909642
(setup_coding_system): Initialize common_flags member
Kenichi Handa <handa@m17n.org>
parents:
20150
diff
changeset
|
3863 |= CODING_REQUIRE_DECODING_MASK | CODING_REQUIRE_ENCODING_MASK; |
17052 | 3864 coding->flags |
20105
c017642863c2
(Qcoding_system_spec): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
19824
diff
changeset
|
3865 = (NILP (XVECTOR (coding_spec)->contents[4]) |
17052 | 3866 ? CODING_FLAG_BIG5_HKU |
3867 : CODING_FLAG_BIG5_ETEN); | |
3868 break; | |
3869 | |
3870 case 4: | |
3871 coding->type = coding_type_ccl; | |
20227
71008f909642
(setup_coding_system): Initialize common_flags member
Kenichi Handa <handa@m17n.org>
parents:
20150
diff
changeset
|
3872 coding->common_flags |
71008f909642
(setup_coding_system): Initialize common_flags member
Kenichi Handa <handa@m17n.org>
parents:
20150
diff
changeset
|
3873 |= CODING_REQUIRE_DECODING_MASK | CODING_REQUIRE_ENCODING_MASK; |
17052 | 3874 { |
22954
928b337d953b
Avoid using initializers for Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents:
22874
diff
changeset
|
3875 val = XVECTOR (coding_spec)->contents[4]; |
25067
23910b121ced
(setup_coding_system): Get compiled CCL code by just
Kenichi Handa <handa@m17n.org>
parents:
24870
diff
changeset
|
3876 if (! CONSP (val) |
23910b121ced
(setup_coding_system): Get compiled CCL code by just
Kenichi Handa <handa@m17n.org>
parents:
24870
diff
changeset
|
3877 || setup_ccl_program (&(coding->spec.ccl.decoder), |
25662
0a7261c1d487
Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25370
diff
changeset
|
3878 XCAR (val)) < 0 |
25067
23910b121ced
(setup_coding_system): Get compiled CCL code by just
Kenichi Handa <handa@m17n.org>
parents:
24870
diff
changeset
|
3879 || setup_ccl_program (&(coding->spec.ccl.encoder), |
25662
0a7261c1d487
Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25370
diff
changeset
|
3880 XCDR (val)) < 0) |
17052 | 3881 goto label_invalid_coding_system; |
22874
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
3882 |
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
3883 bzero (coding->spec.ccl.valid_codes, 256); |
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
3884 val = Fplist_get (plist, Qvalid_codes); |
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
3885 if (CONSP (val)) |
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
3886 { |
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
3887 Lisp_Object this; |
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
3888 |
25662
0a7261c1d487
Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25370
diff
changeset
|
3889 for (; CONSP (val); val = XCDR (val)) |
22874
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
3890 { |
25662
0a7261c1d487
Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25370
diff
changeset
|
3891 this = XCAR (val); |
22874
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
3892 if (INTEGERP (this) |
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
3893 && XINT (this) >= 0 && XINT (this) < 256) |
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
3894 coding->spec.ccl.valid_codes[XINT (this)] = 1; |
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
3895 else if (CONSP (this) |
25662
0a7261c1d487
Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25370
diff
changeset
|
3896 && INTEGERP (XCAR (this)) |
0a7261c1d487
Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25370
diff
changeset
|
3897 && INTEGERP (XCDR (this))) |
22874
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
3898 { |
25662
0a7261c1d487
Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25370
diff
changeset
|
3899 int start = XINT (XCAR (this)); |
0a7261c1d487
Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25370
diff
changeset
|
3900 int end = XINT (XCDR (this)); |
22874
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
3901 |
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
3902 if (start >= 0 && start <= end && end < 256) |
23514
7bad909cd6f1
(setup_coding_system): Fix setting up
Kenichi Handa <handa@m17n.org>
parents:
23475
diff
changeset
|
3903 while (start <= end) |
22874
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
3904 coding->spec.ccl.valid_codes[start++] = 1; |
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
3905 } |
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
3906 } |
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
3907 } |
17052 | 3908 } |
20227
71008f909642
(setup_coding_system): Initialize common_flags member
Kenichi Handa <handa@m17n.org>
parents:
20150
diff
changeset
|
3909 coding->common_flags |= CODING_REQUIRE_FLUSHING_MASK; |
29725
2bc397e9b09a
(setup_coding_system) <4>: Reset member `cr_carryover'.
Kenichi Handa <handa@m17n.org>
parents:
29663
diff
changeset
|
3910 coding->spec.ccl.cr_carryover = 0; |
34892
3868f2e7355a
(setup_coding_system): Initialize
Kenichi Handa <handa@m17n.org>
parents:
34888
diff
changeset
|
3911 coding->spec.ccl.eight_bit_carryover[0] = 0; |
17052 | 3912 break; |
3913 | |
19612
783efd6c7c1e
(Qno_conversion, Qundecided): New variables.
Kenichi Handa <handa@m17n.org>
parents:
19546
diff
changeset
|
3914 case 5: |
783efd6c7c1e
(Qno_conversion, Qundecided): New variables.
Kenichi Handa <handa@m17n.org>
parents:
19546
diff
changeset
|
3915 coding->type = coding_type_raw_text; |
783efd6c7c1e
(Qno_conversion, Qundecided): New variables.
Kenichi Handa <handa@m17n.org>
parents:
19546
diff
changeset
|
3916 break; |
783efd6c7c1e
(Qno_conversion, Qundecided): New variables.
Kenichi Handa <handa@m17n.org>
parents:
19546
diff
changeset
|
3917 |
17052 | 3918 default: |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3919 goto label_invalid_coding_system; |
17052 | 3920 } |
3921 return 0; | |
3922 | |
3923 label_invalid_coding_system: | |
3924 coding->type = coding_type_no_conversion; | |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3925 coding->category_idx = CODING_CATEGORY_IDX_BINARY; |
20227
71008f909642
(setup_coding_system): Initialize common_flags member
Kenichi Handa <handa@m17n.org>
parents:
20150
diff
changeset
|
3926 coding->common_flags = 0; |
70520
b6740a317343
(setup_coding_system): For invalid coding-system, set
Kenichi Handa <handa@m17n.org>
parents:
69995
diff
changeset
|
3927 coding->eol_type = CODING_EOL_UNDECIDED; |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3928 coding->pre_write_conversion = coding->post_read_conversion = Qnil; |
69995
d4a5619e5025
(setup_coding_system): If eol-type is not yet decided
Kenichi Handa <handa@m17n.org>
parents:
69993
diff
changeset
|
3929 return NILP (coding_system) ? 0 : -1; |
17052 | 3930 } |
3931 | |
26847 | 3932 /* Free memory blocks allocated for storing composition information. */ |
3933 | |
3934 void | |
3935 coding_free_composition_data (coding) | |
3936 struct coding_system *coding; | |
3937 { | |
3938 struct composition_data *cmp_data = coding->cmp_data, *next; | |
3939 | |
3940 if (!cmp_data) | |
3941 return; | |
3942 /* Memory blocks are chained. At first, rewind to the first, then, | |
3943 free blocks one by one. */ | |
3944 while (cmp_data->prev) | |
3945 cmp_data = cmp_data->prev; | |
3946 while (cmp_data) | |
3947 { | |
3948 next = cmp_data->next; | |
3949 xfree (cmp_data); | |
3950 cmp_data = next; | |
3951 } | |
3952 coding->cmp_data = NULL; | |
3953 } | |
3954 | |
3955 /* Set `char_offset' member of all memory blocks pointed by | |
3956 coding->cmp_data to POS. */ | |
3957 | |
3958 void | |
3959 coding_adjust_composition_offset (coding, pos) | |
3960 struct coding_system *coding; | |
3961 int pos; | |
3962 { | |
3963 struct composition_data *cmp_data; | |
3964 | |
3965 for (cmp_data = coding->cmp_data; cmp_data; cmp_data = cmp_data->next) | |
3966 cmp_data->char_offset = pos; | |
3967 } | |
3968 | |
22616
c493ce6a31e4
(setup_raw_text_coding_system): New function.
Kenichi Handa <handa@m17n.org>
parents:
22529
diff
changeset
|
3969 /* Setup raw-text or one of its subsidiaries in the structure |
c493ce6a31e4
(setup_raw_text_coding_system): New function.
Kenichi Handa <handa@m17n.org>
parents:
22529
diff
changeset
|
3970 coding_system CODING according to the already setup value eol_type |
c493ce6a31e4
(setup_raw_text_coding_system): New function.
Kenichi Handa <handa@m17n.org>
parents:
22529
diff
changeset
|
3971 in CODING. CODING should be setup for some coding system in |
c493ce6a31e4
(setup_raw_text_coding_system): New function.
Kenichi Handa <handa@m17n.org>
parents:
22529
diff
changeset
|
3972 advance. */ |
c493ce6a31e4
(setup_raw_text_coding_system): New function.
Kenichi Handa <handa@m17n.org>
parents:
22529
diff
changeset
|
3973 |
c493ce6a31e4
(setup_raw_text_coding_system): New function.
Kenichi Handa <handa@m17n.org>
parents:
22529
diff
changeset
|
3974 void |
c493ce6a31e4
(setup_raw_text_coding_system): New function.
Kenichi Handa <handa@m17n.org>
parents:
22529
diff
changeset
|
3975 setup_raw_text_coding_system (coding) |
c493ce6a31e4
(setup_raw_text_coding_system): New function.
Kenichi Handa <handa@m17n.org>
parents:
22529
diff
changeset
|
3976 struct coding_system *coding; |
c493ce6a31e4
(setup_raw_text_coding_system): New function.
Kenichi Handa <handa@m17n.org>
parents:
22529
diff
changeset
|
3977 { |
c493ce6a31e4
(setup_raw_text_coding_system): New function.
Kenichi Handa <handa@m17n.org>
parents:
22529
diff
changeset
|
3978 if (coding->type != coding_type_raw_text) |
c493ce6a31e4
(setup_raw_text_coding_system): New function.
Kenichi Handa <handa@m17n.org>
parents:
22529
diff
changeset
|
3979 { |
c493ce6a31e4
(setup_raw_text_coding_system): New function.
Kenichi Handa <handa@m17n.org>
parents:
22529
diff
changeset
|
3980 coding->symbol = Qraw_text; |
c493ce6a31e4
(setup_raw_text_coding_system): New function.
Kenichi Handa <handa@m17n.org>
parents:
22529
diff
changeset
|
3981 coding->type = coding_type_raw_text; |
c493ce6a31e4
(setup_raw_text_coding_system): New function.
Kenichi Handa <handa@m17n.org>
parents:
22529
diff
changeset
|
3982 if (coding->eol_type != CODING_EOL_UNDECIDED) |
c493ce6a31e4
(setup_raw_text_coding_system): New function.
Kenichi Handa <handa@m17n.org>
parents:
22529
diff
changeset
|
3983 { |
22954
928b337d953b
Avoid using initializers for Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents:
22874
diff
changeset
|
3984 Lisp_Object subsidiaries; |
928b337d953b
Avoid using initializers for Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents:
22874
diff
changeset
|
3985 subsidiaries = Fget (Qraw_text, Qeol_type); |
22616
c493ce6a31e4
(setup_raw_text_coding_system): New function.
Kenichi Handa <handa@m17n.org>
parents:
22529
diff
changeset
|
3986 |
c493ce6a31e4
(setup_raw_text_coding_system): New function.
Kenichi Handa <handa@m17n.org>
parents:
22529
diff
changeset
|
3987 if (VECTORP (subsidiaries) |
c493ce6a31e4
(setup_raw_text_coding_system): New function.
Kenichi Handa <handa@m17n.org>
parents:
22529
diff
changeset
|
3988 && XVECTOR (subsidiaries)->size == 3) |
c493ce6a31e4
(setup_raw_text_coding_system): New function.
Kenichi Handa <handa@m17n.org>
parents:
22529
diff
changeset
|
3989 coding->symbol |
c493ce6a31e4
(setup_raw_text_coding_system): New function.
Kenichi Handa <handa@m17n.org>
parents:
22529
diff
changeset
|
3990 = XVECTOR (subsidiaries)->contents[coding->eol_type]; |
c493ce6a31e4
(setup_raw_text_coding_system): New function.
Kenichi Handa <handa@m17n.org>
parents:
22529
diff
changeset
|
3991 } |
24667 | 3992 setup_coding_system (coding->symbol, coding); |
22616
c493ce6a31e4
(setup_raw_text_coding_system): New function.
Kenichi Handa <handa@m17n.org>
parents:
22529
diff
changeset
|
3993 } |
c493ce6a31e4
(setup_raw_text_coding_system): New function.
Kenichi Handa <handa@m17n.org>
parents:
22529
diff
changeset
|
3994 return; |
c493ce6a31e4
(setup_raw_text_coding_system): New function.
Kenichi Handa <handa@m17n.org>
parents:
22529
diff
changeset
|
3995 } |
c493ce6a31e4
(setup_raw_text_coding_system): New function.
Kenichi Handa <handa@m17n.org>
parents:
22529
diff
changeset
|
3996 |
17052 | 3997 /* Emacs has a mechanism to automatically detect a coding system if it |
3998 is one of Emacs' internal format, ISO2022, SJIS, and BIG5. But, | |
3999 it's impossible to distinguish some coding systems accurately | |
4000 because they use the same range of codes. So, at first, coding | |
4001 systems are categorized into 7, those are: | |
4002 | |
17835
f36ffb6f1208
Name change through the code:
Kenichi Handa <handa@m17n.org>
parents:
17725
diff
changeset
|
4003 o coding-category-emacs-mule |
17052 | 4004 |
4005 The category for a coding system which has the same code range | |
4006 as Emacs' internal format. Assigned the coding-system (Lisp | |
17835
f36ffb6f1208
Name change through the code:
Kenichi Handa <handa@m17n.org>
parents:
17725
diff
changeset
|
4007 symbol) `emacs-mule' by default. |
17052 | 4008 |
4009 o coding-category-sjis | |
4010 | |
4011 The category for a coding system which has the same code range | |
4012 as SJIS. Assigned the coding-system (Lisp | |
18787
954e6be0a757
(detect_coding_iso2022): Distinguish coding-category-iso-7-else and
Kenichi Handa <handa@m17n.org>
parents:
18766
diff
changeset
|
4013 symbol) `japanese-shift-jis' by default. |
17052 | 4014 |
4015 o coding-category-iso-7 | |
4016 | |
4017 The category for a coding system which has the same code range | |
18787
954e6be0a757
(detect_coding_iso2022): Distinguish coding-category-iso-7-else and
Kenichi Handa <handa@m17n.org>
parents:
18766
diff
changeset
|
4018 as ISO2022 of 7-bit environment. This doesn't use any locking |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4019 shift and single shift functions. This can encode/decode all |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4020 charsets. Assigned the coding-system (Lisp symbol) |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4021 `iso-2022-7bit' by default. |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4022 |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4023 o coding-category-iso-7-tight |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4024 |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4025 Same as coding-category-iso-7 except that this can |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4026 encode/decode only the specified charsets. |
17052 | 4027 |
4028 o coding-category-iso-8-1 | |
4029 | |
4030 The category for a coding system which has the same code range | |
4031 as ISO2022 of 8-bit environment and graphic plane 1 used only | |
18787
954e6be0a757
(detect_coding_iso2022): Distinguish coding-category-iso-7-else and
Kenichi Handa <handa@m17n.org>
parents:
18766
diff
changeset
|
4032 for DIMENSION1 charset. This doesn't use any locking shift |
954e6be0a757
(detect_coding_iso2022): Distinguish coding-category-iso-7-else and
Kenichi Handa <handa@m17n.org>
parents:
18766
diff
changeset
|
4033 and single shift functions. Assigned the coding-system (Lisp |
954e6be0a757
(detect_coding_iso2022): Distinguish coding-category-iso-7-else and
Kenichi Handa <handa@m17n.org>
parents:
18766
diff
changeset
|
4034 symbol) `iso-latin-1' by default. |
17052 | 4035 |
4036 o coding-category-iso-8-2 | |
4037 | |
4038 The category for a coding system which has the same code range | |
4039 as ISO2022 of 8-bit environment and graphic plane 1 used only | |
18787
954e6be0a757
(detect_coding_iso2022): Distinguish coding-category-iso-7-else and
Kenichi Handa <handa@m17n.org>
parents:
18766
diff
changeset
|
4040 for DIMENSION2 charset. This doesn't use any locking shift |
954e6be0a757
(detect_coding_iso2022): Distinguish coding-category-iso-7-else and
Kenichi Handa <handa@m17n.org>
parents:
18766
diff
changeset
|
4041 and single shift functions. Assigned the coding-system (Lisp |
954e6be0a757
(detect_coding_iso2022): Distinguish coding-category-iso-7-else and
Kenichi Handa <handa@m17n.org>
parents:
18766
diff
changeset
|
4042 symbol) `japanese-iso-8bit' by default. |
954e6be0a757
(detect_coding_iso2022): Distinguish coding-category-iso-7-else and
Kenichi Handa <handa@m17n.org>
parents:
18766
diff
changeset
|
4043 |
954e6be0a757
(detect_coding_iso2022): Distinguish coding-category-iso-7-else and
Kenichi Handa <handa@m17n.org>
parents:
18766
diff
changeset
|
4044 o coding-category-iso-7-else |
17052 | 4045 |
4046 The category for a coding system which has the same code range | |
36087 | 4047 as ISO2022 of 7-bit environment but uses locking shift or |
18787
954e6be0a757
(detect_coding_iso2022): Distinguish coding-category-iso-7-else and
Kenichi Handa <handa@m17n.org>
parents:
18766
diff
changeset
|
4048 single shift functions. Assigned the coding-system (Lisp |
954e6be0a757
(detect_coding_iso2022): Distinguish coding-category-iso-7-else and
Kenichi Handa <handa@m17n.org>
parents:
18766
diff
changeset
|
4049 symbol) `iso-2022-7bit-lock' by default. |
954e6be0a757
(detect_coding_iso2022): Distinguish coding-category-iso-7-else and
Kenichi Handa <handa@m17n.org>
parents:
18766
diff
changeset
|
4050 |
954e6be0a757
(detect_coding_iso2022): Distinguish coding-category-iso-7-else and
Kenichi Handa <handa@m17n.org>
parents:
18766
diff
changeset
|
4051 o coding-category-iso-8-else |
954e6be0a757
(detect_coding_iso2022): Distinguish coding-category-iso-7-else and
Kenichi Handa <handa@m17n.org>
parents:
18766
diff
changeset
|
4052 |
954e6be0a757
(detect_coding_iso2022): Distinguish coding-category-iso-7-else and
Kenichi Handa <handa@m17n.org>
parents:
18766
diff
changeset
|
4053 The category for a coding system which has the same code range |
36087 | 4054 as ISO2022 of 8-bit environment but uses locking shift or |
18787
954e6be0a757
(detect_coding_iso2022): Distinguish coding-category-iso-7-else and
Kenichi Handa <handa@m17n.org>
parents:
18766
diff
changeset
|
4055 single shift functions. Assigned the coding-system (Lisp |
954e6be0a757
(detect_coding_iso2022): Distinguish coding-category-iso-7-else and
Kenichi Handa <handa@m17n.org>
parents:
18766
diff
changeset
|
4056 symbol) `iso-2022-8bit-ss2' by default. |
17052 | 4057 |
4058 o coding-category-big5 | |
4059 | |
4060 The category for a coding system which has the same code range | |
4061 as BIG5. Assigned the coding-system (Lisp symbol) | |
17119
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
4062 `cn-big5' by default. |
17052 | 4063 |
28022
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
4064 o coding-category-utf-8 |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
4065 |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
4066 The category for a coding system which has the same code range |
54303 | 4067 as UTF-8 (cf. RFC3629). Assigned the coding-system (Lisp |
28022
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
4068 symbol) `utf-8' by default. |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
4069 |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
4070 o coding-category-utf-16-be |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
4071 |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
4072 The category for a coding system in which a text has an |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
4073 Unicode signature (cf. Unicode Standard) in the order of BIG |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
4074 endian at the head. Assigned the coding-system (Lisp symbol) |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
4075 `utf-16-be' by default. |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
4076 |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
4077 o coding-category-utf-16-le |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
4078 |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
4079 The category for a coding system in which a text has an |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
4080 Unicode signature (cf. Unicode Standard) in the order of |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
4081 LITTLE endian at the head. Assigned the coding-system (Lisp |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
4082 symbol) `utf-16-le' by default. |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
4083 |
22874
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
4084 o coding-category-ccl |
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
4085 |
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
4086 The category for a coding system of which encoder/decoder is |
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
4087 written in CCL programs. The default value is nil, i.e., no |
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
4088 coding system is assigned. |
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
4089 |
17052 | 4090 o coding-category-binary |
4091 | |
4092 The category for a coding system not categorized in any of the | |
4093 above. Assigned the coding-system (Lisp symbol) | |
17119
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
4094 `no-conversion' by default. |
17052 | 4095 |
4096 Each of them is a Lisp symbol and the value is an actual | |
35053 | 4097 `coding-system' (this is also a Lisp symbol) assigned by a user. |
17052 | 4098 What Emacs does actually is to detect a category of coding system. |
4099 Then, it uses a `coding-system' assigned to it. If Emacs can't | |
35053 | 4100 decide a single possible category, it selects a category of the |
17052 | 4101 highest priority. Priorities of categories are also specified by a |
4102 user in a Lisp variable `coding-category-list'. | |
4103 | |
4104 */ | |
4105 | |
22226
557fac086b1b
(ascii_skip_code): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22186
diff
changeset
|
4106 static |
557fac086b1b
(ascii_skip_code): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22186
diff
changeset
|
4107 int ascii_skip_code[256]; |
557fac086b1b
(ascii_skip_code): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22186
diff
changeset
|
4108 |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4109 /* Detect how a text of length SRC_BYTES pointed by SOURCE is encoded. |
17052 | 4110 If it detects possible coding systems, return an integer in which |
4111 appropriate flag bits are set. Flag bits are defined by macros | |
28022
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
4112 CODING_CATEGORY_MASK_XXX in `coding.h'. If PRIORITIES is non-NULL, |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
4113 it should point the table `coding_priorities'. In that case, only |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
4114 the flag bit for a coding system of the highest priority is set in |
34531
37f85e931855
(ONE_MORE_BYTE_CHECK_MULTIBYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34197
diff
changeset
|
4115 the returned value. If MULTIBYTEP is nonzero, 8-bit codes of the |
37f85e931855
(ONE_MORE_BYTE_CHECK_MULTIBYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34197
diff
changeset
|
4116 range 0x80..0x9F are in multibyte form. |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4117 |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4118 How many ASCII characters are at the head is returned as *SKIP. */ |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4119 |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4120 static int |
34531
37f85e931855
(ONE_MORE_BYTE_CHECK_MULTIBYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34197
diff
changeset
|
4121 detect_coding_mask (source, src_bytes, priorities, skip, multibytep) |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4122 unsigned char *source; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4123 int src_bytes, *priorities, *skip; |
34531
37f85e931855
(ONE_MORE_BYTE_CHECK_MULTIBYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34197
diff
changeset
|
4124 int multibytep; |
17052 | 4125 { |
4126 register unsigned char c; | |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4127 unsigned char *src = source, *src_end = source + src_bytes; |
28022
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
4128 unsigned int mask, utf16_examined_p, iso2022_examined_p; |
34988
8cd5e6ad71a2
(detect_coding_iso2022, setup_coding_system): Remove
Eli Zaretskii <eliz@gnu.org>
parents:
34892
diff
changeset
|
4129 int i; |
17052 | 4130 |
4131 /* At first, skip all ASCII characters and control characters except | |
4132 for three ISO2022 specific control characters. */ | |
22226
557fac086b1b
(ascii_skip_code): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22186
diff
changeset
|
4133 ascii_skip_code[ISO_CODE_SO] = 0; |
557fac086b1b
(ascii_skip_code): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22186
diff
changeset
|
4134 ascii_skip_code[ISO_CODE_SI] = 0; |
557fac086b1b
(ascii_skip_code): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22186
diff
changeset
|
4135 ascii_skip_code[ISO_CODE_ESC] = 0; |
557fac086b1b
(ascii_skip_code): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22186
diff
changeset
|
4136 |
17320
9d15bec5f47e
(detect_coding_iso2022, detect_coding_mask): Ignore
Kenichi Handa <handa@m17n.org>
parents:
17304
diff
changeset
|
4137 label_loop_detect_coding: |
22226
557fac086b1b
(ascii_skip_code): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22186
diff
changeset
|
4138 while (src < src_end && ascii_skip_code[*src]) src++; |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4139 *skip = src - source; |
17052 | 4140 |
4141 if (src >= src_end) | |
4142 /* We found nothing other than ASCII. There's nothing to do. */ | |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4143 return 0; |
17052 | 4144 |
22329
4786b00d2973
(detect_coding_mask): Initilize local variable C.
Kenichi Handa <handa@m17n.org>
parents:
22254
diff
changeset
|
4145 c = *src; |
17052 | 4146 /* The text seems to be encoded in some multilingual coding system. |
4147 Now, try to find in which coding system the text is encoded. */ | |
4148 if (c < 0x80) | |
17320
9d15bec5f47e
(detect_coding_iso2022, detect_coding_mask): Ignore
Kenichi Handa <handa@m17n.org>
parents:
17304
diff
changeset
|
4149 { |
9d15bec5f47e
(detect_coding_iso2022, detect_coding_mask): Ignore
Kenichi Handa <handa@m17n.org>
parents:
17304
diff
changeset
|
4150 /* i.e. (c == ISO_CODE_ESC || c == ISO_CODE_SI || c == ISO_CODE_SO) */ |
9d15bec5f47e
(detect_coding_iso2022, detect_coding_mask): Ignore
Kenichi Handa <handa@m17n.org>
parents:
17304
diff
changeset
|
4151 /* C is an ISO2022 specific control code of C0. */ |
34531
37f85e931855
(ONE_MORE_BYTE_CHECK_MULTIBYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34197
diff
changeset
|
4152 mask = detect_coding_iso2022 (src, src_end, multibytep); |
19743
b228f82192d5
(detect_coding_mask): Re-work previous change.
Richard M. Stallman <rms@gnu.org>
parents:
19688
diff
changeset
|
4153 if (mask == 0) |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4154 { |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4155 /* No valid ISO2022 code follows C. Try again. */ |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4156 src++; |
22226
557fac086b1b
(ascii_skip_code): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22186
diff
changeset
|
4157 if (c == ISO_CODE_ESC) |
557fac086b1b
(ascii_skip_code): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22186
diff
changeset
|
4158 ascii_skip_code[ISO_CODE_ESC] = 1; |
557fac086b1b
(ascii_skip_code): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22186
diff
changeset
|
4159 else |
557fac086b1b
(ascii_skip_code): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22186
diff
changeset
|
4160 ascii_skip_code[ISO_CODE_SO] = ascii_skip_code[ISO_CODE_SI] = 1; |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4161 goto label_loop_detect_coding; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4162 } |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4163 if (priorities) |
28022
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
4164 { |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
4165 for (i = 0; i < CODING_CATEGORY_IDX_MAX; i++) |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
4166 { |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
4167 if (mask & priorities[i]) |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
4168 return priorities[i]; |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
4169 } |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
4170 return CODING_CATEGORY_MASK_RAW_TEXT; |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
4171 } |
19280
e755044718ee
(ENCODE_ISO_CHARACTER_DIMENSION1): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
19193
diff
changeset
|
4172 } |
17052 | 4173 else |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4174 { |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4175 int try; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4176 |
34531
37f85e931855
(ONE_MORE_BYTE_CHECK_MULTIBYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34197
diff
changeset
|
4177 if (multibytep && c == LEADING_CODE_8_BIT_CONTROL) |
36649
5dc88f9ab0ef
(detect_coding_mask): Fix the incorrect handling of arg MULTIBYTEP.
Kenichi Handa <handa@m17n.org>
parents:
36647
diff
changeset
|
4178 c = src[1] - 0x20; |
34531
37f85e931855
(ONE_MORE_BYTE_CHECK_MULTIBYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34197
diff
changeset
|
4179 |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4180 if (c < 0xA0) |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4181 { |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4182 /* C is the first byte of SJIS character code, |
28022
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
4183 or a leading-code of Emacs' internal format (emacs-mule), |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
4184 or the first byte of UTF-16. */ |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
4185 try = (CODING_CATEGORY_MASK_SJIS |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
4186 | CODING_CATEGORY_MASK_EMACS_MULE |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
4187 | CODING_CATEGORY_MASK_UTF_16_BE |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
4188 | CODING_CATEGORY_MASK_UTF_16_LE); |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4189 |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4190 /* Or, if C is a special latin extra code, |
42104
d69c2368e549
(DECODE_COMPOSITION_END): Fixed a typo in the last
Sam Steingold <sds@gnu.org>
parents:
42103
diff
changeset
|
4191 or is an ISO2022 specific control code of C1 (SS2 or SS3), |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4192 or is an ISO2022 control-sequence-introducer (CSI), |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4193 we should also consider the possibility of ISO2022 codings. */ |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4194 if ((VECTORP (Vlatin_extra_code_table) |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4195 && !NILP (XVECTOR (Vlatin_extra_code_table)->contents[c])) |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4196 || (c == ISO_CODE_SS2 || c == ISO_CODE_SS3) |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4197 || (c == ISO_CODE_CSI |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4198 && (src < src_end |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4199 && (*src == ']' |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4200 || ((*src == '0' || *src == '1' || *src == '2') |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4201 && src + 1 < src_end |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4202 && src[1] == ']'))))) |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4203 try |= (CODING_CATEGORY_MASK_ISO_8_ELSE |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4204 | CODING_CATEGORY_MASK_ISO_8BIT); |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4205 } |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4206 else |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4207 /* C is a character of ISO2022 in graphic plane right, |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4208 or a SJIS's 1-byte character code (i.e. JISX0201), |
28022
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
4209 or the first byte of BIG5's 2-byte code, |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
4210 or the first byte of UTF-8/16. */ |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4211 try = (CODING_CATEGORY_MASK_ISO_8_ELSE |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4212 | CODING_CATEGORY_MASK_ISO_8BIT |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4213 | CODING_CATEGORY_MASK_SJIS |
28022
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
4214 | CODING_CATEGORY_MASK_BIG5 |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
4215 | CODING_CATEGORY_MASK_UTF_8 |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
4216 | CODING_CATEGORY_MASK_UTF_16_BE |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
4217 | CODING_CATEGORY_MASK_UTF_16_LE); |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4218 |
22874
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
4219 /* Or, we may have to consider the possibility of CCL. */ |
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
4220 if (coding_system_table[CODING_CATEGORY_IDX_CCL] |
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
4221 && (coding_system_table[CODING_CATEGORY_IDX_CCL] |
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
4222 ->spec.ccl.valid_codes)[c]) |
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
4223 try |= CODING_CATEGORY_MASK_CCL; |
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
4224 |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4225 mask = 0; |
28022
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
4226 utf16_examined_p = iso2022_examined_p = 0; |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4227 if (priorities) |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4228 { |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4229 for (i = 0; i < CODING_CATEGORY_IDX_MAX; i++) |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4230 { |
28022
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
4231 if (!iso2022_examined_p |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
4232 && (priorities[i] & try & CODING_CATEGORY_MASK_ISO)) |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
4233 { |
41678
5aa97e545399
(syms_of_coding) <Qchar_coding_system>: Give it an
Dave Love <fx@gnu.org>
parents:
41624
diff
changeset
|
4234 mask |= detect_coding_iso2022 (src, src_end, multibytep); |
28022
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
4235 iso2022_examined_p = 1; |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
4236 } |
22009
8a2d45cadd66
(detect_coding_mask): Check also coding-category-binary.
Richard M. Stallman <rms@gnu.org>
parents:
21939
diff
changeset
|
4237 else if (priorities[i] & try & CODING_CATEGORY_MASK_SJIS) |
34531
37f85e931855
(ONE_MORE_BYTE_CHECK_MULTIBYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34197
diff
changeset
|
4238 mask |= detect_coding_sjis (src, src_end, multibytep); |
28022
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
4239 else if (priorities[i] & try & CODING_CATEGORY_MASK_UTF_8) |
34531
37f85e931855
(ONE_MORE_BYTE_CHECK_MULTIBYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34197
diff
changeset
|
4240 mask |= detect_coding_utf_8 (src, src_end, multibytep); |
28022
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
4241 else if (!utf16_examined_p |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
4242 && (priorities[i] & try & |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
4243 CODING_CATEGORY_MASK_UTF_16_BE_LE)) |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
4244 { |
34531
37f85e931855
(ONE_MORE_BYTE_CHECK_MULTIBYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34197
diff
changeset
|
4245 mask |= detect_coding_utf_16 (src, src_end, multibytep); |
28022
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
4246 utf16_examined_p = 1; |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
4247 } |
22009
8a2d45cadd66
(detect_coding_mask): Check also coding-category-binary.
Richard M. Stallman <rms@gnu.org>
parents:
21939
diff
changeset
|
4248 else if (priorities[i] & try & CODING_CATEGORY_MASK_BIG5) |
34531
37f85e931855
(ONE_MORE_BYTE_CHECK_MULTIBYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34197
diff
changeset
|
4249 mask |= detect_coding_big5 (src, src_end, multibytep); |
22009
8a2d45cadd66
(detect_coding_mask): Check also coding-category-binary.
Richard M. Stallman <rms@gnu.org>
parents:
21939
diff
changeset
|
4250 else if (priorities[i] & try & CODING_CATEGORY_MASK_EMACS_MULE) |
34531
37f85e931855
(ONE_MORE_BYTE_CHECK_MULTIBYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34197
diff
changeset
|
4251 mask |= detect_coding_emacs_mule (src, src_end, multibytep); |
23027
0dc823b2335f
(coding_category_name): Fix the order of initial
Kenichi Handa <handa@m17n.org>
parents:
22979
diff
changeset
|
4252 else if (priorities[i] & try & CODING_CATEGORY_MASK_CCL) |
34531
37f85e931855
(ONE_MORE_BYTE_CHECK_MULTIBYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34197
diff
changeset
|
4253 mask |= detect_coding_ccl (src, src_end, multibytep); |
22009
8a2d45cadd66
(detect_coding_mask): Check also coding-category-binary.
Richard M. Stallman <rms@gnu.org>
parents:
21939
diff
changeset
|
4254 else if (priorities[i] & CODING_CATEGORY_MASK_RAW_TEXT) |
28022
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
4255 mask |= CODING_CATEGORY_MASK_RAW_TEXT; |
22009
8a2d45cadd66
(detect_coding_mask): Check also coding-category-binary.
Richard M. Stallman <rms@gnu.org>
parents:
21939
diff
changeset
|
4256 else if (priorities[i] & CODING_CATEGORY_MASK_BINARY) |
28022
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
4257 mask |= CODING_CATEGORY_MASK_BINARY; |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
4258 if (mask & priorities[i]) |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
4259 return priorities[i]; |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4260 } |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4261 return CODING_CATEGORY_MASK_RAW_TEXT; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4262 } |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4263 if (try & CODING_CATEGORY_MASK_ISO) |
34531
37f85e931855
(ONE_MORE_BYTE_CHECK_MULTIBYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34197
diff
changeset
|
4264 mask |= detect_coding_iso2022 (src, src_end, multibytep); |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4265 if (try & CODING_CATEGORY_MASK_SJIS) |
34531
37f85e931855
(ONE_MORE_BYTE_CHECK_MULTIBYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34197
diff
changeset
|
4266 mask |= detect_coding_sjis (src, src_end, multibytep); |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4267 if (try & CODING_CATEGORY_MASK_BIG5) |
34531
37f85e931855
(ONE_MORE_BYTE_CHECK_MULTIBYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34197
diff
changeset
|
4268 mask |= detect_coding_big5 (src, src_end, multibytep); |
28022
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
4269 if (try & CODING_CATEGORY_MASK_UTF_8) |
34531
37f85e931855
(ONE_MORE_BYTE_CHECK_MULTIBYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34197
diff
changeset
|
4270 mask |= detect_coding_utf_8 (src, src_end, multibytep); |
28022
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
4271 if (try & CODING_CATEGORY_MASK_UTF_16_BE_LE) |
34531
37f85e931855
(ONE_MORE_BYTE_CHECK_MULTIBYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34197
diff
changeset
|
4272 mask |= detect_coding_utf_16 (src, src_end, multibytep); |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4273 if (try & CODING_CATEGORY_MASK_EMACS_MULE) |
34531
37f85e931855
(ONE_MORE_BYTE_CHECK_MULTIBYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34197
diff
changeset
|
4274 mask |= detect_coding_emacs_mule (src, src_end, multibytep); |
22874
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
4275 if (try & CODING_CATEGORY_MASK_CCL) |
34531
37f85e931855
(ONE_MORE_BYTE_CHECK_MULTIBYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34197
diff
changeset
|
4276 mask |= detect_coding_ccl (src, src_end, multibytep); |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4277 } |
22009
8a2d45cadd66
(detect_coding_mask): Check also coding-category-binary.
Richard M. Stallman <rms@gnu.org>
parents:
21939
diff
changeset
|
4278 return (mask | CODING_CATEGORY_MASK_RAW_TEXT | CODING_CATEGORY_MASK_BINARY); |
17052 | 4279 } |
4280 | |
4281 /* Detect how a text of length SRC_BYTES pointed by SRC is encoded. | |
4282 The information of the detected coding system is set in CODING. */ | |
4283 | |
4284 void | |
4285 detect_coding (coding, src, src_bytes) | |
4286 struct coding_system *coding; | |
46548
cb1914307488
(encode_eol, detect_coding, detect_eol):
Ken Raeburn <raeburn@raeburn.org>
parents:
46462
diff
changeset
|
4287 const unsigned char *src; |
17052 | 4288 int src_bytes; |
4289 { | |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4290 unsigned int idx; |
34988
8cd5e6ad71a2
(detect_coding_iso2022, setup_coding_system): Remove
Eli Zaretskii <eliz@gnu.org>
parents:
34892
diff
changeset
|
4291 int skip, mask; |
22954
928b337d953b
Avoid using initializers for Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents:
22874
diff
changeset
|
4292 Lisp_Object val; |
928b337d953b
Avoid using initializers for Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents:
22874
diff
changeset
|
4293 |
928b337d953b
Avoid using initializers for Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents:
22874
diff
changeset
|
4294 val = Vcoding_category_list; |
34593
f727eb496b4e
(detect_coding): Call detect_coding_mask with a correct MULTIBYTEP
Kenichi Handa <handa@m17n.org>
parents:
34591
diff
changeset
|
4295 mask = detect_coding_mask (src, src_bytes, coding_priorities, &skip, |
f727eb496b4e
(detect_coding): Call detect_coding_mask with a correct MULTIBYTEP
Kenichi Handa <handa@m17n.org>
parents:
34591
diff
changeset
|
4296 coding->src_multibyte); |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4297 coding->heading_ascii = skip; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4298 |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4299 if (!mask) return; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4300 |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4301 /* We found a single coding system of the highest priority in MASK. */ |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4302 idx = 0; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4303 while (mask && ! (mask & 1)) mask >>= 1, idx++; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4304 if (! mask) |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4305 idx = CODING_CATEGORY_IDX_RAW_TEXT; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4306 |
86228
8e5b337fea59
* coding.c (detect_coding, Fupdate_coding_systems_internal):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
85332
diff
changeset
|
4307 val = find_symbol_value (XVECTOR (Vcoding_category_table)->contents[idx]); |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4308 |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4309 if (coding->eol_type != CODING_EOL_UNDECIDED) |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4310 { |
22954
928b337d953b
Avoid using initializers for Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents:
22874
diff
changeset
|
4311 Lisp_Object tmp; |
928b337d953b
Avoid using initializers for Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents:
22874
diff
changeset
|
4312 |
928b337d953b
Avoid using initializers for Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents:
22874
diff
changeset
|
4313 tmp = Fget (val, Qeol_type); |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4314 if (VECTORP (tmp)) |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4315 val = XVECTOR (tmp)->contents[coding->eol_type]; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4316 } |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4317 |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4318 /* Setup this new coding system while preserving some slots. */ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4319 { |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4320 int src_multibyte = coding->src_multibyte; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4321 int dst_multibyte = coding->dst_multibyte; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4322 |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4323 setup_coding_system (val, coding); |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4324 coding->src_multibyte = src_multibyte; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4325 coding->dst_multibyte = dst_multibyte; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4326 coding->heading_ascii = skip; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4327 } |
17052 | 4328 } |
4329 | |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4330 /* Detect how end-of-line of a text of length SRC_BYTES pointed by |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4331 SOURCE is encoded. Return one of CODING_EOL_LF, CODING_EOL_CRLF, |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4332 CODING_EOL_CR, and CODING_EOL_UNDECIDED. |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4333 |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4334 How many non-eol characters are at the head is returned as *SKIP. */ |
17052 | 4335 |
19173
04ed7c3f5cee
(detect_eol_type): If EOL representation does not
Richard M. Stallman <rms@gnu.org>
parents:
19134
diff
changeset
|
4336 #define MAX_EOL_CHECK_COUNT 3 |
04ed7c3f5cee
(detect_eol_type): If EOL representation does not
Richard M. Stallman <rms@gnu.org>
parents:
19134
diff
changeset
|
4337 |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4338 static int |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4339 detect_eol_type (source, src_bytes, skip) |
84646
922a7e3b7383
(detect_eol_type, detect_eol_type_in_2_octet_form):
Michaël Cadilhac <michael.cadilhac@lrde.org>
parents:
83648
diff
changeset
|
4340 const unsigned char *source; |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4341 int src_bytes, *skip; |
17052 | 4342 { |
84646
922a7e3b7383
(detect_eol_type, detect_eol_type_in_2_octet_form):
Michaël Cadilhac <michael.cadilhac@lrde.org>
parents:
83648
diff
changeset
|
4343 const unsigned char *src = source, *src_end = src + src_bytes; |
17052 | 4344 unsigned char c; |
19173
04ed7c3f5cee
(detect_eol_type): If EOL representation does not
Richard M. Stallman <rms@gnu.org>
parents:
19134
diff
changeset
|
4345 int total = 0; /* How many end-of-lines are found so far. */ |
04ed7c3f5cee
(detect_eol_type): If EOL representation does not
Richard M. Stallman <rms@gnu.org>
parents:
19134
diff
changeset
|
4346 int eol_type = CODING_EOL_UNDECIDED; |
04ed7c3f5cee
(detect_eol_type): If EOL representation does not
Richard M. Stallman <rms@gnu.org>
parents:
19134
diff
changeset
|
4347 int this_eol_type; |
04ed7c3f5cee
(detect_eol_type): If EOL representation does not
Richard M. Stallman <rms@gnu.org>
parents:
19134
diff
changeset
|
4348 |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4349 *skip = 0; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4350 |
19173
04ed7c3f5cee
(detect_eol_type): If EOL representation does not
Richard M. Stallman <rms@gnu.org>
parents:
19134
diff
changeset
|
4351 while (src < src_end && total < MAX_EOL_CHECK_COUNT) |
17052 | 4352 { |
4353 c = *src++; | |
19173
04ed7c3f5cee
(detect_eol_type): If EOL representation does not
Richard M. Stallman <rms@gnu.org>
parents:
19134
diff
changeset
|
4354 if (c == '\n' || c == '\r') |
17052 | 4355 { |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4356 if (*skip == 0) |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4357 *skip = src - 1 - source; |
19173
04ed7c3f5cee
(detect_eol_type): If EOL representation does not
Richard M. Stallman <rms@gnu.org>
parents:
19134
diff
changeset
|
4358 total++; |
04ed7c3f5cee
(detect_eol_type): If EOL representation does not
Richard M. Stallman <rms@gnu.org>
parents:
19134
diff
changeset
|
4359 if (c == '\n') |
04ed7c3f5cee
(detect_eol_type): If EOL representation does not
Richard M. Stallman <rms@gnu.org>
parents:
19134
diff
changeset
|
4360 this_eol_type = CODING_EOL_LF; |
04ed7c3f5cee
(detect_eol_type): If EOL representation does not
Richard M. Stallman <rms@gnu.org>
parents:
19134
diff
changeset
|
4361 else if (src >= src_end || *src != '\n') |
04ed7c3f5cee
(detect_eol_type): If EOL representation does not
Richard M. Stallman <rms@gnu.org>
parents:
19134
diff
changeset
|
4362 this_eol_type = CODING_EOL_CR; |
17052 | 4363 else |
19173
04ed7c3f5cee
(detect_eol_type): If EOL representation does not
Richard M. Stallman <rms@gnu.org>
parents:
19134
diff
changeset
|
4364 this_eol_type = CODING_EOL_CRLF, src++; |
04ed7c3f5cee
(detect_eol_type): If EOL representation does not
Richard M. Stallman <rms@gnu.org>
parents:
19134
diff
changeset
|
4365 |
04ed7c3f5cee
(detect_eol_type): If EOL representation does not
Richard M. Stallman <rms@gnu.org>
parents:
19134
diff
changeset
|
4366 if (eol_type == CODING_EOL_UNDECIDED) |
04ed7c3f5cee
(detect_eol_type): If EOL representation does not
Richard M. Stallman <rms@gnu.org>
parents:
19134
diff
changeset
|
4367 /* This is the first end-of-line. */ |
04ed7c3f5cee
(detect_eol_type): If EOL representation does not
Richard M. Stallman <rms@gnu.org>
parents:
19134
diff
changeset
|
4368 eol_type = this_eol_type; |
04ed7c3f5cee
(detect_eol_type): If EOL representation does not
Richard M. Stallman <rms@gnu.org>
parents:
19134
diff
changeset
|
4369 else if (eol_type != this_eol_type) |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4370 { |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4371 /* The found type is different from what found before. */ |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4372 eol_type = CODING_EOL_INCONSISTENT; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4373 break; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4374 } |
17052 | 4375 } |
4376 } | |
19173
04ed7c3f5cee
(detect_eol_type): If EOL representation does not
Richard M. Stallman <rms@gnu.org>
parents:
19134
diff
changeset
|
4377 |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4378 if (*skip == 0) |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4379 *skip = src_end - source; |
19181
917138730635
(detect_eol_type): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
19173
diff
changeset
|
4380 return eol_type; |
17052 | 4381 } |
4382 | |
28022
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
4383 /* Like detect_eol_type, but detect EOL type in 2-octet |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
4384 big-endian/little-endian format for coding systems utf-16-be and |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
4385 utf-16-le. */ |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
4386 |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
4387 static int |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
4388 detect_eol_type_in_2_octet_form (source, src_bytes, skip, big_endian_p) |
84646
922a7e3b7383
(detect_eol_type, detect_eol_type_in_2_octet_form):
Michaël Cadilhac <michael.cadilhac@lrde.org>
parents:
83648
diff
changeset
|
4389 const unsigned char *source; |
35053 | 4390 int src_bytes, *skip, big_endian_p; |
28022
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
4391 { |
84646
922a7e3b7383
(detect_eol_type, detect_eol_type_in_2_octet_form):
Michaël Cadilhac <michael.cadilhac@lrde.org>
parents:
83648
diff
changeset
|
4392 const unsigned char *src = source, *src_end = src + src_bytes; |
28022
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
4393 unsigned int c1, c2; |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
4394 int total = 0; /* How many end-of-lines are found so far. */ |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
4395 int eol_type = CODING_EOL_UNDECIDED; |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
4396 int this_eol_type; |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
4397 int msb, lsb; |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
4398 |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
4399 if (big_endian_p) |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
4400 msb = 0, lsb = 1; |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
4401 else |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
4402 msb = 1, lsb = 0; |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
4403 |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
4404 *skip = 0; |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
4405 |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
4406 while ((src + 1) < src_end && total < MAX_EOL_CHECK_COUNT) |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
4407 { |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
4408 c1 = (src[msb] << 8) | (src[lsb]); |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
4409 src += 2; |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
4410 |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
4411 if (c1 == '\n' || c1 == '\r') |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
4412 { |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
4413 if (*skip == 0) |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
4414 *skip = src - 2 - source; |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
4415 total++; |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
4416 if (c1 == '\n') |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
4417 { |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
4418 this_eol_type = CODING_EOL_LF; |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
4419 } |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
4420 else |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
4421 { |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
4422 if ((src + 1) >= src_end) |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
4423 { |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
4424 this_eol_type = CODING_EOL_CR; |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
4425 } |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
4426 else |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
4427 { |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
4428 c2 = (src[msb] << 8) | (src[lsb]); |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
4429 if (c2 == '\n') |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
4430 this_eol_type = CODING_EOL_CRLF, src += 2; |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
4431 else |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
4432 this_eol_type = CODING_EOL_CR; |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
4433 } |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
4434 } |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
4435 |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
4436 if (eol_type == CODING_EOL_UNDECIDED) |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
4437 /* This is the first end-of-line. */ |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
4438 eol_type = this_eol_type; |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
4439 else if (eol_type != this_eol_type) |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
4440 { |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
4441 /* The found type is different from what found before. */ |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
4442 eol_type = CODING_EOL_INCONSISTENT; |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
4443 break; |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
4444 } |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
4445 } |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
4446 } |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
4447 |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
4448 if (*skip == 0) |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
4449 *skip = src_end - source; |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
4450 return eol_type; |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
4451 } |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
4452 |
17052 | 4453 /* Detect how end-of-line of a text of length SRC_BYTES pointed by SRC |
4454 is encoded. If it detects an appropriate format of end-of-line, it | |
4455 sets the information in *CODING. */ | |
4456 | |
4457 void | |
4458 detect_eol (coding, src, src_bytes) | |
4459 struct coding_system *coding; | |
46548
cb1914307488
(encode_eol, detect_coding, detect_eol):
Ken Raeburn <raeburn@raeburn.org>
parents:
46462
diff
changeset
|
4460 const unsigned char *src; |
17052 | 4461 int src_bytes; |
4462 { | |
20105
c017642863c2
(Qcoding_system_spec): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
19824
diff
changeset
|
4463 Lisp_Object val; |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4464 int skip; |
28022
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
4465 int eol_type; |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
4466 |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
4467 switch (coding->category_idx) |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
4468 { |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
4469 case CODING_CATEGORY_IDX_UTF_16_BE: |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
4470 eol_type = detect_eol_type_in_2_octet_form (src, src_bytes, &skip, 1); |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
4471 break; |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
4472 case CODING_CATEGORY_IDX_UTF_16_LE: |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
4473 eol_type = detect_eol_type_in_2_octet_form (src, src_bytes, &skip, 0); |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
4474 break; |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
4475 default: |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
4476 eol_type = detect_eol_type (src, src_bytes, &skip); |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
4477 break; |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
4478 } |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4479 |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4480 if (coding->heading_ascii > skip) |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4481 coding->heading_ascii = skip; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4482 else |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4483 skip = coding->heading_ascii; |
17052 | 4484 |
17835
f36ffb6f1208
Name change through the code:
Kenichi Handa <handa@m17n.org>
parents:
17725
diff
changeset
|
4485 if (eol_type == CODING_EOL_UNDECIDED) |
17052 | 4486 return; |
19612
783efd6c7c1e
(Qno_conversion, Qundecided): New variables.
Kenichi Handa <handa@m17n.org>
parents:
19546
diff
changeset
|
4487 if (eol_type == CODING_EOL_INCONSISTENT) |
783efd6c7c1e
(Qno_conversion, Qundecided): New variables.
Kenichi Handa <handa@m17n.org>
parents:
19546
diff
changeset
|
4488 { |
783efd6c7c1e
(Qno_conversion, Qundecided): New variables.
Kenichi Handa <handa@m17n.org>
parents:
19546
diff
changeset
|
4489 #if 0 |
783efd6c7c1e
(Qno_conversion, Qundecided): New variables.
Kenichi Handa <handa@m17n.org>
parents:
19546
diff
changeset
|
4490 /* This code is suppressed until we find a better way to |
19613
666288d82ae1
(detect_eol): Do not select no-conversion even if EOL
Kenichi Handa <handa@m17n.org>
parents:
19612
diff
changeset
|
4491 distinguish raw text file and binary file. */ |
19612
783efd6c7c1e
(Qno_conversion, Qundecided): New variables.
Kenichi Handa <handa@m17n.org>
parents:
19546
diff
changeset
|
4492 |
783efd6c7c1e
(Qno_conversion, Qundecided): New variables.
Kenichi Handa <handa@m17n.org>
parents:
19546
diff
changeset
|
4493 /* If we have already detected that the coding is raw-text, the |
783efd6c7c1e
(Qno_conversion, Qundecided): New variables.
Kenichi Handa <handa@m17n.org>
parents:
19546
diff
changeset
|
4494 coding should actually be no-conversion. */ |
783efd6c7c1e
(Qno_conversion, Qundecided): New variables.
Kenichi Handa <handa@m17n.org>
parents:
19546
diff
changeset
|
4495 if (coding->type == coding_type_raw_text) |
783efd6c7c1e
(Qno_conversion, Qundecided): New variables.
Kenichi Handa <handa@m17n.org>
parents:
19546
diff
changeset
|
4496 { |
783efd6c7c1e
(Qno_conversion, Qundecided): New variables.
Kenichi Handa <handa@m17n.org>
parents:
19546
diff
changeset
|
4497 setup_coding_system (Qno_conversion, coding); |
783efd6c7c1e
(Qno_conversion, Qundecided): New variables.
Kenichi Handa <handa@m17n.org>
parents:
19546
diff
changeset
|
4498 return; |
783efd6c7c1e
(Qno_conversion, Qundecided): New variables.
Kenichi Handa <handa@m17n.org>
parents:
19546
diff
changeset
|
4499 } |
783efd6c7c1e
(Qno_conversion, Qundecided): New variables.
Kenichi Handa <handa@m17n.org>
parents:
19546
diff
changeset
|
4500 /* Else, let's decode only text code anyway. */ |
783efd6c7c1e
(Qno_conversion, Qundecided): New variables.
Kenichi Handa <handa@m17n.org>
parents:
19546
diff
changeset
|
4501 #endif /* 0 */ |
19743
b228f82192d5
(detect_coding_mask): Re-work previous change.
Richard M. Stallman <rms@gnu.org>
parents:
19688
diff
changeset
|
4502 eol_type = CODING_EOL_LF; |
19612
783efd6c7c1e
(Qno_conversion, Qundecided): New variables.
Kenichi Handa <handa@m17n.org>
parents:
19546
diff
changeset
|
4503 } |
783efd6c7c1e
(Qno_conversion, Qundecided): New variables.
Kenichi Handa <handa@m17n.org>
parents:
19546
diff
changeset
|
4504 |
20105
c017642863c2
(Qcoding_system_spec): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
19824
diff
changeset
|
4505 val = Fget (coding->symbol, Qeol_type); |
17052 | 4506 if (VECTORP (val) && XVECTOR (val)->size == 3) |
4507 { | |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4508 int src_multibyte = coding->src_multibyte; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4509 int dst_multibyte = coding->dst_multibyte; |
45981
e513f55424f6
(detect_eol): Preserve coding->cmp_data.
Kenichi Handa <handa@m17n.org>
parents:
45396
diff
changeset
|
4510 struct composition_data *cmp_data = coding->cmp_data; |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4511 |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4512 setup_coding_system (XVECTOR (val)->contents[eol_type], coding); |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4513 coding->src_multibyte = src_multibyte; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4514 coding->dst_multibyte = dst_multibyte; |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4515 coding->heading_ascii = skip; |
45981
e513f55424f6
(detect_eol): Preserve coding->cmp_data.
Kenichi Handa <handa@m17n.org>
parents:
45396
diff
changeset
|
4516 coding->cmp_data = cmp_data; |
17052 | 4517 } |
4518 } | |
4519 | |
4520 #define CONVERSION_BUFFER_EXTRA_ROOM 256 | |
4521 | |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4522 #define DECODING_BUFFER_MAG(coding) \ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4523 (coding->type == coding_type_iso2022 \ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4524 ? 3 \ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4525 : (coding->type == coding_type_ccl \ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4526 ? coding->spec.ccl.decoder.buf_magnification \ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4527 : 2)) |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4528 |
17052 | 4529 /* Return maximum size (bytes) of a buffer enough for decoding |
4530 SRC_BYTES of text encoded in CODING. */ | |
4531 | |
4532 int | |
4533 decoding_buffer_size (coding, src_bytes) | |
4534 struct coding_system *coding; | |
4535 int src_bytes; | |
4536 { | |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4537 return (src_bytes * DECODING_BUFFER_MAG (coding) |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4538 + CONVERSION_BUFFER_EXTRA_ROOM); |
17052 | 4539 } |
4540 | |
4541 /* Return maximum size (bytes) of a buffer enough for encoding | |
4542 SRC_BYTES of text to CODING. */ | |
4543 | |
4544 int | |
4545 encoding_buffer_size (coding, src_bytes) | |
4546 struct coding_system *coding; | |
4547 int src_bytes; | |
4548 { | |
4549 int magnification; | |
4550 | |
4551 if (coding->type == coding_type_ccl) | |
51458
28be64986453
_buffer_size): If coding->type is
Kenichi Handa <handa@m17n.org>
parents:
51406
diff
changeset
|
4552 { |
28be64986453
_buffer_size): If coding->type is
Kenichi Handa <handa@m17n.org>
parents:
51406
diff
changeset
|
4553 magnification = coding->spec.ccl.encoder.buf_magnification; |
28be64986453
_buffer_size): If coding->type is
Kenichi Handa <handa@m17n.org>
parents:
51406
diff
changeset
|
4554 if (coding->eol_type == CODING_EOL_CRLF) |
28be64986453
_buffer_size): If coding->type is
Kenichi Handa <handa@m17n.org>
parents:
51406
diff
changeset
|
4555 magnification *= 2; |
28be64986453
_buffer_size): If coding->type is
Kenichi Handa <handa@m17n.org>
parents:
51406
diff
changeset
|
4556 } |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4557 else if (CODING_REQUIRE_ENCODING (coding)) |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4558 magnification = 3; |
17052 | 4559 else |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4560 magnification = 1; |
17052 | 4561 |
4562 return (src_bytes * magnification + CONVERSION_BUFFER_EXTRA_ROOM); | |
4563 } | |
4564 | |
30833
2db6e42a6ba3
(MINIMUM_CONVERSION_BUFFER_SIZE): Macro deleted.
Kenichi Handa <handa@m17n.org>
parents:
30756
diff
changeset
|
4565 /* Working buffer for code conversion. */ |
2db6e42a6ba3
(MINIMUM_CONVERSION_BUFFER_SIZE): Macro deleted.
Kenichi Handa <handa@m17n.org>
parents:
30756
diff
changeset
|
4566 struct conversion_buffer |
17052 | 4567 { |
30833
2db6e42a6ba3
(MINIMUM_CONVERSION_BUFFER_SIZE): Macro deleted.
Kenichi Handa <handa@m17n.org>
parents:
30756
diff
changeset
|
4568 int size; /* size of data. */ |
2db6e42a6ba3
(MINIMUM_CONVERSION_BUFFER_SIZE): Macro deleted.
Kenichi Handa <handa@m17n.org>
parents:
30756
diff
changeset
|
4569 int on_stack; /* 1 if allocated by alloca. */ |
2db6e42a6ba3
(MINIMUM_CONVERSION_BUFFER_SIZE): Macro deleted.
Kenichi Handa <handa@m17n.org>
parents:
30756
diff
changeset
|
4570 unsigned char *data; |
2db6e42a6ba3
(MINIMUM_CONVERSION_BUFFER_SIZE): Macro deleted.
Kenichi Handa <handa@m17n.org>
parents:
30756
diff
changeset
|
4571 }; |
2db6e42a6ba3
(MINIMUM_CONVERSION_BUFFER_SIZE): Macro deleted.
Kenichi Handa <handa@m17n.org>
parents:
30756
diff
changeset
|
4572 |
2db6e42a6ba3
(MINIMUM_CONVERSION_BUFFER_SIZE): Macro deleted.
Kenichi Handa <handa@m17n.org>
parents:
30756
diff
changeset
|
4573 /* Allocate LEN bytes of memory for BUF (struct conversion_buffer). */ |
2db6e42a6ba3
(MINIMUM_CONVERSION_BUFFER_SIZE): Macro deleted.
Kenichi Handa <handa@m17n.org>
parents:
30756
diff
changeset
|
4574 #define allocate_conversion_buffer(buf, len) \ |
2db6e42a6ba3
(MINIMUM_CONVERSION_BUFFER_SIZE): Macro deleted.
Kenichi Handa <handa@m17n.org>
parents:
30756
diff
changeset
|
4575 do { \ |
2db6e42a6ba3
(MINIMUM_CONVERSION_BUFFER_SIZE): Macro deleted.
Kenichi Handa <handa@m17n.org>
parents:
30756
diff
changeset
|
4576 if (len < MAX_ALLOCA) \ |
2db6e42a6ba3
(MINIMUM_CONVERSION_BUFFER_SIZE): Macro deleted.
Kenichi Handa <handa@m17n.org>
parents:
30756
diff
changeset
|
4577 { \ |
2db6e42a6ba3
(MINIMUM_CONVERSION_BUFFER_SIZE): Macro deleted.
Kenichi Handa <handa@m17n.org>
parents:
30756
diff
changeset
|
4578 buf.data = (unsigned char *) alloca (len); \ |
2db6e42a6ba3
(MINIMUM_CONVERSION_BUFFER_SIZE): Macro deleted.
Kenichi Handa <handa@m17n.org>
parents:
30756
diff
changeset
|
4579 buf.on_stack = 1; \ |
2db6e42a6ba3
(MINIMUM_CONVERSION_BUFFER_SIZE): Macro deleted.
Kenichi Handa <handa@m17n.org>
parents:
30756
diff
changeset
|
4580 } \ |
2db6e42a6ba3
(MINIMUM_CONVERSION_BUFFER_SIZE): Macro deleted.
Kenichi Handa <handa@m17n.org>
parents:
30756
diff
changeset
|
4581 else \ |
2db6e42a6ba3
(MINIMUM_CONVERSION_BUFFER_SIZE): Macro deleted.
Kenichi Handa <handa@m17n.org>
parents:
30756
diff
changeset
|
4582 { \ |
2db6e42a6ba3
(MINIMUM_CONVERSION_BUFFER_SIZE): Macro deleted.
Kenichi Handa <handa@m17n.org>
parents:
30756
diff
changeset
|
4583 buf.data = (unsigned char *) xmalloc (len); \ |
2db6e42a6ba3
(MINIMUM_CONVERSION_BUFFER_SIZE): Macro deleted.
Kenichi Handa <handa@m17n.org>
parents:
30756
diff
changeset
|
4584 buf.on_stack = 0; \ |
2db6e42a6ba3
(MINIMUM_CONVERSION_BUFFER_SIZE): Macro deleted.
Kenichi Handa <handa@m17n.org>
parents:
30756
diff
changeset
|
4585 } \ |
2db6e42a6ba3
(MINIMUM_CONVERSION_BUFFER_SIZE): Macro deleted.
Kenichi Handa <handa@m17n.org>
parents:
30756
diff
changeset
|
4586 buf.size = len; \ |
2db6e42a6ba3
(MINIMUM_CONVERSION_BUFFER_SIZE): Macro deleted.
Kenichi Handa <handa@m17n.org>
parents:
30756
diff
changeset
|
4587 } while (0) |
2db6e42a6ba3
(MINIMUM_CONVERSION_BUFFER_SIZE): Macro deleted.
Kenichi Handa <handa@m17n.org>
parents:
30756
diff
changeset
|
4588 |
2db6e42a6ba3
(MINIMUM_CONVERSION_BUFFER_SIZE): Macro deleted.
Kenichi Handa <handa@m17n.org>
parents:
30756
diff
changeset
|
4589 /* Double the allocated memory for *BUF. */ |
2db6e42a6ba3
(MINIMUM_CONVERSION_BUFFER_SIZE): Macro deleted.
Kenichi Handa <handa@m17n.org>
parents:
30756
diff
changeset
|
4590 static void |
2db6e42a6ba3
(MINIMUM_CONVERSION_BUFFER_SIZE): Macro deleted.
Kenichi Handa <handa@m17n.org>
parents:
30756
diff
changeset
|
4591 extend_conversion_buffer (buf) |
2db6e42a6ba3
(MINIMUM_CONVERSION_BUFFER_SIZE): Macro deleted.
Kenichi Handa <handa@m17n.org>
parents:
30756
diff
changeset
|
4592 struct conversion_buffer *buf; |
2db6e42a6ba3
(MINIMUM_CONVERSION_BUFFER_SIZE): Macro deleted.
Kenichi Handa <handa@m17n.org>
parents:
30756
diff
changeset
|
4593 { |
2db6e42a6ba3
(MINIMUM_CONVERSION_BUFFER_SIZE): Macro deleted.
Kenichi Handa <handa@m17n.org>
parents:
30756
diff
changeset
|
4594 if (buf->on_stack) |
17052 | 4595 { |
30833
2db6e42a6ba3
(MINIMUM_CONVERSION_BUFFER_SIZE): Macro deleted.
Kenichi Handa <handa@m17n.org>
parents:
30756
diff
changeset
|
4596 unsigned char *save = buf->data; |
2db6e42a6ba3
(MINIMUM_CONVERSION_BUFFER_SIZE): Macro deleted.
Kenichi Handa <handa@m17n.org>
parents:
30756
diff
changeset
|
4597 buf->data = (unsigned char *) xmalloc (buf->size * 2); |
2db6e42a6ba3
(MINIMUM_CONVERSION_BUFFER_SIZE): Macro deleted.
Kenichi Handa <handa@m17n.org>
parents:
30756
diff
changeset
|
4598 bcopy (save, buf->data, buf->size); |
2db6e42a6ba3
(MINIMUM_CONVERSION_BUFFER_SIZE): Macro deleted.
Kenichi Handa <handa@m17n.org>
parents:
30756
diff
changeset
|
4599 buf->on_stack = 0; |
2db6e42a6ba3
(MINIMUM_CONVERSION_BUFFER_SIZE): Macro deleted.
Kenichi Handa <handa@m17n.org>
parents:
30756
diff
changeset
|
4600 } |
2db6e42a6ba3
(MINIMUM_CONVERSION_BUFFER_SIZE): Macro deleted.
Kenichi Handa <handa@m17n.org>
parents:
30756
diff
changeset
|
4601 else |
2db6e42a6ba3
(MINIMUM_CONVERSION_BUFFER_SIZE): Macro deleted.
Kenichi Handa <handa@m17n.org>
parents:
30756
diff
changeset
|
4602 { |
2db6e42a6ba3
(MINIMUM_CONVERSION_BUFFER_SIZE): Macro deleted.
Kenichi Handa <handa@m17n.org>
parents:
30756
diff
changeset
|
4603 buf->data = (unsigned char *) xrealloc (buf->data, buf->size * 2); |
17052 | 4604 } |
30833
2db6e42a6ba3
(MINIMUM_CONVERSION_BUFFER_SIZE): Macro deleted.
Kenichi Handa <handa@m17n.org>
parents:
30756
diff
changeset
|
4605 buf->size *= 2; |
2db6e42a6ba3
(MINIMUM_CONVERSION_BUFFER_SIZE): Macro deleted.
Kenichi Handa <handa@m17n.org>
parents:
30756
diff
changeset
|
4606 } |
2db6e42a6ba3
(MINIMUM_CONVERSION_BUFFER_SIZE): Macro deleted.
Kenichi Handa <handa@m17n.org>
parents:
30756
diff
changeset
|
4607 |
2db6e42a6ba3
(MINIMUM_CONVERSION_BUFFER_SIZE): Macro deleted.
Kenichi Handa <handa@m17n.org>
parents:
30756
diff
changeset
|
4608 /* Free the allocated memory for BUF if it is not on stack. */ |
2db6e42a6ba3
(MINIMUM_CONVERSION_BUFFER_SIZE): Macro deleted.
Kenichi Handa <handa@m17n.org>
parents:
30756
diff
changeset
|
4609 static void |
2db6e42a6ba3
(MINIMUM_CONVERSION_BUFFER_SIZE): Macro deleted.
Kenichi Handa <handa@m17n.org>
parents:
30756
diff
changeset
|
4610 free_conversion_buffer (buf) |
2db6e42a6ba3
(MINIMUM_CONVERSION_BUFFER_SIZE): Macro deleted.
Kenichi Handa <handa@m17n.org>
parents:
30756
diff
changeset
|
4611 struct conversion_buffer *buf; |
2db6e42a6ba3
(MINIMUM_CONVERSION_BUFFER_SIZE): Macro deleted.
Kenichi Handa <handa@m17n.org>
parents:
30756
diff
changeset
|
4612 { |
2db6e42a6ba3
(MINIMUM_CONVERSION_BUFFER_SIZE): Macro deleted.
Kenichi Handa <handa@m17n.org>
parents:
30756
diff
changeset
|
4613 if (!buf->on_stack) |
2db6e42a6ba3
(MINIMUM_CONVERSION_BUFFER_SIZE): Macro deleted.
Kenichi Handa <handa@m17n.org>
parents:
30756
diff
changeset
|
4614 xfree (buf->data); |
17052 | 4615 } |
4616 | |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4617 int |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4618 ccl_coding_driver (coding, source, destination, src_bytes, dst_bytes, encodep) |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4619 struct coding_system *coding; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4620 unsigned char *source, *destination; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4621 int src_bytes, dst_bytes, encodep; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4622 { |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4623 struct ccl_program *ccl |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4624 = encodep ? &coding->spec.ccl.encoder : &coding->spec.ccl.decoder; |
34892
3868f2e7355a
(setup_coding_system): Initialize
Kenichi Handa <handa@m17n.org>
parents:
34888
diff
changeset
|
4625 unsigned char *dst = destination; |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4626 |
35531
36de5bf9969c
(ccl_coding_driver): Setup ccl->suppress_error.
Kenichi Handa <handa@m17n.org>
parents:
35053
diff
changeset
|
4627 ccl->suppress_error = coding->suppress_error; |
23116
6736da064f4a
(detect_coding_iso2022): Handle ESC N and ESC O
Kenichi Handa <handa@m17n.org>
parents:
23089
diff
changeset
|
4628 ccl->last_block = coding->mode & CODING_MODE_LAST_BLOCK; |
29725
2bc397e9b09a
(setup_coding_system) <4>: Reset member `cr_carryover'.
Kenichi Handa <handa@m17n.org>
parents:
29663
diff
changeset
|
4629 if (encodep) |
34813
e112f39ea5b6
(ccl_coding_driver): Initialize ccl->cr_consumed.
Kenichi Handa <handa@m17n.org>
parents:
34593
diff
changeset
|
4630 { |
e112f39ea5b6
(ccl_coding_driver): Initialize ccl->cr_consumed.
Kenichi Handa <handa@m17n.org>
parents:
34593
diff
changeset
|
4631 /* On encoding, EOL format is converted within ccl_driver. For |
e112f39ea5b6
(ccl_coding_driver): Initialize ccl->cr_consumed.
Kenichi Handa <handa@m17n.org>
parents:
34593
diff
changeset
|
4632 that, setup proper information in the structure CCL. */ |
e112f39ea5b6
(ccl_coding_driver): Initialize ccl->cr_consumed.
Kenichi Handa <handa@m17n.org>
parents:
34593
diff
changeset
|
4633 ccl->eol_type = coding->eol_type; |
e112f39ea5b6
(ccl_coding_driver): Initialize ccl->cr_consumed.
Kenichi Handa <handa@m17n.org>
parents:
34593
diff
changeset
|
4634 if (ccl->eol_type ==CODING_EOL_UNDECIDED) |
e112f39ea5b6
(ccl_coding_driver): Initialize ccl->cr_consumed.
Kenichi Handa <handa@m17n.org>
parents:
34593
diff
changeset
|
4635 ccl->eol_type = CODING_EOL_LF; |
e112f39ea5b6
(ccl_coding_driver): Initialize ccl->cr_consumed.
Kenichi Handa <handa@m17n.org>
parents:
34593
diff
changeset
|
4636 ccl->cr_consumed = coding->spec.ccl.cr_carryover; |
51327
389d833cd25e
(ccl_coding_driver): Set ccl->eight_bit_control
Kenichi Handa <handa@m17n.org>
parents:
51311
diff
changeset
|
4637 ccl->eight_bit_control = coding->dst_multibyte; |
389d833cd25e
(ccl_coding_driver): Set ccl->eight_bit_control
Kenichi Handa <handa@m17n.org>
parents:
51311
diff
changeset
|
4638 } |
389d833cd25e
(ccl_coding_driver): Set ccl->eight_bit_control
Kenichi Handa <handa@m17n.org>
parents:
51311
diff
changeset
|
4639 else |
389d833cd25e
(ccl_coding_driver): Set ccl->eight_bit_control
Kenichi Handa <handa@m17n.org>
parents:
51311
diff
changeset
|
4640 ccl->eight_bit_control = 1; |
30756
b72c2759ac70
(ccl_coding_driver): Initialize ccl->multibyte.
Kenichi Handa <handa@m17n.org>
parents:
30674
diff
changeset
|
4641 ccl->multibyte = coding->src_multibyte; |
34892
3868f2e7355a
(setup_coding_system): Initialize
Kenichi Handa <handa@m17n.org>
parents:
34888
diff
changeset
|
4642 if (coding->spec.ccl.eight_bit_carryover[0] != 0) |
3868f2e7355a
(setup_coding_system): Initialize
Kenichi Handa <handa@m17n.org>
parents:
34888
diff
changeset
|
4643 { |
3868f2e7355a
(setup_coding_system): Initialize
Kenichi Handa <handa@m17n.org>
parents:
34888
diff
changeset
|
4644 /* Move carryover bytes to DESTINATION. */ |
3868f2e7355a
(setup_coding_system): Initialize
Kenichi Handa <handa@m17n.org>
parents:
34888
diff
changeset
|
4645 unsigned char *p = coding->spec.ccl.eight_bit_carryover; |
3868f2e7355a
(setup_coding_system): Initialize
Kenichi Handa <handa@m17n.org>
parents:
34888
diff
changeset
|
4646 while (*p) |
3868f2e7355a
(setup_coding_system): Initialize
Kenichi Handa <handa@m17n.org>
parents:
34888
diff
changeset
|
4647 *dst++ = *p++; |
3868f2e7355a
(setup_coding_system): Initialize
Kenichi Handa <handa@m17n.org>
parents:
34888
diff
changeset
|
4648 coding->spec.ccl.eight_bit_carryover[0] = 0; |
3868f2e7355a
(setup_coding_system): Initialize
Kenichi Handa <handa@m17n.org>
parents:
34888
diff
changeset
|
4649 if (dst_bytes) |
3868f2e7355a
(setup_coding_system): Initialize
Kenichi Handa <handa@m17n.org>
parents:
34888
diff
changeset
|
4650 dst_bytes -= dst - destination; |
3868f2e7355a
(setup_coding_system): Initialize
Kenichi Handa <handa@m17n.org>
parents:
34888
diff
changeset
|
4651 } |
3868f2e7355a
(setup_coding_system): Initialize
Kenichi Handa <handa@m17n.org>
parents:
34888
diff
changeset
|
4652 |
3868f2e7355a
(setup_coding_system): Initialize
Kenichi Handa <handa@m17n.org>
parents:
34888
diff
changeset
|
4653 coding->produced = (ccl_driver (ccl, source, dst, src_bytes, dst_bytes, |
3868f2e7355a
(setup_coding_system): Initialize
Kenichi Handa <handa@m17n.org>
parents:
34888
diff
changeset
|
4654 &(coding->consumed)) |
3868f2e7355a
(setup_coding_system): Initialize
Kenichi Handa <handa@m17n.org>
parents:
34888
diff
changeset
|
4655 + dst - destination); |
3868f2e7355a
(setup_coding_system): Initialize
Kenichi Handa <handa@m17n.org>
parents:
34888
diff
changeset
|
4656 |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4657 if (encodep) |
34813
e112f39ea5b6
(ccl_coding_driver): Initialize ccl->cr_consumed.
Kenichi Handa <handa@m17n.org>
parents:
34593
diff
changeset
|
4658 { |
e112f39ea5b6
(ccl_coding_driver): Initialize ccl->cr_consumed.
Kenichi Handa <handa@m17n.org>
parents:
34593
diff
changeset
|
4659 coding->produced_char = coding->produced; |
e112f39ea5b6
(ccl_coding_driver): Initialize ccl->cr_consumed.
Kenichi Handa <handa@m17n.org>
parents:
34593
diff
changeset
|
4660 coding->spec.ccl.cr_carryover = ccl->cr_consumed; |
e112f39ea5b6
(ccl_coding_driver): Initialize ccl->cr_consumed.
Kenichi Handa <handa@m17n.org>
parents:
34593
diff
changeset
|
4661 } |
36410
27b5c760df31
(ccl_coding_driver): If ccl->eight_bit_control is zero,
Kenichi Handa <handa@m17n.org>
parents:
36087
diff
changeset
|
4662 else if (!ccl->eight_bit_control) |
27b5c760df31
(ccl_coding_driver): If ccl->eight_bit_control is zero,
Kenichi Handa <handa@m17n.org>
parents:
36087
diff
changeset
|
4663 { |
27b5c760df31
(ccl_coding_driver): If ccl->eight_bit_control is zero,
Kenichi Handa <handa@m17n.org>
parents:
36087
diff
changeset
|
4664 /* The produced bytes forms a valid multibyte sequence. */ |
27b5c760df31
(ccl_coding_driver): If ccl->eight_bit_control is zero,
Kenichi Handa <handa@m17n.org>
parents:
36087
diff
changeset
|
4665 coding->produced_char |
27b5c760df31
(ccl_coding_driver): If ccl->eight_bit_control is zero,
Kenichi Handa <handa@m17n.org>
parents:
36087
diff
changeset
|
4666 = multibyte_chars_in_text (destination, coding->produced); |
27b5c760df31
(ccl_coding_driver): If ccl->eight_bit_control is zero,
Kenichi Handa <handa@m17n.org>
parents:
36087
diff
changeset
|
4667 coding->spec.ccl.eight_bit_carryover[0] = 0; |
27b5c760df31
(ccl_coding_driver): If ccl->eight_bit_control is zero,
Kenichi Handa <handa@m17n.org>
parents:
36087
diff
changeset
|
4668 } |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4669 else |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4670 { |
34892
3868f2e7355a
(setup_coding_system): Initialize
Kenichi Handa <handa@m17n.org>
parents:
34888
diff
changeset
|
4671 /* On decoding, the destination should always multibyte. But, |
3868f2e7355a
(setup_coding_system): Initialize
Kenichi Handa <handa@m17n.org>
parents:
34888
diff
changeset
|
4672 CCL program might have been generated an invalid multibyte |
3868f2e7355a
(setup_coding_system): Initialize
Kenichi Handa <handa@m17n.org>
parents:
34888
diff
changeset
|
4673 sequence. Here we make such a sequence valid as |
3868f2e7355a
(setup_coding_system): Initialize
Kenichi Handa <handa@m17n.org>
parents:
34888
diff
changeset
|
4674 multibyte. */ |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4675 int bytes |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4676 = dst_bytes ? dst_bytes : source + coding->consumed - destination; |
34892
3868f2e7355a
(setup_coding_system): Initialize
Kenichi Handa <handa@m17n.org>
parents:
34888
diff
changeset
|
4677 |
3868f2e7355a
(setup_coding_system): Initialize
Kenichi Handa <handa@m17n.org>
parents:
34888
diff
changeset
|
4678 if ((coding->consumed < src_bytes |
3868f2e7355a
(setup_coding_system): Initialize
Kenichi Handa <handa@m17n.org>
parents:
34888
diff
changeset
|
4679 || !ccl->last_block) |
3868f2e7355a
(setup_coding_system): Initialize
Kenichi Handa <handa@m17n.org>
parents:
34888
diff
changeset
|
4680 && coding->produced >= 1 |
3868f2e7355a
(setup_coding_system): Initialize
Kenichi Handa <handa@m17n.org>
parents:
34888
diff
changeset
|
4681 && destination[coding->produced - 1] >= 0x80) |
3868f2e7355a
(setup_coding_system): Initialize
Kenichi Handa <handa@m17n.org>
parents:
34888
diff
changeset
|
4682 { |
3868f2e7355a
(setup_coding_system): Initialize
Kenichi Handa <handa@m17n.org>
parents:
34888
diff
changeset
|
4683 /* We should not convert the tailing 8-bit codes to |
3868f2e7355a
(setup_coding_system): Initialize
Kenichi Handa <handa@m17n.org>
parents:
34888
diff
changeset
|
4684 multibyte form even if they doesn't form a valid |
3868f2e7355a
(setup_coding_system): Initialize
Kenichi Handa <handa@m17n.org>
parents:
34888
diff
changeset
|
4685 multibyte sequence. They may form a valid sequence in |
3868f2e7355a
(setup_coding_system): Initialize
Kenichi Handa <handa@m17n.org>
parents:
34888
diff
changeset
|
4686 the next call. */ |
3868f2e7355a
(setup_coding_system): Initialize
Kenichi Handa <handa@m17n.org>
parents:
34888
diff
changeset
|
4687 int carryover = 0; |
3868f2e7355a
(setup_coding_system): Initialize
Kenichi Handa <handa@m17n.org>
parents:
34888
diff
changeset
|
4688 |
3868f2e7355a
(setup_coding_system): Initialize
Kenichi Handa <handa@m17n.org>
parents:
34888
diff
changeset
|
4689 if (destination[coding->produced - 1] < 0xA0) |
3868f2e7355a
(setup_coding_system): Initialize
Kenichi Handa <handa@m17n.org>
parents:
34888
diff
changeset
|
4690 carryover = 1; |
3868f2e7355a
(setup_coding_system): Initialize
Kenichi Handa <handa@m17n.org>
parents:
34888
diff
changeset
|
4691 else if (coding->produced >= 2) |
3868f2e7355a
(setup_coding_system): Initialize
Kenichi Handa <handa@m17n.org>
parents:
34888
diff
changeset
|
4692 { |
3868f2e7355a
(setup_coding_system): Initialize
Kenichi Handa <handa@m17n.org>
parents:
34888
diff
changeset
|
4693 if (destination[coding->produced - 2] >= 0x80) |
3868f2e7355a
(setup_coding_system): Initialize
Kenichi Handa <handa@m17n.org>
parents:
34888
diff
changeset
|
4694 { |
3868f2e7355a
(setup_coding_system): Initialize
Kenichi Handa <handa@m17n.org>
parents:
34888
diff
changeset
|
4695 if (destination[coding->produced - 2] < 0xA0) |
3868f2e7355a
(setup_coding_system): Initialize
Kenichi Handa <handa@m17n.org>
parents:
34888
diff
changeset
|
4696 carryover = 2; |
3868f2e7355a
(setup_coding_system): Initialize
Kenichi Handa <handa@m17n.org>
parents:
34888
diff
changeset
|
4697 else if (coding->produced >= 3 |
3868f2e7355a
(setup_coding_system): Initialize
Kenichi Handa <handa@m17n.org>
parents:
34888
diff
changeset
|
4698 && destination[coding->produced - 3] >= 0x80 |
3868f2e7355a
(setup_coding_system): Initialize
Kenichi Handa <handa@m17n.org>
parents:
34888
diff
changeset
|
4699 && destination[coding->produced - 3] < 0xA0) |
3868f2e7355a
(setup_coding_system): Initialize
Kenichi Handa <handa@m17n.org>
parents:
34888
diff
changeset
|
4700 carryover = 3; |
3868f2e7355a
(setup_coding_system): Initialize
Kenichi Handa <handa@m17n.org>
parents:
34888
diff
changeset
|
4701 } |
3868f2e7355a
(setup_coding_system): Initialize
Kenichi Handa <handa@m17n.org>
parents:
34888
diff
changeset
|
4702 } |
3868f2e7355a
(setup_coding_system): Initialize
Kenichi Handa <handa@m17n.org>
parents:
34888
diff
changeset
|
4703 if (carryover > 0) |
3868f2e7355a
(setup_coding_system): Initialize
Kenichi Handa <handa@m17n.org>
parents:
34888
diff
changeset
|
4704 { |
3868f2e7355a
(setup_coding_system): Initialize
Kenichi Handa <handa@m17n.org>
parents:
34888
diff
changeset
|
4705 BCOPY_SHORT (destination + coding->produced - carryover, |
3868f2e7355a
(setup_coding_system): Initialize
Kenichi Handa <handa@m17n.org>
parents:
34888
diff
changeset
|
4706 coding->spec.ccl.eight_bit_carryover, |
3868f2e7355a
(setup_coding_system): Initialize
Kenichi Handa <handa@m17n.org>
parents:
34888
diff
changeset
|
4707 carryover); |
3868f2e7355a
(setup_coding_system): Initialize
Kenichi Handa <handa@m17n.org>
parents:
34888
diff
changeset
|
4708 coding->spec.ccl.eight_bit_carryover[carryover] = 0; |
3868f2e7355a
(setup_coding_system): Initialize
Kenichi Handa <handa@m17n.org>
parents:
34888
diff
changeset
|
4709 coding->produced -= carryover; |
3868f2e7355a
(setup_coding_system): Initialize
Kenichi Handa <handa@m17n.org>
parents:
34888
diff
changeset
|
4710 } |
3868f2e7355a
(setup_coding_system): Initialize
Kenichi Handa <handa@m17n.org>
parents:
34888
diff
changeset
|
4711 } |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4712 coding->produced = str_as_multibyte (destination, bytes, |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4713 coding->produced, |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4714 &(coding->produced_char)); |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4715 } |
23201
392b44751a22
(ccl_coding_driver): Always calculate correct mulibyte
Kenichi Handa <handa@m17n.org>
parents:
23153
diff
changeset
|
4716 |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4717 switch (ccl->status) |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4718 { |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4719 case CCL_STAT_SUSPEND_BY_SRC: |
30833
2db6e42a6ba3
(MINIMUM_CONVERSION_BUFFER_SIZE): Macro deleted.
Kenichi Handa <handa@m17n.org>
parents:
30756
diff
changeset
|
4720 coding->result = CODING_FINISH_INSUFFICIENT_SRC; |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4721 break; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4722 case CCL_STAT_SUSPEND_BY_DST: |
30833
2db6e42a6ba3
(MINIMUM_CONVERSION_BUFFER_SIZE): Macro deleted.
Kenichi Handa <handa@m17n.org>
parents:
30756
diff
changeset
|
4723 coding->result = CODING_FINISH_INSUFFICIENT_DST; |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4724 break; |
23279
ca159e828a68
(ccl_coding_driver): If ccl_driver is interrupted by a
Kenichi Handa <handa@m17n.org>
parents:
23258
diff
changeset
|
4725 case CCL_STAT_QUIT: |
ca159e828a68
(ccl_coding_driver): If ccl_driver is interrupted by a
Kenichi Handa <handa@m17n.org>
parents:
23258
diff
changeset
|
4726 case CCL_STAT_INVALID_CMD: |
30833
2db6e42a6ba3
(MINIMUM_CONVERSION_BUFFER_SIZE): Macro deleted.
Kenichi Handa <handa@m17n.org>
parents:
30756
diff
changeset
|
4727 coding->result = CODING_FINISH_INTERRUPT; |
23279
ca159e828a68
(ccl_coding_driver): If ccl_driver is interrupted by a
Kenichi Handa <handa@m17n.org>
parents:
23258
diff
changeset
|
4728 break; |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4729 default: |
30833
2db6e42a6ba3
(MINIMUM_CONVERSION_BUFFER_SIZE): Macro deleted.
Kenichi Handa <handa@m17n.org>
parents:
30756
diff
changeset
|
4730 coding->result = CODING_FINISH_NORMAL; |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4731 break; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4732 } |
30833
2db6e42a6ba3
(MINIMUM_CONVERSION_BUFFER_SIZE): Macro deleted.
Kenichi Handa <handa@m17n.org>
parents:
30756
diff
changeset
|
4733 return coding->result; |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4734 } |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4735 |
29725
2bc397e9b09a
(setup_coding_system) <4>: Reset member `cr_carryover'.
Kenichi Handa <handa@m17n.org>
parents:
29663
diff
changeset
|
4736 /* Decode EOL format of the text at PTR of BYTES length destructively |
2bc397e9b09a
(setup_coding_system) <4>: Reset member `cr_carryover'.
Kenichi Handa <handa@m17n.org>
parents:
29663
diff
changeset
|
4737 according to CODING->eol_type. This is called after the CCL |
2bc397e9b09a
(setup_coding_system) <4>: Reset member `cr_carryover'.
Kenichi Handa <handa@m17n.org>
parents:
29663
diff
changeset
|
4738 program produced a decoded text at PTR. If we do CRLF->LF |
2bc397e9b09a
(setup_coding_system) <4>: Reset member `cr_carryover'.
Kenichi Handa <handa@m17n.org>
parents:
29663
diff
changeset
|
4739 conversion, update CODING->produced and CODING->produced_char. */ |
2bc397e9b09a
(setup_coding_system) <4>: Reset member `cr_carryover'.
Kenichi Handa <handa@m17n.org>
parents:
29663
diff
changeset
|
4740 |
2bc397e9b09a
(setup_coding_system) <4>: Reset member `cr_carryover'.
Kenichi Handa <handa@m17n.org>
parents:
29663
diff
changeset
|
4741 static void |
2bc397e9b09a
(setup_coding_system) <4>: Reset member `cr_carryover'.
Kenichi Handa <handa@m17n.org>
parents:
29663
diff
changeset
|
4742 decode_eol_post_ccl (coding, ptr, bytes) |
2bc397e9b09a
(setup_coding_system) <4>: Reset member `cr_carryover'.
Kenichi Handa <handa@m17n.org>
parents:
29663
diff
changeset
|
4743 struct coding_system *coding; |
2bc397e9b09a
(setup_coding_system) <4>: Reset member `cr_carryover'.
Kenichi Handa <handa@m17n.org>
parents:
29663
diff
changeset
|
4744 unsigned char *ptr; |
2bc397e9b09a
(setup_coding_system) <4>: Reset member `cr_carryover'.
Kenichi Handa <handa@m17n.org>
parents:
29663
diff
changeset
|
4745 int bytes; |
2bc397e9b09a
(setup_coding_system) <4>: Reset member `cr_carryover'.
Kenichi Handa <handa@m17n.org>
parents:
29663
diff
changeset
|
4746 { |
2bc397e9b09a
(setup_coding_system) <4>: Reset member `cr_carryover'.
Kenichi Handa <handa@m17n.org>
parents:
29663
diff
changeset
|
4747 Lisp_Object val, saved_coding_symbol; |
2bc397e9b09a
(setup_coding_system) <4>: Reset member `cr_carryover'.
Kenichi Handa <handa@m17n.org>
parents:
29663
diff
changeset
|
4748 unsigned char *pend = ptr + bytes; |
2bc397e9b09a
(setup_coding_system) <4>: Reset member `cr_carryover'.
Kenichi Handa <handa@m17n.org>
parents:
29663
diff
changeset
|
4749 int dummy; |
2bc397e9b09a
(setup_coding_system) <4>: Reset member `cr_carryover'.
Kenichi Handa <handa@m17n.org>
parents:
29663
diff
changeset
|
4750 |
2bc397e9b09a
(setup_coding_system) <4>: Reset member `cr_carryover'.
Kenichi Handa <handa@m17n.org>
parents:
29663
diff
changeset
|
4751 /* Remember the current coding system symbol. We set it back when |
2bc397e9b09a
(setup_coding_system) <4>: Reset member `cr_carryover'.
Kenichi Handa <handa@m17n.org>
parents:
29663
diff
changeset
|
4752 an inconsistent EOL is found so that `last-coding-system-used' is |
2bc397e9b09a
(setup_coding_system) <4>: Reset member `cr_carryover'.
Kenichi Handa <handa@m17n.org>
parents:
29663
diff
changeset
|
4753 set to the coding system that doesn't specify EOL conversion. */ |
2bc397e9b09a
(setup_coding_system) <4>: Reset member `cr_carryover'.
Kenichi Handa <handa@m17n.org>
parents:
29663
diff
changeset
|
4754 saved_coding_symbol = coding->symbol; |
2bc397e9b09a
(setup_coding_system) <4>: Reset member `cr_carryover'.
Kenichi Handa <handa@m17n.org>
parents:
29663
diff
changeset
|
4755 |
2bc397e9b09a
(setup_coding_system) <4>: Reset member `cr_carryover'.
Kenichi Handa <handa@m17n.org>
parents:
29663
diff
changeset
|
4756 coding->spec.ccl.cr_carryover = 0; |
2bc397e9b09a
(setup_coding_system) <4>: Reset member `cr_carryover'.
Kenichi Handa <handa@m17n.org>
parents:
29663
diff
changeset
|
4757 if (coding->eol_type == CODING_EOL_UNDECIDED) |
2bc397e9b09a
(setup_coding_system) <4>: Reset member `cr_carryover'.
Kenichi Handa <handa@m17n.org>
parents:
29663
diff
changeset
|
4758 { |
2bc397e9b09a
(setup_coding_system) <4>: Reset member `cr_carryover'.
Kenichi Handa <handa@m17n.org>
parents:
29663
diff
changeset
|
4759 /* Here, to avoid the call of setup_coding_system, we directly |
2bc397e9b09a
(setup_coding_system) <4>: Reset member `cr_carryover'.
Kenichi Handa <handa@m17n.org>
parents:
29663
diff
changeset
|
4760 call detect_eol_type. */ |
2bc397e9b09a
(setup_coding_system) <4>: Reset member `cr_carryover'.
Kenichi Handa <handa@m17n.org>
parents:
29663
diff
changeset
|
4761 coding->eol_type = detect_eol_type (ptr, bytes, &dummy); |
29877
7b43e1fb478a
(decode_eol_post_ccl): Special handling for undecided
Eli Zaretskii <eliz@gnu.org>
parents:
29725
diff
changeset
|
4762 if (coding->eol_type == CODING_EOL_INCONSISTENT) |
7b43e1fb478a
(decode_eol_post_ccl): Special handling for undecided
Eli Zaretskii <eliz@gnu.org>
parents:
29725
diff
changeset
|
4763 coding->eol_type = CODING_EOL_LF; |
7b43e1fb478a
(decode_eol_post_ccl): Special handling for undecided
Eli Zaretskii <eliz@gnu.org>
parents:
29725
diff
changeset
|
4764 if (coding->eol_type != CODING_EOL_UNDECIDED) |
7b43e1fb478a
(decode_eol_post_ccl): Special handling for undecided
Eli Zaretskii <eliz@gnu.org>
parents:
29725
diff
changeset
|
4765 { |
7b43e1fb478a
(decode_eol_post_ccl): Special handling for undecided
Eli Zaretskii <eliz@gnu.org>
parents:
29725
diff
changeset
|
4766 val = Fget (coding->symbol, Qeol_type); |
7b43e1fb478a
(decode_eol_post_ccl): Special handling for undecided
Eli Zaretskii <eliz@gnu.org>
parents:
29725
diff
changeset
|
4767 if (VECTORP (val) && XVECTOR (val)->size == 3) |
7b43e1fb478a
(decode_eol_post_ccl): Special handling for undecided
Eli Zaretskii <eliz@gnu.org>
parents:
29725
diff
changeset
|
4768 coding->symbol = XVECTOR (val)->contents[coding->eol_type]; |
7b43e1fb478a
(decode_eol_post_ccl): Special handling for undecided
Eli Zaretskii <eliz@gnu.org>
parents:
29725
diff
changeset
|
4769 } |
29725
2bc397e9b09a
(setup_coding_system) <4>: Reset member `cr_carryover'.
Kenichi Handa <handa@m17n.org>
parents:
29663
diff
changeset
|
4770 coding->mode |= CODING_MODE_INHIBIT_INCONSISTENT_EOL; |
2bc397e9b09a
(setup_coding_system) <4>: Reset member `cr_carryover'.
Kenichi Handa <handa@m17n.org>
parents:
29663
diff
changeset
|
4771 } |
2bc397e9b09a
(setup_coding_system) <4>: Reset member `cr_carryover'.
Kenichi Handa <handa@m17n.org>
parents:
29663
diff
changeset
|
4772 |
29877
7b43e1fb478a
(decode_eol_post_ccl): Special handling for undecided
Eli Zaretskii <eliz@gnu.org>
parents:
29725
diff
changeset
|
4773 if (coding->eol_type == CODING_EOL_LF |
7b43e1fb478a
(decode_eol_post_ccl): Special handling for undecided
Eli Zaretskii <eliz@gnu.org>
parents:
29725
diff
changeset
|
4774 || coding->eol_type == CODING_EOL_UNDECIDED) |
29725
2bc397e9b09a
(setup_coding_system) <4>: Reset member `cr_carryover'.
Kenichi Handa <handa@m17n.org>
parents:
29663
diff
changeset
|
4775 { |
2bc397e9b09a
(setup_coding_system) <4>: Reset member `cr_carryover'.
Kenichi Handa <handa@m17n.org>
parents:
29663
diff
changeset
|
4776 /* We have nothing to do. */ |
2bc397e9b09a
(setup_coding_system) <4>: Reset member `cr_carryover'.
Kenichi Handa <handa@m17n.org>
parents:
29663
diff
changeset
|
4777 ptr = pend; |
2bc397e9b09a
(setup_coding_system) <4>: Reset member `cr_carryover'.
Kenichi Handa <handa@m17n.org>
parents:
29663
diff
changeset
|
4778 } |
2bc397e9b09a
(setup_coding_system) <4>: Reset member `cr_carryover'.
Kenichi Handa <handa@m17n.org>
parents:
29663
diff
changeset
|
4779 else if (coding->eol_type == CODING_EOL_CRLF) |
2bc397e9b09a
(setup_coding_system) <4>: Reset member `cr_carryover'.
Kenichi Handa <handa@m17n.org>
parents:
29663
diff
changeset
|
4780 { |
2bc397e9b09a
(setup_coding_system) <4>: Reset member `cr_carryover'.
Kenichi Handa <handa@m17n.org>
parents:
29663
diff
changeset
|
4781 unsigned char *pstart = ptr, *p = ptr; |
2bc397e9b09a
(setup_coding_system) <4>: Reset member `cr_carryover'.
Kenichi Handa <handa@m17n.org>
parents:
29663
diff
changeset
|
4782 |
2bc397e9b09a
(setup_coding_system) <4>: Reset member `cr_carryover'.
Kenichi Handa <handa@m17n.org>
parents:
29663
diff
changeset
|
4783 if (! (coding->mode & CODING_MODE_LAST_BLOCK) |
2bc397e9b09a
(setup_coding_system) <4>: Reset member `cr_carryover'.
Kenichi Handa <handa@m17n.org>
parents:
29663
diff
changeset
|
4784 && *(pend - 1) == '\r') |
2bc397e9b09a
(setup_coding_system) <4>: Reset member `cr_carryover'.
Kenichi Handa <handa@m17n.org>
parents:
29663
diff
changeset
|
4785 { |
2bc397e9b09a
(setup_coding_system) <4>: Reset member `cr_carryover'.
Kenichi Handa <handa@m17n.org>
parents:
29663
diff
changeset
|
4786 /* If the last character is CR, we can't handle it here |
2bc397e9b09a
(setup_coding_system) <4>: Reset member `cr_carryover'.
Kenichi Handa <handa@m17n.org>
parents:
29663
diff
changeset
|
4787 because LF will be in the not-yet-decoded source text. |
45239
6a20d4c6bb78
(decode_coding) <coding_type_ccl>: If a lone CR
Eli Zaretskii <eliz@gnu.org>
parents:
45237
diff
changeset
|
4788 Record that the CR is not yet processed. */ |
29725
2bc397e9b09a
(setup_coding_system) <4>: Reset member `cr_carryover'.
Kenichi Handa <handa@m17n.org>
parents:
29663
diff
changeset
|
4789 coding->spec.ccl.cr_carryover = 1; |
2bc397e9b09a
(setup_coding_system) <4>: Reset member `cr_carryover'.
Kenichi Handa <handa@m17n.org>
parents:
29663
diff
changeset
|
4790 coding->produced--; |
2bc397e9b09a
(setup_coding_system) <4>: Reset member `cr_carryover'.
Kenichi Handa <handa@m17n.org>
parents:
29663
diff
changeset
|
4791 coding->produced_char--; |
2bc397e9b09a
(setup_coding_system) <4>: Reset member `cr_carryover'.
Kenichi Handa <handa@m17n.org>
parents:
29663
diff
changeset
|
4792 pend--; |
2bc397e9b09a
(setup_coding_system) <4>: Reset member `cr_carryover'.
Kenichi Handa <handa@m17n.org>
parents:
29663
diff
changeset
|
4793 } |
2bc397e9b09a
(setup_coding_system) <4>: Reset member `cr_carryover'.
Kenichi Handa <handa@m17n.org>
parents:
29663
diff
changeset
|
4794 while (ptr < pend) |
2bc397e9b09a
(setup_coding_system) <4>: Reset member `cr_carryover'.
Kenichi Handa <handa@m17n.org>
parents:
29663
diff
changeset
|
4795 { |
2bc397e9b09a
(setup_coding_system) <4>: Reset member `cr_carryover'.
Kenichi Handa <handa@m17n.org>
parents:
29663
diff
changeset
|
4796 if (*ptr == '\r') |
2bc397e9b09a
(setup_coding_system) <4>: Reset member `cr_carryover'.
Kenichi Handa <handa@m17n.org>
parents:
29663
diff
changeset
|
4797 { |
2bc397e9b09a
(setup_coding_system) <4>: Reset member `cr_carryover'.
Kenichi Handa <handa@m17n.org>
parents:
29663
diff
changeset
|
4798 if (ptr + 1 < pend && *(ptr + 1) == '\n') |
2bc397e9b09a
(setup_coding_system) <4>: Reset member `cr_carryover'.
Kenichi Handa <handa@m17n.org>
parents:
29663
diff
changeset
|
4799 { |
2bc397e9b09a
(setup_coding_system) <4>: Reset member `cr_carryover'.
Kenichi Handa <handa@m17n.org>
parents:
29663
diff
changeset
|
4800 *p++ = '\n'; |
2bc397e9b09a
(setup_coding_system) <4>: Reset member `cr_carryover'.
Kenichi Handa <handa@m17n.org>
parents:
29663
diff
changeset
|
4801 ptr += 2; |
2bc397e9b09a
(setup_coding_system) <4>: Reset member `cr_carryover'.
Kenichi Handa <handa@m17n.org>
parents:
29663
diff
changeset
|
4802 } |
2bc397e9b09a
(setup_coding_system) <4>: Reset member `cr_carryover'.
Kenichi Handa <handa@m17n.org>
parents:
29663
diff
changeset
|
4803 else |
2bc397e9b09a
(setup_coding_system) <4>: Reset member `cr_carryover'.
Kenichi Handa <handa@m17n.org>
parents:
29663
diff
changeset
|
4804 { |
2bc397e9b09a
(setup_coding_system) <4>: Reset member `cr_carryover'.
Kenichi Handa <handa@m17n.org>
parents:
29663
diff
changeset
|
4805 if (coding->mode & CODING_MODE_INHIBIT_INCONSISTENT_EOL) |
2bc397e9b09a
(setup_coding_system) <4>: Reset member `cr_carryover'.
Kenichi Handa <handa@m17n.org>
parents:
29663
diff
changeset
|
4806 goto undo_eol_conversion; |
2bc397e9b09a
(setup_coding_system) <4>: Reset member `cr_carryover'.
Kenichi Handa <handa@m17n.org>
parents:
29663
diff
changeset
|
4807 *p++ = *ptr++; |
2bc397e9b09a
(setup_coding_system) <4>: Reset member `cr_carryover'.
Kenichi Handa <handa@m17n.org>
parents:
29663
diff
changeset
|
4808 } |
2bc397e9b09a
(setup_coding_system) <4>: Reset member `cr_carryover'.
Kenichi Handa <handa@m17n.org>
parents:
29663
diff
changeset
|
4809 } |
2bc397e9b09a
(setup_coding_system) <4>: Reset member `cr_carryover'.
Kenichi Handa <handa@m17n.org>
parents:
29663
diff
changeset
|
4810 else if (*ptr == '\n' |
2bc397e9b09a
(setup_coding_system) <4>: Reset member `cr_carryover'.
Kenichi Handa <handa@m17n.org>
parents:
29663
diff
changeset
|
4811 && coding->mode & CODING_MODE_INHIBIT_INCONSISTENT_EOL) |
2bc397e9b09a
(setup_coding_system) <4>: Reset member `cr_carryover'.
Kenichi Handa <handa@m17n.org>
parents:
29663
diff
changeset
|
4812 goto undo_eol_conversion; |
2bc397e9b09a
(setup_coding_system) <4>: Reset member `cr_carryover'.
Kenichi Handa <handa@m17n.org>
parents:
29663
diff
changeset
|
4813 else |
2bc397e9b09a
(setup_coding_system) <4>: Reset member `cr_carryover'.
Kenichi Handa <handa@m17n.org>
parents:
29663
diff
changeset
|
4814 *p++ = *ptr++; |
2bc397e9b09a
(setup_coding_system) <4>: Reset member `cr_carryover'.
Kenichi Handa <handa@m17n.org>
parents:
29663
diff
changeset
|
4815 continue; |
2bc397e9b09a
(setup_coding_system) <4>: Reset member `cr_carryover'.
Kenichi Handa <handa@m17n.org>
parents:
29663
diff
changeset
|
4816 |
2bc397e9b09a
(setup_coding_system) <4>: Reset member `cr_carryover'.
Kenichi Handa <handa@m17n.org>
parents:
29663
diff
changeset
|
4817 undo_eol_conversion: |
2bc397e9b09a
(setup_coding_system) <4>: Reset member `cr_carryover'.
Kenichi Handa <handa@m17n.org>
parents:
29663
diff
changeset
|
4818 /* We have faced with inconsistent EOL format at PTR. |
2bc397e9b09a
(setup_coding_system) <4>: Reset member `cr_carryover'.
Kenichi Handa <handa@m17n.org>
parents:
29663
diff
changeset
|
4819 Convert all LFs before PTR back to CRLFs. */ |
2bc397e9b09a
(setup_coding_system) <4>: Reset member `cr_carryover'.
Kenichi Handa <handa@m17n.org>
parents:
29663
diff
changeset
|
4820 for (p--, ptr--; p >= pstart; p--) |
2bc397e9b09a
(setup_coding_system) <4>: Reset member `cr_carryover'.
Kenichi Handa <handa@m17n.org>
parents:
29663
diff
changeset
|
4821 { |
2bc397e9b09a
(setup_coding_system) <4>: Reset member `cr_carryover'.
Kenichi Handa <handa@m17n.org>
parents:
29663
diff
changeset
|
4822 if (*p == '\n') |
2bc397e9b09a
(setup_coding_system) <4>: Reset member `cr_carryover'.
Kenichi Handa <handa@m17n.org>
parents:
29663
diff
changeset
|
4823 *ptr-- = '\n', *ptr-- = '\r'; |
2bc397e9b09a
(setup_coding_system) <4>: Reset member `cr_carryover'.
Kenichi Handa <handa@m17n.org>
parents:
29663
diff
changeset
|
4824 else |
2bc397e9b09a
(setup_coding_system) <4>: Reset member `cr_carryover'.
Kenichi Handa <handa@m17n.org>
parents:
29663
diff
changeset
|
4825 *ptr-- = *p; |
2bc397e9b09a
(setup_coding_system) <4>: Reset member `cr_carryover'.
Kenichi Handa <handa@m17n.org>
parents:
29663
diff
changeset
|
4826 } |
2bc397e9b09a
(setup_coding_system) <4>: Reset member `cr_carryover'.
Kenichi Handa <handa@m17n.org>
parents:
29663
diff
changeset
|
4827 /* If carryover is recorded, cancel it because we don't |
2bc397e9b09a
(setup_coding_system) <4>: Reset member `cr_carryover'.
Kenichi Handa <handa@m17n.org>
parents:
29663
diff
changeset
|
4828 convert CRLF anymore. */ |
2bc397e9b09a
(setup_coding_system) <4>: Reset member `cr_carryover'.
Kenichi Handa <handa@m17n.org>
parents:
29663
diff
changeset
|
4829 if (coding->spec.ccl.cr_carryover) |
2bc397e9b09a
(setup_coding_system) <4>: Reset member `cr_carryover'.
Kenichi Handa <handa@m17n.org>
parents:
29663
diff
changeset
|
4830 { |
2bc397e9b09a
(setup_coding_system) <4>: Reset member `cr_carryover'.
Kenichi Handa <handa@m17n.org>
parents:
29663
diff
changeset
|
4831 coding->spec.ccl.cr_carryover = 0; |
2bc397e9b09a
(setup_coding_system) <4>: Reset member `cr_carryover'.
Kenichi Handa <handa@m17n.org>
parents:
29663
diff
changeset
|
4832 coding->produced++; |
2bc397e9b09a
(setup_coding_system) <4>: Reset member `cr_carryover'.
Kenichi Handa <handa@m17n.org>
parents:
29663
diff
changeset
|
4833 coding->produced_char++; |
2bc397e9b09a
(setup_coding_system) <4>: Reset member `cr_carryover'.
Kenichi Handa <handa@m17n.org>
parents:
29663
diff
changeset
|
4834 pend++; |
2bc397e9b09a
(setup_coding_system) <4>: Reset member `cr_carryover'.
Kenichi Handa <handa@m17n.org>
parents:
29663
diff
changeset
|
4835 } |
2bc397e9b09a
(setup_coding_system) <4>: Reset member `cr_carryover'.
Kenichi Handa <handa@m17n.org>
parents:
29663
diff
changeset
|
4836 p = ptr = pend; |
2bc397e9b09a
(setup_coding_system) <4>: Reset member `cr_carryover'.
Kenichi Handa <handa@m17n.org>
parents:
29663
diff
changeset
|
4837 coding->eol_type = CODING_EOL_LF; |
2bc397e9b09a
(setup_coding_system) <4>: Reset member `cr_carryover'.
Kenichi Handa <handa@m17n.org>
parents:
29663
diff
changeset
|
4838 coding->symbol = saved_coding_symbol; |
2bc397e9b09a
(setup_coding_system) <4>: Reset member `cr_carryover'.
Kenichi Handa <handa@m17n.org>
parents:
29663
diff
changeset
|
4839 } |
2bc397e9b09a
(setup_coding_system) <4>: Reset member `cr_carryover'.
Kenichi Handa <handa@m17n.org>
parents:
29663
diff
changeset
|
4840 if (p < pend) |
2bc397e9b09a
(setup_coding_system) <4>: Reset member `cr_carryover'.
Kenichi Handa <handa@m17n.org>
parents:
29663
diff
changeset
|
4841 { |
2bc397e9b09a
(setup_coding_system) <4>: Reset member `cr_carryover'.
Kenichi Handa <handa@m17n.org>
parents:
29663
diff
changeset
|
4842 /* As each two-byte sequence CRLF was converted to LF, (PEND |
2bc397e9b09a
(setup_coding_system) <4>: Reset member `cr_carryover'.
Kenichi Handa <handa@m17n.org>
parents:
29663
diff
changeset
|
4843 - P) is the number of deleted characters. */ |
2bc397e9b09a
(setup_coding_system) <4>: Reset member `cr_carryover'.
Kenichi Handa <handa@m17n.org>
parents:
29663
diff
changeset
|
4844 coding->produced -= pend - p; |
2bc397e9b09a
(setup_coding_system) <4>: Reset member `cr_carryover'.
Kenichi Handa <handa@m17n.org>
parents:
29663
diff
changeset
|
4845 coding->produced_char -= pend - p; |
2bc397e9b09a
(setup_coding_system) <4>: Reset member `cr_carryover'.
Kenichi Handa <handa@m17n.org>
parents:
29663
diff
changeset
|
4846 } |
2bc397e9b09a
(setup_coding_system) <4>: Reset member `cr_carryover'.
Kenichi Handa <handa@m17n.org>
parents:
29663
diff
changeset
|
4847 } |
2bc397e9b09a
(setup_coding_system) <4>: Reset member `cr_carryover'.
Kenichi Handa <handa@m17n.org>
parents:
29663
diff
changeset
|
4848 else /* i.e. coding->eol_type == CODING_EOL_CR */ |
2bc397e9b09a
(setup_coding_system) <4>: Reset member `cr_carryover'.
Kenichi Handa <handa@m17n.org>
parents:
29663
diff
changeset
|
4849 { |
2bc397e9b09a
(setup_coding_system) <4>: Reset member `cr_carryover'.
Kenichi Handa <handa@m17n.org>
parents:
29663
diff
changeset
|
4850 unsigned char *p = ptr; |
2bc397e9b09a
(setup_coding_system) <4>: Reset member `cr_carryover'.
Kenichi Handa <handa@m17n.org>
parents:
29663
diff
changeset
|
4851 |
2bc397e9b09a
(setup_coding_system) <4>: Reset member `cr_carryover'.
Kenichi Handa <handa@m17n.org>
parents:
29663
diff
changeset
|
4852 for (; ptr < pend; ptr++) |
2bc397e9b09a
(setup_coding_system) <4>: Reset member `cr_carryover'.
Kenichi Handa <handa@m17n.org>
parents:
29663
diff
changeset
|
4853 { |
2bc397e9b09a
(setup_coding_system) <4>: Reset member `cr_carryover'.
Kenichi Handa <handa@m17n.org>
parents:
29663
diff
changeset
|
4854 if (*ptr == '\r') |
2bc397e9b09a
(setup_coding_system) <4>: Reset member `cr_carryover'.
Kenichi Handa <handa@m17n.org>
parents:
29663
diff
changeset
|
4855 *ptr = '\n'; |
2bc397e9b09a
(setup_coding_system) <4>: Reset member `cr_carryover'.
Kenichi Handa <handa@m17n.org>
parents:
29663
diff
changeset
|
4856 else if (*ptr == '\n' |
2bc397e9b09a
(setup_coding_system) <4>: Reset member `cr_carryover'.
Kenichi Handa <handa@m17n.org>
parents:
29663
diff
changeset
|
4857 && coding->mode & CODING_MODE_INHIBIT_INCONSISTENT_EOL) |
2bc397e9b09a
(setup_coding_system) <4>: Reset member `cr_carryover'.
Kenichi Handa <handa@m17n.org>
parents:
29663
diff
changeset
|
4858 { |
2bc397e9b09a
(setup_coding_system) <4>: Reset member `cr_carryover'.
Kenichi Handa <handa@m17n.org>
parents:
29663
diff
changeset
|
4859 for (; p < ptr; p++) |
2bc397e9b09a
(setup_coding_system) <4>: Reset member `cr_carryover'.
Kenichi Handa <handa@m17n.org>
parents:
29663
diff
changeset
|
4860 { |
2bc397e9b09a
(setup_coding_system) <4>: Reset member `cr_carryover'.
Kenichi Handa <handa@m17n.org>
parents:
29663
diff
changeset
|
4861 if (*p == '\n') |
2bc397e9b09a
(setup_coding_system) <4>: Reset member `cr_carryover'.
Kenichi Handa <handa@m17n.org>
parents:
29663
diff
changeset
|
4862 *p = '\r'; |
2bc397e9b09a
(setup_coding_system) <4>: Reset member `cr_carryover'.
Kenichi Handa <handa@m17n.org>
parents:
29663
diff
changeset
|
4863 } |
2bc397e9b09a
(setup_coding_system) <4>: Reset member `cr_carryover'.
Kenichi Handa <handa@m17n.org>
parents:
29663
diff
changeset
|
4864 ptr = pend; |
2bc397e9b09a
(setup_coding_system) <4>: Reset member `cr_carryover'.
Kenichi Handa <handa@m17n.org>
parents:
29663
diff
changeset
|
4865 coding->eol_type = CODING_EOL_LF; |
2bc397e9b09a
(setup_coding_system) <4>: Reset member `cr_carryover'.
Kenichi Handa <handa@m17n.org>
parents:
29663
diff
changeset
|
4866 coding->symbol = saved_coding_symbol; |
2bc397e9b09a
(setup_coding_system) <4>: Reset member `cr_carryover'.
Kenichi Handa <handa@m17n.org>
parents:
29663
diff
changeset
|
4867 } |
2bc397e9b09a
(setup_coding_system) <4>: Reset member `cr_carryover'.
Kenichi Handa <handa@m17n.org>
parents:
29663
diff
changeset
|
4868 } |
2bc397e9b09a
(setup_coding_system) <4>: Reset member `cr_carryover'.
Kenichi Handa <handa@m17n.org>
parents:
29663
diff
changeset
|
4869 } |
2bc397e9b09a
(setup_coding_system) <4>: Reset member `cr_carryover'.
Kenichi Handa <handa@m17n.org>
parents:
29663
diff
changeset
|
4870 } |
2bc397e9b09a
(setup_coding_system) <4>: Reset member `cr_carryover'.
Kenichi Handa <handa@m17n.org>
parents:
29663
diff
changeset
|
4871 |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4872 /* See "GENERAL NOTES about `decode_coding_XXX ()' functions". Before |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4873 decoding, it may detect coding system and format of end-of-line if |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4874 those are not yet decided. The source should be unibyte, the |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4875 result is multibyte if CODING->dst_multibyte is nonzero, else |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4876 unibyte. */ |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4877 |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4878 int |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4879 decode_coding (coding, source, destination, src_bytes, dst_bytes) |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4880 struct coding_system *coding; |
59173
2eadf4401d2d
(decode_coding): Fix previous change.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
59168
diff
changeset
|
4881 const unsigned char *source; |
46548
cb1914307488
(encode_eol, detect_coding, detect_eol):
Ken Raeburn <raeburn@raeburn.org>
parents:
46462
diff
changeset
|
4882 unsigned char *destination; |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4883 int src_bytes, dst_bytes; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4884 { |
45239
6a20d4c6bb78
(decode_coding) <coding_type_ccl>: If a lone CR
Eli Zaretskii <eliz@gnu.org>
parents:
45237
diff
changeset
|
4885 int extra = 0; |
6a20d4c6bb78
(decode_coding) <coding_type_ccl>: If a lone CR
Eli Zaretskii <eliz@gnu.org>
parents:
45237
diff
changeset
|
4886 |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4887 if (coding->type == coding_type_undecided) |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4888 detect_coding (coding, source, src_bytes); |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4889 |
29725
2bc397e9b09a
(setup_coding_system) <4>: Reset member `cr_carryover'.
Kenichi Handa <handa@m17n.org>
parents:
29663
diff
changeset
|
4890 if (coding->eol_type == CODING_EOL_UNDECIDED |
2bc397e9b09a
(setup_coding_system) <4>: Reset member `cr_carryover'.
Kenichi Handa <handa@m17n.org>
parents:
29663
diff
changeset
|
4891 && coding->type != coding_type_ccl) |
35587
7e767148cfdc
(decode_coding): Set a flag for inhibiting
Kenichi Handa <handa@m17n.org>
parents:
35531
diff
changeset
|
4892 { |
7e767148cfdc
(decode_coding): Set a flag for inhibiting
Kenichi Handa <handa@m17n.org>
parents:
35531
diff
changeset
|
4893 detect_eol (coding, source, src_bytes); |
7e767148cfdc
(decode_coding): Set a flag for inhibiting
Kenichi Handa <handa@m17n.org>
parents:
35531
diff
changeset
|
4894 /* We had better recover the original eol format if we |
36087 | 4895 encounter an inconsistent eol format while decoding. */ |
35587
7e767148cfdc
(decode_coding): Set a flag for inhibiting
Kenichi Handa <handa@m17n.org>
parents:
35531
diff
changeset
|
4896 coding->mode |= CODING_MODE_INHIBIT_INCONSISTENT_EOL; |
7e767148cfdc
(decode_coding): Set a flag for inhibiting
Kenichi Handa <handa@m17n.org>
parents:
35531
diff
changeset
|
4897 } |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4898 |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4899 coding->produced = coding->produced_char = 0; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4900 coding->consumed = coding->consumed_char = 0; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4901 coding->errors = 0; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4902 coding->result = CODING_FINISH_NORMAL; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4903 |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4904 switch (coding->type) |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4905 { |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4906 case coding_type_sjis: |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4907 decode_coding_sjis_big5 (coding, source, destination, |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4908 src_bytes, dst_bytes, 1); |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4909 break; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4910 |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4911 case coding_type_iso2022: |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4912 decode_coding_iso2022 (coding, source, destination, |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4913 src_bytes, dst_bytes); |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4914 break; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4915 |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4916 case coding_type_big5: |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4917 decode_coding_sjis_big5 (coding, source, destination, |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4918 src_bytes, dst_bytes, 0); |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4919 break; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4920 |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4921 case coding_type_emacs_mule: |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4922 decode_coding_emacs_mule (coding, source, destination, |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4923 src_bytes, dst_bytes); |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4924 break; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4925 |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4926 case coding_type_ccl: |
29725
2bc397e9b09a
(setup_coding_system) <4>: Reset member `cr_carryover'.
Kenichi Handa <handa@m17n.org>
parents:
29663
diff
changeset
|
4927 if (coding->spec.ccl.cr_carryover) |
2bc397e9b09a
(setup_coding_system) <4>: Reset member `cr_carryover'.
Kenichi Handa <handa@m17n.org>
parents:
29663
diff
changeset
|
4928 { |
45239
6a20d4c6bb78
(decode_coding) <coding_type_ccl>: If a lone CR
Eli Zaretskii <eliz@gnu.org>
parents:
45237
diff
changeset
|
4929 /* Put the CR which was not processed by the previous call |
6a20d4c6bb78
(decode_coding) <coding_type_ccl>: If a lone CR
Eli Zaretskii <eliz@gnu.org>
parents:
45237
diff
changeset
|
4930 of decode_eol_post_ccl in DESTINATION. It will be |
6a20d4c6bb78
(decode_coding) <coding_type_ccl>: If a lone CR
Eli Zaretskii <eliz@gnu.org>
parents:
45237
diff
changeset
|
4931 decoded together with the following LF by the call to |
6a20d4c6bb78
(decode_coding) <coding_type_ccl>: If a lone CR
Eli Zaretskii <eliz@gnu.org>
parents:
45237
diff
changeset
|
4932 decode_eol_post_ccl below. */ |
29725
2bc397e9b09a
(setup_coding_system) <4>: Reset member `cr_carryover'.
Kenichi Handa <handa@m17n.org>
parents:
29663
diff
changeset
|
4933 *destination = '\r'; |
2bc397e9b09a
(setup_coding_system) <4>: Reset member `cr_carryover'.
Kenichi Handa <handa@m17n.org>
parents:
29663
diff
changeset
|
4934 coding->produced++; |
2bc397e9b09a
(setup_coding_system) <4>: Reset member `cr_carryover'.
Kenichi Handa <handa@m17n.org>
parents:
29663
diff
changeset
|
4935 coding->produced_char++; |
2bc397e9b09a
(setup_coding_system) <4>: Reset member `cr_carryover'.
Kenichi Handa <handa@m17n.org>
parents:
29663
diff
changeset
|
4936 dst_bytes--; |
45239
6a20d4c6bb78
(decode_coding) <coding_type_ccl>: If a lone CR
Eli Zaretskii <eliz@gnu.org>
parents:
45237
diff
changeset
|
4937 extra = coding->spec.ccl.cr_carryover; |
29725
2bc397e9b09a
(setup_coding_system) <4>: Reset member `cr_carryover'.
Kenichi Handa <handa@m17n.org>
parents:
29663
diff
changeset
|
4938 } |
45239
6a20d4c6bb78
(decode_coding) <coding_type_ccl>: If a lone CR
Eli Zaretskii <eliz@gnu.org>
parents:
45237
diff
changeset
|
4939 ccl_coding_driver (coding, source, destination + extra, |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4940 src_bytes, dst_bytes, 0); |
29725
2bc397e9b09a
(setup_coding_system) <4>: Reset member `cr_carryover'.
Kenichi Handa <handa@m17n.org>
parents:
29663
diff
changeset
|
4941 if (coding->eol_type != CODING_EOL_LF) |
45239
6a20d4c6bb78
(decode_coding) <coding_type_ccl>: If a lone CR
Eli Zaretskii <eliz@gnu.org>
parents:
45237
diff
changeset
|
4942 { |
6a20d4c6bb78
(decode_coding) <coding_type_ccl>: If a lone CR
Eli Zaretskii <eliz@gnu.org>
parents:
45237
diff
changeset
|
4943 coding->produced += extra; |
6a20d4c6bb78
(decode_coding) <coding_type_ccl>: If a lone CR
Eli Zaretskii <eliz@gnu.org>
parents:
45237
diff
changeset
|
4944 coding->produced_char += extra; |
6a20d4c6bb78
(decode_coding) <coding_type_ccl>: If a lone CR
Eli Zaretskii <eliz@gnu.org>
parents:
45237
diff
changeset
|
4945 decode_eol_post_ccl (coding, destination, coding->produced); |
6a20d4c6bb78
(decode_coding) <coding_type_ccl>: If a lone CR
Eli Zaretskii <eliz@gnu.org>
parents:
45237
diff
changeset
|
4946 } |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4947 break; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4948 |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4949 default: |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4950 decode_eol (coding, source, destination, src_bytes, dst_bytes); |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4951 } |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4952 |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4953 if (coding->result == CODING_FINISH_INSUFFICIENT_SRC |
32896
3d8fb019040f
(decode_coding): Fix previous change (check also
Kenichi Handa <handa@m17n.org>
parents:
32806
diff
changeset
|
4954 && coding->mode & CODING_MODE_LAST_BLOCK |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4955 && coding->consumed == src_bytes) |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4956 coding->result = CODING_FINISH_NORMAL; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4957 |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4958 if (coding->mode & CODING_MODE_LAST_BLOCK |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4959 && coding->result == CODING_FINISH_INSUFFICIENT_SRC) |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4960 { |
46548
cb1914307488
(encode_eol, detect_coding, detect_eol):
Ken Raeburn <raeburn@raeburn.org>
parents:
46462
diff
changeset
|
4961 const unsigned char *src = source + coding->consumed; |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4962 unsigned char *dst = destination + coding->produced; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4963 |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4964 src_bytes -= coding->consumed; |
30847
91e24edb537a
(encode_coding): Fix the bug of not flushing ISO escape sequence at
Kenichi Handa <handa@m17n.org>
parents:
30833
diff
changeset
|
4965 coding->errors++; |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4966 if (COMPOSING_P (coding)) |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4967 DECODE_COMPOSITION_END ('1'); |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4968 while (src_bytes--) |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4969 { |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4970 int c = *src++; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4971 dst += CHAR_STRING (c, dst); |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4972 coding->produced_char++; |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4973 } |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4974 coding->consumed = coding->consumed_char = src - source; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4975 coding->produced = dst - destination; |
30833
2db6e42a6ba3
(MINIMUM_CONVERSION_BUFFER_SIZE): Macro deleted.
Kenichi Handa <handa@m17n.org>
parents:
30756
diff
changeset
|
4976 coding->result = CODING_FINISH_NORMAL; |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4977 } |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4978 |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4979 if (!coding->dst_multibyte) |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4980 { |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4981 coding->produced = str_as_unibyte (destination, coding->produced); |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4982 coding->produced_char = coding->produced; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4983 } |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4984 |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4985 return coding->result; |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4986 } |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4987 |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4988 /* See "GENERAL NOTES about `encode_coding_XXX ()' functions". The |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4989 multibyteness of the source is CODING->src_multibyte, the |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4990 multibyteness of the result is always unibyte. */ |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4991 |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4992 int |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4993 encode_coding (coding, source, destination, src_bytes, dst_bytes) |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4994 struct coding_system *coding; |
46548
cb1914307488
(encode_eol, detect_coding, detect_eol):
Ken Raeburn <raeburn@raeburn.org>
parents:
46462
diff
changeset
|
4995 const unsigned char *source; |
cb1914307488
(encode_eol, detect_coding, detect_eol):
Ken Raeburn <raeburn@raeburn.org>
parents:
46462
diff
changeset
|
4996 unsigned char *destination; |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4997 int src_bytes, dst_bytes; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4998 { |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4999 coding->produced = coding->produced_char = 0; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5000 coding->consumed = coding->consumed_char = 0; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5001 coding->errors = 0; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5002 coding->result = CODING_FINISH_NORMAL; |
69991
c0ec9365428f
(encode_coding): If eol_type is not yet decided, use
Kenichi Handa <handa@m17n.org>
parents:
69989
diff
changeset
|
5003 if (coding->eol_type == CODING_EOL_UNDECIDED) |
70520
b6740a317343
(setup_coding_system): For invalid coding-system, set
Kenichi Handa <handa@m17n.org>
parents:
69995
diff
changeset
|
5004 coding->eol_type = CODING_EOL_LF; |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5005 |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5006 switch (coding->type) |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5007 { |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5008 case coding_type_sjis: |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5009 encode_coding_sjis_big5 (coding, source, destination, |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5010 src_bytes, dst_bytes, 1); |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5011 break; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5012 |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5013 case coding_type_iso2022: |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5014 encode_coding_iso2022 (coding, source, destination, |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5015 src_bytes, dst_bytes); |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5016 break; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5017 |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5018 case coding_type_big5: |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5019 encode_coding_sjis_big5 (coding, source, destination, |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5020 src_bytes, dst_bytes, 0); |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5021 break; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5022 |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5023 case coding_type_emacs_mule: |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5024 encode_coding_emacs_mule (coding, source, destination, |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5025 src_bytes, dst_bytes); |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5026 break; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5027 |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5028 case coding_type_ccl: |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5029 ccl_coding_driver (coding, source, destination, |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5030 src_bytes, dst_bytes, 1); |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5031 break; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5032 |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5033 default: |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5034 encode_eol (coding, source, destination, src_bytes, dst_bytes); |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5035 } |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5036 |
30833
2db6e42a6ba3
(MINIMUM_CONVERSION_BUFFER_SIZE): Macro deleted.
Kenichi Handa <handa@m17n.org>
parents:
30756
diff
changeset
|
5037 if (coding->mode & CODING_MODE_LAST_BLOCK |
2db6e42a6ba3
(MINIMUM_CONVERSION_BUFFER_SIZE): Macro deleted.
Kenichi Handa <handa@m17n.org>
parents:
30756
diff
changeset
|
5038 && coding->result == CODING_FINISH_INSUFFICIENT_SRC) |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5039 { |
46548
cb1914307488
(encode_eol, detect_coding, detect_eol):
Ken Raeburn <raeburn@raeburn.org>
parents:
46462
diff
changeset
|
5040 const unsigned char *src = source + coding->consumed; |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5041 unsigned char *dst = destination + coding->produced; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5042 |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5043 if (coding->type == coding_type_iso2022) |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5044 ENCODE_RESET_PLANE_AND_REGISTER; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5045 if (COMPOSING_P (coding)) |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5046 *dst++ = ISO_CODE_ESC, *dst++ = '1'; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5047 if (coding->consumed < src_bytes) |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5048 { |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5049 int len = src_bytes - coding->consumed; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5050 |
40842
27fa759cd153
(encode_coding): Use precomputed value of `src'.
Pavel Janík <Pavel@Janik.cz>
parents:
40713
diff
changeset
|
5051 BCOPY_SHORT (src, dst, len); |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5052 if (coding->src_multibyte) |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5053 len = str_as_unibyte (dst, len); |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5054 dst += len; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5055 coding->consumed = src_bytes; |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5056 } |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5057 coding->produced = coding->produced_char = dst - destination; |
30833
2db6e42a6ba3
(MINIMUM_CONVERSION_BUFFER_SIZE): Macro deleted.
Kenichi Handa <handa@m17n.org>
parents:
30756
diff
changeset
|
5058 coding->result = CODING_FINISH_NORMAL; |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5059 } |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5060 |
30847
91e24edb537a
(encode_coding): Fix the bug of not flushing ISO escape sequence at
Kenichi Handa <handa@m17n.org>
parents:
30833
diff
changeset
|
5061 if (coding->result == CODING_FINISH_INSUFFICIENT_SRC |
91e24edb537a
(encode_coding): Fix the bug of not flushing ISO escape sequence at
Kenichi Handa <handa@m17n.org>
parents:
30833
diff
changeset
|
5062 && coding->consumed == src_bytes) |
91e24edb537a
(encode_coding): Fix the bug of not flushing ISO escape sequence at
Kenichi Handa <handa@m17n.org>
parents:
30833
diff
changeset
|
5063 coding->result = CODING_FINISH_NORMAL; |
91e24edb537a
(encode_coding): Fix the bug of not flushing ISO escape sequence at
Kenichi Handa <handa@m17n.org>
parents:
30833
diff
changeset
|
5064 |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5065 return coding->result; |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5066 } |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5067 |
20931
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
5068 /* Scan text in the region between *BEG and *END (byte positions), |
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
5069 skip characters which we don't have to decode by coding system |
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
5070 CODING at the head and tail, then set *BEG and *END to the region |
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
5071 of the text we actually have to convert. The caller should move |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5072 the gap out of the region in advance if the region is from a |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5073 buffer. |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5074 |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5075 If STR is not NULL, *BEG and *END are indices into STR. */ |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5076 |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5077 static void |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5078 shrink_decoding_region (beg, end, coding, str) |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5079 int *beg, *end; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5080 struct coding_system *coding; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5081 unsigned char *str; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5082 { |
20931
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
5083 unsigned char *begp_orig, *begp, *endp_orig, *endp, c; |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5084 int eol_conversion; |
23339
2da87b489590
(check_composing_code): Fix previous change. Now it
Kenichi Handa <handa@m17n.org>
parents:
23325
diff
changeset
|
5085 Lisp_Object translation_table; |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5086 |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5087 if (coding->type == coding_type_ccl |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5088 || coding->type == coding_type_undecided |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5089 || coding->eol_type != CODING_EOL_LF |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5090 || !NILP (coding->post_read_conversion) |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5091 || coding->composing != COMPOSITION_DISABLED) |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5092 { |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5093 /* We can't skip any data. */ |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5094 return; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5095 } |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5096 if (coding->type == coding_type_no_conversion |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5097 || coding->type == coding_type_raw_text |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5098 || coding->type == coding_type_emacs_mule) |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5099 { |
20931
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
5100 /* We need no conversion, but don't have to skip any data here. |
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
5101 Decoding routine handles them effectively anyway. */ |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5102 return; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5103 } |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5104 |
23339
2da87b489590
(check_composing_code): Fix previous change. Now it
Kenichi Handa <handa@m17n.org>
parents:
23325
diff
changeset
|
5105 translation_table = coding->translation_table_for_decode; |
2da87b489590
(check_composing_code): Fix previous change. Now it
Kenichi Handa <handa@m17n.org>
parents:
23325
diff
changeset
|
5106 if (NILP (translation_table) && !NILP (Venable_character_translation)) |
2da87b489590
(check_composing_code): Fix previous change. Now it
Kenichi Handa <handa@m17n.org>
parents:
23325
diff
changeset
|
5107 translation_table = Vstandard_translation_table_for_decode; |
2da87b489590
(check_composing_code): Fix previous change. Now it
Kenichi Handa <handa@m17n.org>
parents:
23325
diff
changeset
|
5108 if (CHAR_TABLE_P (translation_table)) |
2da87b489590
(check_composing_code): Fix previous change. Now it
Kenichi Handa <handa@m17n.org>
parents:
23325
diff
changeset
|
5109 { |
2da87b489590
(check_composing_code): Fix previous change. Now it
Kenichi Handa <handa@m17n.org>
parents:
23325
diff
changeset
|
5110 int i; |
2da87b489590
(check_composing_code): Fix previous change. Now it
Kenichi Handa <handa@m17n.org>
parents:
23325
diff
changeset
|
5111 for (i = 0; i < 128; i++) |
2da87b489590
(check_composing_code): Fix previous change. Now it
Kenichi Handa <handa@m17n.org>
parents:
23325
diff
changeset
|
5112 if (!NILP (CHAR_TABLE_REF (translation_table, i))) |
2da87b489590
(check_composing_code): Fix previous change. Now it
Kenichi Handa <handa@m17n.org>
parents:
23325
diff
changeset
|
5113 break; |
2da87b489590
(check_composing_code): Fix previous change. Now it
Kenichi Handa <handa@m17n.org>
parents:
23325
diff
changeset
|
5114 if (i < 128) |
29247
c748b4b1c785
(shrink_decoding_region): Initialize eol_conversion.
Dave Love <fx@gnu.org>
parents:
29184
diff
changeset
|
5115 /* Some ASCII character should be translated. We give up |
23339
2da87b489590
(check_composing_code): Fix previous change. Now it
Kenichi Handa <handa@m17n.org>
parents:
23325
diff
changeset
|
5116 shrinking. */ |
2da87b489590
(check_composing_code): Fix previous change. Now it
Kenichi Handa <handa@m17n.org>
parents:
23325
diff
changeset
|
5117 return; |
2da87b489590
(check_composing_code): Fix previous change. Now it
Kenichi Handa <handa@m17n.org>
parents:
23325
diff
changeset
|
5118 } |
2da87b489590
(check_composing_code): Fix previous change. Now it
Kenichi Handa <handa@m17n.org>
parents:
23325
diff
changeset
|
5119 |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5120 if (coding->heading_ascii >= 0) |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5121 /* Detection routine has already found how much we can skip at the |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5122 head. */ |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5123 *beg += coding->heading_ascii; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5124 |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5125 if (str) |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5126 { |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5127 begp_orig = begp = str + *beg; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5128 endp_orig = endp = str + *end; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5129 } |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5130 else |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5131 { |
20931
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
5132 begp_orig = begp = BYTE_POS_ADDR (*beg); |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5133 endp_orig = endp = begp + *end - *beg; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5134 } |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5135 |
29247
c748b4b1c785
(shrink_decoding_region): Initialize eol_conversion.
Dave Love <fx@gnu.org>
parents:
29184
diff
changeset
|
5136 eol_conversion = (coding->eol_type == CODING_EOL_CR |
c748b4b1c785
(shrink_decoding_region): Initialize eol_conversion.
Dave Love <fx@gnu.org>
parents:
29184
diff
changeset
|
5137 || coding->eol_type == CODING_EOL_CRLF); |
c748b4b1c785
(shrink_decoding_region): Initialize eol_conversion.
Dave Love <fx@gnu.org>
parents:
29184
diff
changeset
|
5138 |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5139 switch (coding->type) |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5140 { |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5141 case coding_type_sjis: |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5142 case coding_type_big5: |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5143 /* We can skip all ASCII characters at the head. */ |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5144 if (coding->heading_ascii < 0) |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5145 { |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5146 if (eol_conversion) |
21273
3d9e12cf2e63
(shrink_decoding_region): If EOL_CONVERSION is nonzero,
Kenichi Handa <handa@m17n.org>
parents:
21253
diff
changeset
|
5147 while (begp < endp && *begp < 0x80 && *begp != '\r') begp++; |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5148 else |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5149 while (begp < endp && *begp < 0x80) begp++; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5150 } |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5151 /* We can skip all ASCII characters at the tail except for the |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5152 second byte of SJIS or BIG5 code. */ |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5153 if (eol_conversion) |
21273
3d9e12cf2e63
(shrink_decoding_region): If EOL_CONVERSION is nonzero,
Kenichi Handa <handa@m17n.org>
parents:
21253
diff
changeset
|
5154 while (begp < endp && endp[-1] < 0x80 && endp[-1] != '\r') endp--; |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5155 else |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5156 while (begp < endp && endp[-1] < 0x80) endp--; |
21744
64c815fe1bdc
(shrink_decoding_region): Do not consider LF as ascii
Richard M. Stallman <rms@gnu.org>
parents:
21664
diff
changeset
|
5157 /* Do not consider LF as ascii if preceded by CR, since that |
64c815fe1bdc
(shrink_decoding_region): Do not consider LF as ascii
Richard M. Stallman <rms@gnu.org>
parents:
21664
diff
changeset
|
5158 confuses eol decoding. */ |
64c815fe1bdc
(shrink_decoding_region): Do not consider LF as ascii
Richard M. Stallman <rms@gnu.org>
parents:
21664
diff
changeset
|
5159 if (begp < endp && endp < endp_orig && endp[-1] == '\r' && endp[0] == '\n') |
64c815fe1bdc
(shrink_decoding_region): Do not consider LF as ascii
Richard M. Stallman <rms@gnu.org>
parents:
21664
diff
changeset
|
5160 endp++; |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5161 if (begp < endp && endp < endp_orig && endp[-1] >= 0x80) |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5162 endp++; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5163 break; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5164 |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5165 case coding_type_iso2022: |
23426
088cb2a804c7
(shrink_decoding_region): If a charset other than ascii
Kenichi Handa <handa@m17n.org>
parents:
23402
diff
changeset
|
5166 if (CODING_SPEC_ISO_INITIAL_DESIGNATION (coding, 0) != CHARSET_ASCII) |
088cb2a804c7
(shrink_decoding_region): If a charset other than ascii
Kenichi Handa <handa@m17n.org>
parents:
23402
diff
changeset
|
5167 /* We can't skip any data. */ |
088cb2a804c7
(shrink_decoding_region): If a charset other than ascii
Kenichi Handa <handa@m17n.org>
parents:
23402
diff
changeset
|
5168 break; |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5169 if (coding->heading_ascii < 0) |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5170 { |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5171 /* We can skip all ASCII characters at the head except for a |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5172 few control codes. */ |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5173 while (begp < endp && (c = *begp) < 0x80 |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5174 && c != ISO_CODE_CR && c != ISO_CODE_SO |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5175 && c != ISO_CODE_SI && c != ISO_CODE_ESC |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5176 && (!eol_conversion || c != ISO_CODE_LF)) |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5177 begp++; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5178 } |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5179 switch (coding->category_idx) |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5180 { |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5181 case CODING_CATEGORY_IDX_ISO_8_1: |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5182 case CODING_CATEGORY_IDX_ISO_8_2: |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5183 /* We can skip all ASCII characters at the tail. */ |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5184 if (eol_conversion) |
21273
3d9e12cf2e63
(shrink_decoding_region): If EOL_CONVERSION is nonzero,
Kenichi Handa <handa@m17n.org>
parents:
21253
diff
changeset
|
5185 while (begp < endp && (c = endp[-1]) < 0x80 && c != '\r') endp--; |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5186 else |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5187 while (begp < endp && endp[-1] < 0x80) endp--; |
21744
64c815fe1bdc
(shrink_decoding_region): Do not consider LF as ascii
Richard M. Stallman <rms@gnu.org>
parents:
21664
diff
changeset
|
5188 /* Do not consider LF as ascii if preceded by CR, since that |
64c815fe1bdc
(shrink_decoding_region): Do not consider LF as ascii
Richard M. Stallman <rms@gnu.org>
parents:
21664
diff
changeset
|
5189 confuses eol decoding. */ |
64c815fe1bdc
(shrink_decoding_region): Do not consider LF as ascii
Richard M. Stallman <rms@gnu.org>
parents:
21664
diff
changeset
|
5190 if (begp < endp && endp < endp_orig && endp[-1] == '\r' && endp[0] == '\n') |
64c815fe1bdc
(shrink_decoding_region): Do not consider LF as ascii
Richard M. Stallman <rms@gnu.org>
parents:
21664
diff
changeset
|
5191 endp++; |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5192 break; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5193 |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5194 case CODING_CATEGORY_IDX_ISO_7: |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5195 case CODING_CATEGORY_IDX_ISO_7_TIGHT: |
23325
bbd06336cd0c
(check_composing_code): If the current composing
Kenichi Handa <handa@m17n.org>
parents:
23315
diff
changeset
|
5196 { |
36087 | 5197 /* We can skip all characters at the tail except for 8-bit |
23325
bbd06336cd0c
(check_composing_code): If the current composing
Kenichi Handa <handa@m17n.org>
parents:
23315
diff
changeset
|
5198 codes and ESC and the following 2-byte at the tail. */ |
bbd06336cd0c
(check_composing_code): If the current composing
Kenichi Handa <handa@m17n.org>
parents:
23315
diff
changeset
|
5199 unsigned char *eight_bit = NULL; |
bbd06336cd0c
(check_composing_code): If the current composing
Kenichi Handa <handa@m17n.org>
parents:
23315
diff
changeset
|
5200 |
bbd06336cd0c
(check_composing_code): If the current composing
Kenichi Handa <handa@m17n.org>
parents:
23315
diff
changeset
|
5201 if (eol_conversion) |
bbd06336cd0c
(check_composing_code): If the current composing
Kenichi Handa <handa@m17n.org>
parents:
23315
diff
changeset
|
5202 while (begp < endp |
bbd06336cd0c
(check_composing_code): If the current composing
Kenichi Handa <handa@m17n.org>
parents:
23315
diff
changeset
|
5203 && (c = endp[-1]) != ISO_CODE_ESC && c != '\r') |
bbd06336cd0c
(check_composing_code): If the current composing
Kenichi Handa <handa@m17n.org>
parents:
23315
diff
changeset
|
5204 { |
bbd06336cd0c
(check_composing_code): If the current composing
Kenichi Handa <handa@m17n.org>
parents:
23315
diff
changeset
|
5205 if (!eight_bit && c & 0x80) eight_bit = endp; |
bbd06336cd0c
(check_composing_code): If the current composing
Kenichi Handa <handa@m17n.org>
parents:
23315
diff
changeset
|
5206 endp--; |
bbd06336cd0c
(check_composing_code): If the current composing
Kenichi Handa <handa@m17n.org>
parents:
23315
diff
changeset
|
5207 } |
bbd06336cd0c
(check_composing_code): If the current composing
Kenichi Handa <handa@m17n.org>
parents:
23315
diff
changeset
|
5208 else |
bbd06336cd0c
(check_composing_code): If the current composing
Kenichi Handa <handa@m17n.org>
parents:
23315
diff
changeset
|
5209 while (begp < endp |
bbd06336cd0c
(check_composing_code): If the current composing
Kenichi Handa <handa@m17n.org>
parents:
23315
diff
changeset
|
5210 && (c = endp[-1]) != ISO_CODE_ESC) |
bbd06336cd0c
(check_composing_code): If the current composing
Kenichi Handa <handa@m17n.org>
parents:
23315
diff
changeset
|
5211 { |
bbd06336cd0c
(check_composing_code): If the current composing
Kenichi Handa <handa@m17n.org>
parents:
23315
diff
changeset
|
5212 if (!eight_bit && c & 0x80) eight_bit = endp; |
bbd06336cd0c
(check_composing_code): If the current composing
Kenichi Handa <handa@m17n.org>
parents:
23315
diff
changeset
|
5213 endp--; |
bbd06336cd0c
(check_composing_code): If the current composing
Kenichi Handa <handa@m17n.org>
parents:
23315
diff
changeset
|
5214 } |
bbd06336cd0c
(check_composing_code): If the current composing
Kenichi Handa <handa@m17n.org>
parents:
23315
diff
changeset
|
5215 /* Do not consider LF as ascii if preceded by CR, since that |
bbd06336cd0c
(check_composing_code): If the current composing
Kenichi Handa <handa@m17n.org>
parents:
23315
diff
changeset
|
5216 confuses eol decoding. */ |
bbd06336cd0c
(check_composing_code): If the current composing
Kenichi Handa <handa@m17n.org>
parents:
23315
diff
changeset
|
5217 if (begp < endp && endp < endp_orig |
bbd06336cd0c
(check_composing_code): If the current composing
Kenichi Handa <handa@m17n.org>
parents:
23315
diff
changeset
|
5218 && endp[-1] == '\r' && endp[0] == '\n') |
bbd06336cd0c
(check_composing_code): If the current composing
Kenichi Handa <handa@m17n.org>
parents:
23315
diff
changeset
|
5219 endp++; |
bbd06336cd0c
(check_composing_code): If the current composing
Kenichi Handa <handa@m17n.org>
parents:
23315
diff
changeset
|
5220 if (begp < endp && endp[-1] == ISO_CODE_ESC) |
bbd06336cd0c
(check_composing_code): If the current composing
Kenichi Handa <handa@m17n.org>
parents:
23315
diff
changeset
|
5221 { |
bbd06336cd0c
(check_composing_code): If the current composing
Kenichi Handa <handa@m17n.org>
parents:
23315
diff
changeset
|
5222 if (endp + 1 < endp_orig && end[0] == '(' && end[1] == 'B') |
bbd06336cd0c
(check_composing_code): If the current composing
Kenichi Handa <handa@m17n.org>
parents:
23315
diff
changeset
|
5223 /* This is an ASCII designation sequence. We can |
bbd06336cd0c
(check_composing_code): If the current composing
Kenichi Handa <handa@m17n.org>
parents:
23315
diff
changeset
|
5224 surely skip the tail. But, if we have |
bbd06336cd0c
(check_composing_code): If the current composing
Kenichi Handa <handa@m17n.org>
parents:
23315
diff
changeset
|
5225 encountered an 8-bit code, skip only the codes |
bbd06336cd0c
(check_composing_code): If the current composing
Kenichi Handa <handa@m17n.org>
parents:
23315
diff
changeset
|
5226 after that. */ |
bbd06336cd0c
(check_composing_code): If the current composing
Kenichi Handa <handa@m17n.org>
parents:
23315
diff
changeset
|
5227 endp = eight_bit ? eight_bit : endp + 2; |
bbd06336cd0c
(check_composing_code): If the current composing
Kenichi Handa <handa@m17n.org>
parents:
23315
diff
changeset
|
5228 else |
bbd06336cd0c
(check_composing_code): If the current composing
Kenichi Handa <handa@m17n.org>
parents:
23315
diff
changeset
|
5229 /* Hmmm, we can't skip the tail. */ |
bbd06336cd0c
(check_composing_code): If the current composing
Kenichi Handa <handa@m17n.org>
parents:
23315
diff
changeset
|
5230 endp = endp_orig; |
bbd06336cd0c
(check_composing_code): If the current composing
Kenichi Handa <handa@m17n.org>
parents:
23315
diff
changeset
|
5231 } |
bbd06336cd0c
(check_composing_code): If the current composing
Kenichi Handa <handa@m17n.org>
parents:
23315
diff
changeset
|
5232 else if (eight_bit) |
bbd06336cd0c
(check_composing_code): If the current composing
Kenichi Handa <handa@m17n.org>
parents:
23315
diff
changeset
|
5233 endp = eight_bit; |
bbd06336cd0c
(check_composing_code): If the current composing
Kenichi Handa <handa@m17n.org>
parents:
23315
diff
changeset
|
5234 } |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5235 } |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5236 break; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5237 |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5238 default: |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5239 abort (); |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5240 } |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5241 *beg += begp - begp_orig; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5242 *end += endp - endp_orig; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5243 return; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5244 } |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5245 |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5246 /* Like shrink_decoding_region but for encoding. */ |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5247 |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5248 static void |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5249 shrink_encoding_region (beg, end, coding, str) |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5250 int *beg, *end; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5251 struct coding_system *coding; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5252 unsigned char *str; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5253 { |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5254 unsigned char *begp_orig, *begp, *endp_orig, *endp; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5255 int eol_conversion; |
23339
2da87b489590
(check_composing_code): Fix previous change. Now it
Kenichi Handa <handa@m17n.org>
parents:
23325
diff
changeset
|
5256 Lisp_Object translation_table; |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5257 |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5258 if (coding->type == coding_type_ccl |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5259 || coding->eol_type == CODING_EOL_CRLF |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5260 || coding->eol_type == CODING_EOL_CR |
41899
5c01da9c8604
(setup_coding_system, shrink_encoding_region)
Pavel Janík <Pavel@Janik.cz>
parents:
41678
diff
changeset
|
5261 || (coding->cmp_data && coding->cmp_data->used > 0)) |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5262 { |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5263 /* We can't skip any data. */ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5264 return; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5265 } |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5266 if (coding->type == coding_type_no_conversion |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5267 || coding->type == coding_type_raw_text |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5268 || coding->type == coding_type_emacs_mule |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5269 || coding->type == coding_type_undecided) |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5270 { |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5271 /* We need no conversion, but don't have to skip any data here. |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5272 Encoding routine handles them effectively anyway. */ |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5273 return; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5274 } |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5275 |
23339
2da87b489590
(check_composing_code): Fix previous change. Now it
Kenichi Handa <handa@m17n.org>
parents:
23325
diff
changeset
|
5276 translation_table = coding->translation_table_for_encode; |
2da87b489590
(check_composing_code): Fix previous change. Now it
Kenichi Handa <handa@m17n.org>
parents:
23325
diff
changeset
|
5277 if (NILP (translation_table) && !NILP (Venable_character_translation)) |
2da87b489590
(check_composing_code): Fix previous change. Now it
Kenichi Handa <handa@m17n.org>
parents:
23325
diff
changeset
|
5278 translation_table = Vstandard_translation_table_for_encode; |
2da87b489590
(check_composing_code): Fix previous change. Now it
Kenichi Handa <handa@m17n.org>
parents:
23325
diff
changeset
|
5279 if (CHAR_TABLE_P (translation_table)) |
2da87b489590
(check_composing_code): Fix previous change. Now it
Kenichi Handa <handa@m17n.org>
parents:
23325
diff
changeset
|
5280 { |
2da87b489590
(check_composing_code): Fix previous change. Now it
Kenichi Handa <handa@m17n.org>
parents:
23325
diff
changeset
|
5281 int i; |
2da87b489590
(check_composing_code): Fix previous change. Now it
Kenichi Handa <handa@m17n.org>
parents:
23325
diff
changeset
|
5282 for (i = 0; i < 128; i++) |
2da87b489590
(check_composing_code): Fix previous change. Now it
Kenichi Handa <handa@m17n.org>
parents:
23325
diff
changeset
|
5283 if (!NILP (CHAR_TABLE_REF (translation_table, i))) |
2da87b489590
(check_composing_code): Fix previous change. Now it
Kenichi Handa <handa@m17n.org>
parents:
23325
diff
changeset
|
5284 break; |
2da87b489590
(check_composing_code): Fix previous change. Now it
Kenichi Handa <handa@m17n.org>
parents:
23325
diff
changeset
|
5285 if (i < 128) |
36087 | 5286 /* Some ASCII character should be translated. We give up |
23339
2da87b489590
(check_composing_code): Fix previous change. Now it
Kenichi Handa <handa@m17n.org>
parents:
23325
diff
changeset
|
5287 shrinking. */ |
2da87b489590
(check_composing_code): Fix previous change. Now it
Kenichi Handa <handa@m17n.org>
parents:
23325
diff
changeset
|
5288 return; |
2da87b489590
(check_composing_code): Fix previous change. Now it
Kenichi Handa <handa@m17n.org>
parents:
23325
diff
changeset
|
5289 } |
2da87b489590
(check_composing_code): Fix previous change. Now it
Kenichi Handa <handa@m17n.org>
parents:
23325
diff
changeset
|
5290 |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5291 if (str) |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5292 { |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5293 begp_orig = begp = str + *beg; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5294 endp_orig = endp = str + *end; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5295 } |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5296 else |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5297 { |
20931
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
5298 begp_orig = begp = BYTE_POS_ADDR (*beg); |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5299 endp_orig = endp = begp + *end - *beg; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5300 } |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5301 |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5302 eol_conversion = (coding->eol_type == CODING_EOL_CR |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5303 || coding->eol_type == CODING_EOL_CRLF); |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5304 |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5305 /* Here, we don't have to check coding->pre_write_conversion because |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5306 the caller is expected to have handled it already. */ |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5307 switch (coding->type) |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5308 { |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5309 case coding_type_iso2022: |
23426
088cb2a804c7
(shrink_decoding_region): If a charset other than ascii
Kenichi Handa <handa@m17n.org>
parents:
23402
diff
changeset
|
5310 if (CODING_SPEC_ISO_INITIAL_DESIGNATION (coding, 0) != CHARSET_ASCII) |
088cb2a804c7
(shrink_decoding_region): If a charset other than ascii
Kenichi Handa <handa@m17n.org>
parents:
23402
diff
changeset
|
5311 /* We can't skip any data. */ |
088cb2a804c7
(shrink_decoding_region): If a charset other than ascii
Kenichi Handa <handa@m17n.org>
parents:
23402
diff
changeset
|
5312 break; |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5313 if (coding->flags & CODING_FLAG_ISO_DESIGNATE_AT_BOL) |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5314 { |
42104
d69c2368e549
(DECODE_COMPOSITION_END): Fixed a typo in the last
Sam Steingold <sds@gnu.org>
parents:
42103
diff
changeset
|
5315 unsigned char *bol = begp; |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5316 while (begp < endp && *begp < 0x80) |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5317 { |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5318 begp++; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5319 if (begp[-1] == '\n') |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5320 bol = begp; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5321 } |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5322 begp = bol; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5323 goto label_skip_tail; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5324 } |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5325 /* fall down ... */ |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5326 |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5327 case coding_type_sjis: |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5328 case coding_type_big5: |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5329 /* We can skip all ASCII characters at the head and tail. */ |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5330 if (eol_conversion) |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5331 while (begp < endp && *begp < 0x80 && *begp != '\n') begp++; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5332 else |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5333 while (begp < endp && *begp < 0x80) begp++; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5334 label_skip_tail: |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5335 if (eol_conversion) |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5336 while (begp < endp && endp[-1] < 0x80 && endp[-1] != '\n') endp--; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5337 else |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5338 while (begp < endp && *(endp - 1) < 0x80) endp--; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5339 break; |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5340 |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5341 default: |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5342 abort (); |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5343 } |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5344 |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5345 *beg += begp - begp_orig; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5346 *end += endp - endp_orig; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5347 return; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5348 } |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5349 |
23339
2da87b489590
(check_composing_code): Fix previous change. Now it
Kenichi Handa <handa@m17n.org>
parents:
23325
diff
changeset
|
5350 /* As shrinking conversion region requires some overhead, we don't try |
2da87b489590
(check_composing_code): Fix previous change. Now it
Kenichi Handa <handa@m17n.org>
parents:
23325
diff
changeset
|
5351 shrinking if the length of conversion region is less than this |
2da87b489590
(check_composing_code): Fix previous change. Now it
Kenichi Handa <handa@m17n.org>
parents:
23325
diff
changeset
|
5352 value. */ |
2da87b489590
(check_composing_code): Fix previous change. Now it
Kenichi Handa <handa@m17n.org>
parents:
23325
diff
changeset
|
5353 static int shrink_conversion_region_threshhold = 1024; |
2da87b489590
(check_composing_code): Fix previous change. Now it
Kenichi Handa <handa@m17n.org>
parents:
23325
diff
changeset
|
5354 |
2da87b489590
(check_composing_code): Fix previous change. Now it
Kenichi Handa <handa@m17n.org>
parents:
23325
diff
changeset
|
5355 #define SHRINK_CONVERSION_REGION(beg, end, coding, str, encodep) \ |
2da87b489590
(check_composing_code): Fix previous change. Now it
Kenichi Handa <handa@m17n.org>
parents:
23325
diff
changeset
|
5356 do { \ |
2da87b489590
(check_composing_code): Fix previous change. Now it
Kenichi Handa <handa@m17n.org>
parents:
23325
diff
changeset
|
5357 if (*(end) - *(beg) > shrink_conversion_region_threshhold) \ |
2da87b489590
(check_composing_code): Fix previous change. Now it
Kenichi Handa <handa@m17n.org>
parents:
23325
diff
changeset
|
5358 { \ |
2da87b489590
(check_composing_code): Fix previous change. Now it
Kenichi Handa <handa@m17n.org>
parents:
23325
diff
changeset
|
5359 if (encodep) shrink_encoding_region (beg, end, coding, str); \ |
2da87b489590
(check_composing_code): Fix previous change. Now it
Kenichi Handa <handa@m17n.org>
parents:
23325
diff
changeset
|
5360 else shrink_decoding_region (beg, end, coding, str); \ |
2da87b489590
(check_composing_code): Fix previous change. Now it
Kenichi Handa <handa@m17n.org>
parents:
23325
diff
changeset
|
5361 } \ |
2da87b489590
(check_composing_code): Fix previous change. Now it
Kenichi Handa <handa@m17n.org>
parents:
23325
diff
changeset
|
5362 } while (0) |
2da87b489590
(check_composing_code): Fix previous change. Now it
Kenichi Handa <handa@m17n.org>
parents:
23325
diff
changeset
|
5363 |
65506
f376635f5061
(code_convert_region_unwind): Argument format changed.
Kenichi Handa <handa@m17n.org>
parents:
64770
diff
changeset
|
5364 /* ARG is (CODING BUFFER ...) where CODING is what to be set in |
f376635f5061
(code_convert_region_unwind): Argument format changed.
Kenichi Handa <handa@m17n.org>
parents:
64770
diff
changeset
|
5365 Vlast_coding_system_used and the remaining elements are buffers to |
64308
93129de4b8a4
(code_convert_region_unwind): ARG is changed to a cons.
Kenichi Handa <handa@m17n.org>
parents:
64251
diff
changeset
|
5366 kill. */ |
26067
f54ca66e2571
(code_convert_string): Add record_unwind_protect to
Kenichi Handa <handa@m17n.org>
parents:
25860
diff
changeset
|
5367 static Lisp_Object |
50484
6818550bfbc7
(code_convert_region_unwind): Set
Kenichi Handa <handa@m17n.org>
parents:
50185
diff
changeset
|
5368 code_convert_region_unwind (arg) |
6818550bfbc7
(code_convert_region_unwind): Set
Kenichi Handa <handa@m17n.org>
parents:
50185
diff
changeset
|
5369 Lisp_Object arg; |
26067
f54ca66e2571
(code_convert_string): Add record_unwind_protect to
Kenichi Handa <handa@m17n.org>
parents:
25860
diff
changeset
|
5370 { |
67555
3e443750ea4c
(code_convert_region_unwind): GCPRO arg.
Kenichi Handa <handa@m17n.org>
parents:
65506
diff
changeset
|
5371 struct gcpro gcpro1; |
3e443750ea4c
(code_convert_region_unwind): GCPRO arg.
Kenichi Handa <handa@m17n.org>
parents:
65506
diff
changeset
|
5372 GCPRO1 (arg); |
3e443750ea4c
(code_convert_region_unwind): GCPRO arg.
Kenichi Handa <handa@m17n.org>
parents:
65506
diff
changeset
|
5373 |
26067
f54ca66e2571
(code_convert_string): Add record_unwind_protect to
Kenichi Handa <handa@m17n.org>
parents:
25860
diff
changeset
|
5374 inhibit_pre_post_conversion = 0; |
64308
93129de4b8a4
(code_convert_region_unwind): ARG is changed to a cons.
Kenichi Handa <handa@m17n.org>
parents:
64251
diff
changeset
|
5375 Vlast_coding_system_used = XCAR (arg); |
85330
0bc184c59770
* xfns.c (Fx_create_frame, Fx_display_list):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84646
diff
changeset
|
5376 for (arg = XCDR (arg); CONSP (arg); arg = XCDR (arg)) |
65506
f376635f5061
(code_convert_region_unwind): Argument format changed.
Kenichi Handa <handa@m17n.org>
parents:
64770
diff
changeset
|
5377 Fkill_buffer (XCAR (arg)); |
67555
3e443750ea4c
(code_convert_region_unwind): GCPRO arg.
Kenichi Handa <handa@m17n.org>
parents:
65506
diff
changeset
|
5378 |
3e443750ea4c
(code_convert_region_unwind): GCPRO arg.
Kenichi Handa <handa@m17n.org>
parents:
65506
diff
changeset
|
5379 UNGCPRO; |
26067
f54ca66e2571
(code_convert_string): Add record_unwind_protect to
Kenichi Handa <handa@m17n.org>
parents:
25860
diff
changeset
|
5380 return Qnil; |
f54ca66e2571
(code_convert_string): Add record_unwind_protect to
Kenichi Handa <handa@m17n.org>
parents:
25860
diff
changeset
|
5381 } |
f54ca66e2571
(code_convert_string): Add record_unwind_protect to
Kenichi Handa <handa@m17n.org>
parents:
25860
diff
changeset
|
5382 |
26847 | 5383 /* Store information about all compositions in the range FROM and TO |
5384 of OBJ in memory blocks pointed by CODING->cmp_data. OBJ is a | |
5385 buffer or a string, defaults to the current buffer. */ | |
5386 | |
5387 void | |
5388 coding_save_composition (coding, from, to, obj) | |
5389 struct coding_system *coding; | |
5390 int from, to; | |
5391 Lisp_Object obj; | |
5392 { | |
5393 Lisp_Object prop; | |
5394 int start, end; | |
5395 | |
27943
c2e0998057f9
(coding_save_composition): Be sure to allocate
Kenichi Handa <handa@m17n.org>
parents:
27271
diff
changeset
|
5396 if (coding->composing == COMPOSITION_DISABLED) |
c2e0998057f9
(coding_save_composition): Be sure to allocate
Kenichi Handa <handa@m17n.org>
parents:
27271
diff
changeset
|
5397 return; |
c2e0998057f9
(coding_save_composition): Be sure to allocate
Kenichi Handa <handa@m17n.org>
parents:
27271
diff
changeset
|
5398 if (!coding->cmp_data) |
c2e0998057f9
(coding_save_composition): Be sure to allocate
Kenichi Handa <handa@m17n.org>
parents:
27271
diff
changeset
|
5399 coding_allocate_composition_data (coding, from); |
26847 | 5400 if (!find_composition (from, to, &start, &end, &prop, obj) |
5401 || end > to) | |
5402 return; | |
5403 if (start < from | |
5404 && (!find_composition (end, to, &start, &end, &prop, obj) | |
5405 || end > to)) | |
5406 return; | |
5407 coding->composing = COMPOSITION_NO; | |
5408 do | |
5409 { | |
5410 if (COMPOSITION_VALID_P (start, end, prop)) | |
5411 { | |
5412 enum composition_method method = COMPOSITION_METHOD (prop); | |
5413 if (coding->cmp_data->used + COMPOSITION_DATA_MAX_BUNCH_LENGTH | |
5414 >= COMPOSITION_DATA_SIZE) | |
5415 coding_allocate_composition_data (coding, from); | |
5416 /* For relative composition, we remember start and end | |
5417 positions, for the other compositions, we also remember | |
5418 components. */ | |
5419 CODING_ADD_COMPOSITION_START (coding, start - from, method); | |
5420 if (method != COMPOSITION_RELATIVE) | |
5421 { | |
5422 /* We must store a*/ | |
5423 Lisp_Object val, ch; | |
5424 | |
5425 val = COMPOSITION_COMPONENTS (prop); | |
5426 if (CONSP (val)) | |
5427 while (CONSP (val)) | |
5428 { | |
5429 ch = XCAR (val), val = XCDR (val); | |
5430 CODING_ADD_COMPOSITION_COMPONENT (coding, XINT (ch)); | |
5431 } | |
5432 else if (VECTORP (val) || STRINGP (val)) | |
5433 { | |
5434 int len = (VECTORP (val) | |
46370
40db0673e6f0
Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents:
46293
diff
changeset
|
5435 ? XVECTOR (val)->size : SCHARS (val)); |
26847 | 5436 int i; |
5437 for (i = 0; i < len; i++) | |
5438 { | |
5439 ch = (STRINGP (val) | |
5440 ? Faref (val, make_number (i)) | |
5441 : XVECTOR (val)->contents[i]); | |
5442 CODING_ADD_COMPOSITION_COMPONENT (coding, XINT (ch)); | |
5443 } | |
5444 } | |
5445 else /* INTEGERP (val) */ | |
5446 CODING_ADD_COMPOSITION_COMPONENT (coding, XINT (val)); | |
5447 } | |
5448 CODING_ADD_COMPOSITION_END (coding, end - from); | |
5449 } | |
5450 start = end; | |
5451 } | |
5452 while (start < to | |
5453 && find_composition (start, to, &start, &end, &prop, obj) | |
5454 && end <= to); | |
5455 | |
5456 /* Make coding->cmp_data point to the first memory block. */ | |
5457 while (coding->cmp_data->prev) | |
5458 coding->cmp_data = coding->cmp_data->prev; | |
5459 coding->cmp_data_start = 0; | |
5460 } | |
5461 | |
5462 /* Reflect the saved information about compositions to OBJ. | |
36087 | 5463 CODING->cmp_data points to a memory block for the information. OBJ |
26847 | 5464 is a buffer or a string, defaults to the current buffer. */ |
5465 | |
29275
b4ea9178e480
(DECODE_COMPOSITION_START): If coding->cmp_data is not
Kenichi Handa <handa@m17n.org>
parents:
29247
diff
changeset
|
5466 void |
26847 | 5467 coding_restore_composition (coding, obj) |
5468 struct coding_system *coding; | |
5469 Lisp_Object obj; | |
5470 { | |
5471 struct composition_data *cmp_data = coding->cmp_data; | |
5472 | |
5473 if (!cmp_data) | |
5474 return; | |
5475 | |
5476 while (cmp_data->prev) | |
5477 cmp_data = cmp_data->prev; | |
5478 | |
5479 while (cmp_data) | |
5480 { | |
5481 int i; | |
5482 | |
30581
6c7a9202a815
(coding_restore_composition): Pay attention to the case that
Kenichi Handa <handa@m17n.org>
parents:
30578
diff
changeset
|
5483 for (i = 0; i < cmp_data->used && cmp_data->data[i] > 0; |
6c7a9202a815
(coding_restore_composition): Pay attention to the case that
Kenichi Handa <handa@m17n.org>
parents:
30578
diff
changeset
|
5484 i += cmp_data->data[i]) |
26847 | 5485 { |
5486 int *data = cmp_data->data + i; | |
5487 enum composition_method method = (enum composition_method) data[3]; | |
5488 Lisp_Object components; | |
5489 | |
53007
36796e056954
(coding_allocate_composition_data): Reset
Kenichi Handa <handa@m17n.org>
parents:
52806
diff
changeset
|
5490 if (data[0] < 0 || i + data[0] > cmp_data->used) |
36796e056954
(coding_allocate_composition_data): Reset
Kenichi Handa <handa@m17n.org>
parents:
52806
diff
changeset
|
5491 /* Invalid composition data. */ |
36796e056954
(coding_allocate_composition_data): Reset
Kenichi Handa <handa@m17n.org>
parents:
52806
diff
changeset
|
5492 break; |
36796e056954
(coding_allocate_composition_data): Reset
Kenichi Handa <handa@m17n.org>
parents:
52806
diff
changeset
|
5493 |
26847 | 5494 if (method == COMPOSITION_RELATIVE) |
5495 components = Qnil; | |
5496 else | |
5497 { | |
5498 int len = data[0] - 4, j; | |
5499 Lisp_Object args[MAX_COMPOSITION_COMPONENTS * 2 - 1]; | |
5500 | |
50047
8e17fbb2ac77
(CODING_ADD_COMPOSITION_COMPONENT): If the number of
Kenichi Handa <handa@m17n.org>
parents:
49600
diff
changeset
|
5501 if (method == COMPOSITION_WITH_RULE_ALTCHARS |
8e17fbb2ac77
(CODING_ADD_COMPOSITION_COMPONENT): If the number of
Kenichi Handa <handa@m17n.org>
parents:
49600
diff
changeset
|
5502 && len % 2 == 0) |
8e17fbb2ac77
(CODING_ADD_COMPOSITION_COMPONENT): If the number of
Kenichi Handa <handa@m17n.org>
parents:
49600
diff
changeset
|
5503 len --; |
53775
68f86fa2b022
(coding_restore_composition): Check invalid
Kenichi Handa <handa@m17n.org>
parents:
53348
diff
changeset
|
5504 if (len < 1) |
68f86fa2b022
(coding_restore_composition): Check invalid
Kenichi Handa <handa@m17n.org>
parents:
53348
diff
changeset
|
5505 /* Invalid composition data. */ |
68f86fa2b022
(coding_restore_composition): Check invalid
Kenichi Handa <handa@m17n.org>
parents:
53348
diff
changeset
|
5506 break; |
26847 | 5507 for (j = 0; j < len; j++) |
5508 args[j] = make_number (data[4 + j]); | |
5509 components = (method == COMPOSITION_WITH_ALTCHARS | |
53087
858cdfcb7635
(coding_restore_composition): Lisp_Object/int mixup.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53007
diff
changeset
|
5510 ? Fstring (len, args) |
858cdfcb7635
(coding_restore_composition): Lisp_Object/int mixup.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53007
diff
changeset
|
5511 : Fvector (len, args)); |
26847 | 5512 } |
5513 compose_text (data[1], data[2], components, Qnil, obj); | |
5514 } | |
5515 cmp_data = cmp_data->next; | |
5516 } | |
5517 } | |
5518 | |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5519 /* Decode (if ENCODEP is zero) or encode (if ENCODEP is nonzero) the |
20931
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
5520 text from FROM to TO (byte positions are FROM_BYTE and TO_BYTE) by |
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
5521 coding system CODING, and return the status code of code conversion |
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
5522 (currently, this value has no meaning). |
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
5523 |
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
5524 How many characters (and bytes) are converted to how many |
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
5525 characters (and bytes) are recorded in members of the structure |
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
5526 CODING. |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5527 |
21190
d704dd953837
(code_convert_region): The 6th arg name is changed to
Kenichi Handa <handa@m17n.org>
parents:
21140
diff
changeset
|
5528 If REPLACE is nonzero, we do various things as if the original text |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5529 is deleted and a new text is inserted. See the comments in |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5530 replace_range (insdel.c) to know what we are doing. |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5531 |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5532 If REPLACE is zero, it is assumed that the source text is unibyte. |
36087 | 5533 Otherwise, it is assumed that the source text is multibyte. */ |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5534 |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5535 int |
21190
d704dd953837
(code_convert_region): The 6th arg name is changed to
Kenichi Handa <handa@m17n.org>
parents:
21140
diff
changeset
|
5536 code_convert_region (from, from_byte, to, to_byte, coding, encodep, replace) |
d704dd953837
(code_convert_region): The 6th arg name is changed to
Kenichi Handa <handa@m17n.org>
parents:
21140
diff
changeset
|
5537 int from, from_byte, to, to_byte, encodep, replace; |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5538 struct coding_system *coding; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5539 { |
20931
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
5540 int len = to - from, len_byte = to_byte - from_byte; |
42661
e85e4d9494b1
(code_convert_region): Don't copy old text if undo disabled.
Richard M. Stallman <rms@gnu.org>
parents:
42105
diff
changeset
|
5541 int nchars_del = 0, nbytes_del = 0; |
20931
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
5542 int require, inserted, inserted_byte; |
27271
7b495b311f18
(code_convert_region): Initialize total_skip.
Andreas Schwab <schwab@suse.de>
parents:
26900
diff
changeset
|
5543 int head_skip, tail_skip, total_skip = 0; |
22954
928b337d953b
Avoid using initializers for Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents:
22874
diff
changeset
|
5544 Lisp_Object saved_coding_symbol; |
20931
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
5545 int first = 1; |
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
5546 unsigned char *src, *dst; |
22954
928b337d953b
Avoid using initializers for Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents:
22874
diff
changeset
|
5547 Lisp_Object deletion; |
23514
7bad909cd6f1
(setup_coding_system): Fix setting up
Kenichi Handa <handa@m17n.org>
parents:
23475
diff
changeset
|
5548 int orig_point = PT, orig_len = len; |
23537
28cd5faf93dd
(code_convert_region): While preserving the orignal
Kenichi Handa <handa@m17n.org>
parents:
23514
diff
changeset
|
5549 int prev_Z; |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5550 int multibyte_p = !NILP (current_buffer->enable_multibyte_characters); |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5551 |
22954
928b337d953b
Avoid using initializers for Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents:
22874
diff
changeset
|
5552 deletion = Qnil; |
35587
7e767148cfdc
(decode_coding): Set a flag for inhibiting
Kenichi Handa <handa@m17n.org>
parents:
35531
diff
changeset
|
5553 saved_coding_symbol = coding->symbol; |
21190
d704dd953837
(code_convert_region): The 6th arg name is changed to
Kenichi Handa <handa@m17n.org>
parents:
21140
diff
changeset
|
5554 |
21576
8043d47984fd
(code_convert_region): If point in the conversion
Kenichi Handa <handa@m17n.org>
parents:
21574
diff
changeset
|
5555 if (from < PT && PT < to) |
23514
7bad909cd6f1
(setup_coding_system): Fix setting up
Kenichi Handa <handa@m17n.org>
parents:
23475
diff
changeset
|
5556 { |
7bad909cd6f1
(setup_coding_system): Fix setting up
Kenichi Handa <handa@m17n.org>
parents:
23475
diff
changeset
|
5557 TEMP_SET_PT_BOTH (from, from_byte); |
7bad909cd6f1
(setup_coding_system): Fix setting up
Kenichi Handa <handa@m17n.org>
parents:
23475
diff
changeset
|
5558 orig_point = from; |
7bad909cd6f1
(setup_coding_system): Fix setting up
Kenichi Handa <handa@m17n.org>
parents:
23475
diff
changeset
|
5559 } |
21576
8043d47984fd
(code_convert_region): If point in the conversion
Kenichi Handa <handa@m17n.org>
parents:
21574
diff
changeset
|
5560 |
21190
d704dd953837
(code_convert_region): The 6th arg name is changed to
Kenichi Handa <handa@m17n.org>
parents:
21140
diff
changeset
|
5561 if (replace) |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5562 { |
20931
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
5563 int saved_from = from; |
30315
8067ad173141
(code_convert_region): Delete text properties before shrinking the
Kenichi Handa <handa@m17n.org>
parents:
30292
diff
changeset
|
5564 int saved_inhibit_modification_hooks; |
20931
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
5565 |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5566 prepare_to_modify_buffer (from, to, &from); |
20931
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
5567 if (saved_from != from) |
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
5568 { |
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
5569 to = from + len; |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5570 from_byte = CHAR_TO_BYTE (from), to_byte = CHAR_TO_BYTE (to); |
20931
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
5571 len_byte = to_byte - from_byte; |
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
5572 } |
30315
8067ad173141
(code_convert_region): Delete text properties before shrinking the
Kenichi Handa <handa@m17n.org>
parents:
30292
diff
changeset
|
5573 |
8067ad173141
(code_convert_region): Delete text properties before shrinking the
Kenichi Handa <handa@m17n.org>
parents:
30292
diff
changeset
|
5574 /* The code conversion routine can not preserve text properties |
8067ad173141
(code_convert_region): Delete text properties before shrinking the
Kenichi Handa <handa@m17n.org>
parents:
30292
diff
changeset
|
5575 for now. So, we must remove all text properties in the |
8067ad173141
(code_convert_region): Delete text properties before shrinking the
Kenichi Handa <handa@m17n.org>
parents:
30292
diff
changeset
|
5576 region. Here, we must suppress all modification hooks. */ |
8067ad173141
(code_convert_region): Delete text properties before shrinking the
Kenichi Handa <handa@m17n.org>
parents:
30292
diff
changeset
|
5577 saved_inhibit_modification_hooks = inhibit_modification_hooks; |
8067ad173141
(code_convert_region): Delete text properties before shrinking the
Kenichi Handa <handa@m17n.org>
parents:
30292
diff
changeset
|
5578 inhibit_modification_hooks = 1; |
8067ad173141
(code_convert_region): Delete text properties before shrinking the
Kenichi Handa <handa@m17n.org>
parents:
30292
diff
changeset
|
5579 Fset_text_properties (make_number (from), make_number (to), Qnil, Qnil); |
8067ad173141
(code_convert_region): Delete text properties before shrinking the
Kenichi Handa <handa@m17n.org>
parents:
30292
diff
changeset
|
5580 inhibit_modification_hooks = saved_inhibit_modification_hooks; |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5581 } |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5582 |
73995
11025612f889
(code_convert_region): Initialize
Kenichi Handa <handa@m17n.org>
parents:
73949
diff
changeset
|
5583 coding->heading_ascii = 0; |
11025612f889
(code_convert_region): Initialize
Kenichi Handa <handa@m17n.org>
parents:
73949
diff
changeset
|
5584 |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5585 if (! encodep && CODING_REQUIRE_DETECTION (coding)) |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5586 { |
21321
27b08da98abe
(code_convert_region): Handle skipped ASCII characters
Kenichi Handa <handa@m17n.org>
parents:
21308
diff
changeset
|
5587 /* We must detect encoding of text and eol format. */ |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5588 |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5589 if (from < GPT && to > GPT) |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5590 move_gap_both (from, from_byte); |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5591 if (coding->type == coding_type_undecided) |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5592 { |
20931
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
5593 detect_coding (coding, BYTE_POS_ADDR (from_byte), len_byte); |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5594 if (coding->type == coding_type_undecided) |
32443
57fa108c491f
(code_convert_region): Be sure to initialize coding->category_idx.
Kenichi Handa <handa@m17n.org>
parents:
31458
diff
changeset
|
5595 { |
57fa108c491f
(code_convert_region): Be sure to initialize coding->category_idx.
Kenichi Handa <handa@m17n.org>
parents:
31458
diff
changeset
|
5596 /* It seems that the text contains only ASCII, but we |
32745 | 5597 should not leave it undecided because the deeper |
32443
57fa108c491f
(code_convert_region): Be sure to initialize coding->category_idx.
Kenichi Handa <handa@m17n.org>
parents:
31458
diff
changeset
|
5598 decoding routine (decode_coding) tries to detect the |
57fa108c491f
(code_convert_region): Be sure to initialize coding->category_idx.
Kenichi Handa <handa@m17n.org>
parents:
31458
diff
changeset
|
5599 encodings again in vain. */ |
57fa108c491f
(code_convert_region): Be sure to initialize coding->category_idx.
Kenichi Handa <handa@m17n.org>
parents:
31458
diff
changeset
|
5600 coding->type = coding_type_emacs_mule; |
57fa108c491f
(code_convert_region): Be sure to initialize coding->category_idx.
Kenichi Handa <handa@m17n.org>
parents:
31458
diff
changeset
|
5601 coding->category_idx = CODING_CATEGORY_IDX_EMACS_MULE; |
35995
b511edc4a348
(code_convert_region): After detecting a coding, if
Kenichi Handa <handa@m17n.org>
parents:
35587
diff
changeset
|
5602 /* As emacs-mule decoder will handle composition, we |
b511edc4a348
(code_convert_region): After detecting a coding, if
Kenichi Handa <handa@m17n.org>
parents:
35587
diff
changeset
|
5603 need this setting to allocate coding->cmp_data |
b511edc4a348
(code_convert_region): After detecting a coding, if
Kenichi Handa <handa@m17n.org>
parents:
35587
diff
changeset
|
5604 later. */ |
b511edc4a348
(code_convert_region): After detecting a coding, if
Kenichi Handa <handa@m17n.org>
parents:
35587
diff
changeset
|
5605 coding->composing = COMPOSITION_NO; |
32443
57fa108c491f
(code_convert_region): Be sure to initialize coding->category_idx.
Kenichi Handa <handa@m17n.org>
parents:
31458
diff
changeset
|
5606 } |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5607 } |
29725
2bc397e9b09a
(setup_coding_system) <4>: Reset member `cr_carryover'.
Kenichi Handa <handa@m17n.org>
parents:
29663
diff
changeset
|
5608 if (coding->eol_type == CODING_EOL_UNDECIDED |
2bc397e9b09a
(setup_coding_system) <4>: Reset member `cr_carryover'.
Kenichi Handa <handa@m17n.org>
parents:
29663
diff
changeset
|
5609 && coding->type != coding_type_ccl) |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5610 { |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5611 detect_eol (coding, BYTE_POS_ADDR (from_byte), len_byte); |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5612 if (coding->eol_type == CODING_EOL_UNDECIDED) |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5613 coding->eol_type = CODING_EOL_LF; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5614 /* We had better recover the original eol format if we |
36087 | 5615 encounter an inconsistent eol format while decoding. */ |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5616 coding->mode |= CODING_MODE_INHIBIT_INCONSISTENT_EOL; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5617 } |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5618 } |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5619 |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5620 /* Now we convert the text. */ |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5621 |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5622 /* For encoding, we must process pre-write-conversion in advance. */ |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5623 if (! inhibit_pre_post_conversion |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5624 && encodep |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5625 && SYMBOLP (coding->pre_write_conversion) |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5626 && ! NILP (Ffboundp (coding->pre_write_conversion))) |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5627 { |
21140
179c73d91f70
(code_convert_region): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
21132
diff
changeset
|
5628 /* The function in pre-write-conversion may put a new text in a |
179c73d91f70
(code_convert_region): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
21132
diff
changeset
|
5629 new buffer. */ |
23542
eaf358b2e8dd
(code_convert_region): Kill the work buffer created by
Kenichi Handa <handa@m17n.org>
parents:
23537
diff
changeset
|
5630 struct buffer *prev = current_buffer; |
eaf358b2e8dd
(code_convert_region): Kill the work buffer created by
Kenichi Handa <handa@m17n.org>
parents:
23537
diff
changeset
|
5631 Lisp_Object new; |
26067
f54ca66e2571
(code_convert_string): Add record_unwind_protect to
Kenichi Handa <handa@m17n.org>
parents:
25860
diff
changeset
|
5632 |
50484
6818550bfbc7
(code_convert_region_unwind): Set
Kenichi Handa <handa@m17n.org>
parents:
50185
diff
changeset
|
5633 record_unwind_protect (code_convert_region_unwind, |
64308
93129de4b8a4
(code_convert_region_unwind): ARG is changed to a cons.
Kenichi Handa <handa@m17n.org>
parents:
64251
diff
changeset
|
5634 Fcons (Vlast_coding_system_used, Qnil)); |
26067
f54ca66e2571
(code_convert_string): Add record_unwind_protect to
Kenichi Handa <handa@m17n.org>
parents:
25860
diff
changeset
|
5635 /* We should not call any more pre-write/post-read-conversion |
f54ca66e2571
(code_convert_string): Add record_unwind_protect to
Kenichi Handa <handa@m17n.org>
parents:
25860
diff
changeset
|
5636 functions while this pre-write-conversion is running. */ |
f54ca66e2571
(code_convert_string): Add record_unwind_protect to
Kenichi Handa <handa@m17n.org>
parents:
25860
diff
changeset
|
5637 inhibit_pre_post_conversion = 1; |
21520
ca4819c36ab9
(code_convert_region): Fix mixing of Lisp_Object and
Andreas Schwab <schwab@suse.de>
parents:
21514
diff
changeset
|
5638 call2 (coding->pre_write_conversion, |
ca4819c36ab9
(code_convert_region): Fix mixing of Lisp_Object and
Andreas Schwab <schwab@suse.de>
parents:
21514
diff
changeset
|
5639 make_number (from), make_number (to)); |
26067
f54ca66e2571
(code_convert_string): Add record_unwind_protect to
Kenichi Handa <handa@m17n.org>
parents:
25860
diff
changeset
|
5640 inhibit_pre_post_conversion = 0; |
f54ca66e2571
(code_convert_string): Add record_unwind_protect to
Kenichi Handa <handa@m17n.org>
parents:
25860
diff
changeset
|
5641 /* Discard the unwind protect. */ |
f54ca66e2571
(code_convert_string): Add record_unwind_protect to
Kenichi Handa <handa@m17n.org>
parents:
25860
diff
changeset
|
5642 specpdl_ptr--; |
f54ca66e2571
(code_convert_string): Add record_unwind_protect to
Kenichi Handa <handa@m17n.org>
parents:
25860
diff
changeset
|
5643 |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5644 if (current_buffer != prev) |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5645 { |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5646 len = ZV - BEGV; |
23542
eaf358b2e8dd
(code_convert_region): Kill the work buffer created by
Kenichi Handa <handa@m17n.org>
parents:
23537
diff
changeset
|
5647 new = Fcurrent_buffer (); |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5648 set_buffer_internal_1 (prev); |
26742
936b39bd05b4
* editfns.c (Fdelete_and_extract_region): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
26526
diff
changeset
|
5649 del_range_2 (from, from_byte, to, to_byte, 0); |
23514
7bad909cd6f1
(setup_coding_system): Fix setting up
Kenichi Handa <handa@m17n.org>
parents:
23475
diff
changeset
|
5650 TEMP_SET_PT_BOTH (from, from_byte); |
23542
eaf358b2e8dd
(code_convert_region): Kill the work buffer created by
Kenichi Handa <handa@m17n.org>
parents:
23537
diff
changeset
|
5651 insert_from_buffer (XBUFFER (new), 1, len, 0); |
eaf358b2e8dd
(code_convert_region): Kill the work buffer created by
Kenichi Handa <handa@m17n.org>
parents:
23537
diff
changeset
|
5652 Fkill_buffer (new); |
23514
7bad909cd6f1
(setup_coding_system): Fix setting up
Kenichi Handa <handa@m17n.org>
parents:
23475
diff
changeset
|
5653 if (orig_point >= to) |
7bad909cd6f1
(setup_coding_system): Fix setting up
Kenichi Handa <handa@m17n.org>
parents:
23475
diff
changeset
|
5654 orig_point += len - orig_len; |
7bad909cd6f1
(setup_coding_system): Fix setting up
Kenichi Handa <handa@m17n.org>
parents:
23475
diff
changeset
|
5655 else if (orig_point > from) |
7bad909cd6f1
(setup_coding_system): Fix setting up
Kenichi Handa <handa@m17n.org>
parents:
23475
diff
changeset
|
5656 orig_point = from; |
7bad909cd6f1
(setup_coding_system): Fix setting up
Kenichi Handa <handa@m17n.org>
parents:
23475
diff
changeset
|
5657 orig_len = len; |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5658 to = from + len; |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5659 from_byte = CHAR_TO_BYTE (from); |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5660 to_byte = CHAR_TO_BYTE (to); |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5661 len_byte = to_byte - from_byte; |
23514
7bad909cd6f1
(setup_coding_system): Fix setting up
Kenichi Handa <handa@m17n.org>
parents:
23475
diff
changeset
|
5662 TEMP_SET_PT_BOTH (from, from_byte); |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5663 } |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5664 } |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5665 |
21321
27b08da98abe
(code_convert_region): Handle skipped ASCII characters
Kenichi Handa <handa@m17n.org>
parents:
21308
diff
changeset
|
5666 if (replace) |
42661
e85e4d9494b1
(code_convert_region): Don't copy old text if undo disabled.
Richard M. Stallman <rms@gnu.org>
parents:
42105
diff
changeset
|
5667 { |
e85e4d9494b1
(code_convert_region): Don't copy old text if undo disabled.
Richard M. Stallman <rms@gnu.org>
parents:
42105
diff
changeset
|
5668 if (! EQ (current_buffer->undo_list, Qt)) |
e85e4d9494b1
(code_convert_region): Don't copy old text if undo disabled.
Richard M. Stallman <rms@gnu.org>
parents:
42105
diff
changeset
|
5669 deletion = make_buffer_string_both (from, from_byte, to, to_byte, 1); |
e85e4d9494b1
(code_convert_region): Don't copy old text if undo disabled.
Richard M. Stallman <rms@gnu.org>
parents:
42105
diff
changeset
|
5670 else |
e85e4d9494b1
(code_convert_region): Don't copy old text if undo disabled.
Richard M. Stallman <rms@gnu.org>
parents:
42105
diff
changeset
|
5671 { |
e85e4d9494b1
(code_convert_region): Don't copy old text if undo disabled.
Richard M. Stallman <rms@gnu.org>
parents:
42105
diff
changeset
|
5672 nchars_del = to - from; |
e85e4d9494b1
(code_convert_region): Don't copy old text if undo disabled.
Richard M. Stallman <rms@gnu.org>
parents:
42105
diff
changeset
|
5673 nbytes_del = to_byte - from_byte; |
e85e4d9494b1
(code_convert_region): Don't copy old text if undo disabled.
Richard M. Stallman <rms@gnu.org>
parents:
42105
diff
changeset
|
5674 } |
e85e4d9494b1
(code_convert_region): Don't copy old text if undo disabled.
Richard M. Stallman <rms@gnu.org>
parents:
42105
diff
changeset
|
5675 } |
21321
27b08da98abe
(code_convert_region): Handle skipped ASCII characters
Kenichi Handa <handa@m17n.org>
parents:
21308
diff
changeset
|
5676 |
26847 | 5677 if (coding->composing != COMPOSITION_DISABLED) |
5678 { | |
5679 if (encodep) | |
5680 coding_save_composition (coding, from, to, Fcurrent_buffer ()); | |
5681 else | |
5682 coding_allocate_composition_data (coding, from); | |
5683 } | |
5684 | |
57285
9093a2e9c3fd
(code_convert_region): Don't skip ASCIIs if there are compositions to encode.
Kenichi Handa <handa@m17n.org>
parents:
56595
diff
changeset
|
5685 /* Try to skip the heading and tailing ASCIIs. We can't skip them |
9093a2e9c3fd
(code_convert_region): Don't skip ASCIIs if there are compositions to encode.
Kenichi Handa <handa@m17n.org>
parents:
56595
diff
changeset
|
5686 if we must run CCL program or there are compositions to |
9093a2e9c3fd
(code_convert_region): Don't skip ASCIIs if there are compositions to encode.
Kenichi Handa <handa@m17n.org>
parents:
56595
diff
changeset
|
5687 encode. */ |
9093a2e9c3fd
(code_convert_region): Don't skip ASCIIs if there are compositions to encode.
Kenichi Handa <handa@m17n.org>
parents:
56595
diff
changeset
|
5688 if (coding->type != coding_type_ccl |
9093a2e9c3fd
(code_convert_region): Don't skip ASCIIs if there are compositions to encode.
Kenichi Handa <handa@m17n.org>
parents:
56595
diff
changeset
|
5689 && (! coding->cmp_data || coding->cmp_data->used == 0)) |
29985
c17e78d8c720
(code_convert_region): Even if the length of text is
Kenichi Handa <handa@m17n.org>
parents:
29932
diff
changeset
|
5690 { |
c17e78d8c720
(code_convert_region): Even if the length of text is
Kenichi Handa <handa@m17n.org>
parents:
29932
diff
changeset
|
5691 int from_byte_orig = from_byte, to_byte_orig = to_byte; |
c17e78d8c720
(code_convert_region): Even if the length of text is
Kenichi Handa <handa@m17n.org>
parents:
29932
diff
changeset
|
5692 |
c17e78d8c720
(code_convert_region): Even if the length of text is
Kenichi Handa <handa@m17n.org>
parents:
29932
diff
changeset
|
5693 if (from < GPT && GPT < to) |
c17e78d8c720
(code_convert_region): Even if the length of text is
Kenichi Handa <handa@m17n.org>
parents:
29932
diff
changeset
|
5694 move_gap_both (from, from_byte); |
c17e78d8c720
(code_convert_region): Even if the length of text is
Kenichi Handa <handa@m17n.org>
parents:
29932
diff
changeset
|
5695 SHRINK_CONVERSION_REGION (&from_byte, &to_byte, coding, NULL, encodep); |
c17e78d8c720
(code_convert_region): Even if the length of text is
Kenichi Handa <handa@m17n.org>
parents:
29932
diff
changeset
|
5696 if (from_byte == to_byte |
c17e78d8c720
(code_convert_region): Even if the length of text is
Kenichi Handa <handa@m17n.org>
parents:
29932
diff
changeset
|
5697 && (encodep || NILP (coding->post_read_conversion)) |
c17e78d8c720
(code_convert_region): Even if the length of text is
Kenichi Handa <handa@m17n.org>
parents:
29932
diff
changeset
|
5698 && ! CODING_REQUIRE_FLUSHING (coding)) |
c17e78d8c720
(code_convert_region): Even if the length of text is
Kenichi Handa <handa@m17n.org>
parents:
29932
diff
changeset
|
5699 { |
c17e78d8c720
(code_convert_region): Even if the length of text is
Kenichi Handa <handa@m17n.org>
parents:
29932
diff
changeset
|
5700 coding->produced = len_byte; |
c17e78d8c720
(code_convert_region): Even if the length of text is
Kenichi Handa <handa@m17n.org>
parents:
29932
diff
changeset
|
5701 coding->produced_char = len; |
c17e78d8c720
(code_convert_region): Even if the length of text is
Kenichi Handa <handa@m17n.org>
parents:
29932
diff
changeset
|
5702 if (!replace) |
c17e78d8c720
(code_convert_region): Even if the length of text is
Kenichi Handa <handa@m17n.org>
parents:
29932
diff
changeset
|
5703 /* We must record and adjust for this new text now. */ |
c17e78d8c720
(code_convert_region): Even if the length of text is
Kenichi Handa <handa@m17n.org>
parents:
29932
diff
changeset
|
5704 adjust_after_insert (from, from_byte_orig, to, to_byte_orig, len); |
57285
9093a2e9c3fd
(code_convert_region): Don't skip ASCIIs if there are compositions to encode.
Kenichi Handa <handa@m17n.org>
parents:
56595
diff
changeset
|
5705 coding_free_composition_data (coding); |
29985
c17e78d8c720
(code_convert_region): Even if the length of text is
Kenichi Handa <handa@m17n.org>
parents:
29932
diff
changeset
|
5706 return 0; |
c17e78d8c720
(code_convert_region): Even if the length of text is
Kenichi Handa <handa@m17n.org>
parents:
29932
diff
changeset
|
5707 } |
c17e78d8c720
(code_convert_region): Even if the length of text is
Kenichi Handa <handa@m17n.org>
parents:
29932
diff
changeset
|
5708 |
c17e78d8c720
(code_convert_region): Even if the length of text is
Kenichi Handa <handa@m17n.org>
parents:
29932
diff
changeset
|
5709 head_skip = from_byte - from_byte_orig; |
c17e78d8c720
(code_convert_region): Even if the length of text is
Kenichi Handa <handa@m17n.org>
parents:
29932
diff
changeset
|
5710 tail_skip = to_byte_orig - to_byte; |
c17e78d8c720
(code_convert_region): Even if the length of text is
Kenichi Handa <handa@m17n.org>
parents:
29932
diff
changeset
|
5711 total_skip = head_skip + tail_skip; |
c17e78d8c720
(code_convert_region): Even if the length of text is
Kenichi Handa <handa@m17n.org>
parents:
29932
diff
changeset
|
5712 from += head_skip; |
c17e78d8c720
(code_convert_region): Even if the length of text is
Kenichi Handa <handa@m17n.org>
parents:
29932
diff
changeset
|
5713 to -= tail_skip; |
c17e78d8c720
(code_convert_region): Even if the length of text is
Kenichi Handa <handa@m17n.org>
parents:
29932
diff
changeset
|
5714 len -= total_skip; len_byte -= total_skip; |
c17e78d8c720
(code_convert_region): Even if the length of text is
Kenichi Handa <handa@m17n.org>
parents:
29932
diff
changeset
|
5715 } |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5716 |
36087 | 5717 /* For conversion, we must put the gap before the text in addition to |
20931
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
5718 making the gap larger for efficient decoding. The required gap |
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
5719 size starts from 2000 which is the magic number used in make_gap. |
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
5720 But, after one batch of conversion, it will be incremented if we |
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
5721 find that it is not enough . */ |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5722 require = 2000; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5723 |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5724 if (GAP_SIZE < require) |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5725 make_gap (require - GAP_SIZE); |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5726 move_gap_both (from, from_byte); |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5727 |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5728 inserted = inserted_byte = 0; |
20931
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
5729 |
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
5730 GAP_SIZE += len_byte; |
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
5731 ZV -= len; |
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
5732 Z -= len; |
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
5733 ZV_BYTE -= len_byte; |
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
5734 Z_BYTE -= len_byte; |
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
5735 |
25370
20d8158841b0
(code_convert_region): Compute beg/end_unchanged per
Gerd Moellmann <gerd@gnu.org>
parents:
25067
diff
changeset
|
5736 if (GPT - BEG < BEG_UNCHANGED) |
20d8158841b0
(code_convert_region): Compute beg/end_unchanged per
Gerd Moellmann <gerd@gnu.org>
parents:
25067
diff
changeset
|
5737 BEG_UNCHANGED = GPT - BEG; |
20d8158841b0
(code_convert_region): Compute beg/end_unchanged per
Gerd Moellmann <gerd@gnu.org>
parents:
25067
diff
changeset
|
5738 if (Z - GPT < END_UNCHANGED) |
20d8158841b0
(code_convert_region): Compute beg/end_unchanged per
Gerd Moellmann <gerd@gnu.org>
parents:
25067
diff
changeset
|
5739 END_UNCHANGED = Z - GPT; |
23258
2f8585bcea90
(code_convert_region): Update beg_unchanged and
Kenichi Handa <handa@m17n.org>
parents:
23201
diff
changeset
|
5740 |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5741 if (!encodep && coding->src_multibyte) |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5742 { |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5743 /* Decoding routines expects that the source text is unibyte. |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5744 We must convert 8-bit characters of multibyte form to |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5745 unibyte. */ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5746 int len_byte_orig = len_byte; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5747 len_byte = str_as_unibyte (GAP_END_ADDR - len_byte, len_byte); |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5748 if (len_byte < len_byte_orig) |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5749 safe_bcopy (GAP_END_ADDR - len_byte_orig, GAP_END_ADDR - len_byte, |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5750 len_byte); |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5751 coding->src_multibyte = 0; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5752 } |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5753 |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5754 for (;;) |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5755 { |
20931
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
5756 int result; |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5757 |
26847 | 5758 /* The buffer memory is now: |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5759 +--------+converted-text+---------+-------original-text-------+---+ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5760 |<-from->|<--inserted-->|---------|<--------len_byte--------->|---| |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5761 |<---------------------- GAP ----------------------->| */ |
26847 | 5762 src = GAP_END_ADDR - len_byte; |
5763 dst = GPT_ADDR + inserted_byte; | |
5764 | |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5765 if (encodep) |
20931
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
5766 result = encode_coding (coding, src, dst, len_byte, 0); |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5767 else |
42105
09cc243e2d14
(code_convert_region): Update coding->cmp_data->char_offset
Richard M. Stallman <rms@gnu.org>
parents:
42104
diff
changeset
|
5768 { |
09cc243e2d14
(code_convert_region): Update coding->cmp_data->char_offset
Richard M. Stallman <rms@gnu.org>
parents:
42104
diff
changeset
|
5769 if (coding->composing != COMPOSITION_DISABLED) |
09cc243e2d14
(code_convert_region): Update coding->cmp_data->char_offset
Richard M. Stallman <rms@gnu.org>
parents:
42104
diff
changeset
|
5770 coding->cmp_data->char_offset = from + inserted; |
09cc243e2d14
(code_convert_region): Update coding->cmp_data->char_offset
Richard M. Stallman <rms@gnu.org>
parents:
42104
diff
changeset
|
5771 result = decode_coding (coding, src, dst, len_byte, 0); |
09cc243e2d14
(code_convert_region): Update coding->cmp_data->char_offset
Richard M. Stallman <rms@gnu.org>
parents:
42104
diff
changeset
|
5772 } |
26847 | 5773 |
5774 /* The buffer memory is now: | |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5775 +--------+-------converted-text----+--+------original-text----+---+ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5776 |<-from->|<-inserted->|<-produced->|--|<-(len_byte-consumed)->|---| |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5777 |<---------------------- GAP ----------------------->| */ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5778 |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5779 inserted += coding->produced_char; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5780 inserted_byte += coding->produced; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5781 len_byte -= coding->consumed; |
26847 | 5782 |
5783 if (result == CODING_FINISH_INSUFFICIENT_CMP) | |
5784 { | |
5785 coding_allocate_composition_data (coding, from + inserted); | |
5786 continue; | |
5787 } | |
5788 | |
20931
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
5789 src += coding->consumed; |
26240
93f3d2337323
(code_convert_region): Update `dst' correctly.
Kenichi Handa <handa@m17n.org>
parents:
26088
diff
changeset
|
5790 dst += coding->produced; |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5791 |
23279
ca159e828a68
(ccl_coding_driver): If ccl_driver is interrupted by a
Kenichi Handa <handa@m17n.org>
parents:
23258
diff
changeset
|
5792 if (result == CODING_FINISH_NORMAL) |
ca159e828a68
(ccl_coding_driver): If ccl_driver is interrupted by a
Kenichi Handa <handa@m17n.org>
parents:
23258
diff
changeset
|
5793 { |
ca159e828a68
(ccl_coding_driver): If ccl_driver is interrupted by a
Kenichi Handa <handa@m17n.org>
parents:
23258
diff
changeset
|
5794 src += len_byte; |
ca159e828a68
(ccl_coding_driver): If ccl_driver is interrupted by a
Kenichi Handa <handa@m17n.org>
parents:
23258
diff
changeset
|
5795 break; |
ca159e828a68
(ccl_coding_driver): If ccl_driver is interrupted by a
Kenichi Handa <handa@m17n.org>
parents:
23258
diff
changeset
|
5796 } |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5797 if (! encodep && result == CODING_FINISH_INCONSISTENT_EOL) |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5798 { |
20931
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
5799 unsigned char *pend = dst, *p = pend - inserted_byte; |
24706
778b3f056f7f
(code_convert_region): If eol format is inconsistent,
Kenichi Handa <handa@m17n.org>
parents:
24667
diff
changeset
|
5800 Lisp_Object eol_type; |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5801 |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5802 /* Encode LFs back to the original eol format (CR or CRLF). */ |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5803 if (coding->eol_type == CODING_EOL_CR) |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5804 { |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5805 while (p < pend) if (*p++ == '\n') p[-1] = '\r'; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5806 } |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5807 else |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5808 { |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5809 int count = 0; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5810 |
20931
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
5811 while (p < pend) if (*p++ == '\n') count++; |
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
5812 if (src - dst < count) |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5813 { |
24706
778b3f056f7f
(code_convert_region): If eol format is inconsistent,
Kenichi Handa <handa@m17n.org>
parents:
24667
diff
changeset
|
5814 /* We don't have sufficient room for encoding LFs |
20931
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
5815 back to CRLF. We must record converted and |
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
5816 not-yet-converted text back to the buffer |
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
5817 content, enlarge the gap, then record them out of |
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
5818 the buffer contents again. */ |
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
5819 int add = len_byte + inserted_byte; |
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
5820 |
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
5821 GAP_SIZE -= add; |
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
5822 ZV += add; Z += add; ZV_BYTE += add; Z_BYTE += add; |
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
5823 GPT += inserted_byte; GPT_BYTE += inserted_byte; |
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
5824 make_gap (count - GAP_SIZE); |
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
5825 GAP_SIZE += add; |
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
5826 ZV -= add; Z -= add; ZV_BYTE -= add; Z_BYTE -= add; |
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
5827 GPT -= inserted_byte; GPT_BYTE -= inserted_byte; |
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
5828 /* Don't forget to update SRC, DST, and PEND. */ |
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
5829 src = GAP_END_ADDR - len_byte; |
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
5830 dst = GPT_ADDR + inserted_byte; |
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
5831 pend = dst; |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5832 } |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5833 inserted += count; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5834 inserted_byte += count; |
20931
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
5835 coding->produced += count; |
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
5836 p = dst = pend + count; |
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
5837 while (count) |
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
5838 { |
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
5839 *--p = *--pend; |
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
5840 if (*p == '\n') count--, *--p = '\r'; |
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
5841 } |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5842 } |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5843 |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5844 /* Suppress eol-format conversion in the further conversion. */ |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5845 coding->eol_type = CODING_EOL_LF; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5846 |
24706
778b3f056f7f
(code_convert_region): If eol format is inconsistent,
Kenichi Handa <handa@m17n.org>
parents:
24667
diff
changeset
|
5847 /* Set the coding system symbol to that for Unix-like EOL. */ |
778b3f056f7f
(code_convert_region): If eol format is inconsistent,
Kenichi Handa <handa@m17n.org>
parents:
24667
diff
changeset
|
5848 eol_type = Fget (saved_coding_symbol, Qeol_type); |
778b3f056f7f
(code_convert_region): If eol format is inconsistent,
Kenichi Handa <handa@m17n.org>
parents:
24667
diff
changeset
|
5849 if (VECTORP (eol_type) |
778b3f056f7f
(code_convert_region): If eol format is inconsistent,
Kenichi Handa <handa@m17n.org>
parents:
24667
diff
changeset
|
5850 && XVECTOR (eol_type)->size == 3 |
778b3f056f7f
(code_convert_region): If eol format is inconsistent,
Kenichi Handa <handa@m17n.org>
parents:
24667
diff
changeset
|
5851 && SYMBOLP (XVECTOR (eol_type)->contents[CODING_EOL_LF])) |
778b3f056f7f
(code_convert_region): If eol format is inconsistent,
Kenichi Handa <handa@m17n.org>
parents:
24667
diff
changeset
|
5852 coding->symbol = XVECTOR (eol_type)->contents[CODING_EOL_LF]; |
778b3f056f7f
(code_convert_region): If eol format is inconsistent,
Kenichi Handa <handa@m17n.org>
parents:
24667
diff
changeset
|
5853 else |
778b3f056f7f
(code_convert_region): If eol format is inconsistent,
Kenichi Handa <handa@m17n.org>
parents:
24667
diff
changeset
|
5854 coding->symbol = saved_coding_symbol; |
42104
d69c2368e549
(DECODE_COMPOSITION_END): Fixed a typo in the last
Sam Steingold <sds@gnu.org>
parents:
42103
diff
changeset
|
5855 |
20931
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
5856 continue; |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5857 } |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5858 if (len_byte <= 0) |
23881
20d595402dea
(DECODE_DESIGNATION): Jump to label_invalid_code if
Kenichi Handa <handa@m17n.org>
parents:
23564
diff
changeset
|
5859 { |
20d595402dea
(DECODE_DESIGNATION): Jump to label_invalid_code if
Kenichi Handa <handa@m17n.org>
parents:
23564
diff
changeset
|
5860 if (coding->type != coding_type_ccl |
20d595402dea
(DECODE_DESIGNATION): Jump to label_invalid_code if
Kenichi Handa <handa@m17n.org>
parents:
23564
diff
changeset
|
5861 || coding->mode & CODING_MODE_LAST_BLOCK) |
20d595402dea
(DECODE_DESIGNATION): Jump to label_invalid_code if
Kenichi Handa <handa@m17n.org>
parents:
23564
diff
changeset
|
5862 break; |
20d595402dea
(DECODE_DESIGNATION): Jump to label_invalid_code if
Kenichi Handa <handa@m17n.org>
parents:
23564
diff
changeset
|
5863 coding->mode |= CODING_MODE_LAST_BLOCK; |
20d595402dea
(DECODE_DESIGNATION): Jump to label_invalid_code if
Kenichi Handa <handa@m17n.org>
parents:
23564
diff
changeset
|
5864 continue; |
20d595402dea
(DECODE_DESIGNATION): Jump to label_invalid_code if
Kenichi Handa <handa@m17n.org>
parents:
23564
diff
changeset
|
5865 } |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5866 if (result == CODING_FINISH_INSUFFICIENT_SRC) |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5867 { |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5868 /* The source text ends in invalid codes. Let's just |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5869 make them valid buffer contents, and finish conversion. */ |
38518
883da5f3dbac
(code_convert_region): Handle the multibyte case if
Gerd Moellmann <gerd@gnu.org>
parents:
38473
diff
changeset
|
5870 if (multibyte_p) |
883da5f3dbac
(code_convert_region): Handle the multibyte case if
Gerd Moellmann <gerd@gnu.org>
parents:
38473
diff
changeset
|
5871 { |
883da5f3dbac
(code_convert_region): Handle the multibyte case if
Gerd Moellmann <gerd@gnu.org>
parents:
38473
diff
changeset
|
5872 unsigned char *start = dst; |
42104
d69c2368e549
(DECODE_COMPOSITION_END): Fixed a typo in the last
Sam Steingold <sds@gnu.org>
parents:
42103
diff
changeset
|
5873 |
38518
883da5f3dbac
(code_convert_region): Handle the multibyte case if
Gerd Moellmann <gerd@gnu.org>
parents:
38473
diff
changeset
|
5874 inserted += len_byte; |
883da5f3dbac
(code_convert_region): Handle the multibyte case if
Gerd Moellmann <gerd@gnu.org>
parents:
38473
diff
changeset
|
5875 while (len_byte--) |
883da5f3dbac
(code_convert_region): Handle the multibyte case if
Gerd Moellmann <gerd@gnu.org>
parents:
38473
diff
changeset
|
5876 { |
883da5f3dbac
(code_convert_region): Handle the multibyte case if
Gerd Moellmann <gerd@gnu.org>
parents:
38473
diff
changeset
|
5877 int c = *src++; |
883da5f3dbac
(code_convert_region): Handle the multibyte case if
Gerd Moellmann <gerd@gnu.org>
parents:
38473
diff
changeset
|
5878 dst += CHAR_STRING (c, dst); |
883da5f3dbac
(code_convert_region): Handle the multibyte case if
Gerd Moellmann <gerd@gnu.org>
parents:
38473
diff
changeset
|
5879 } |
883da5f3dbac
(code_convert_region): Handle the multibyte case if
Gerd Moellmann <gerd@gnu.org>
parents:
38473
diff
changeset
|
5880 |
883da5f3dbac
(code_convert_region): Handle the multibyte case if
Gerd Moellmann <gerd@gnu.org>
parents:
38473
diff
changeset
|
5881 inserted_byte += dst - start; |
883da5f3dbac
(code_convert_region): Handle the multibyte case if
Gerd Moellmann <gerd@gnu.org>
parents:
38473
diff
changeset
|
5882 } |
883da5f3dbac
(code_convert_region): Handle the multibyte case if
Gerd Moellmann <gerd@gnu.org>
parents:
38473
diff
changeset
|
5883 else |
883da5f3dbac
(code_convert_region): Handle the multibyte case if
Gerd Moellmann <gerd@gnu.org>
parents:
38473
diff
changeset
|
5884 { |
883da5f3dbac
(code_convert_region): Handle the multibyte case if
Gerd Moellmann <gerd@gnu.org>
parents:
38473
diff
changeset
|
5885 inserted += len_byte; |
883da5f3dbac
(code_convert_region): Handle the multibyte case if
Gerd Moellmann <gerd@gnu.org>
parents:
38473
diff
changeset
|
5886 inserted_byte += len_byte; |
883da5f3dbac
(code_convert_region): Handle the multibyte case if
Gerd Moellmann <gerd@gnu.org>
parents:
38473
diff
changeset
|
5887 while (len_byte--) |
883da5f3dbac
(code_convert_region): Handle the multibyte case if
Gerd Moellmann <gerd@gnu.org>
parents:
38473
diff
changeset
|
5888 *dst++ = *src++; |
883da5f3dbac
(code_convert_region): Handle the multibyte case if
Gerd Moellmann <gerd@gnu.org>
parents:
38473
diff
changeset
|
5889 } |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5890 break; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5891 } |
23279
ca159e828a68
(ccl_coding_driver): If ccl_driver is interrupted by a
Kenichi Handa <handa@m17n.org>
parents:
23258
diff
changeset
|
5892 if (result == CODING_FINISH_INTERRUPT) |
ca159e828a68
(ccl_coding_driver): If ccl_driver is interrupted by a
Kenichi Handa <handa@m17n.org>
parents:
23258
diff
changeset
|
5893 { |
ca159e828a68
(ccl_coding_driver): If ccl_driver is interrupted by a
Kenichi Handa <handa@m17n.org>
parents:
23258
diff
changeset
|
5894 /* The conversion procedure was interrupted by a user. */ |
ca159e828a68
(ccl_coding_driver): If ccl_driver is interrupted by a
Kenichi Handa <handa@m17n.org>
parents:
23258
diff
changeset
|
5895 break; |
ca159e828a68
(ccl_coding_driver): If ccl_driver is interrupted by a
Kenichi Handa <handa@m17n.org>
parents:
23258
diff
changeset
|
5896 } |
ca159e828a68
(ccl_coding_driver): If ccl_driver is interrupted by a
Kenichi Handa <handa@m17n.org>
parents:
23258
diff
changeset
|
5897 /* Now RESULT == CODING_FINISH_INSUFFICIENT_DST */ |
ca159e828a68
(ccl_coding_driver): If ccl_driver is interrupted by a
Kenichi Handa <handa@m17n.org>
parents:
23258
diff
changeset
|
5898 if (coding->consumed < 1) |
ca159e828a68
(ccl_coding_driver): If ccl_driver is interrupted by a
Kenichi Handa <handa@m17n.org>
parents:
23258
diff
changeset
|
5899 { |
ca159e828a68
(ccl_coding_driver): If ccl_driver is interrupted by a
Kenichi Handa <handa@m17n.org>
parents:
23258
diff
changeset
|
5900 /* It's quite strange to require more memory without |
ca159e828a68
(ccl_coding_driver): If ccl_driver is interrupted by a
Kenichi Handa <handa@m17n.org>
parents:
23258
diff
changeset
|
5901 consuming any bytes. Perhaps CCL program bug. */ |
ca159e828a68
(ccl_coding_driver): If ccl_driver is interrupted by a
Kenichi Handa <handa@m17n.org>
parents:
23258
diff
changeset
|
5902 break; |
ca159e828a68
(ccl_coding_driver): If ccl_driver is interrupted by a
Kenichi Handa <handa@m17n.org>
parents:
23258
diff
changeset
|
5903 } |
20931
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
5904 if (first) |
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
5905 { |
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
5906 /* We have just done the first batch of conversion which was |
36087 | 5907 stopped because of insufficient gap. Let's reconsider the |
20931
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
5908 required gap size (i.e. SRT - DST) now. |
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
5909 |
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
5910 We have converted ORIG bytes (== coding->consumed) into |
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
5911 NEW bytes (coding->produced). To convert the remaining |
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
5912 LEN bytes, we may need REQUIRE bytes of gap, where: |
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
5913 REQUIRE + LEN_BYTE = LEN_BYTE * (NEW / ORIG) |
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
5914 REQUIRE = LEN_BYTE * (NEW - ORIG) / ORIG |
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
5915 Here, we are sure that NEW >= ORIG. */ |
47791
1a71f916ad2f
(code_convert_region): When we need more GAP for
Kenichi Handa <handa@m17n.org>
parents:
47698
diff
changeset
|
5916 |
1a71f916ad2f
(code_convert_region): When we need more GAP for
Kenichi Handa <handa@m17n.org>
parents:
47698
diff
changeset
|
5917 if (coding->produced <= coding->consumed) |
1a71f916ad2f
(code_convert_region): When we need more GAP for
Kenichi Handa <handa@m17n.org>
parents:
47698
diff
changeset
|
5918 { |
1a71f916ad2f
(code_convert_region): When we need more GAP for
Kenichi Handa <handa@m17n.org>
parents:
47698
diff
changeset
|
5919 /* This happens because of CCL-based coding system with |
1a71f916ad2f
(code_convert_region): When we need more GAP for
Kenichi Handa <handa@m17n.org>
parents:
47698
diff
changeset
|
5920 eol-type CRLF. */ |
1a71f916ad2f
(code_convert_region): When we need more GAP for
Kenichi Handa <handa@m17n.org>
parents:
47698
diff
changeset
|
5921 require = 0; |
1a71f916ad2f
(code_convert_region): When we need more GAP for
Kenichi Handa <handa@m17n.org>
parents:
47698
diff
changeset
|
5922 } |
1a71f916ad2f
(code_convert_region): When we need more GAP for
Kenichi Handa <handa@m17n.org>
parents:
47698
diff
changeset
|
5923 else |
1a71f916ad2f
(code_convert_region): When we need more GAP for
Kenichi Handa <handa@m17n.org>
parents:
47698
diff
changeset
|
5924 { |
59095
8a2a99b47220
(code_convert_region): Fix calculation of `ratio'.
Kenichi Handa <handa@m17n.org>
parents:
58637
diff
changeset
|
5925 float ratio = coding->produced - coding->consumed; |
8a2a99b47220
(code_convert_region): Fix calculation of `ratio'.
Kenichi Handa <handa@m17n.org>
parents:
58637
diff
changeset
|
5926 ratio /= coding->consumed; |
47791
1a71f916ad2f
(code_convert_region): When we need more GAP for
Kenichi Handa <handa@m17n.org>
parents:
47698
diff
changeset
|
5927 require = len_byte * ratio; |
1a71f916ad2f
(code_convert_region): When we need more GAP for
Kenichi Handa <handa@m17n.org>
parents:
47698
diff
changeset
|
5928 } |
20931
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
5929 first = 0; |
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
5930 } |
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
5931 if ((src - dst) < (require + 2000)) |
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
5932 { |
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
5933 /* See the comment above the previous call of make_gap. */ |
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
5934 int add = len_byte + inserted_byte; |
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
5935 |
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
5936 GAP_SIZE -= add; |
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
5937 ZV += add; Z += add; ZV_BYTE += add; Z_BYTE += add; |
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
5938 GPT += inserted_byte; GPT_BYTE += inserted_byte; |
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
5939 make_gap (require + 2000); |
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
5940 GAP_SIZE += add; |
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
5941 ZV -= add; Z -= add; ZV_BYTE -= add; Z_BYTE -= add; |
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
5942 GPT -= inserted_byte; GPT_BYTE -= inserted_byte; |
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
5943 } |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5944 } |
20931
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
5945 if (src - dst > 0) *dst = 0; /* Put an anchor. */ |
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
5946 |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5947 if (encodep && coding->dst_multibyte) |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5948 { |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5949 /* The output is unibyte. We must convert 8-bit characters to |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5950 multibyte form. */ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5951 if (inserted_byte * 2 > GAP_SIZE) |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5952 { |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5953 GAP_SIZE -= inserted_byte; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5954 ZV += inserted_byte; Z += inserted_byte; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5955 ZV_BYTE += inserted_byte; Z_BYTE += inserted_byte; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5956 GPT += inserted_byte; GPT_BYTE += inserted_byte; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5957 make_gap (inserted_byte - GAP_SIZE); |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5958 GAP_SIZE += inserted_byte; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5959 ZV -= inserted_byte; Z -= inserted_byte; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5960 ZV_BYTE -= inserted_byte; Z_BYTE -= inserted_byte; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5961 GPT -= inserted_byte; GPT_BYTE -= inserted_byte; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5962 } |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5963 inserted_byte = str_to_multibyte (GPT_ADDR, GAP_SIZE, inserted_byte); |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5964 } |
21140
179c73d91f70
(code_convert_region): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
21132
diff
changeset
|
5965 |
42104
d69c2368e549
(DECODE_COMPOSITION_END): Fixed a typo in the last
Sam Steingold <sds@gnu.org>
parents:
42103
diff
changeset
|
5966 /* If we shrank the conversion area, adjust it now. */ |
21321
27b08da98abe
(code_convert_region): Handle skipped ASCII characters
Kenichi Handa <handa@m17n.org>
parents:
21308
diff
changeset
|
5967 if (total_skip > 0) |
27b08da98abe
(code_convert_region): Handle skipped ASCII characters
Kenichi Handa <handa@m17n.org>
parents:
21308
diff
changeset
|
5968 { |
27b08da98abe
(code_convert_region): Handle skipped ASCII characters
Kenichi Handa <handa@m17n.org>
parents:
21308
diff
changeset
|
5969 if (tail_skip > 0) |
27b08da98abe
(code_convert_region): Handle skipped ASCII characters
Kenichi Handa <handa@m17n.org>
parents:
21308
diff
changeset
|
5970 safe_bcopy (GAP_END_ADDR, GPT_ADDR + inserted_byte, tail_skip); |
27b08da98abe
(code_convert_region): Handle skipped ASCII characters
Kenichi Handa <handa@m17n.org>
parents:
21308
diff
changeset
|
5971 inserted += total_skip; inserted_byte += total_skip; |
27b08da98abe
(code_convert_region): Handle skipped ASCII characters
Kenichi Handa <handa@m17n.org>
parents:
21308
diff
changeset
|
5972 GAP_SIZE += total_skip; |
27b08da98abe
(code_convert_region): Handle skipped ASCII characters
Kenichi Handa <handa@m17n.org>
parents:
21308
diff
changeset
|
5973 GPT -= head_skip; GPT_BYTE -= head_skip; |
27b08da98abe
(code_convert_region): Handle skipped ASCII characters
Kenichi Handa <handa@m17n.org>
parents:
21308
diff
changeset
|
5974 ZV -= total_skip; ZV_BYTE -= total_skip; |
27b08da98abe
(code_convert_region): Handle skipped ASCII characters
Kenichi Handa <handa@m17n.org>
parents:
21308
diff
changeset
|
5975 Z -= total_skip; Z_BYTE -= total_skip; |
27b08da98abe
(code_convert_region): Handle skipped ASCII characters
Kenichi Handa <handa@m17n.org>
parents:
21308
diff
changeset
|
5976 from -= head_skip; from_byte -= head_skip; |
27b08da98abe
(code_convert_region): Handle skipped ASCII characters
Kenichi Handa <handa@m17n.org>
parents:
21308
diff
changeset
|
5977 to += tail_skip; to_byte += tail_skip; |
27b08da98abe
(code_convert_region): Handle skipped ASCII characters
Kenichi Handa <handa@m17n.org>
parents:
21308
diff
changeset
|
5978 } |
27b08da98abe
(code_convert_region): Handle skipped ASCII characters
Kenichi Handa <handa@m17n.org>
parents:
21308
diff
changeset
|
5979 |
23537
28cd5faf93dd
(code_convert_region): While preserving the orignal
Kenichi Handa <handa@m17n.org>
parents:
23514
diff
changeset
|
5980 prev_Z = Z; |
42661
e85e4d9494b1
(code_convert_region): Don't copy old text if undo disabled.
Richard M. Stallman <rms@gnu.org>
parents:
42105
diff
changeset
|
5981 if (! EQ (current_buffer->undo_list, Qt)) |
e85e4d9494b1
(code_convert_region): Don't copy old text if undo disabled.
Richard M. Stallman <rms@gnu.org>
parents:
42105
diff
changeset
|
5982 adjust_after_replace (from, from_byte, deletion, inserted, inserted_byte); |
e85e4d9494b1
(code_convert_region): Don't copy old text if undo disabled.
Richard M. Stallman <rms@gnu.org>
parents:
42105
diff
changeset
|
5983 else |
e85e4d9494b1
(code_convert_region): Don't copy old text if undo disabled.
Richard M. Stallman <rms@gnu.org>
parents:
42105
diff
changeset
|
5984 adjust_after_replace_noundo (from, from_byte, nchars_del, nbytes_del, |
e85e4d9494b1
(code_convert_region): Don't copy old text if undo disabled.
Richard M. Stallman <rms@gnu.org>
parents:
42105
diff
changeset
|
5985 inserted, inserted_byte); |
23537
28cd5faf93dd
(code_convert_region): While preserving the orignal
Kenichi Handa <handa@m17n.org>
parents:
23514
diff
changeset
|
5986 inserted = Z - prev_Z; |
21140
179c73d91f70
(code_convert_region): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
21132
diff
changeset
|
5987 |
26847 | 5988 if (!encodep && coding->cmp_data && coding->cmp_data->used) |
5989 coding_restore_composition (coding, Fcurrent_buffer ()); | |
5990 coding_free_composition_data (coding); | |
5991 | |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5992 if (! inhibit_pre_post_conversion |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5993 && ! encodep && ! NILP (coding->post_read_conversion)) |
21062
839b22ad1e42
(code_convert_region): Handle the case that codes
Kenichi Handa <handa@m17n.org>
parents:
20999
diff
changeset
|
5994 { |
21140
179c73d91f70
(code_convert_region): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
21132
diff
changeset
|
5995 Lisp_Object val; |
50484
6818550bfbc7
(code_convert_region_unwind): Set
Kenichi Handa <handa@m17n.org>
parents:
50185
diff
changeset
|
5996 Lisp_Object saved_coding_system; |
23514
7bad909cd6f1
(setup_coding_system): Fix setting up
Kenichi Handa <handa@m17n.org>
parents:
23475
diff
changeset
|
5997 |
7bad909cd6f1
(setup_coding_system): Fix setting up
Kenichi Handa <handa@m17n.org>
parents:
23475
diff
changeset
|
5998 if (from != PT) |
7bad909cd6f1
(setup_coding_system): Fix setting up
Kenichi Handa <handa@m17n.org>
parents:
23475
diff
changeset
|
5999 TEMP_SET_PT_BOTH (from, from_byte); |
23537
28cd5faf93dd
(code_convert_region): While preserving the orignal
Kenichi Handa <handa@m17n.org>
parents:
23514
diff
changeset
|
6000 prev_Z = Z; |
50484
6818550bfbc7
(code_convert_region_unwind): Set
Kenichi Handa <handa@m17n.org>
parents:
50185
diff
changeset
|
6001 record_unwind_protect (code_convert_region_unwind, |
64308
93129de4b8a4
(code_convert_region_unwind): ARG is changed to a cons.
Kenichi Handa <handa@m17n.org>
parents:
64251
diff
changeset
|
6002 Fcons (Vlast_coding_system_used, Qnil)); |
50484
6818550bfbc7
(code_convert_region_unwind): Set
Kenichi Handa <handa@m17n.org>
parents:
50185
diff
changeset
|
6003 saved_coding_system = Vlast_coding_system_used; |
6818550bfbc7
(code_convert_region_unwind): Set
Kenichi Handa <handa@m17n.org>
parents:
50185
diff
changeset
|
6004 Vlast_coding_system_used = coding->symbol; |
26067
f54ca66e2571
(code_convert_string): Add record_unwind_protect to
Kenichi Handa <handa@m17n.org>
parents:
25860
diff
changeset
|
6005 /* We should not call any more pre-write/post-read-conversion |
f54ca66e2571
(code_convert_string): Add record_unwind_protect to
Kenichi Handa <handa@m17n.org>
parents:
25860
diff
changeset
|
6006 functions while this post-read-conversion is running. */ |
f54ca66e2571
(code_convert_string): Add record_unwind_protect to
Kenichi Handa <handa@m17n.org>
parents:
25860
diff
changeset
|
6007 inhibit_pre_post_conversion = 1; |
21140
179c73d91f70
(code_convert_region): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
21132
diff
changeset
|
6008 val = call1 (coding->post_read_conversion, make_number (inserted)); |
26067
f54ca66e2571
(code_convert_string): Add record_unwind_protect to
Kenichi Handa <handa@m17n.org>
parents:
25860
diff
changeset
|
6009 inhibit_pre_post_conversion = 0; |
50484
6818550bfbc7
(code_convert_region_unwind): Set
Kenichi Handa <handa@m17n.org>
parents:
50185
diff
changeset
|
6010 coding->symbol = Vlast_coding_system_used; |
6818550bfbc7
(code_convert_region_unwind): Set
Kenichi Handa <handa@m17n.org>
parents:
50185
diff
changeset
|
6011 Vlast_coding_system_used = saved_coding_system; |
26067
f54ca66e2571
(code_convert_string): Add record_unwind_protect to
Kenichi Handa <handa@m17n.org>
parents:
25860
diff
changeset
|
6012 /* Discard the unwind protect. */ |
f54ca66e2571
(code_convert_string): Add record_unwind_protect to
Kenichi Handa <handa@m17n.org>
parents:
25860
diff
changeset
|
6013 specpdl_ptr--; |
40656
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents:
40461
diff
changeset
|
6014 CHECK_NUMBER (val); |
23881
20d595402dea
(DECODE_DESIGNATION): Jump to label_invalid_code if
Kenichi Handa <handa@m17n.org>
parents:
23564
diff
changeset
|
6015 inserted += Z - prev_Z; |
23514
7bad909cd6f1
(setup_coding_system): Fix setting up
Kenichi Handa <handa@m17n.org>
parents:
23475
diff
changeset
|
6016 } |
7bad909cd6f1
(setup_coding_system): Fix setting up
Kenichi Handa <handa@m17n.org>
parents:
23475
diff
changeset
|
6017 |
7bad909cd6f1
(setup_coding_system): Fix setting up
Kenichi Handa <handa@m17n.org>
parents:
23475
diff
changeset
|
6018 if (orig_point >= from) |
7bad909cd6f1
(setup_coding_system): Fix setting up
Kenichi Handa <handa@m17n.org>
parents:
23475
diff
changeset
|
6019 { |
7bad909cd6f1
(setup_coding_system): Fix setting up
Kenichi Handa <handa@m17n.org>
parents:
23475
diff
changeset
|
6020 if (orig_point >= from + orig_len) |
7bad909cd6f1
(setup_coding_system): Fix setting up
Kenichi Handa <handa@m17n.org>
parents:
23475
diff
changeset
|
6021 orig_point += inserted - orig_len; |
7bad909cd6f1
(setup_coding_system): Fix setting up
Kenichi Handa <handa@m17n.org>
parents:
23475
diff
changeset
|
6022 else |
7bad909cd6f1
(setup_coding_system): Fix setting up
Kenichi Handa <handa@m17n.org>
parents:
23475
diff
changeset
|
6023 orig_point = from; |
7bad909cd6f1
(setup_coding_system): Fix setting up
Kenichi Handa <handa@m17n.org>
parents:
23475
diff
changeset
|
6024 TEMP_SET_PT (orig_point); |
21062
839b22ad1e42
(code_convert_region): Handle the case that codes
Kenichi Handa <handa@m17n.org>
parents:
20999
diff
changeset
|
6025 } |
20931
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
6026 |
26847 | 6027 if (replace) |
6028 { | |
6029 signal_after_change (from, to - from, inserted); | |
26900
a8f4cebb614d
(code_convert_region): Fix the secoding arg to
Kenichi Handa <handa@m17n.org>
parents:
26847
diff
changeset
|
6030 update_compositions (from, from + inserted, CHECK_BORDER); |
26847 | 6031 } |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
6032 |
20931
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
6033 { |
21321
27b08da98abe
(code_convert_region): Handle skipped ASCII characters
Kenichi Handa <handa@m17n.org>
parents:
21308
diff
changeset
|
6034 coding->consumed = to_byte - from_byte; |
27b08da98abe
(code_convert_region): Handle skipped ASCII characters
Kenichi Handa <handa@m17n.org>
parents:
21308
diff
changeset
|
6035 coding->consumed_char = to - from; |
27b08da98abe
(code_convert_region): Handle skipped ASCII characters
Kenichi Handa <handa@m17n.org>
parents:
21308
diff
changeset
|
6036 coding->produced = inserted_byte; |
27b08da98abe
(code_convert_region): Handle skipped ASCII characters
Kenichi Handa <handa@m17n.org>
parents:
21308
diff
changeset
|
6037 coding->produced_char = inserted; |
20931
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
6038 } |
21132
75c6408013e5
(code_convert_region): Fix previous change. Adjusted
Richard M. Stallman <rms@gnu.org>
parents:
21067
diff
changeset
|
6039 |
20931
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
6040 return 0; |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
6041 } |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
6042 |
58637
ff8a37b5299b
(Vcode_conversion_workbuf_name): New variable.
Kenichi Handa <handa@m17n.org>
parents:
58502
diff
changeset
|
6043 /* Name (or base name) of work buffer for code conversion. */ |
ff8a37b5299b
(Vcode_conversion_workbuf_name): New variable.
Kenichi Handa <handa@m17n.org>
parents:
58502
diff
changeset
|
6044 static Lisp_Object Vcode_conversion_workbuf_name; |
ff8a37b5299b
(Vcode_conversion_workbuf_name): New variable.
Kenichi Handa <handa@m17n.org>
parents:
58502
diff
changeset
|
6045 |
ff8a37b5299b
(Vcode_conversion_workbuf_name): New variable.
Kenichi Handa <handa@m17n.org>
parents:
58502
diff
changeset
|
6046 /* Set the current buffer to the working buffer prepared for |
ff8a37b5299b
(Vcode_conversion_workbuf_name): New variable.
Kenichi Handa <handa@m17n.org>
parents:
58502
diff
changeset
|
6047 code-conversion. MULTIBYTE specifies the multibyteness of the |
64308
93129de4b8a4
(code_convert_region_unwind): ARG is changed to a cons.
Kenichi Handa <handa@m17n.org>
parents:
64251
diff
changeset
|
6048 buffer. Return the buffer we set if it must be killed after use. |
93129de4b8a4
(code_convert_region_unwind): ARG is changed to a cons.
Kenichi Handa <handa@m17n.org>
parents:
64251
diff
changeset
|
6049 Otherwise return Qnil. */ |
93129de4b8a4
(code_convert_region_unwind): ARG is changed to a cons.
Kenichi Handa <handa@m17n.org>
parents:
64251
diff
changeset
|
6050 |
93129de4b8a4
(code_convert_region_unwind): ARG is changed to a cons.
Kenichi Handa <handa@m17n.org>
parents:
64251
diff
changeset
|
6051 static Lisp_Object |
58637
ff8a37b5299b
(Vcode_conversion_workbuf_name): New variable.
Kenichi Handa <handa@m17n.org>
parents:
58502
diff
changeset
|
6052 set_conversion_work_buffer (multibyte) |
ff8a37b5299b
(Vcode_conversion_workbuf_name): New variable.
Kenichi Handa <handa@m17n.org>
parents:
58502
diff
changeset
|
6053 int multibyte; |
ff8a37b5299b
(Vcode_conversion_workbuf_name): New variable.
Kenichi Handa <handa@m17n.org>
parents:
58502
diff
changeset
|
6054 { |
64308
93129de4b8a4
(code_convert_region_unwind): ARG is changed to a cons.
Kenichi Handa <handa@m17n.org>
parents:
64251
diff
changeset
|
6055 Lisp_Object buffer, buffer_to_kill; |
58637
ff8a37b5299b
(Vcode_conversion_workbuf_name): New variable.
Kenichi Handa <handa@m17n.org>
parents:
58502
diff
changeset
|
6056 struct buffer *buf; |
ff8a37b5299b
(Vcode_conversion_workbuf_name): New variable.
Kenichi Handa <handa@m17n.org>
parents:
58502
diff
changeset
|
6057 |
ff8a37b5299b
(Vcode_conversion_workbuf_name): New variable.
Kenichi Handa <handa@m17n.org>
parents:
58502
diff
changeset
|
6058 buffer = Fget_buffer_create (Vcode_conversion_workbuf_name); |
ff8a37b5299b
(Vcode_conversion_workbuf_name): New variable.
Kenichi Handa <handa@m17n.org>
parents:
58502
diff
changeset
|
6059 buf = XBUFFER (buffer); |
64308
93129de4b8a4
(code_convert_region_unwind): ARG is changed to a cons.
Kenichi Handa <handa@m17n.org>
parents:
64251
diff
changeset
|
6060 if (buf == current_buffer) |
93129de4b8a4
(code_convert_region_unwind): ARG is changed to a cons.
Kenichi Handa <handa@m17n.org>
parents:
64251
diff
changeset
|
6061 { |
93129de4b8a4
(code_convert_region_unwind): ARG is changed to a cons.
Kenichi Handa <handa@m17n.org>
parents:
64251
diff
changeset
|
6062 /* As we are already in the work buffer, we must generate a new |
93129de4b8a4
(code_convert_region_unwind): ARG is changed to a cons.
Kenichi Handa <handa@m17n.org>
parents:
64251
diff
changeset
|
6063 buffer for the work. */ |
93129de4b8a4
(code_convert_region_unwind): ARG is changed to a cons.
Kenichi Handa <handa@m17n.org>
parents:
64251
diff
changeset
|
6064 Lisp_Object name; |
71972
eaa3c19b94d2
(Fcheck_coding_system): Use xsignal1. Remove loop.
Kim F. Storm <storm@cua.dk>
parents:
71084
diff
changeset
|
6065 |
64308
93129de4b8a4
(code_convert_region_unwind): ARG is changed to a cons.
Kenichi Handa <handa@m17n.org>
parents:
64251
diff
changeset
|
6066 name = Fgenerate_new_buffer_name (Vcode_conversion_workbuf_name, Qnil); |
93129de4b8a4
(code_convert_region_unwind): ARG is changed to a cons.
Kenichi Handa <handa@m17n.org>
parents:
64251
diff
changeset
|
6067 buffer = buffer_to_kill = Fget_buffer_create (name); |
93129de4b8a4
(code_convert_region_unwind): ARG is changed to a cons.
Kenichi Handa <handa@m17n.org>
parents:
64251
diff
changeset
|
6068 buf = XBUFFER (buffer); |
93129de4b8a4
(code_convert_region_unwind): ARG is changed to a cons.
Kenichi Handa <handa@m17n.org>
parents:
64251
diff
changeset
|
6069 } |
93129de4b8a4
(code_convert_region_unwind): ARG is changed to a cons.
Kenichi Handa <handa@m17n.org>
parents:
64251
diff
changeset
|
6070 else |
93129de4b8a4
(code_convert_region_unwind): ARG is changed to a cons.
Kenichi Handa <handa@m17n.org>
parents:
64251
diff
changeset
|
6071 buffer_to_kill = Qnil; |
93129de4b8a4
(code_convert_region_unwind): ARG is changed to a cons.
Kenichi Handa <handa@m17n.org>
parents:
64251
diff
changeset
|
6072 |
58637
ff8a37b5299b
(Vcode_conversion_workbuf_name): New variable.
Kenichi Handa <handa@m17n.org>
parents:
58502
diff
changeset
|
6073 delete_all_overlays (buf); |
ff8a37b5299b
(Vcode_conversion_workbuf_name): New variable.
Kenichi Handa <handa@m17n.org>
parents:
58502
diff
changeset
|
6074 buf->directory = current_buffer->directory; |
ff8a37b5299b
(Vcode_conversion_workbuf_name): New variable.
Kenichi Handa <handa@m17n.org>
parents:
58502
diff
changeset
|
6075 buf->read_only = Qnil; |
ff8a37b5299b
(Vcode_conversion_workbuf_name): New variable.
Kenichi Handa <handa@m17n.org>
parents:
58502
diff
changeset
|
6076 buf->filename = Qnil; |
ff8a37b5299b
(Vcode_conversion_workbuf_name): New variable.
Kenichi Handa <handa@m17n.org>
parents:
58502
diff
changeset
|
6077 buf->undo_list = Qt; |
ff8a37b5299b
(Vcode_conversion_workbuf_name): New variable.
Kenichi Handa <handa@m17n.org>
parents:
58502
diff
changeset
|
6078 eassert (buf->overlays_before == NULL); |
ff8a37b5299b
(Vcode_conversion_workbuf_name): New variable.
Kenichi Handa <handa@m17n.org>
parents:
58502
diff
changeset
|
6079 eassert (buf->overlays_after == NULL); |
ff8a37b5299b
(Vcode_conversion_workbuf_name): New variable.
Kenichi Handa <handa@m17n.org>
parents:
58502
diff
changeset
|
6080 set_buffer_internal (buf); |
ff8a37b5299b
(Vcode_conversion_workbuf_name): New variable.
Kenichi Handa <handa@m17n.org>
parents:
58502
diff
changeset
|
6081 if (BEG != BEGV || Z != ZV) |
ff8a37b5299b
(Vcode_conversion_workbuf_name): New variable.
Kenichi Handa <handa@m17n.org>
parents:
58502
diff
changeset
|
6082 Fwiden (); |
ff8a37b5299b
(Vcode_conversion_workbuf_name): New variable.
Kenichi Handa <handa@m17n.org>
parents:
58502
diff
changeset
|
6083 del_range_2 (BEG, BEG_BYTE, Z, Z_BYTE, 0); |
ff8a37b5299b
(Vcode_conversion_workbuf_name): New variable.
Kenichi Handa <handa@m17n.org>
parents:
58502
diff
changeset
|
6084 buf->enable_multibyte_characters = multibyte ? Qt : Qnil; |
64308
93129de4b8a4
(code_convert_region_unwind): ARG is changed to a cons.
Kenichi Handa <handa@m17n.org>
parents:
64251
diff
changeset
|
6085 return buffer_to_kill; |
58637
ff8a37b5299b
(Vcode_conversion_workbuf_name): New variable.
Kenichi Handa <handa@m17n.org>
parents:
58502
diff
changeset
|
6086 } |
ff8a37b5299b
(Vcode_conversion_workbuf_name): New variable.
Kenichi Handa <handa@m17n.org>
parents:
58502
diff
changeset
|
6087 |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
6088 Lisp_Object |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
6089 run_pre_post_conversion_on_str (str, coding, encodep) |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
6090 Lisp_Object str; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
6091 struct coding_system *coding; |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
6092 int encodep; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
6093 { |
46293
1fb8f75062c6
Use macro SPECPDL_INDEX.
Juanma Barranquero <lekktu@gmail.com>
parents:
46150
diff
changeset
|
6094 int count = SPECPDL_INDEX (); |
47632
551472d77d2a
(run_pre_post_conversion_on_str): Save and restore Vdeactivate_mark.
Richard M. Stallman <rms@gnu.org>
parents:
47274
diff
changeset
|
6095 struct gcpro gcpro1, gcpro2; |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
6096 int multibyte = STRING_MULTIBYTE (str); |
47632
551472d77d2a
(run_pre_post_conversion_on_str): Save and restore Vdeactivate_mark.
Richard M. Stallman <rms@gnu.org>
parents:
47274
diff
changeset
|
6097 Lisp_Object old_deactivate_mark; |
64308
93129de4b8a4
(code_convert_region_unwind): ARG is changed to a cons.
Kenichi Handa <handa@m17n.org>
parents:
64251
diff
changeset
|
6098 Lisp_Object buffer_to_kill; |
65506
f376635f5061
(code_convert_region_unwind): Argument format changed.
Kenichi Handa <handa@m17n.org>
parents:
64770
diff
changeset
|
6099 Lisp_Object unwind_arg; |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
6100 |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
6101 record_unwind_protect (Fset_buffer, Fcurrent_buffer ()); |
47632
551472d77d2a
(run_pre_post_conversion_on_str): Save and restore Vdeactivate_mark.
Richard M. Stallman <rms@gnu.org>
parents:
47274
diff
changeset
|
6102 /* It is not crucial to specbind this. */ |
551472d77d2a
(run_pre_post_conversion_on_str): Save and restore Vdeactivate_mark.
Richard M. Stallman <rms@gnu.org>
parents:
47274
diff
changeset
|
6103 old_deactivate_mark = Vdeactivate_mark; |
551472d77d2a
(run_pre_post_conversion_on_str): Save and restore Vdeactivate_mark.
Richard M. Stallman <rms@gnu.org>
parents:
47274
diff
changeset
|
6104 GCPRO2 (str, old_deactivate_mark); |
44562
11442d8a69cc
(run_pre_post_conversion_on_str):
Richard M. Stallman <rms@gnu.org>
parents:
43841
diff
changeset
|
6105 |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
6106 /* We must insert the contents of STR as is without |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
6107 unibyte<->multibyte conversion. For that, we adjust the |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
6108 multibyteness of the working buffer to that of STR. */ |
64308
93129de4b8a4
(code_convert_region_unwind): ARG is changed to a cons.
Kenichi Handa <handa@m17n.org>
parents:
64251
diff
changeset
|
6109 buffer_to_kill = set_conversion_work_buffer (multibyte); |
65506
f376635f5061
(code_convert_region_unwind): Argument format changed.
Kenichi Handa <handa@m17n.org>
parents:
64770
diff
changeset
|
6110 if (NILP (buffer_to_kill)) |
f376635f5061
(code_convert_region_unwind): Argument format changed.
Kenichi Handa <handa@m17n.org>
parents:
64770
diff
changeset
|
6111 unwind_arg = Fcons (Vlast_coding_system_used, Qnil); |
f376635f5061
(code_convert_region_unwind): Argument format changed.
Kenichi Handa <handa@m17n.org>
parents:
64770
diff
changeset
|
6112 else |
f376635f5061
(code_convert_region_unwind): Argument format changed.
Kenichi Handa <handa@m17n.org>
parents:
64770
diff
changeset
|
6113 unwind_arg = list2 (Vlast_coding_system_used, buffer_to_kill); |
f376635f5061
(code_convert_region_unwind): Argument format changed.
Kenichi Handa <handa@m17n.org>
parents:
64770
diff
changeset
|
6114 record_unwind_protect (code_convert_region_unwind, unwind_arg); |
44562
11442d8a69cc
(run_pre_post_conversion_on_str):
Richard M. Stallman <rms@gnu.org>
parents:
43841
diff
changeset
|
6115 |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
6116 insert_from_string (str, 0, 0, |
46370
40db0673e6f0
Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents:
46293
diff
changeset
|
6117 SCHARS (str), SBYTES (str), 0); |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
6118 UNGCPRO; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
6119 inhibit_pre_post_conversion = 1; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
6120 if (encodep) |
65506
f376635f5061
(code_convert_region_unwind): Argument format changed.
Kenichi Handa <handa@m17n.org>
parents:
64770
diff
changeset
|
6121 { |
f376635f5061
(code_convert_region_unwind): Argument format changed.
Kenichi Handa <handa@m17n.org>
parents:
64770
diff
changeset
|
6122 struct buffer *prev = current_buffer; |
f376635f5061
(code_convert_region_unwind): Argument format changed.
Kenichi Handa <handa@m17n.org>
parents:
64770
diff
changeset
|
6123 |
f376635f5061
(code_convert_region_unwind): Argument format changed.
Kenichi Handa <handa@m17n.org>
parents:
64770
diff
changeset
|
6124 call2 (coding->pre_write_conversion, make_number (BEG), make_number (Z)); |
f376635f5061
(code_convert_region_unwind): Argument format changed.
Kenichi Handa <handa@m17n.org>
parents:
64770
diff
changeset
|
6125 if (prev != current_buffer) |
f376635f5061
(code_convert_region_unwind): Argument format changed.
Kenichi Handa <handa@m17n.org>
parents:
64770
diff
changeset
|
6126 /* We must kill the current buffer too. */ |
f376635f5061
(code_convert_region_unwind): Argument format changed.
Kenichi Handa <handa@m17n.org>
parents:
64770
diff
changeset
|
6127 Fsetcdr (unwind_arg, Fcons (Fcurrent_buffer (), XCDR (unwind_arg))); |
f376635f5061
(code_convert_region_unwind): Argument format changed.
Kenichi Handa <handa@m17n.org>
parents:
64770
diff
changeset
|
6128 } |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
6129 else |
29172
46ad5a027334
(run_pre_post_conversion_on_str): Set point to the
Kenichi Handa <handa@m17n.org>
parents:
29093
diff
changeset
|
6130 { |
50484
6818550bfbc7
(code_convert_region_unwind): Set
Kenichi Handa <handa@m17n.org>
parents:
50185
diff
changeset
|
6131 Vlast_coding_system_used = coding->symbol; |
29172
46ad5a027334
(run_pre_post_conversion_on_str): Set point to the
Kenichi Handa <handa@m17n.org>
parents:
29093
diff
changeset
|
6132 TEMP_SET_PT_BOTH (BEG, BEG_BYTE); |
46ad5a027334
(run_pre_post_conversion_on_str): Set point to the
Kenichi Handa <handa@m17n.org>
parents:
29093
diff
changeset
|
6133 call1 (coding->post_read_conversion, make_number (Z - BEG)); |
50484
6818550bfbc7
(code_convert_region_unwind): Set
Kenichi Handa <handa@m17n.org>
parents:
50185
diff
changeset
|
6134 coding->symbol = Vlast_coding_system_used; |
29172
46ad5a027334
(run_pre_post_conversion_on_str): Set point to the
Kenichi Handa <handa@m17n.org>
parents:
29093
diff
changeset
|
6135 } |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
6136 inhibit_pre_post_conversion = 0; |
47632
551472d77d2a
(run_pre_post_conversion_on_str): Save and restore Vdeactivate_mark.
Richard M. Stallman <rms@gnu.org>
parents:
47274
diff
changeset
|
6137 Vdeactivate_mark = old_deactivate_mark; |
30581
6c7a9202a815
(coding_restore_composition): Pay attention to the case that
Kenichi Handa <handa@m17n.org>
parents:
30578
diff
changeset
|
6138 str = make_buffer_string (BEG, Z, 1); |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
6139 return unbind_to (count, str); |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
6140 } |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
6141 |
58637
ff8a37b5299b
(Vcode_conversion_workbuf_name): New variable.
Kenichi Handa <handa@m17n.org>
parents:
58502
diff
changeset
|
6142 |
ff8a37b5299b
(Vcode_conversion_workbuf_name): New variable.
Kenichi Handa <handa@m17n.org>
parents:
58502
diff
changeset
|
6143 /* Run pre-write-conversion function of CODING on NCHARS/NBYTES |
ff8a37b5299b
(Vcode_conversion_workbuf_name): New variable.
Kenichi Handa <handa@m17n.org>
parents:
58502
diff
changeset
|
6144 text in *STR. *SIZE is the allocated bytes for STR. As it |
ff8a37b5299b
(Vcode_conversion_workbuf_name): New variable.
Kenichi Handa <handa@m17n.org>
parents:
58502
diff
changeset
|
6145 is intended that this function is called from encode_terminal_code, |
ff8a37b5299b
(Vcode_conversion_workbuf_name): New variable.
Kenichi Handa <handa@m17n.org>
parents:
58502
diff
changeset
|
6146 the pre-write-conversion function is run by safe_call and thus |
ff8a37b5299b
(Vcode_conversion_workbuf_name): New variable.
Kenichi Handa <handa@m17n.org>
parents:
58502
diff
changeset
|
6147 "Error during redisplay: ..." is logged when an error occurs. |
ff8a37b5299b
(Vcode_conversion_workbuf_name): New variable.
Kenichi Handa <handa@m17n.org>
parents:
58502
diff
changeset
|
6148 |
ff8a37b5299b
(Vcode_conversion_workbuf_name): New variable.
Kenichi Handa <handa@m17n.org>
parents:
58502
diff
changeset
|
6149 Store the resulting text in *STR and set CODING->produced_char and |
ff8a37b5299b
(Vcode_conversion_workbuf_name): New variable.
Kenichi Handa <handa@m17n.org>
parents:
58502
diff
changeset
|
6150 CODING->produced to the number of characters and bytes |
ff8a37b5299b
(Vcode_conversion_workbuf_name): New variable.
Kenichi Handa <handa@m17n.org>
parents:
58502
diff
changeset
|
6151 respectively. If the size of *STR is too small, enlarge it by |
ff8a37b5299b
(Vcode_conversion_workbuf_name): New variable.
Kenichi Handa <handa@m17n.org>
parents:
58502
diff
changeset
|
6152 xrealloc and update *STR and *SIZE. */ |
ff8a37b5299b
(Vcode_conversion_workbuf_name): New variable.
Kenichi Handa <handa@m17n.org>
parents:
58502
diff
changeset
|
6153 |
ff8a37b5299b
(Vcode_conversion_workbuf_name): New variable.
Kenichi Handa <handa@m17n.org>
parents:
58502
diff
changeset
|
6154 void |
ff8a37b5299b
(Vcode_conversion_workbuf_name): New variable.
Kenichi Handa <handa@m17n.org>
parents:
58502
diff
changeset
|
6155 run_pre_write_conversin_on_c_str (str, size, nchars, nbytes, coding) |
ff8a37b5299b
(Vcode_conversion_workbuf_name): New variable.
Kenichi Handa <handa@m17n.org>
parents:
58502
diff
changeset
|
6156 unsigned char **str; |
ff8a37b5299b
(Vcode_conversion_workbuf_name): New variable.
Kenichi Handa <handa@m17n.org>
parents:
58502
diff
changeset
|
6157 int *size, nchars, nbytes; |
ff8a37b5299b
(Vcode_conversion_workbuf_name): New variable.
Kenichi Handa <handa@m17n.org>
parents:
58502
diff
changeset
|
6158 struct coding_system *coding; |
ff8a37b5299b
(Vcode_conversion_workbuf_name): New variable.
Kenichi Handa <handa@m17n.org>
parents:
58502
diff
changeset
|
6159 { |
ff8a37b5299b
(Vcode_conversion_workbuf_name): New variable.
Kenichi Handa <handa@m17n.org>
parents:
58502
diff
changeset
|
6160 struct gcpro gcpro1, gcpro2; |
ff8a37b5299b
(Vcode_conversion_workbuf_name): New variable.
Kenichi Handa <handa@m17n.org>
parents:
58502
diff
changeset
|
6161 struct buffer *cur = current_buffer; |
65506
f376635f5061
(code_convert_region_unwind): Argument format changed.
Kenichi Handa <handa@m17n.org>
parents:
64770
diff
changeset
|
6162 struct buffer *prev; |
58637
ff8a37b5299b
(Vcode_conversion_workbuf_name): New variable.
Kenichi Handa <handa@m17n.org>
parents:
58502
diff
changeset
|
6163 Lisp_Object old_deactivate_mark, old_last_coding_system_used; |
ff8a37b5299b
(Vcode_conversion_workbuf_name): New variable.
Kenichi Handa <handa@m17n.org>
parents:
58502
diff
changeset
|
6164 Lisp_Object args[3]; |
64308
93129de4b8a4
(code_convert_region_unwind): ARG is changed to a cons.
Kenichi Handa <handa@m17n.org>
parents:
64251
diff
changeset
|
6165 Lisp_Object buffer_to_kill; |
58637
ff8a37b5299b
(Vcode_conversion_workbuf_name): New variable.
Kenichi Handa <handa@m17n.org>
parents:
58502
diff
changeset
|
6166 |
ff8a37b5299b
(Vcode_conversion_workbuf_name): New variable.
Kenichi Handa <handa@m17n.org>
parents:
58502
diff
changeset
|
6167 /* It is not crucial to specbind this. */ |
ff8a37b5299b
(Vcode_conversion_workbuf_name): New variable.
Kenichi Handa <handa@m17n.org>
parents:
58502
diff
changeset
|
6168 old_deactivate_mark = Vdeactivate_mark; |
ff8a37b5299b
(Vcode_conversion_workbuf_name): New variable.
Kenichi Handa <handa@m17n.org>
parents:
58502
diff
changeset
|
6169 old_last_coding_system_used = Vlast_coding_system_used; |
ff8a37b5299b
(Vcode_conversion_workbuf_name): New variable.
Kenichi Handa <handa@m17n.org>
parents:
58502
diff
changeset
|
6170 GCPRO2 (old_deactivate_mark, old_last_coding_system_used); |
ff8a37b5299b
(Vcode_conversion_workbuf_name): New variable.
Kenichi Handa <handa@m17n.org>
parents:
58502
diff
changeset
|
6171 |
ff8a37b5299b
(Vcode_conversion_workbuf_name): New variable.
Kenichi Handa <handa@m17n.org>
parents:
58502
diff
changeset
|
6172 /* We must insert the contents of STR as is without |
ff8a37b5299b
(Vcode_conversion_workbuf_name): New variable.
Kenichi Handa <handa@m17n.org>
parents:
58502
diff
changeset
|
6173 unibyte<->multibyte conversion. For that, we adjust the |
ff8a37b5299b
(Vcode_conversion_workbuf_name): New variable.
Kenichi Handa <handa@m17n.org>
parents:
58502
diff
changeset
|
6174 multibyteness of the working buffer to that of STR. */ |
64308
93129de4b8a4
(code_convert_region_unwind): ARG is changed to a cons.
Kenichi Handa <handa@m17n.org>
parents:
64251
diff
changeset
|
6175 buffer_to_kill = set_conversion_work_buffer (coding->src_multibyte); |
58637
ff8a37b5299b
(Vcode_conversion_workbuf_name): New variable.
Kenichi Handa <handa@m17n.org>
parents:
58502
diff
changeset
|
6176 insert_1_both (*str, nchars, nbytes, 0, 0, 0); |
ff8a37b5299b
(Vcode_conversion_workbuf_name): New variable.
Kenichi Handa <handa@m17n.org>
parents:
58502
diff
changeset
|
6177 UNGCPRO; |
ff8a37b5299b
(Vcode_conversion_workbuf_name): New variable.
Kenichi Handa <handa@m17n.org>
parents:
58502
diff
changeset
|
6178 inhibit_pre_post_conversion = 1; |
65506
f376635f5061
(code_convert_region_unwind): Argument format changed.
Kenichi Handa <handa@m17n.org>
parents:
64770
diff
changeset
|
6179 prev = current_buffer; |
58637
ff8a37b5299b
(Vcode_conversion_workbuf_name): New variable.
Kenichi Handa <handa@m17n.org>
parents:
58502
diff
changeset
|
6180 args[0] = coding->pre_write_conversion; |
ff8a37b5299b
(Vcode_conversion_workbuf_name): New variable.
Kenichi Handa <handa@m17n.org>
parents:
58502
diff
changeset
|
6181 args[1] = make_number (BEG); |
ff8a37b5299b
(Vcode_conversion_workbuf_name): New variable.
Kenichi Handa <handa@m17n.org>
parents:
58502
diff
changeset
|
6182 args[2] = make_number (Z); |
ff8a37b5299b
(Vcode_conversion_workbuf_name): New variable.
Kenichi Handa <handa@m17n.org>
parents:
58502
diff
changeset
|
6183 safe_call (3, args); |
ff8a37b5299b
(Vcode_conversion_workbuf_name): New variable.
Kenichi Handa <handa@m17n.org>
parents:
58502
diff
changeset
|
6184 inhibit_pre_post_conversion = 0; |
ff8a37b5299b
(Vcode_conversion_workbuf_name): New variable.
Kenichi Handa <handa@m17n.org>
parents:
58502
diff
changeset
|
6185 Vdeactivate_mark = old_deactivate_mark; |
ff8a37b5299b
(Vcode_conversion_workbuf_name): New variable.
Kenichi Handa <handa@m17n.org>
parents:
58502
diff
changeset
|
6186 Vlast_coding_system_used = old_last_coding_system_used; |
ff8a37b5299b
(Vcode_conversion_workbuf_name): New variable.
Kenichi Handa <handa@m17n.org>
parents:
58502
diff
changeset
|
6187 coding->produced_char = Z - BEG; |
ff8a37b5299b
(Vcode_conversion_workbuf_name): New variable.
Kenichi Handa <handa@m17n.org>
parents:
58502
diff
changeset
|
6188 coding->produced = Z_BYTE - BEG_BYTE; |
ff8a37b5299b
(Vcode_conversion_workbuf_name): New variable.
Kenichi Handa <handa@m17n.org>
parents:
58502
diff
changeset
|
6189 if (coding->produced > *size) |
ff8a37b5299b
(Vcode_conversion_workbuf_name): New variable.
Kenichi Handa <handa@m17n.org>
parents:
58502
diff
changeset
|
6190 { |
ff8a37b5299b
(Vcode_conversion_workbuf_name): New variable.
Kenichi Handa <handa@m17n.org>
parents:
58502
diff
changeset
|
6191 *size = coding->produced; |
ff8a37b5299b
(Vcode_conversion_workbuf_name): New variable.
Kenichi Handa <handa@m17n.org>
parents:
58502
diff
changeset
|
6192 *str = xrealloc (*str, *size); |
ff8a37b5299b
(Vcode_conversion_workbuf_name): New variable.
Kenichi Handa <handa@m17n.org>
parents:
58502
diff
changeset
|
6193 } |
ff8a37b5299b
(Vcode_conversion_workbuf_name): New variable.
Kenichi Handa <handa@m17n.org>
parents:
58502
diff
changeset
|
6194 if (BEG < GPT && GPT < Z) |
ff8a37b5299b
(Vcode_conversion_workbuf_name): New variable.
Kenichi Handa <handa@m17n.org>
parents:
58502
diff
changeset
|
6195 move_gap (BEG); |
ff8a37b5299b
(Vcode_conversion_workbuf_name): New variable.
Kenichi Handa <handa@m17n.org>
parents:
58502
diff
changeset
|
6196 bcopy (BEG_ADDR, *str, coding->produced); |
ff8a37b5299b
(Vcode_conversion_workbuf_name): New variable.
Kenichi Handa <handa@m17n.org>
parents:
58502
diff
changeset
|
6197 coding->src_multibyte |
ff8a37b5299b
(Vcode_conversion_workbuf_name): New variable.
Kenichi Handa <handa@m17n.org>
parents:
58502
diff
changeset
|
6198 = ! NILP (current_buffer->enable_multibyte_characters); |
65506
f376635f5061
(code_convert_region_unwind): Argument format changed.
Kenichi Handa <handa@m17n.org>
parents:
64770
diff
changeset
|
6199 if (prev != current_buffer) |
f376635f5061
(code_convert_region_unwind): Argument format changed.
Kenichi Handa <handa@m17n.org>
parents:
64770
diff
changeset
|
6200 Fkill_buffer (Fcurrent_buffer ()); |
58637
ff8a37b5299b
(Vcode_conversion_workbuf_name): New variable.
Kenichi Handa <handa@m17n.org>
parents:
58502
diff
changeset
|
6201 set_buffer_internal (cur); |
64308
93129de4b8a4
(code_convert_region_unwind): ARG is changed to a cons.
Kenichi Handa <handa@m17n.org>
parents:
64251
diff
changeset
|
6202 if (! NILP (buffer_to_kill)) |
93129de4b8a4
(code_convert_region_unwind): ARG is changed to a cons.
Kenichi Handa <handa@m17n.org>
parents:
64251
diff
changeset
|
6203 Fkill_buffer (buffer_to_kill); |
58637
ff8a37b5299b
(Vcode_conversion_workbuf_name): New variable.
Kenichi Handa <handa@m17n.org>
parents:
58502
diff
changeset
|
6204 } |
ff8a37b5299b
(Vcode_conversion_workbuf_name): New variable.
Kenichi Handa <handa@m17n.org>
parents:
58502
diff
changeset
|
6205 |
ff8a37b5299b
(Vcode_conversion_workbuf_name): New variable.
Kenichi Handa <handa@m17n.org>
parents:
58502
diff
changeset
|
6206 |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
6207 Lisp_Object |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
6208 decode_coding_string (str, coding, nocopy) |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
6209 Lisp_Object str; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
6210 struct coding_system *coding; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
6211 int nocopy; |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
6212 { |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
6213 int len; |
30833
2db6e42a6ba3
(MINIMUM_CONVERSION_BUFFER_SIZE): Macro deleted.
Kenichi Handa <handa@m17n.org>
parents:
30756
diff
changeset
|
6214 struct conversion_buffer buf; |
34988
8cd5e6ad71a2
(detect_coding_iso2022, setup_coding_system): Remove
Eli Zaretskii <eliz@gnu.org>
parents:
34892
diff
changeset
|
6215 int from, to_byte; |
22954
928b337d953b
Avoid using initializers for Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents:
22874
diff
changeset
|
6216 Lisp_Object saved_coding_symbol; |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
6217 int result; |
30581
6c7a9202a815
(coding_restore_composition): Pay attention to the case that
Kenichi Handa <handa@m17n.org>
parents:
30578
diff
changeset
|
6218 int require_decoding; |
30833
2db6e42a6ba3
(MINIMUM_CONVERSION_BUFFER_SIZE): Macro deleted.
Kenichi Handa <handa@m17n.org>
parents:
30756
diff
changeset
|
6219 int shrinked_bytes = 0; |
2db6e42a6ba3
(MINIMUM_CONVERSION_BUFFER_SIZE): Macro deleted.
Kenichi Handa <handa@m17n.org>
parents:
30756
diff
changeset
|
6220 Lisp_Object newstr; |
30950
5682de5cfdac
(decode_coding_string): Set members consumed,
Kenichi Handa <handa@m17n.org>
parents:
30847
diff
changeset
|
6221 int consumed, consumed_char, produced, produced_char; |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
6222 |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
6223 from = 0; |
46370
40db0673e6f0
Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents:
46293
diff
changeset
|
6224 to_byte = SBYTES (str); |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
6225 |
35587
7e767148cfdc
(decode_coding): Set a flag for inhibiting
Kenichi Handa <handa@m17n.org>
parents:
35531
diff
changeset
|
6226 saved_coding_symbol = coding->symbol; |
34536
aa667988f2b0
(decode_coding_string): Set coding->src_multibyte and
Kenichi Handa <handa@m17n.org>
parents:
34531
diff
changeset
|
6227 coding->src_multibyte = STRING_MULTIBYTE (str); |
aa667988f2b0
(decode_coding_string): Set coding->src_multibyte and
Kenichi Handa <handa@m17n.org>
parents:
34531
diff
changeset
|
6228 coding->dst_multibyte = 1; |
73995
11025612f889
(code_convert_region): Initialize
Kenichi Handa <handa@m17n.org>
parents:
73949
diff
changeset
|
6229 coding->heading_ascii = 0; |
11025612f889
(code_convert_region): Initialize
Kenichi Handa <handa@m17n.org>
parents:
73949
diff
changeset
|
6230 |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
6231 if (CODING_REQUIRE_DETECTION (coding)) |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
6232 { |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
6233 /* See the comments in code_convert_region. */ |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
6234 if (coding->type == coding_type_undecided) |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
6235 { |
46370
40db0673e6f0
Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents:
46293
diff
changeset
|
6236 detect_coding (coding, SDATA (str), to_byte); |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
6237 if (coding->type == coding_type_undecided) |
35995
b511edc4a348
(code_convert_region): After detecting a coding, if
Kenichi Handa <handa@m17n.org>
parents:
35587
diff
changeset
|
6238 { |
b511edc4a348
(code_convert_region): After detecting a coding, if
Kenichi Handa <handa@m17n.org>
parents:
35587
diff
changeset
|
6239 coding->type = coding_type_emacs_mule; |
b511edc4a348
(code_convert_region): After detecting a coding, if
Kenichi Handa <handa@m17n.org>
parents:
35587
diff
changeset
|
6240 coding->category_idx = CODING_CATEGORY_IDX_EMACS_MULE; |
b511edc4a348
(code_convert_region): After detecting a coding, if
Kenichi Handa <handa@m17n.org>
parents:
35587
diff
changeset
|
6241 /* As emacs-mule decoder will handle composition, we |
b511edc4a348
(code_convert_region): After detecting a coding, if
Kenichi Handa <handa@m17n.org>
parents:
35587
diff
changeset
|
6242 need this setting to allocate coding->cmp_data |
b511edc4a348
(code_convert_region): After detecting a coding, if
Kenichi Handa <handa@m17n.org>
parents:
35587
diff
changeset
|
6243 later. */ |
b511edc4a348
(code_convert_region): After detecting a coding, if
Kenichi Handa <handa@m17n.org>
parents:
35587
diff
changeset
|
6244 coding->composing = COMPOSITION_NO; |
b511edc4a348
(code_convert_region): After detecting a coding, if
Kenichi Handa <handa@m17n.org>
parents:
35587
diff
changeset
|
6245 } |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
6246 } |
29725
2bc397e9b09a
(setup_coding_system) <4>: Reset member `cr_carryover'.
Kenichi Handa <handa@m17n.org>
parents:
29663
diff
changeset
|
6247 if (coding->eol_type == CODING_EOL_UNDECIDED |
2bc397e9b09a
(setup_coding_system) <4>: Reset member `cr_carryover'.
Kenichi Handa <handa@m17n.org>
parents:
29663
diff
changeset
|
6248 && coding->type != coding_type_ccl) |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
6249 { |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
6250 saved_coding_symbol = coding->symbol; |
46370
40db0673e6f0
Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents:
46293
diff
changeset
|
6251 detect_eol (coding, SDATA (str), to_byte); |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
6252 if (coding->eol_type == CODING_EOL_UNDECIDED) |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
6253 coding->eol_type = CODING_EOL_LF; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
6254 /* We had better recover the original eol format if we |
36087 | 6255 encounter an inconsistent eol format while decoding. */ |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
6256 coding->mode |= CODING_MODE_INHIBIT_INCONSISTENT_EOL; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
6257 } |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
6258 } |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
6259 |
34536
aa667988f2b0
(decode_coding_string): Set coding->src_multibyte and
Kenichi Handa <handa@m17n.org>
parents:
34531
diff
changeset
|
6260 if (coding->type == coding_type_no_conversion |
aa667988f2b0
(decode_coding_string): Set coding->src_multibyte and
Kenichi Handa <handa@m17n.org>
parents:
34531
diff
changeset
|
6261 || coding->type == coding_type_raw_text) |
aa667988f2b0
(decode_coding_string): Set coding->src_multibyte and
Kenichi Handa <handa@m17n.org>
parents:
34531
diff
changeset
|
6262 coding->dst_multibyte = 0; |
aa667988f2b0
(decode_coding_string): Set coding->src_multibyte and
Kenichi Handa <handa@m17n.org>
parents:
34531
diff
changeset
|
6263 |
30581
6c7a9202a815
(coding_restore_composition): Pay attention to the case that
Kenichi Handa <handa@m17n.org>
parents:
30578
diff
changeset
|
6264 require_decoding = CODING_REQUIRE_DECODING (coding); |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
6265 |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
6266 if (STRING_MULTIBYTE (str)) |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
6267 { |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
6268 /* Decoding routines expect the source text to be unibyte. */ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
6269 str = Fstring_as_unibyte (str); |
46370
40db0673e6f0
Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents:
46293
diff
changeset
|
6270 to_byte = SBYTES (str); |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
6271 nocopy = 1; |
34536
aa667988f2b0
(decode_coding_string): Set coding->src_multibyte and
Kenichi Handa <handa@m17n.org>
parents:
34531
diff
changeset
|
6272 coding->src_multibyte = 0; |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
6273 } |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
6274 |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
6275 /* Try to skip the heading and tailing ASCIIs. */ |
30581
6c7a9202a815
(coding_restore_composition): Pay attention to the case that
Kenichi Handa <handa@m17n.org>
parents:
30578
diff
changeset
|
6276 if (require_decoding && coding->type != coding_type_ccl) |
29985
c17e78d8c720
(code_convert_region): Even if the length of text is
Kenichi Handa <handa@m17n.org>
parents:
29932
diff
changeset
|
6277 { |
46370
40db0673e6f0
Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents:
46293
diff
changeset
|
6278 SHRINK_CONVERSION_REGION (&from, &to_byte, coding, SDATA (str), |
29985
c17e78d8c720
(code_convert_region): Even if the length of text is
Kenichi Handa <handa@m17n.org>
parents:
29932
diff
changeset
|
6279 0); |
c17e78d8c720
(code_convert_region): Even if the length of text is
Kenichi Handa <handa@m17n.org>
parents:
29932
diff
changeset
|
6280 if (from == to_byte) |
30581
6c7a9202a815
(coding_restore_composition): Pay attention to the case that
Kenichi Handa <handa@m17n.org>
parents:
30578
diff
changeset
|
6281 require_decoding = 0; |
46370
40db0673e6f0
Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents:
46293
diff
changeset
|
6282 shrinked_bytes = from + (SBYTES (str) - to_byte); |
29985
c17e78d8c720
(code_convert_region): Even if the length of text is
Kenichi Handa <handa@m17n.org>
parents:
29932
diff
changeset
|
6283 } |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
6284 |
51090
269d016f45bd
(decode_coding_string): Handle post-read-conversion
Kenichi Handa <handa@m17n.org>
parents:
50896
diff
changeset
|
6285 if (!require_decoding |
269d016f45bd
(decode_coding_string): Handle post-read-conversion
Kenichi Handa <handa@m17n.org>
parents:
50896
diff
changeset
|
6286 && !(SYMBOLP (coding->post_read_conversion) |
269d016f45bd
(decode_coding_string): Handle post-read-conversion
Kenichi Handa <handa@m17n.org>
parents:
50896
diff
changeset
|
6287 && !NILP (Ffboundp (coding->post_read_conversion)))) |
30581
6c7a9202a815
(coding_restore_composition): Pay attention to the case that
Kenichi Handa <handa@m17n.org>
parents:
30578
diff
changeset
|
6288 { |
46370
40db0673e6f0
Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents:
46293
diff
changeset
|
6289 coding->consumed = SBYTES (str); |
40db0673e6f0
Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents:
46293
diff
changeset
|
6290 coding->consumed_char = SCHARS (str); |
30581
6c7a9202a815
(coding_restore_composition): Pay attention to the case that
Kenichi Handa <handa@m17n.org>
parents:
30578
diff
changeset
|
6291 if (coding->dst_multibyte) |
6c7a9202a815
(coding_restore_composition): Pay attention to the case that
Kenichi Handa <handa@m17n.org>
parents:
30578
diff
changeset
|
6292 { |
6c7a9202a815
(coding_restore_composition): Pay attention to the case that
Kenichi Handa <handa@m17n.org>
parents:
30578
diff
changeset
|
6293 str = Fstring_as_multibyte (str); |
6c7a9202a815
(coding_restore_composition): Pay attention to the case that
Kenichi Handa <handa@m17n.org>
parents:
30578
diff
changeset
|
6294 nocopy = 1; |
6c7a9202a815
(coding_restore_composition): Pay attention to the case that
Kenichi Handa <handa@m17n.org>
parents:
30578
diff
changeset
|
6295 } |
46370
40db0673e6f0
Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents:
46293
diff
changeset
|
6296 coding->produced = SBYTES (str); |
40db0673e6f0
Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents:
46293
diff
changeset
|
6297 coding->produced_char = SCHARS (str); |
30581
6c7a9202a815
(coding_restore_composition): Pay attention to the case that
Kenichi Handa <handa@m17n.org>
parents:
30578
diff
changeset
|
6298 return (nocopy ? str : Fcopy_sequence (str)); |
6c7a9202a815
(coding_restore_composition): Pay attention to the case that
Kenichi Handa <handa@m17n.org>
parents:
30578
diff
changeset
|
6299 } |
6c7a9202a815
(coding_restore_composition): Pay attention to the case that
Kenichi Handa <handa@m17n.org>
parents:
30578
diff
changeset
|
6300 |
6c7a9202a815
(coding_restore_composition): Pay attention to the case that
Kenichi Handa <handa@m17n.org>
parents:
30578
diff
changeset
|
6301 if (coding->composing != COMPOSITION_DISABLED) |
6c7a9202a815
(coding_restore_composition): Pay attention to the case that
Kenichi Handa <handa@m17n.org>
parents:
30578
diff
changeset
|
6302 coding_allocate_composition_data (coding, from); |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
6303 len = decoding_buffer_size (coding, to_byte - from); |
30833
2db6e42a6ba3
(MINIMUM_CONVERSION_BUFFER_SIZE): Macro deleted.
Kenichi Handa <handa@m17n.org>
parents:
30756
diff
changeset
|
6304 allocate_conversion_buffer (buf, len); |
2db6e42a6ba3
(MINIMUM_CONVERSION_BUFFER_SIZE): Macro deleted.
Kenichi Handa <handa@m17n.org>
parents:
30756
diff
changeset
|
6305 |
30950
5682de5cfdac
(decode_coding_string): Set members consumed,
Kenichi Handa <handa@m17n.org>
parents:
30847
diff
changeset
|
6306 consumed = consumed_char = produced = produced_char = 0; |
30833
2db6e42a6ba3
(MINIMUM_CONVERSION_BUFFER_SIZE): Macro deleted.
Kenichi Handa <handa@m17n.org>
parents:
30756
diff
changeset
|
6307 while (1) |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
6308 { |
46370
40db0673e6f0
Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents:
46293
diff
changeset
|
6309 result = decode_coding (coding, SDATA (str) + from + consumed, |
30833
2db6e42a6ba3
(MINIMUM_CONVERSION_BUFFER_SIZE): Macro deleted.
Kenichi Handa <handa@m17n.org>
parents:
30756
diff
changeset
|
6310 buf.data + produced, to_byte - from - consumed, |
2db6e42a6ba3
(MINIMUM_CONVERSION_BUFFER_SIZE): Macro deleted.
Kenichi Handa <handa@m17n.org>
parents:
30756
diff
changeset
|
6311 buf.size - produced); |
2db6e42a6ba3
(MINIMUM_CONVERSION_BUFFER_SIZE): Macro deleted.
Kenichi Handa <handa@m17n.org>
parents:
30756
diff
changeset
|
6312 consumed += coding->consumed; |
30950
5682de5cfdac
(decode_coding_string): Set members consumed,
Kenichi Handa <handa@m17n.org>
parents:
30847
diff
changeset
|
6313 consumed_char += coding->consumed_char; |
30833
2db6e42a6ba3
(MINIMUM_CONVERSION_BUFFER_SIZE): Macro deleted.
Kenichi Handa <handa@m17n.org>
parents:
30756
diff
changeset
|
6314 produced += coding->produced; |
2db6e42a6ba3
(MINIMUM_CONVERSION_BUFFER_SIZE): Macro deleted.
Kenichi Handa <handa@m17n.org>
parents:
30756
diff
changeset
|
6315 produced_char += coding->produced_char; |
30950
5682de5cfdac
(decode_coding_string): Set members consumed,
Kenichi Handa <handa@m17n.org>
parents:
30847
diff
changeset
|
6316 if (result == CODING_FINISH_NORMAL |
62983
5a6bae733c66
(decode_coding_string): Handle CODING_FINISH_INTERRUPT.
Kim F. Storm <storm@cua.dk>
parents:
61722
diff
changeset
|
6317 || result == CODING_FINISH_INTERRUPT |
30950
5682de5cfdac
(decode_coding_string): Set members consumed,
Kenichi Handa <handa@m17n.org>
parents:
30847
diff
changeset
|
6318 || (result == CODING_FINISH_INSUFFICIENT_SRC |
5682de5cfdac
(decode_coding_string): Set members consumed,
Kenichi Handa <handa@m17n.org>
parents:
30847
diff
changeset
|
6319 && coding->consumed == 0)) |
30833
2db6e42a6ba3
(MINIMUM_CONVERSION_BUFFER_SIZE): Macro deleted.
Kenichi Handa <handa@m17n.org>
parents:
30756
diff
changeset
|
6320 break; |
2db6e42a6ba3
(MINIMUM_CONVERSION_BUFFER_SIZE): Macro deleted.
Kenichi Handa <handa@m17n.org>
parents:
30756
diff
changeset
|
6321 if (result == CODING_FINISH_INSUFFICIENT_CMP) |
2db6e42a6ba3
(MINIMUM_CONVERSION_BUFFER_SIZE): Macro deleted.
Kenichi Handa <handa@m17n.org>
parents:
30756
diff
changeset
|
6322 coding_allocate_composition_data (coding, from + produced_char); |
2db6e42a6ba3
(MINIMUM_CONVERSION_BUFFER_SIZE): Macro deleted.
Kenichi Handa <handa@m17n.org>
parents:
30756
diff
changeset
|
6323 else if (result == CODING_FINISH_INSUFFICIENT_DST) |
2db6e42a6ba3
(MINIMUM_CONVERSION_BUFFER_SIZE): Macro deleted.
Kenichi Handa <handa@m17n.org>
parents:
30756
diff
changeset
|
6324 extend_conversion_buffer (&buf); |
2db6e42a6ba3
(MINIMUM_CONVERSION_BUFFER_SIZE): Macro deleted.
Kenichi Handa <handa@m17n.org>
parents:
30756
diff
changeset
|
6325 else if (result == CODING_FINISH_INCONSISTENT_EOL) |
2db6e42a6ba3
(MINIMUM_CONVERSION_BUFFER_SIZE): Macro deleted.
Kenichi Handa <handa@m17n.org>
parents:
30756
diff
changeset
|
6326 { |
35587
7e767148cfdc
(decode_coding): Set a flag for inhibiting
Kenichi Handa <handa@m17n.org>
parents:
35531
diff
changeset
|
6327 Lisp_Object eol_type; |
7e767148cfdc
(decode_coding): Set a flag for inhibiting
Kenichi Handa <handa@m17n.org>
parents:
35531
diff
changeset
|
6328 |
30833
2db6e42a6ba3
(MINIMUM_CONVERSION_BUFFER_SIZE): Macro deleted.
Kenichi Handa <handa@m17n.org>
parents:
30756
diff
changeset
|
6329 /* Recover the original EOL format. */ |
2db6e42a6ba3
(MINIMUM_CONVERSION_BUFFER_SIZE): Macro deleted.
Kenichi Handa <handa@m17n.org>
parents:
30756
diff
changeset
|
6330 if (coding->eol_type == CODING_EOL_CR) |
2db6e42a6ba3
(MINIMUM_CONVERSION_BUFFER_SIZE): Macro deleted.
Kenichi Handa <handa@m17n.org>
parents:
30756
diff
changeset
|
6331 { |
2db6e42a6ba3
(MINIMUM_CONVERSION_BUFFER_SIZE): Macro deleted.
Kenichi Handa <handa@m17n.org>
parents:
30756
diff
changeset
|
6332 unsigned char *p; |
2db6e42a6ba3
(MINIMUM_CONVERSION_BUFFER_SIZE): Macro deleted.
Kenichi Handa <handa@m17n.org>
parents:
30756
diff
changeset
|
6333 for (p = buf.data; p < buf.data + produced; p++) |
2db6e42a6ba3
(MINIMUM_CONVERSION_BUFFER_SIZE): Macro deleted.
Kenichi Handa <handa@m17n.org>
parents:
30756
diff
changeset
|
6334 if (*p == '\n') *p = '\r'; |
2db6e42a6ba3
(MINIMUM_CONVERSION_BUFFER_SIZE): Macro deleted.
Kenichi Handa <handa@m17n.org>
parents:
30756
diff
changeset
|
6335 } |
2db6e42a6ba3
(MINIMUM_CONVERSION_BUFFER_SIZE): Macro deleted.
Kenichi Handa <handa@m17n.org>
parents:
30756
diff
changeset
|
6336 else if (coding->eol_type == CODING_EOL_CRLF) |
2db6e42a6ba3
(MINIMUM_CONVERSION_BUFFER_SIZE): Macro deleted.
Kenichi Handa <handa@m17n.org>
parents:
30756
diff
changeset
|
6337 { |
2db6e42a6ba3
(MINIMUM_CONVERSION_BUFFER_SIZE): Macro deleted.
Kenichi Handa <handa@m17n.org>
parents:
30756
diff
changeset
|
6338 int num_eol = 0; |
2db6e42a6ba3
(MINIMUM_CONVERSION_BUFFER_SIZE): Macro deleted.
Kenichi Handa <handa@m17n.org>
parents:
30756
diff
changeset
|
6339 unsigned char *p0, *p1; |
2db6e42a6ba3
(MINIMUM_CONVERSION_BUFFER_SIZE): Macro deleted.
Kenichi Handa <handa@m17n.org>
parents:
30756
diff
changeset
|
6340 for (p0 = buf.data, p1 = p0 + produced; p0 < p1; p0++) |
2db6e42a6ba3
(MINIMUM_CONVERSION_BUFFER_SIZE): Macro deleted.
Kenichi Handa <handa@m17n.org>
parents:
30756
diff
changeset
|
6341 if (*p0 == '\n') num_eol++; |
2db6e42a6ba3
(MINIMUM_CONVERSION_BUFFER_SIZE): Macro deleted.
Kenichi Handa <handa@m17n.org>
parents:
30756
diff
changeset
|
6342 if (produced + num_eol >= buf.size) |
2db6e42a6ba3
(MINIMUM_CONVERSION_BUFFER_SIZE): Macro deleted.
Kenichi Handa <handa@m17n.org>
parents:
30756
diff
changeset
|
6343 extend_conversion_buffer (&buf); |
2db6e42a6ba3
(MINIMUM_CONVERSION_BUFFER_SIZE): Macro deleted.
Kenichi Handa <handa@m17n.org>
parents:
30756
diff
changeset
|
6344 for (p0 = buf.data + produced, p1 = p0 + num_eol; p0 > buf.data;) |
2db6e42a6ba3
(MINIMUM_CONVERSION_BUFFER_SIZE): Macro deleted.
Kenichi Handa <handa@m17n.org>
parents:
30756
diff
changeset
|
6345 { |
2db6e42a6ba3
(MINIMUM_CONVERSION_BUFFER_SIZE): Macro deleted.
Kenichi Handa <handa@m17n.org>
parents:
30756
diff
changeset
|
6346 *--p1 = *--p0; |
2db6e42a6ba3
(MINIMUM_CONVERSION_BUFFER_SIZE): Macro deleted.
Kenichi Handa <handa@m17n.org>
parents:
30756
diff
changeset
|
6347 if (*p0 == '\n') *--p1 = '\r'; |
2db6e42a6ba3
(MINIMUM_CONVERSION_BUFFER_SIZE): Macro deleted.
Kenichi Handa <handa@m17n.org>
parents:
30756
diff
changeset
|
6348 } |
2db6e42a6ba3
(MINIMUM_CONVERSION_BUFFER_SIZE): Macro deleted.
Kenichi Handa <handa@m17n.org>
parents:
30756
diff
changeset
|
6349 produced += num_eol; |
2db6e42a6ba3
(MINIMUM_CONVERSION_BUFFER_SIZE): Macro deleted.
Kenichi Handa <handa@m17n.org>
parents:
30756
diff
changeset
|
6350 produced_char += num_eol; |
42104
d69c2368e549
(DECODE_COMPOSITION_END): Fixed a typo in the last
Sam Steingold <sds@gnu.org>
parents:
42103
diff
changeset
|
6351 } |
35587
7e767148cfdc
(decode_coding): Set a flag for inhibiting
Kenichi Handa <handa@m17n.org>
parents:
35531
diff
changeset
|
6352 /* Suppress eol-format conversion in the further conversion. */ |
30833
2db6e42a6ba3
(MINIMUM_CONVERSION_BUFFER_SIZE): Macro deleted.
Kenichi Handa <handa@m17n.org>
parents:
30756
diff
changeset
|
6353 coding->eol_type = CODING_EOL_LF; |
35587
7e767148cfdc
(decode_coding): Set a flag for inhibiting
Kenichi Handa <handa@m17n.org>
parents:
35531
diff
changeset
|
6354 |
7e767148cfdc
(decode_coding): Set a flag for inhibiting
Kenichi Handa <handa@m17n.org>
parents:
35531
diff
changeset
|
6355 /* Set the coding system symbol to that for Unix-like EOL. */ |
7e767148cfdc
(decode_coding): Set a flag for inhibiting
Kenichi Handa <handa@m17n.org>
parents:
35531
diff
changeset
|
6356 eol_type = Fget (saved_coding_symbol, Qeol_type); |
7e767148cfdc
(decode_coding): Set a flag for inhibiting
Kenichi Handa <handa@m17n.org>
parents:
35531
diff
changeset
|
6357 if (VECTORP (eol_type) |
7e767148cfdc
(decode_coding): Set a flag for inhibiting
Kenichi Handa <handa@m17n.org>
parents:
35531
diff
changeset
|
6358 && XVECTOR (eol_type)->size == 3 |
7e767148cfdc
(decode_coding): Set a flag for inhibiting
Kenichi Handa <handa@m17n.org>
parents:
35531
diff
changeset
|
6359 && SYMBOLP (XVECTOR (eol_type)->contents[CODING_EOL_LF])) |
7e767148cfdc
(decode_coding): Set a flag for inhibiting
Kenichi Handa <handa@m17n.org>
parents:
35531
diff
changeset
|
6360 coding->symbol = XVECTOR (eol_type)->contents[CODING_EOL_LF]; |
7e767148cfdc
(decode_coding): Set a flag for inhibiting
Kenichi Handa <handa@m17n.org>
parents:
35531
diff
changeset
|
6361 else |
7e767148cfdc
(decode_coding): Set a flag for inhibiting
Kenichi Handa <handa@m17n.org>
parents:
35531
diff
changeset
|
6362 coding->symbol = saved_coding_symbol; |
7e767148cfdc
(decode_coding): Set a flag for inhibiting
Kenichi Handa <handa@m17n.org>
parents:
35531
diff
changeset
|
6363 |
7e767148cfdc
(decode_coding): Set a flag for inhibiting
Kenichi Handa <handa@m17n.org>
parents:
35531
diff
changeset
|
6364 |
30833
2db6e42a6ba3
(MINIMUM_CONVERSION_BUFFER_SIZE): Macro deleted.
Kenichi Handa <handa@m17n.org>
parents:
30756
diff
changeset
|
6365 } |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
6366 } |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
6367 |
30950
5682de5cfdac
(decode_coding_string): Set members consumed,
Kenichi Handa <handa@m17n.org>
parents:
30847
diff
changeset
|
6368 coding->consumed = consumed; |
5682de5cfdac
(decode_coding_string): Set members consumed,
Kenichi Handa <handa@m17n.org>
parents:
30847
diff
changeset
|
6369 coding->consumed_char = consumed_char; |
5682de5cfdac
(decode_coding_string): Set members consumed,
Kenichi Handa <handa@m17n.org>
parents:
30847
diff
changeset
|
6370 coding->produced = produced; |
5682de5cfdac
(decode_coding_string): Set members consumed,
Kenichi Handa <handa@m17n.org>
parents:
30847
diff
changeset
|
6371 coding->produced_char = produced_char; |
5682de5cfdac
(decode_coding_string): Set members consumed,
Kenichi Handa <handa@m17n.org>
parents:
30847
diff
changeset
|
6372 |
30581
6c7a9202a815
(coding_restore_composition): Pay attention to the case that
Kenichi Handa <handa@m17n.org>
parents:
30578
diff
changeset
|
6373 if (coding->dst_multibyte) |
30833
2db6e42a6ba3
(MINIMUM_CONVERSION_BUFFER_SIZE): Macro deleted.
Kenichi Handa <handa@m17n.org>
parents:
30756
diff
changeset
|
6374 newstr = make_uninit_multibyte_string (produced_char + shrinked_bytes, |
2db6e42a6ba3
(MINIMUM_CONVERSION_BUFFER_SIZE): Macro deleted.
Kenichi Handa <handa@m17n.org>
parents:
30756
diff
changeset
|
6375 produced + shrinked_bytes); |
30581
6c7a9202a815
(coding_restore_composition): Pay attention to the case that
Kenichi Handa <handa@m17n.org>
parents:
30578
diff
changeset
|
6376 else |
30833
2db6e42a6ba3
(MINIMUM_CONVERSION_BUFFER_SIZE): Macro deleted.
Kenichi Handa <handa@m17n.org>
parents:
30756
diff
changeset
|
6377 newstr = make_uninit_string (produced + shrinked_bytes); |
2db6e42a6ba3
(MINIMUM_CONVERSION_BUFFER_SIZE): Macro deleted.
Kenichi Handa <handa@m17n.org>
parents:
30756
diff
changeset
|
6378 if (from > 0) |
46548
cb1914307488
(encode_eol, detect_coding, detect_eol):
Ken Raeburn <raeburn@raeburn.org>
parents:
46462
diff
changeset
|
6379 STRING_COPYIN (newstr, 0, SDATA (str), from); |
cb1914307488
(encode_eol, detect_coding, detect_eol):
Ken Raeburn <raeburn@raeburn.org>
parents:
46462
diff
changeset
|
6380 STRING_COPYIN (newstr, from, buf.data, produced); |
30833
2db6e42a6ba3
(MINIMUM_CONVERSION_BUFFER_SIZE): Macro deleted.
Kenichi Handa <handa@m17n.org>
parents:
30756
diff
changeset
|
6381 if (shrinked_bytes > from) |
46548
cb1914307488
(encode_eol, detect_coding, detect_eol):
Ken Raeburn <raeburn@raeburn.org>
parents:
46462
diff
changeset
|
6382 STRING_COPYIN (newstr, from + produced, |
cb1914307488
(encode_eol, detect_coding, detect_eol):
Ken Raeburn <raeburn@raeburn.org>
parents:
46462
diff
changeset
|
6383 SDATA (str) + to_byte, |
cb1914307488
(encode_eol, detect_coding, detect_eol):
Ken Raeburn <raeburn@raeburn.org>
parents:
46462
diff
changeset
|
6384 shrinked_bytes - from); |
30833
2db6e42a6ba3
(MINIMUM_CONVERSION_BUFFER_SIZE): Macro deleted.
Kenichi Handa <handa@m17n.org>
parents:
30756
diff
changeset
|
6385 free_conversion_buffer (&buf); |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
6386 |
56595
40a0843be50a
(decode_coding_string): Adjust coding->consumed, and
Kenichi Handa <handa@m17n.org>
parents:
56191
diff
changeset
|
6387 coding->consumed += shrinked_bytes; |
40a0843be50a
(decode_coding_string): Adjust coding->consumed, and
Kenichi Handa <handa@m17n.org>
parents:
56191
diff
changeset
|
6388 coding->consumed_char += shrinked_bytes; |
40a0843be50a
(decode_coding_string): Adjust coding->consumed, and
Kenichi Handa <handa@m17n.org>
parents:
56191
diff
changeset
|
6389 coding->produced += shrinked_bytes; |
40a0843be50a
(decode_coding_string): Adjust coding->consumed, and
Kenichi Handa <handa@m17n.org>
parents:
56191
diff
changeset
|
6390 coding->produced_char += shrinked_bytes; |
40a0843be50a
(decode_coding_string): Adjust coding->consumed, and
Kenichi Handa <handa@m17n.org>
parents:
56191
diff
changeset
|
6391 |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
6392 if (coding->cmp_data && coding->cmp_data->used) |
30833
2db6e42a6ba3
(MINIMUM_CONVERSION_BUFFER_SIZE): Macro deleted.
Kenichi Handa <handa@m17n.org>
parents:
30756
diff
changeset
|
6393 coding_restore_composition (coding, newstr); |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
6394 coding_free_composition_data (coding); |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
6395 |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
6396 if (SYMBOLP (coding->post_read_conversion) |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
6397 && !NILP (Ffboundp (coding->post_read_conversion))) |
30833
2db6e42a6ba3
(MINIMUM_CONVERSION_BUFFER_SIZE): Macro deleted.
Kenichi Handa <handa@m17n.org>
parents:
30756
diff
changeset
|
6398 newstr = run_pre_post_conversion_on_str (newstr, coding, 0); |
2db6e42a6ba3
(MINIMUM_CONVERSION_BUFFER_SIZE): Macro deleted.
Kenichi Handa <handa@m17n.org>
parents:
30756
diff
changeset
|
6399 |
2db6e42a6ba3
(MINIMUM_CONVERSION_BUFFER_SIZE): Macro deleted.
Kenichi Handa <handa@m17n.org>
parents:
30756
diff
changeset
|
6400 return newstr; |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
6401 } |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
6402 |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
6403 Lisp_Object |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
6404 encode_coding_string (str, coding, nocopy) |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
6405 Lisp_Object str; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
6406 struct coding_system *coding; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
6407 int nocopy; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
6408 { |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
6409 int len; |
30833
2db6e42a6ba3
(MINIMUM_CONVERSION_BUFFER_SIZE): Macro deleted.
Kenichi Handa <handa@m17n.org>
parents:
30756
diff
changeset
|
6410 struct conversion_buffer buf; |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
6411 int from, to, to_byte; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
6412 int result; |
30833
2db6e42a6ba3
(MINIMUM_CONVERSION_BUFFER_SIZE): Macro deleted.
Kenichi Handa <handa@m17n.org>
parents:
30756
diff
changeset
|
6413 int shrinked_bytes = 0; |
2db6e42a6ba3
(MINIMUM_CONVERSION_BUFFER_SIZE): Macro deleted.
Kenichi Handa <handa@m17n.org>
parents:
30756
diff
changeset
|
6414 Lisp_Object newstr; |
30950
5682de5cfdac
(decode_coding_string): Set members consumed,
Kenichi Handa <handa@m17n.org>
parents:
30847
diff
changeset
|
6415 int consumed, consumed_char, produced, produced_char; |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
6416 |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
6417 if (SYMBOLP (coding->pre_write_conversion) |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
6418 && !NILP (Ffboundp (coding->pre_write_conversion))) |
60031
8d84cdf36525
(encode_coding_string): Always return a unibyte string.
Kenichi Handa <handa@m17n.org>
parents:
59608
diff
changeset
|
6419 { |
8d84cdf36525
(encode_coding_string): Always return a unibyte string.
Kenichi Handa <handa@m17n.org>
parents:
59608
diff
changeset
|
6420 str = run_pre_post_conversion_on_str (str, coding, 1); |
8d84cdf36525
(encode_coding_string): Always return a unibyte string.
Kenichi Handa <handa@m17n.org>
parents:
59608
diff
changeset
|
6421 /* As STR is just newly generated, we don't have to copy it |
8d84cdf36525
(encode_coding_string): Always return a unibyte string.
Kenichi Handa <handa@m17n.org>
parents:
59608
diff
changeset
|
6422 anymore. */ |
8d84cdf36525
(encode_coding_string): Always return a unibyte string.
Kenichi Handa <handa@m17n.org>
parents:
59608
diff
changeset
|
6423 nocopy = 1; |
8d84cdf36525
(encode_coding_string): Always return a unibyte string.
Kenichi Handa <handa@m17n.org>
parents:
59608
diff
changeset
|
6424 } |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
6425 |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
6426 from = 0; |
46370
40db0673e6f0
Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents:
46293
diff
changeset
|
6427 to = SCHARS (str); |
40db0673e6f0
Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents:
46293
diff
changeset
|
6428 to_byte = SBYTES (str); |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
6429 |
32445
05513a882886
(decode_coding_string): Set coding->src_multibyte and
Kenichi Handa <handa@m17n.org>
parents:
32443
diff
changeset
|
6430 /* Encoding routines determine the multibyteness of the source text |
05513a882886
(decode_coding_string): Set coding->src_multibyte and
Kenichi Handa <handa@m17n.org>
parents:
32443
diff
changeset
|
6431 by coding->src_multibyte. */ |
60031
8d84cdf36525
(encode_coding_string): Always return a unibyte string.
Kenichi Handa <handa@m17n.org>
parents:
59608
diff
changeset
|
6432 coding->src_multibyte = SCHARS (str) < SBYTES (str); |
32445
05513a882886
(decode_coding_string): Set coding->src_multibyte and
Kenichi Handa <handa@m17n.org>
parents:
32443
diff
changeset
|
6433 coding->dst_multibyte = 0; |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
6434 if (! CODING_REQUIRE_ENCODING (coding)) |
60031
8d84cdf36525
(encode_coding_string): Always return a unibyte string.
Kenichi Handa <handa@m17n.org>
parents:
59608
diff
changeset
|
6435 goto no_need_of_encoding; |
22723
04b653d7f842
(code_convert_string): Count characters again if we
Kenichi Handa <handa@m17n.org>
parents:
22717
diff
changeset
|
6436 |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
6437 if (coding->composing != COMPOSITION_DISABLED) |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
6438 coding_save_composition (coding, from, to, str); |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
6439 |
57285
9093a2e9c3fd
(code_convert_region): Don't skip ASCIIs if there are compositions to encode.
Kenichi Handa <handa@m17n.org>
parents:
56595
diff
changeset
|
6440 /* Try to skip the heading and tailing ASCIIs. We can't skip them |
9093a2e9c3fd
(code_convert_region): Don't skip ASCIIs if there are compositions to encode.
Kenichi Handa <handa@m17n.org>
parents:
56595
diff
changeset
|
6441 if we must run CCL program or there are compositions to |
9093a2e9c3fd
(code_convert_region): Don't skip ASCIIs if there are compositions to encode.
Kenichi Handa <handa@m17n.org>
parents:
56595
diff
changeset
|
6442 encode. */ |
73995
11025612f889
(code_convert_region): Initialize
Kenichi Handa <handa@m17n.org>
parents:
73949
diff
changeset
|
6443 coding->heading_ascii = 0; |
57285
9093a2e9c3fd
(code_convert_region): Don't skip ASCIIs if there are compositions to encode.
Kenichi Handa <handa@m17n.org>
parents:
56595
diff
changeset
|
6444 if (coding->type != coding_type_ccl |
9093a2e9c3fd
(code_convert_region): Don't skip ASCIIs if there are compositions to encode.
Kenichi Handa <handa@m17n.org>
parents:
56595
diff
changeset
|
6445 && (! coding->cmp_data || coding->cmp_data->used == 0)) |
29985
c17e78d8c720
(code_convert_region): Even if the length of text is
Kenichi Handa <handa@m17n.org>
parents:
29932
diff
changeset
|
6446 { |
46370
40db0673e6f0
Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents:
46293
diff
changeset
|
6447 SHRINK_CONVERSION_REGION (&from, &to_byte, coding, SDATA (str), |
29985
c17e78d8c720
(code_convert_region): Even if the length of text is
Kenichi Handa <handa@m17n.org>
parents:
29932
diff
changeset
|
6448 1); |
c17e78d8c720
(code_convert_region): Even if the length of text is
Kenichi Handa <handa@m17n.org>
parents:
29932
diff
changeset
|
6449 if (from == to_byte) |
57285
9093a2e9c3fd
(code_convert_region): Don't skip ASCIIs if there are compositions to encode.
Kenichi Handa <handa@m17n.org>
parents:
56595
diff
changeset
|
6450 { |
9093a2e9c3fd
(code_convert_region): Don't skip ASCIIs if there are compositions to encode.
Kenichi Handa <handa@m17n.org>
parents:
56595
diff
changeset
|
6451 coding_free_composition_data (coding); |
60031
8d84cdf36525
(encode_coding_string): Always return a unibyte string.
Kenichi Handa <handa@m17n.org>
parents:
59608
diff
changeset
|
6452 goto no_need_of_encoding; |
57285
9093a2e9c3fd
(code_convert_region): Don't skip ASCIIs if there are compositions to encode.
Kenichi Handa <handa@m17n.org>
parents:
56595
diff
changeset
|
6453 } |
46370
40db0673e6f0
Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents:
46293
diff
changeset
|
6454 shrinked_bytes = from + (SBYTES (str) - to_byte); |
29985
c17e78d8c720
(code_convert_region): Even if the length of text is
Kenichi Handa <handa@m17n.org>
parents:
29932
diff
changeset
|
6455 } |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
6456 |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
6457 len = encoding_buffer_size (coding, to_byte - from); |
30833
2db6e42a6ba3
(MINIMUM_CONVERSION_BUFFER_SIZE): Macro deleted.
Kenichi Handa <handa@m17n.org>
parents:
30756
diff
changeset
|
6458 allocate_conversion_buffer (buf, len); |
2db6e42a6ba3
(MINIMUM_CONVERSION_BUFFER_SIZE): Macro deleted.
Kenichi Handa <handa@m17n.org>
parents:
30756
diff
changeset
|
6459 |
30950
5682de5cfdac
(decode_coding_string): Set members consumed,
Kenichi Handa <handa@m17n.org>
parents:
30847
diff
changeset
|
6460 consumed = consumed_char = produced = produced_char = 0; |
30833
2db6e42a6ba3
(MINIMUM_CONVERSION_BUFFER_SIZE): Macro deleted.
Kenichi Handa <handa@m17n.org>
parents:
30756
diff
changeset
|
6461 while (1) |
2db6e42a6ba3
(MINIMUM_CONVERSION_BUFFER_SIZE): Macro deleted.
Kenichi Handa <handa@m17n.org>
parents:
30756
diff
changeset
|
6462 { |
46370
40db0673e6f0
Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents:
46293
diff
changeset
|
6463 result = encode_coding (coding, SDATA (str) + from + consumed, |
30833
2db6e42a6ba3
(MINIMUM_CONVERSION_BUFFER_SIZE): Macro deleted.
Kenichi Handa <handa@m17n.org>
parents:
30756
diff
changeset
|
6464 buf.data + produced, to_byte - from - consumed, |
2db6e42a6ba3
(MINIMUM_CONVERSION_BUFFER_SIZE): Macro deleted.
Kenichi Handa <handa@m17n.org>
parents:
30756
diff
changeset
|
6465 buf.size - produced); |
2db6e42a6ba3
(MINIMUM_CONVERSION_BUFFER_SIZE): Macro deleted.
Kenichi Handa <handa@m17n.org>
parents:
30756
diff
changeset
|
6466 consumed += coding->consumed; |
30950
5682de5cfdac
(decode_coding_string): Set members consumed,
Kenichi Handa <handa@m17n.org>
parents:
30847
diff
changeset
|
6467 consumed_char += coding->consumed_char; |
30951
e6acd4b6a8d5
(encode_coding_string): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
30950
diff
changeset
|
6468 produced += coding->produced; |
30950
5682de5cfdac
(decode_coding_string): Set members consumed,
Kenichi Handa <handa@m17n.org>
parents:
30847
diff
changeset
|
6469 produced_char += coding->produced_char; |
5682de5cfdac
(decode_coding_string): Set members consumed,
Kenichi Handa <handa@m17n.org>
parents:
30847
diff
changeset
|
6470 if (result == CODING_FINISH_NORMAL |
56028
32381d1c4eab
(encode_coding_string): Check CODING_FINISH_INTERRUPT.
Kenichi Handa <handa@m17n.org>
parents:
55964
diff
changeset
|
6471 || result == CODING_FINISH_INTERRUPT |
30950
5682de5cfdac
(decode_coding_string): Set members consumed,
Kenichi Handa <handa@m17n.org>
parents:
30847
diff
changeset
|
6472 || (result == CODING_FINISH_INSUFFICIENT_SRC |
5682de5cfdac
(decode_coding_string): Set members consumed,
Kenichi Handa <handa@m17n.org>
parents:
30847
diff
changeset
|
6473 && coding->consumed == 0)) |
30833
2db6e42a6ba3
(MINIMUM_CONVERSION_BUFFER_SIZE): Macro deleted.
Kenichi Handa <handa@m17n.org>
parents:
30756
diff
changeset
|
6474 break; |
2db6e42a6ba3
(MINIMUM_CONVERSION_BUFFER_SIZE): Macro deleted.
Kenichi Handa <handa@m17n.org>
parents:
30756
diff
changeset
|
6475 /* Now result should be CODING_FINISH_INSUFFICIENT_DST. */ |
2db6e42a6ba3
(MINIMUM_CONVERSION_BUFFER_SIZE): Macro deleted.
Kenichi Handa <handa@m17n.org>
parents:
30756
diff
changeset
|
6476 extend_conversion_buffer (&buf); |
2db6e42a6ba3
(MINIMUM_CONVERSION_BUFFER_SIZE): Macro deleted.
Kenichi Handa <handa@m17n.org>
parents:
30756
diff
changeset
|
6477 } |
2db6e42a6ba3
(MINIMUM_CONVERSION_BUFFER_SIZE): Macro deleted.
Kenichi Handa <handa@m17n.org>
parents:
30756
diff
changeset
|
6478 |
30950
5682de5cfdac
(decode_coding_string): Set members consumed,
Kenichi Handa <handa@m17n.org>
parents:
30847
diff
changeset
|
6479 coding->consumed = consumed; |
5682de5cfdac
(decode_coding_string): Set members consumed,
Kenichi Handa <handa@m17n.org>
parents:
30847
diff
changeset
|
6480 coding->consumed_char = consumed_char; |
5682de5cfdac
(decode_coding_string): Set members consumed,
Kenichi Handa <handa@m17n.org>
parents:
30847
diff
changeset
|
6481 coding->produced = produced; |
5682de5cfdac
(decode_coding_string): Set members consumed,
Kenichi Handa <handa@m17n.org>
parents:
30847
diff
changeset
|
6482 coding->produced_char = produced_char; |
5682de5cfdac
(decode_coding_string): Set members consumed,
Kenichi Handa <handa@m17n.org>
parents:
30847
diff
changeset
|
6483 |
30833
2db6e42a6ba3
(MINIMUM_CONVERSION_BUFFER_SIZE): Macro deleted.
Kenichi Handa <handa@m17n.org>
parents:
30756
diff
changeset
|
6484 newstr = make_uninit_string (produced + shrinked_bytes); |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
6485 if (from > 0) |
46548
cb1914307488
(encode_eol, detect_coding, detect_eol):
Ken Raeburn <raeburn@raeburn.org>
parents:
46462
diff
changeset
|
6486 STRING_COPYIN (newstr, 0, SDATA (str), from); |
cb1914307488
(encode_eol, detect_coding, detect_eol):
Ken Raeburn <raeburn@raeburn.org>
parents:
46462
diff
changeset
|
6487 STRING_COPYIN (newstr, from, buf.data, produced); |
30833
2db6e42a6ba3
(MINIMUM_CONVERSION_BUFFER_SIZE): Macro deleted.
Kenichi Handa <handa@m17n.org>
parents:
30756
diff
changeset
|
6488 if (shrinked_bytes > from) |
46548
cb1914307488
(encode_eol, detect_coding, detect_eol):
Ken Raeburn <raeburn@raeburn.org>
parents:
46462
diff
changeset
|
6489 STRING_COPYIN (newstr, from + produced, |
cb1914307488
(encode_eol, detect_coding, detect_eol):
Ken Raeburn <raeburn@raeburn.org>
parents:
46462
diff
changeset
|
6490 SDATA (str) + to_byte, |
cb1914307488
(encode_eol, detect_coding, detect_eol):
Ken Raeburn <raeburn@raeburn.org>
parents:
46462
diff
changeset
|
6491 shrinked_bytes - from); |
30833
2db6e42a6ba3
(MINIMUM_CONVERSION_BUFFER_SIZE): Macro deleted.
Kenichi Handa <handa@m17n.org>
parents:
30756
diff
changeset
|
6492 |
2db6e42a6ba3
(MINIMUM_CONVERSION_BUFFER_SIZE): Macro deleted.
Kenichi Handa <handa@m17n.org>
parents:
30756
diff
changeset
|
6493 free_conversion_buffer (&buf); |
26847 | 6494 coding_free_composition_data (coding); |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
6495 |
30833
2db6e42a6ba3
(MINIMUM_CONVERSION_BUFFER_SIZE): Macro deleted.
Kenichi Handa <handa@m17n.org>
parents:
30756
diff
changeset
|
6496 return newstr; |
60031
8d84cdf36525
(encode_coding_string): Always return a unibyte string.
Kenichi Handa <handa@m17n.org>
parents:
59608
diff
changeset
|
6497 |
8d84cdf36525
(encode_coding_string): Always return a unibyte string.
Kenichi Handa <handa@m17n.org>
parents:
59608
diff
changeset
|
6498 no_need_of_encoding: |
8d84cdf36525
(encode_coding_string): Always return a unibyte string.
Kenichi Handa <handa@m17n.org>
parents:
59608
diff
changeset
|
6499 coding->consumed = SBYTES (str); |
8d84cdf36525
(encode_coding_string): Always return a unibyte string.
Kenichi Handa <handa@m17n.org>
parents:
59608
diff
changeset
|
6500 coding->consumed_char = SCHARS (str); |
8d84cdf36525
(encode_coding_string): Always return a unibyte string.
Kenichi Handa <handa@m17n.org>
parents:
59608
diff
changeset
|
6501 if (STRING_MULTIBYTE (str)) |
8d84cdf36525
(encode_coding_string): Always return a unibyte string.
Kenichi Handa <handa@m17n.org>
parents:
59608
diff
changeset
|
6502 { |
8d84cdf36525
(encode_coding_string): Always return a unibyte string.
Kenichi Handa <handa@m17n.org>
parents:
59608
diff
changeset
|
6503 if (nocopy) |
8d84cdf36525
(encode_coding_string): Always return a unibyte string.
Kenichi Handa <handa@m17n.org>
parents:
59608
diff
changeset
|
6504 /* We are sure that STR doesn't contain a multibyte |
8d84cdf36525
(encode_coding_string): Always return a unibyte string.
Kenichi Handa <handa@m17n.org>
parents:
59608
diff
changeset
|
6505 character. */ |
8d84cdf36525
(encode_coding_string): Always return a unibyte string.
Kenichi Handa <handa@m17n.org>
parents:
59608
diff
changeset
|
6506 STRING_SET_UNIBYTE (str); |
8d84cdf36525
(encode_coding_string): Always return a unibyte string.
Kenichi Handa <handa@m17n.org>
parents:
59608
diff
changeset
|
6507 else |
8d84cdf36525
(encode_coding_string): Always return a unibyte string.
Kenichi Handa <handa@m17n.org>
parents:
59608
diff
changeset
|
6508 { |
8d84cdf36525
(encode_coding_string): Always return a unibyte string.
Kenichi Handa <handa@m17n.org>
parents:
59608
diff
changeset
|
6509 str = Fstring_as_unibyte (str); |
8d84cdf36525
(encode_coding_string): Always return a unibyte string.
Kenichi Handa <handa@m17n.org>
parents:
59608
diff
changeset
|
6510 nocopy = 1; |
8d84cdf36525
(encode_coding_string): Always return a unibyte string.
Kenichi Handa <handa@m17n.org>
parents:
59608
diff
changeset
|
6511 } |
8d84cdf36525
(encode_coding_string): Always return a unibyte string.
Kenichi Handa <handa@m17n.org>
parents:
59608
diff
changeset
|
6512 } |
8d84cdf36525
(encode_coding_string): Always return a unibyte string.
Kenichi Handa <handa@m17n.org>
parents:
59608
diff
changeset
|
6513 coding->produced = SBYTES (str); |
8d84cdf36525
(encode_coding_string): Always return a unibyte string.
Kenichi Handa <handa@m17n.org>
parents:
59608
diff
changeset
|
6514 coding->produced_char = SCHARS (str); |
8d84cdf36525
(encode_coding_string): Always return a unibyte string.
Kenichi Handa <handa@m17n.org>
parents:
59608
diff
changeset
|
6515 return (nocopy ? str : Fcopy_sequence (str)); |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
6516 } |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
6517 |
17052 | 6518 |
6519 #ifdef emacs | |
22874
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
6520 /*** 8. Emacs Lisp library functions ***/ |
17052 | 6521 |
6522 DEFUN ("coding-system-p", Fcoding_system_p, Scoding_system_p, 1, 1, 0, | |
40713
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
6523 doc: /* Return t if OBJECT is nil or a coding-system. |
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
6524 See the documentation of `make-coding-system' for information |
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
6525 about coding-system objects. */) |
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
6526 (obj) |
17052 | 6527 Lisp_Object obj; |
6528 { | |
20105
c017642863c2
(Qcoding_system_spec): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
19824
diff
changeset
|
6529 if (NILP (obj)) |
c017642863c2
(Qcoding_system_spec): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
19824
diff
changeset
|
6530 return Qt; |
c017642863c2
(Qcoding_system_spec): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
19824
diff
changeset
|
6531 if (!SYMBOLP (obj)) |
c017642863c2
(Qcoding_system_spec): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
19824
diff
changeset
|
6532 return Qnil; |
52806
4519d019f12e
(Fcoding_system_p): Return t for auto-loading coding system.
Kenichi Handa <handa@m17n.org>
parents:
52794
diff
changeset
|
6533 if (! NILP (Fget (obj, Qcoding_system_define_form))) |
4519d019f12e
(Fcoding_system_p): Return t for auto-loading coding system.
Kenichi Handa <handa@m17n.org>
parents:
52794
diff
changeset
|
6534 return Qt; |
20105
c017642863c2
(Qcoding_system_spec): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
19824
diff
changeset
|
6535 /* Get coding-spec vector for OBJ. */ |
c017642863c2
(Qcoding_system_spec): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
19824
diff
changeset
|
6536 obj = Fget (obj, Qcoding_system); |
c017642863c2
(Qcoding_system_spec): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
19824
diff
changeset
|
6537 return ((VECTORP (obj) && XVECTOR (obj)->size == 5) |
c017642863c2
(Qcoding_system_spec): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
19824
diff
changeset
|
6538 ? Qt : Qnil); |
17052 | 6539 } |
6540 | |
17717
4891aaecc5cc
(Fread_coding_system, Fread_non_nil_coding_system):
Richard M. Stallman <rms@gnu.org>
parents:
17485
diff
changeset
|
6541 DEFUN ("read-non-nil-coding-system", Fread_non_nil_coding_system, |
4891aaecc5cc
(Fread_coding_system, Fread_non_nil_coding_system):
Richard M. Stallman <rms@gnu.org>
parents:
17485
diff
changeset
|
6542 Sread_non_nil_coding_system, 1, 1, 0, |
40713
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
6543 doc: /* Read a coding system from the minibuffer, prompting with string PROMPT. */) |
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
6544 (prompt) |
17052 | 6545 Lisp_Object prompt; |
6546 { | |
17119
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
6547 Lisp_Object val; |
17717
4891aaecc5cc
(Fread_coding_system, Fread_non_nil_coding_system):
Richard M. Stallman <rms@gnu.org>
parents:
17485
diff
changeset
|
6548 do |
4891aaecc5cc
(Fread_coding_system, Fread_non_nil_coding_system):
Richard M. Stallman <rms@gnu.org>
parents:
17485
diff
changeset
|
6549 { |
20105
c017642863c2
(Qcoding_system_spec): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
19824
diff
changeset
|
6550 val = Fcompleting_read (prompt, Vcoding_system_alist, Qnil, |
c017642863c2
(Qcoding_system_spec): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
19824
diff
changeset
|
6551 Qt, Qnil, Qcoding_system_history, Qnil, Qnil); |
17717
4891aaecc5cc
(Fread_coding_system, Fread_non_nil_coding_system):
Richard M. Stallman <rms@gnu.org>
parents:
17485
diff
changeset
|
6552 } |
46370
40db0673e6f0
Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents:
46293
diff
changeset
|
6553 while (SCHARS (val) == 0); |
17119
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
6554 return (Fintern (val, Qnil)); |
17052 | 6555 } |
6556 | |
19758
49a1662b68dd
(Fread_coding_system): New optional arg DEFAULT_CODING_SYSTEM.
Richard M. Stallman <rms@gnu.org>
parents:
19750
diff
changeset
|
6557 DEFUN ("read-coding-system", Fread_coding_system, Sread_coding_system, 1, 2, 0, |
40713
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
6558 doc: /* Read a coding system from the minibuffer, prompting with string PROMPT. |
85332
bb808ca35bd9
(Qcompletion_ignore_case): New external Lisp_Object.
Glenn Morris <rgm@gnu.org>
parents:
85330
diff
changeset
|
6559 If the user enters null input, return second argument DEFAULT-CODING-SYSTEM. |
bb808ca35bd9
(Qcompletion_ignore_case): New external Lisp_Object.
Glenn Morris <rgm@gnu.org>
parents:
85330
diff
changeset
|
6560 Ignores case when completing coding systems (all Emacs coding systems |
bb808ca35bd9
(Qcompletion_ignore_case): New external Lisp_Object.
Glenn Morris <rgm@gnu.org>
parents:
85330
diff
changeset
|
6561 are lower-case). */) |
40713
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
6562 (prompt, default_coding_system) |
19758
49a1662b68dd
(Fread_coding_system): New optional arg DEFAULT_CODING_SYSTEM.
Richard M. Stallman <rms@gnu.org>
parents:
19750
diff
changeset
|
6563 Lisp_Object prompt, default_coding_system; |
17052 | 6564 { |
19747
bed06df9cbc5
(setup_coding_system, Ffind_operation_coding_system)
Richard M. Stallman <rms@gnu.org>
parents:
19743
diff
changeset
|
6565 Lisp_Object val; |
85332
bb808ca35bd9
(Qcompletion_ignore_case): New external Lisp_Object.
Glenn Morris <rgm@gnu.org>
parents:
85330
diff
changeset
|
6566 int count = SPECPDL_INDEX (); |
bb808ca35bd9
(Qcompletion_ignore_case): New external Lisp_Object.
Glenn Morris <rgm@gnu.org>
parents:
85330
diff
changeset
|
6567 |
19758
49a1662b68dd
(Fread_coding_system): New optional arg DEFAULT_CODING_SYSTEM.
Richard M. Stallman <rms@gnu.org>
parents:
19750
diff
changeset
|
6568 if (SYMBOLP (default_coding_system)) |
45396
cab845213388
* coding.c (Fread_coding_system, code_convert_region1)
Ken Raeburn <raeburn@raeburn.org>
parents:
45239
diff
changeset
|
6569 default_coding_system = SYMBOL_NAME (default_coding_system); |
85332
bb808ca35bd9
(Qcompletion_ignore_case): New external Lisp_Object.
Glenn Morris <rgm@gnu.org>
parents:
85330
diff
changeset
|
6570 specbind (Qcompletion_ignore_case, Qt); |
20105
c017642863c2
(Qcoding_system_spec): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
19824
diff
changeset
|
6571 val = Fcompleting_read (prompt, Vcoding_system_alist, Qnil, |
19758
49a1662b68dd
(Fread_coding_system): New optional arg DEFAULT_CODING_SYSTEM.
Richard M. Stallman <rms@gnu.org>
parents:
19750
diff
changeset
|
6572 Qt, Qnil, Qcoding_system_history, |
49a1662b68dd
(Fread_coding_system): New optional arg DEFAULT_CODING_SYSTEM.
Richard M. Stallman <rms@gnu.org>
parents:
19750
diff
changeset
|
6573 default_coding_system, Qnil); |
85332
bb808ca35bd9
(Qcompletion_ignore_case): New external Lisp_Object.
Glenn Morris <rgm@gnu.org>
parents:
85330
diff
changeset
|
6574 unbind_to (count, Qnil); |
46370
40db0673e6f0
Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents:
46293
diff
changeset
|
6575 return (SCHARS (val) == 0 ? Qnil : Fintern (val, Qnil)); |
17052 | 6576 } |
6577 | |
6578 DEFUN ("check-coding-system", Fcheck_coding_system, Scheck_coding_system, | |
6579 1, 1, 0, | |
40713
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
6580 doc: /* Check validity of CODING-SYSTEM. |
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
6581 If valid, return CODING-SYSTEM, else signal a `coding-system-error' error. |
53347
7138148f7ace
(Fcheck_coding_system): Doc fix.
Luc Teirlinck <teirllm@auburn.edu>
parents:
53239
diff
changeset
|
6582 It is valid if it is nil or a symbol with a non-nil `coding-system' property. |
53348
58de40c3a5c1
(Fcheck_coding_system): Further doc fix.
Luc Teirlinck <teirllm@auburn.edu>
parents:
53347
diff
changeset
|
6583 The value of this property should be a vector of length 5. */) |
40713
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
6584 (coding_system) |
17052 | 6585 Lisp_Object coding_system; |
6586 { | |
52794
f4d906e31662
(Qcoding_system_define_form): New variable.
Kenichi Handa <handa@m17n.org>
parents:
52401
diff
changeset
|
6587 Lisp_Object define_form; |
f4d906e31662
(Qcoding_system_define_form): New variable.
Kenichi Handa <handa@m17n.org>
parents:
52401
diff
changeset
|
6588 |
f4d906e31662
(Qcoding_system_define_form): New variable.
Kenichi Handa <handa@m17n.org>
parents:
52401
diff
changeset
|
6589 define_form = Fget (coding_system, Qcoding_system_define_form); |
f4d906e31662
(Qcoding_system_define_form): New variable.
Kenichi Handa <handa@m17n.org>
parents:
52401
diff
changeset
|
6590 if (! NILP (define_form)) |
f4d906e31662
(Qcoding_system_define_form): New variable.
Kenichi Handa <handa@m17n.org>
parents:
52401
diff
changeset
|
6591 { |
f4d906e31662
(Qcoding_system_define_form): New variable.
Kenichi Handa <handa@m17n.org>
parents:
52401
diff
changeset
|
6592 Fput (coding_system, Qcoding_system_define_form, Qnil); |
f4d906e31662
(Qcoding_system_define_form): New variable.
Kenichi Handa <handa@m17n.org>
parents:
52401
diff
changeset
|
6593 safe_eval (define_form); |
f4d906e31662
(Qcoding_system_define_form): New variable.
Kenichi Handa <handa@m17n.org>
parents:
52401
diff
changeset
|
6594 } |
17052 | 6595 if (!NILP (Fcoding_system_p (coding_system))) |
6596 return coding_system; | |
71972
eaa3c19b94d2
(Fcheck_coding_system): Use xsignal1. Remove loop.
Kim F. Storm <storm@cua.dk>
parents:
71084
diff
changeset
|
6597 xsignal1 (Qcoding_system_error, coding_system); |
17052 | 6598 } |
20680
dd46027e8412
(code_convert_region): Always count chars inserted
Richard M. Stallman <rms@gnu.org>
parents:
20668
diff
changeset
|
6599 |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
6600 Lisp_Object |
34531
37f85e931855
(ONE_MORE_BYTE_CHECK_MULTIBYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34197
diff
changeset
|
6601 detect_coding_system (src, src_bytes, highest, multibytep) |
46548
cb1914307488
(encode_eol, detect_coding, detect_eol):
Ken Raeburn <raeburn@raeburn.org>
parents:
46462
diff
changeset
|
6602 const unsigned char *src; |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
6603 int src_bytes, highest; |
34531
37f85e931855
(ONE_MORE_BYTE_CHECK_MULTIBYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34197
diff
changeset
|
6604 int multibytep; |
17052 | 6605 { |
6606 int coding_mask, eol_type; | |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
6607 Lisp_Object val, tmp; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
6608 int dummy; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
6609 |
34531
37f85e931855
(ONE_MORE_BYTE_CHECK_MULTIBYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34197
diff
changeset
|
6610 coding_mask = detect_coding_mask (src, src_bytes, NULL, &dummy, multibytep); |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
6611 eol_type = detect_eol_type (src, src_bytes, &dummy); |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
6612 if (eol_type == CODING_EOL_INCONSISTENT) |
23082
910740dcedb5
(detect_coding_system): If detect_eol_type returns
Kenichi Handa <handa@m17n.org>
parents:
23067
diff
changeset
|
6613 eol_type = CODING_EOL_UNDECIDED; |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
6614 |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
6615 if (!coding_mask) |
17052 | 6616 { |
19612
783efd6c7c1e
(Qno_conversion, Qundecided): New variables.
Kenichi Handa <handa@m17n.org>
parents:
19546
diff
changeset
|
6617 val = Qundecided; |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
6618 if (eol_type != CODING_EOL_UNDECIDED) |
17052 | 6619 { |
19747
bed06df9cbc5
(setup_coding_system, Ffind_operation_coding_system)
Richard M. Stallman <rms@gnu.org>
parents:
19743
diff
changeset
|
6620 Lisp_Object val2; |
bed06df9cbc5
(setup_coding_system, Ffind_operation_coding_system)
Richard M. Stallman <rms@gnu.org>
parents:
19743
diff
changeset
|
6621 val2 = Fget (Qundecided, Qeol_type); |
17052 | 6622 if (VECTORP (val2)) |
6623 val = XVECTOR (val2)->contents[eol_type]; | |
6624 } | |
22460
7ca919476042
(detect_coding_system): Always return a list of HIGHEST is zero.
Kenichi Handa <handa@m17n.org>
parents:
22341
diff
changeset
|
6625 return (highest ? val : Fcons (val, Qnil)); |
17052 | 6626 } |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
6627 |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
6628 /* At first, gather possible coding systems in VAL. */ |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
6629 val = Qnil; |
28022
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
6630 for (tmp = Vcoding_category_list; CONSP (tmp); tmp = XCDR (tmp)) |
17052 | 6631 { |
28022
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
6632 Lisp_Object category_val, category_index; |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
6633 |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
6634 category_index = Fget (XCAR (tmp), Qcoding_category_index); |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
6635 category_val = Fsymbol_value (XCAR (tmp)); |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
6636 if (!NILP (category_val) |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
6637 && NATNUMP (category_index) |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
6638 && (coding_mask & (1 << XFASTINT (category_index)))) |
17052 | 6639 { |
28022
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
6640 val = Fcons (category_val, val); |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
6641 if (highest) |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
6642 break; |
17052 | 6643 } |
6644 } | |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
6645 if (!highest) |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
6646 val = Fnreverse (val); |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
6647 |
22254
1deb7d79af00
(detect_coding_system): Treat CODING_EOL_INCONSISTENT
Richard M. Stallman <rms@gnu.org>
parents:
22226
diff
changeset
|
6648 /* Then, replace the elements with subsidiary coding systems. */ |
28022
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
6649 for (tmp = val; CONSP (tmp); tmp = XCDR (tmp)) |
17052 | 6650 { |
22254
1deb7d79af00
(detect_coding_system): Treat CODING_EOL_INCONSISTENT
Richard M. Stallman <rms@gnu.org>
parents:
22226
diff
changeset
|
6651 if (eol_type != CODING_EOL_UNDECIDED |
1deb7d79af00
(detect_coding_system): Treat CODING_EOL_INCONSISTENT
Richard M. Stallman <rms@gnu.org>
parents:
22226
diff
changeset
|
6652 && eol_type != CODING_EOL_INCONSISTENT) |
17052 | 6653 { |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
6654 Lisp_Object eol; |
25662
0a7261c1d487
Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25370
diff
changeset
|
6655 eol = Fget (XCAR (tmp), Qeol_type); |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
6656 if (VECTORP (eol)) |
39973
579177964efa
Avoid (most) uses of XCAR/XCDR as lvalues, for flexibility in experimenting
Ken Raeburn <raeburn@raeburn.org>
parents:
39581
diff
changeset
|
6657 XSETCAR (tmp, XVECTOR (eol)->contents[eol_type]); |
17052 | 6658 } |
6659 } | |
25662
0a7261c1d487
Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25370
diff
changeset
|
6660 return (highest ? XCAR (val) : val); |
42104
d69c2368e549
(DECODE_COMPOSITION_END): Fixed a typo in the last
Sam Steingold <sds@gnu.org>
parents:
42103
diff
changeset
|
6661 } |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
6662 |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
6663 DEFUN ("detect-coding-region", Fdetect_coding_region, Sdetect_coding_region, |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
6664 2, 3, 0, |
50121
71039837d881
(Fdetect_coding_region): Fix docstring.
Kenichi Handa <handa@m17n.org>
parents:
50120
diff
changeset
|
6665 doc: /* Detect how the byte sequence in the region is encoded. |
71039837d881
(Fdetect_coding_region): Fix docstring.
Kenichi Handa <handa@m17n.org>
parents:
50120
diff
changeset
|
6666 Return a list of possible coding systems used on decoding a byte |
71039837d881
(Fdetect_coding_region): Fix docstring.
Kenichi Handa <handa@m17n.org>
parents:
50120
diff
changeset
|
6667 sequence containing the bytes in the region between START and END when |
71039837d881
(Fdetect_coding_region): Fix docstring.
Kenichi Handa <handa@m17n.org>
parents:
50120
diff
changeset
|
6668 the coding system `undecided' is specified. The list is ordered by |
71039837d881
(Fdetect_coding_region): Fix docstring.
Kenichi Handa <handa@m17n.org>
parents:
50120
diff
changeset
|
6669 priority decided in the current language environment. |
40713
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
6670 |
72552
6493d4697ad2
(Fdetect_coding_region, Fdetect_coding_string): Fix
Kenichi Handa <handa@m17n.org>
parents:
72395
diff
changeset
|
6671 If only ASCII characters are found (except for such ISO-2022 control |
6493d4697ad2
(Fdetect_coding_region, Fdetect_coding_string): Fix
Kenichi Handa <handa@m17n.org>
parents:
72395
diff
changeset
|
6672 characters ISO-2022 as ESC), it returns a list of single element |
40713
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
6673 `undecided' or its subsidiary coding system according to a detected |
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
6674 end-of-line format. |
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
6675 |
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
6676 If optional argument HIGHEST is non-nil, return the coding system of |
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
6677 highest priority. */) |
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
6678 (start, end, highest) |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
6679 Lisp_Object start, end, highest; |
17052 | 6680 { |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
6681 int from, to; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
6682 int from_byte, to_byte; |
36647
0a75ccbe42b2
(detect_coding_sjis): Do more rigid check.
Kenichi Handa <handa@m17n.org>
parents:
36520
diff
changeset
|
6683 int include_anchor_byte = 0; |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
6684 |
40656
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents:
40461
diff
changeset
|
6685 CHECK_NUMBER_COERCE_MARKER (start); |
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents:
40461
diff
changeset
|
6686 CHECK_NUMBER_COERCE_MARKER (end); |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
6687 |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
6688 validate_region (&start, &end); |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
6689 from = XINT (start), to = XINT (end); |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
6690 from_byte = CHAR_TO_BYTE (from); |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
6691 to_byte = CHAR_TO_BYTE (to); |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
6692 |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
6693 if (from < GPT && to >= GPT) |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
6694 move_gap_both (to, to_byte); |
36650
a1859dfb6a1b
(Fdetect_coding_region): Fix comments added by the previous change.
Kenichi Handa <handa@m17n.org>
parents:
36649
diff
changeset
|
6695 /* If we an anchor byte `\0' follows the region, we include it in |
a1859dfb6a1b
(Fdetect_coding_region): Fix comments added by the previous change.
Kenichi Handa <handa@m17n.org>
parents:
36649
diff
changeset
|
6696 the detecting source. Then code detectors can handle the tailing |
a1859dfb6a1b
(Fdetect_coding_region): Fix comments added by the previous change.
Kenichi Handa <handa@m17n.org>
parents:
36649
diff
changeset
|
6697 byte sequence more accurately. |
a1859dfb6a1b
(Fdetect_coding_region): Fix comments added by the previous change.
Kenichi Handa <handa@m17n.org>
parents:
36649
diff
changeset
|
6698 |
47942
080b4586492b
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
47791
diff
changeset
|
6699 Fix me: This is not a perfect solution. It is better that we |
36650
a1859dfb6a1b
(Fdetect_coding_region): Fix comments added by the previous change.
Kenichi Handa <handa@m17n.org>
parents:
36649
diff
changeset
|
6700 add one more argument, say LAST_BLOCK, to all detect_coding_XXX. |
a1859dfb6a1b
(Fdetect_coding_region): Fix comments added by the previous change.
Kenichi Handa <handa@m17n.org>
parents:
36649
diff
changeset
|
6701 */ |
36647
0a75ccbe42b2
(detect_coding_sjis): Do more rigid check.
Kenichi Handa <handa@m17n.org>
parents:
36520
diff
changeset
|
6702 if (to == Z || (to == GPT && GAP_SIZE > 0)) |
0a75ccbe42b2
(detect_coding_sjis): Do more rigid check.
Kenichi Handa <handa@m17n.org>
parents:
36520
diff
changeset
|
6703 include_anchor_byte = 1; |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
6704 return detect_coding_system (BYTE_POS_ADDR (from_byte), |
36647
0a75ccbe42b2
(detect_coding_sjis): Do more rigid check.
Kenichi Handa <handa@m17n.org>
parents:
36520
diff
changeset
|
6705 to_byte - from_byte + include_anchor_byte, |
34531
37f85e931855
(ONE_MORE_BYTE_CHECK_MULTIBYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34197
diff
changeset
|
6706 !NILP (highest), |
37f85e931855
(ONE_MORE_BYTE_CHECK_MULTIBYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34197
diff
changeset
|
6707 !NILP (current_buffer |
37f85e931855
(ONE_MORE_BYTE_CHECK_MULTIBYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34197
diff
changeset
|
6708 ->enable_multibyte_characters)); |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
6709 } |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
6710 |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
6711 DEFUN ("detect-coding-string", Fdetect_coding_string, Sdetect_coding_string, |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
6712 1, 2, 0, |
50120
34d5ae26ea24
(Fdetect_coding_string): Fix docstring.
Kenichi Handa <handa@m17n.org>
parents:
50047
diff
changeset
|
6713 doc: /* Detect how the byte sequence in STRING is encoded. |
34d5ae26ea24
(Fdetect_coding_string): Fix docstring.
Kenichi Handa <handa@m17n.org>
parents:
50047
diff
changeset
|
6714 Return a list of possible coding systems used on decoding a byte |
34d5ae26ea24
(Fdetect_coding_string): Fix docstring.
Kenichi Handa <handa@m17n.org>
parents:
50047
diff
changeset
|
6715 sequence containing the bytes in STRING when the coding system |
34d5ae26ea24
(Fdetect_coding_string): Fix docstring.
Kenichi Handa <handa@m17n.org>
parents:
50047
diff
changeset
|
6716 `undecided' is specified. The list is ordered by priority decided in |
34d5ae26ea24
(Fdetect_coding_string): Fix docstring.
Kenichi Handa <handa@m17n.org>
parents:
50047
diff
changeset
|
6717 the current language environment. |
40713
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
6718 |
72552
6493d4697ad2
(Fdetect_coding_region, Fdetect_coding_string): Fix
Kenichi Handa <handa@m17n.org>
parents:
72395
diff
changeset
|
6719 If only ASCII characters are found (except for such ISO-2022 control |
6493d4697ad2
(Fdetect_coding_region, Fdetect_coding_string): Fix
Kenichi Handa <handa@m17n.org>
parents:
72395
diff
changeset
|
6720 characters ISO-2022 as ESC), it returns a list of single element |
40713
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
6721 `undecided' or its subsidiary coding system according to a detected |
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
6722 end-of-line format. |
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
6723 |
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
6724 If optional argument HIGHEST is non-nil, return the coding system of |
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
6725 highest priority. */) |
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
6726 (string, highest) |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
6727 Lisp_Object string, highest; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
6728 { |
40656
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents:
40461
diff
changeset
|
6729 CHECK_STRING (string); |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
6730 |
46370
40db0673e6f0
Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents:
46293
diff
changeset
|
6731 return detect_coding_system (SDATA (string), |
36647
0a75ccbe42b2
(detect_coding_sjis): Do more rigid check.
Kenichi Handa <handa@m17n.org>
parents:
36520
diff
changeset
|
6732 /* "+ 1" is to include the anchor byte |
0a75ccbe42b2
(detect_coding_sjis): Do more rigid check.
Kenichi Handa <handa@m17n.org>
parents:
36520
diff
changeset
|
6733 `\0'. With this, code detectors can |
36650
a1859dfb6a1b
(Fdetect_coding_region): Fix comments added by the previous change.
Kenichi Handa <handa@m17n.org>
parents:
36649
diff
changeset
|
6734 handle the tailing bytes more |
a1859dfb6a1b
(Fdetect_coding_region): Fix comments added by the previous change.
Kenichi Handa <handa@m17n.org>
parents:
36649
diff
changeset
|
6735 accurately. */ |
46370
40db0673e6f0
Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents:
46293
diff
changeset
|
6736 SBYTES (string) + 1, |
34531
37f85e931855
(ONE_MORE_BYTE_CHECK_MULTIBYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34197
diff
changeset
|
6737 !NILP (highest), |
37f85e931855
(ONE_MORE_BYTE_CHECK_MULTIBYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34197
diff
changeset
|
6738 STRING_MULTIBYTE (string)); |
17052 | 6739 } |
6740 | |
61722 | 6741 /* Subroutine for Ffind_coding_systems_region_internal. |
30487
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
6742 |
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
6743 Return a list of coding systems that safely encode the multibyte |
50765
43076e9d9aaa
(coding_system_accept_latin_extra_p): Delete this
Kenichi Handa <handa@m17n.org>
parents:
50487
diff
changeset
|
6744 text between P and PEND. SAFE_CODINGS, if non-nil, is an alist of |
30487
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
6745 possible coding systems. If it is nil, it means that we have not |
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
6746 yet found any coding systems. |
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
6747 |
55964
49894995b543
(find_safe_codings): Check NILP (safe_codings) only at
Kenichi Handa <handa@m17n.org>
parents:
55759
diff
changeset
|
6748 WORK_TABLE a char-table of which element is set to t once the |
49894995b543
(find_safe_codings): Check NILP (safe_codings) only at
Kenichi Handa <handa@m17n.org>
parents:
55759
diff
changeset
|
6749 element is looked up. |
30487
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
6750 |
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
6751 If a non-ASCII single byte char is found, set |
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
6752 *single_byte_char_found to 1. */ |
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
6753 |
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
6754 static Lisp_Object |
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
6755 find_safe_codings (p, pend, safe_codings, work_table, single_byte_char_found) |
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
6756 unsigned char *p, *pend; |
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
6757 Lisp_Object safe_codings, work_table; |
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
6758 int *single_byte_char_found; |
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
6759 { |
51231
b020f1a52615
(find_safe_codings): Remove unused var `i'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51186
diff
changeset
|
6760 int c, len; |
50185
b64f1af6e142
(Vchar_coding_system_table): Remove this variable.
Kenichi Handa <handa@m17n.org>
parents:
50121
diff
changeset
|
6761 Lisp_Object val, ch; |
b64f1af6e142
(Vchar_coding_system_table): Remove this variable.
Kenichi Handa <handa@m17n.org>
parents:
50121
diff
changeset
|
6762 Lisp_Object prev, tail; |
30487
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
6763 |
55964
49894995b543
(find_safe_codings): Check NILP (safe_codings) only at
Kenichi Handa <handa@m17n.org>
parents:
55759
diff
changeset
|
6764 if (NILP (safe_codings)) |
49894995b543
(find_safe_codings): Check NILP (safe_codings) only at
Kenichi Handa <handa@m17n.org>
parents:
55759
diff
changeset
|
6765 goto done_safe_codings; |
30487
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
6766 while (p < pend) |
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
6767 { |
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
6768 c = STRING_CHAR_AND_LENGTH (p, pend - p, len); |
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
6769 p += len; |
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
6770 if (ASCII_BYTE_P (c)) |
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
6771 /* We can ignore ASCII characters here. */ |
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
6772 continue; |
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
6773 if (SINGLE_BYTE_CHAR_P (c)) |
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
6774 *single_byte_char_found = 1; |
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
6775 /* Check the safe coding systems for C. */ |
50185
b64f1af6e142
(Vchar_coding_system_table): Remove this variable.
Kenichi Handa <handa@m17n.org>
parents:
50121
diff
changeset
|
6776 ch = make_number (c); |
b64f1af6e142
(Vchar_coding_system_table): Remove this variable.
Kenichi Handa <handa@m17n.org>
parents:
50121
diff
changeset
|
6777 val = Faref (work_table, ch); |
30487
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
6778 if (EQ (val, Qt)) |
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
6779 /* This element was already checked. Ignore it. */ |
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
6780 continue; |
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
6781 /* Remember that we checked this element. */ |
50185
b64f1af6e142
(Vchar_coding_system_table): Remove this variable.
Kenichi Handa <handa@m17n.org>
parents:
50121
diff
changeset
|
6782 Faset (work_table, ch, Qt); |
b64f1af6e142
(Vchar_coding_system_table): Remove this variable.
Kenichi Handa <handa@m17n.org>
parents:
50121
diff
changeset
|
6783 |
b64f1af6e142
(Vchar_coding_system_table): Remove this variable.
Kenichi Handa <handa@m17n.org>
parents:
50121
diff
changeset
|
6784 for (prev = tail = safe_codings; CONSP (tail); tail = XCDR (tail)) |
b64f1af6e142
(Vchar_coding_system_table): Remove this variable.
Kenichi Handa <handa@m17n.org>
parents:
50121
diff
changeset
|
6785 { |
50765
43076e9d9aaa
(coding_system_accept_latin_extra_p): Delete this
Kenichi Handa <handa@m17n.org>
parents:
50487
diff
changeset
|
6786 Lisp_Object elt, translation_table, hash_table, accept_latin_extra; |
43076e9d9aaa
(coding_system_accept_latin_extra_p): Delete this
Kenichi Handa <handa@m17n.org>
parents:
50487
diff
changeset
|
6787 int encodable; |
43076e9d9aaa
(coding_system_accept_latin_extra_p): Delete this
Kenichi Handa <handa@m17n.org>
parents:
50487
diff
changeset
|
6788 |
43076e9d9aaa
(coding_system_accept_latin_extra_p): Delete this
Kenichi Handa <handa@m17n.org>
parents:
50487
diff
changeset
|
6789 elt = XCAR (tail); |
43076e9d9aaa
(coding_system_accept_latin_extra_p): Delete this
Kenichi Handa <handa@m17n.org>
parents:
50487
diff
changeset
|
6790 if (CONSP (XCDR (elt))) |
43076e9d9aaa
(coding_system_accept_latin_extra_p): Delete this
Kenichi Handa <handa@m17n.org>
parents:
50487
diff
changeset
|
6791 { |
43076e9d9aaa
(coding_system_accept_latin_extra_p): Delete this
Kenichi Handa <handa@m17n.org>
parents:
50487
diff
changeset
|
6792 /* This entry has this format now: |
43076e9d9aaa
(coding_system_accept_latin_extra_p): Delete this
Kenichi Handa <handa@m17n.org>
parents:
50487
diff
changeset
|
6793 ( CODING SAFE-CHARS TRANSLATION-TABLE HASH-TABLE |
43076e9d9aaa
(coding_system_accept_latin_extra_p): Delete this
Kenichi Handa <handa@m17n.org>
parents:
50487
diff
changeset
|
6794 ACCEPT-LATIN-EXTRA ) */ |
43076e9d9aaa
(coding_system_accept_latin_extra_p): Delete this
Kenichi Handa <handa@m17n.org>
parents:
50487
diff
changeset
|
6795 val = XCDR (elt); |
43076e9d9aaa
(coding_system_accept_latin_extra_p): Delete this
Kenichi Handa <handa@m17n.org>
parents:
50487
diff
changeset
|
6796 encodable = ! NILP (Faref (XCAR (val), ch)); |
43076e9d9aaa
(coding_system_accept_latin_extra_p): Delete this
Kenichi Handa <handa@m17n.org>
parents:
50487
diff
changeset
|
6797 if (! encodable) |
43076e9d9aaa
(coding_system_accept_latin_extra_p): Delete this
Kenichi Handa <handa@m17n.org>
parents:
50487
diff
changeset
|
6798 { |
43076e9d9aaa
(coding_system_accept_latin_extra_p): Delete this
Kenichi Handa <handa@m17n.org>
parents:
50487
diff
changeset
|
6799 val = XCDR (val); |
43076e9d9aaa
(coding_system_accept_latin_extra_p): Delete this
Kenichi Handa <handa@m17n.org>
parents:
50487
diff
changeset
|
6800 translation_table = XCAR (val); |
43076e9d9aaa
(coding_system_accept_latin_extra_p): Delete this
Kenichi Handa <handa@m17n.org>
parents:
50487
diff
changeset
|
6801 hash_table = XCAR (XCDR (val)); |
43076e9d9aaa
(coding_system_accept_latin_extra_p): Delete this
Kenichi Handa <handa@m17n.org>
parents:
50487
diff
changeset
|
6802 accept_latin_extra = XCAR (XCDR (XCDR (val))); |
43076e9d9aaa
(coding_system_accept_latin_extra_p): Delete this
Kenichi Handa <handa@m17n.org>
parents:
50487
diff
changeset
|
6803 } |
43076e9d9aaa
(coding_system_accept_latin_extra_p): Delete this
Kenichi Handa <handa@m17n.org>
parents:
50487
diff
changeset
|
6804 } |
43076e9d9aaa
(coding_system_accept_latin_extra_p): Delete this
Kenichi Handa <handa@m17n.org>
parents:
50487
diff
changeset
|
6805 else |
43076e9d9aaa
(coding_system_accept_latin_extra_p): Delete this
Kenichi Handa <handa@m17n.org>
parents:
50487
diff
changeset
|
6806 { |
43076e9d9aaa
(coding_system_accept_latin_extra_p): Delete this
Kenichi Handa <handa@m17n.org>
parents:
50487
diff
changeset
|
6807 /* This entry has this format now: ( CODING . SAFE-CHARS) */ |
43076e9d9aaa
(coding_system_accept_latin_extra_p): Delete this
Kenichi Handa <handa@m17n.org>
parents:
50487
diff
changeset
|
6808 encodable = ! NILP (Faref (XCDR (elt), ch)); |
43076e9d9aaa
(coding_system_accept_latin_extra_p): Delete this
Kenichi Handa <handa@m17n.org>
parents:
50487
diff
changeset
|
6809 if (! encodable) |
43076e9d9aaa
(coding_system_accept_latin_extra_p): Delete this
Kenichi Handa <handa@m17n.org>
parents:
50487
diff
changeset
|
6810 { |
43076e9d9aaa
(coding_system_accept_latin_extra_p): Delete this
Kenichi Handa <handa@m17n.org>
parents:
50487
diff
changeset
|
6811 /* Transform the format to: |
43076e9d9aaa
(coding_system_accept_latin_extra_p): Delete this
Kenichi Handa <handa@m17n.org>
parents:
50487
diff
changeset
|
6812 ( CODING SAFE-CHARS TRANSLATION-TABLE HASH-TABLE |
43076e9d9aaa
(coding_system_accept_latin_extra_p): Delete this
Kenichi Handa <handa@m17n.org>
parents:
50487
diff
changeset
|
6813 ACCEPT-LATIN-EXTRA ) */ |
43076e9d9aaa
(coding_system_accept_latin_extra_p): Delete this
Kenichi Handa <handa@m17n.org>
parents:
50487
diff
changeset
|
6814 val = Fget (XCAR (elt), Qcoding_system); |
43076e9d9aaa
(coding_system_accept_latin_extra_p): Delete this
Kenichi Handa <handa@m17n.org>
parents:
50487
diff
changeset
|
6815 translation_table |
43076e9d9aaa
(coding_system_accept_latin_extra_p): Delete this
Kenichi Handa <handa@m17n.org>
parents:
50487
diff
changeset
|
6816 = Fplist_get (AREF (val, 3), |
43076e9d9aaa
(coding_system_accept_latin_extra_p): Delete this
Kenichi Handa <handa@m17n.org>
parents:
50487
diff
changeset
|
6817 Qtranslation_table_for_encode); |
43076e9d9aaa
(coding_system_accept_latin_extra_p): Delete this
Kenichi Handa <handa@m17n.org>
parents:
50487
diff
changeset
|
6818 if (SYMBOLP (translation_table)) |
43076e9d9aaa
(coding_system_accept_latin_extra_p): Delete this
Kenichi Handa <handa@m17n.org>
parents:
50487
diff
changeset
|
6819 translation_table = Fget (translation_table, |
43076e9d9aaa
(coding_system_accept_latin_extra_p): Delete this
Kenichi Handa <handa@m17n.org>
parents:
50487
diff
changeset
|
6820 Qtranslation_table); |
43076e9d9aaa
(coding_system_accept_latin_extra_p): Delete this
Kenichi Handa <handa@m17n.org>
parents:
50487
diff
changeset
|
6821 hash_table |
43076e9d9aaa
(coding_system_accept_latin_extra_p): Delete this
Kenichi Handa <handa@m17n.org>
parents:
50487
diff
changeset
|
6822 = (CHAR_TABLE_P (translation_table) |
43076e9d9aaa
(coding_system_accept_latin_extra_p): Delete this
Kenichi Handa <handa@m17n.org>
parents:
50487
diff
changeset
|
6823 ? XCHAR_TABLE (translation_table)->extras[1] |
43076e9d9aaa
(coding_system_accept_latin_extra_p): Delete this
Kenichi Handa <handa@m17n.org>
parents:
50487
diff
changeset
|
6824 : Qnil); |
43076e9d9aaa
(coding_system_accept_latin_extra_p): Delete this
Kenichi Handa <handa@m17n.org>
parents:
50487
diff
changeset
|
6825 accept_latin_extra |
43076e9d9aaa
(coding_system_accept_latin_extra_p): Delete this
Kenichi Handa <handa@m17n.org>
parents:
50487
diff
changeset
|
6826 = ((EQ (AREF (val, 0), make_number (2)) |
43076e9d9aaa
(coding_system_accept_latin_extra_p): Delete this
Kenichi Handa <handa@m17n.org>
parents:
50487
diff
changeset
|
6827 && VECTORP (AREF (val, 4))) |
51186
e610d367508d
(find_safe_codings): Fix last change.
Andreas Schwab <schwab@suse.de>
parents:
51140
diff
changeset
|
6828 ? AREF (AREF (val, 4), 16) |
50765
43076e9d9aaa
(coding_system_accept_latin_extra_p): Delete this
Kenichi Handa <handa@m17n.org>
parents:
50487
diff
changeset
|
6829 : Qnil); |
43076e9d9aaa
(coding_system_accept_latin_extra_p): Delete this
Kenichi Handa <handa@m17n.org>
parents:
50487
diff
changeset
|
6830 XSETCAR (tail, list5 (XCAR (elt), XCDR (elt), |
43076e9d9aaa
(coding_system_accept_latin_extra_p): Delete this
Kenichi Handa <handa@m17n.org>
parents:
50487
diff
changeset
|
6831 translation_table, hash_table, |
43076e9d9aaa
(coding_system_accept_latin_extra_p): Delete this
Kenichi Handa <handa@m17n.org>
parents:
50487
diff
changeset
|
6832 accept_latin_extra)); |
43076e9d9aaa
(coding_system_accept_latin_extra_p): Delete this
Kenichi Handa <handa@m17n.org>
parents:
50487
diff
changeset
|
6833 } |
43076e9d9aaa
(coding_system_accept_latin_extra_p): Delete this
Kenichi Handa <handa@m17n.org>
parents:
50487
diff
changeset
|
6834 } |
56191 | 6835 |
50765
43076e9d9aaa
(coding_system_accept_latin_extra_p): Delete this
Kenichi Handa <handa@m17n.org>
parents:
50487
diff
changeset
|
6836 if (! encodable |
43076e9d9aaa
(coding_system_accept_latin_extra_p): Delete this
Kenichi Handa <handa@m17n.org>
parents:
50487
diff
changeset
|
6837 && ((CHAR_TABLE_P (translation_table) |
43076e9d9aaa
(coding_system_accept_latin_extra_p): Delete this
Kenichi Handa <handa@m17n.org>
parents:
50487
diff
changeset
|
6838 && ! NILP (Faref (translation_table, ch))) |
43076e9d9aaa
(coding_system_accept_latin_extra_p): Delete this
Kenichi Handa <handa@m17n.org>
parents:
50487
diff
changeset
|
6839 || (HASH_TABLE_P (hash_table) |
43076e9d9aaa
(coding_system_accept_latin_extra_p): Delete this
Kenichi Handa <handa@m17n.org>
parents:
50487
diff
changeset
|
6840 && ! NILP (Fgethash (ch, hash_table, Qnil))) |
43076e9d9aaa
(coding_system_accept_latin_extra_p): Delete this
Kenichi Handa <handa@m17n.org>
parents:
50487
diff
changeset
|
6841 || (SINGLE_BYTE_CHAR_P (c) |
43076e9d9aaa
(coding_system_accept_latin_extra_p): Delete this
Kenichi Handa <handa@m17n.org>
parents:
50487
diff
changeset
|
6842 && ! NILP (accept_latin_extra) |
43076e9d9aaa
(coding_system_accept_latin_extra_p): Delete this
Kenichi Handa <handa@m17n.org>
parents:
50487
diff
changeset
|
6843 && VECTORP (Vlatin_extra_code_table) |
43076e9d9aaa
(coding_system_accept_latin_extra_p): Delete this
Kenichi Handa <handa@m17n.org>
parents:
50487
diff
changeset
|
6844 && ! NILP (AREF (Vlatin_extra_code_table, c))))) |
43076e9d9aaa
(coding_system_accept_latin_extra_p): Delete this
Kenichi Handa <handa@m17n.org>
parents:
50487
diff
changeset
|
6845 encodable = 1; |
43076e9d9aaa
(coding_system_accept_latin_extra_p): Delete this
Kenichi Handa <handa@m17n.org>
parents:
50487
diff
changeset
|
6846 if (encodable) |
43076e9d9aaa
(coding_system_accept_latin_extra_p): Delete this
Kenichi Handa <handa@m17n.org>
parents:
50487
diff
changeset
|
6847 prev = tail; |
43076e9d9aaa
(coding_system_accept_latin_extra_p): Delete this
Kenichi Handa <handa@m17n.org>
parents:
50487
diff
changeset
|
6848 else |
50185
b64f1af6e142
(Vchar_coding_system_table): Remove this variable.
Kenichi Handa <handa@m17n.org>
parents:
50121
diff
changeset
|
6849 { |
50896
0aba658cfdd2
(Vlast_coding_system_used): Doc fix.
Dave Love <fx@gnu.org>
parents:
50765
diff
changeset
|
6850 /* Exclude this coding system from SAFE_CODINGS. */ |
50185
b64f1af6e142
(Vchar_coding_system_table): Remove this variable.
Kenichi Handa <handa@m17n.org>
parents:
50121
diff
changeset
|
6851 if (EQ (tail, safe_codings)) |
55964
49894995b543
(find_safe_codings): Check NILP (safe_codings) only at
Kenichi Handa <handa@m17n.org>
parents:
55759
diff
changeset
|
6852 { |
49894995b543
(find_safe_codings): Check NILP (safe_codings) only at
Kenichi Handa <handa@m17n.org>
parents:
55759
diff
changeset
|
6853 safe_codings = XCDR (safe_codings); |
49894995b543
(find_safe_codings): Check NILP (safe_codings) only at
Kenichi Handa <handa@m17n.org>
parents:
55759
diff
changeset
|
6854 if (NILP (safe_codings)) |
49894995b543
(find_safe_codings): Check NILP (safe_codings) only at
Kenichi Handa <handa@m17n.org>
parents:
55759
diff
changeset
|
6855 goto done_safe_codings; |
49894995b543
(find_safe_codings): Check NILP (safe_codings) only at
Kenichi Handa <handa@m17n.org>
parents:
55759
diff
changeset
|
6856 } |
50185
b64f1af6e142
(Vchar_coding_system_table): Remove this variable.
Kenichi Handa <handa@m17n.org>
parents:
50121
diff
changeset
|
6857 else |
b64f1af6e142
(Vchar_coding_system_table): Remove this variable.
Kenichi Handa <handa@m17n.org>
parents:
50121
diff
changeset
|
6858 XSETCDR (prev, XCDR (tail)); |
b64f1af6e142
(Vchar_coding_system_table): Remove this variable.
Kenichi Handa <handa@m17n.org>
parents:
50121
diff
changeset
|
6859 } |
b64f1af6e142
(Vchar_coding_system_table): Remove this variable.
Kenichi Handa <handa@m17n.org>
parents:
50121
diff
changeset
|
6860 } |
30487
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
6861 } |
55964
49894995b543
(find_safe_codings): Check NILP (safe_codings) only at
Kenichi Handa <handa@m17n.org>
parents:
55759
diff
changeset
|
6862 |
49894995b543
(find_safe_codings): Check NILP (safe_codings) only at
Kenichi Handa <handa@m17n.org>
parents:
55759
diff
changeset
|
6863 done_safe_codings: |
49894995b543
(find_safe_codings): Check NILP (safe_codings) only at
Kenichi Handa <handa@m17n.org>
parents:
55759
diff
changeset
|
6864 /* If the above loop was terminated before P reaches PEND, it means |
49894995b543
(find_safe_codings): Check NILP (safe_codings) only at
Kenichi Handa <handa@m17n.org>
parents:
55759
diff
changeset
|
6865 SAFE_CODINGS was set to nil. If we have not yet found an |
49894995b543
(find_safe_codings): Check NILP (safe_codings) only at
Kenichi Handa <handa@m17n.org>
parents:
55759
diff
changeset
|
6866 non-ASCII single-byte char, check it now. */ |
49894995b543
(find_safe_codings): Check NILP (safe_codings) only at
Kenichi Handa <handa@m17n.org>
parents:
55759
diff
changeset
|
6867 if (! *single_byte_char_found) |
49894995b543
(find_safe_codings): Check NILP (safe_codings) only at
Kenichi Handa <handa@m17n.org>
parents:
55759
diff
changeset
|
6868 while (p < pend) |
49894995b543
(find_safe_codings): Check NILP (safe_codings) only at
Kenichi Handa <handa@m17n.org>
parents:
55759
diff
changeset
|
6869 { |
49894995b543
(find_safe_codings): Check NILP (safe_codings) only at
Kenichi Handa <handa@m17n.org>
parents:
55759
diff
changeset
|
6870 c = STRING_CHAR_AND_LENGTH (p, pend - p, len); |
49894995b543
(find_safe_codings): Check NILP (safe_codings) only at
Kenichi Handa <handa@m17n.org>
parents:
55759
diff
changeset
|
6871 p += len; |
49894995b543
(find_safe_codings): Check NILP (safe_codings) only at
Kenichi Handa <handa@m17n.org>
parents:
55759
diff
changeset
|
6872 if (! ASCII_BYTE_P (c) |
49894995b543
(find_safe_codings): Check NILP (safe_codings) only at
Kenichi Handa <handa@m17n.org>
parents:
55759
diff
changeset
|
6873 && SINGLE_BYTE_CHAR_P (c)) |
49894995b543
(find_safe_codings): Check NILP (safe_codings) only at
Kenichi Handa <handa@m17n.org>
parents:
55759
diff
changeset
|
6874 { |
49894995b543
(find_safe_codings): Check NILP (safe_codings) only at
Kenichi Handa <handa@m17n.org>
parents:
55759
diff
changeset
|
6875 *single_byte_char_found = 1; |
49894995b543
(find_safe_codings): Check NILP (safe_codings) only at
Kenichi Handa <handa@m17n.org>
parents:
55759
diff
changeset
|
6876 break; |
49894995b543
(find_safe_codings): Check NILP (safe_codings) only at
Kenichi Handa <handa@m17n.org>
parents:
55759
diff
changeset
|
6877 } |
49894995b543
(find_safe_codings): Check NILP (safe_codings) only at
Kenichi Handa <handa@m17n.org>
parents:
55759
diff
changeset
|
6878 } |
30487
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
6879 return safe_codings; |
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
6880 } |
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
6881 |
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
6882 DEFUN ("find-coding-systems-region-internal", |
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
6883 Ffind_coding_systems_region_internal, |
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
6884 Sfind_coding_systems_region_internal, 2, 2, 0, |
40713
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
6885 doc: /* Internal use only. */) |
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
6886 (start, end) |
30487
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
6887 Lisp_Object start, end; |
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
6888 { |
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
6889 Lisp_Object work_table, safe_codings; |
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
6890 int non_ascii_p = 0; |
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
6891 int single_byte_char_found = 0; |
46462
c6bb99a483e0
(Ffind_coding_systems_region_interval): Use const for
Ken Raeburn <raeburn@raeburn.org>
parents:
46370
diff
changeset
|
6892 const unsigned char *p1, *p1end, *p2, *p2end, *p; |
30487
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
6893 |
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
6894 if (STRINGP (start)) |
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
6895 { |
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
6896 if (!STRING_MULTIBYTE (start)) |
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
6897 return Qt; |
46370
40db0673e6f0
Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents:
46293
diff
changeset
|
6898 p1 = SDATA (start), p1end = p1 + SBYTES (start); |
30487
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
6899 p2 = p2end = p1end; |
46370
40db0673e6f0
Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents:
46293
diff
changeset
|
6900 if (SCHARS (start) != SBYTES (start)) |
30487
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
6901 non_ascii_p = 1; |
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
6902 } |
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
6903 else |
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
6904 { |
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
6905 int from, to, stop; |
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
6906 |
40656
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents:
40461
diff
changeset
|
6907 CHECK_NUMBER_COERCE_MARKER (start); |
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents:
40461
diff
changeset
|
6908 CHECK_NUMBER_COERCE_MARKER (end); |
30487
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
6909 if (XINT (start) < BEG || XINT (end) > Z || XINT (start) > XINT (end)) |
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
6910 args_out_of_range (start, end); |
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
6911 if (NILP (current_buffer->enable_multibyte_characters)) |
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
6912 return Qt; |
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
6913 from = CHAR_TO_BYTE (XINT (start)); |
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
6914 to = CHAR_TO_BYTE (XINT (end)); |
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
6915 stop = from < GPT_BYTE && GPT_BYTE < to ? GPT_BYTE : to; |
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
6916 p1 = BYTE_POS_ADDR (from), p1end = p1 + (stop - from); |
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
6917 if (stop == to) |
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
6918 p2 = p2end = p1end; |
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
6919 else |
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
6920 p2 = BYTE_POS_ADDR (stop), p2end = p2 + (to - stop); |
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
6921 if (XINT (end) - XINT (start) != to - from) |
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
6922 non_ascii_p = 1; |
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
6923 } |
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
6924 |
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
6925 if (!non_ascii_p) |
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
6926 { |
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
6927 /* We are sure that the text contains no multibyte character. |
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
6928 Check if it contains eight-bit-graphic. */ |
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
6929 p = p1; |
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
6930 for (p = p1; p < p1end && ASCII_BYTE_P (*p); p++); |
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
6931 if (p == p1end) |
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
6932 { |
42104
d69c2368e549
(DECODE_COMPOSITION_END): Fixed a typo in the last
Sam Steingold <sds@gnu.org>
parents:
42103
diff
changeset
|
6933 for (p = p2; p < p2end && ASCII_BYTE_P (*p); p++); |
30487
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
6934 if (p == p2end) |
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
6935 return Qt; |
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
6936 } |
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
6937 } |
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
6938 |
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
6939 /* The text contains non-ASCII characters. */ |
50185
b64f1af6e142
(Vchar_coding_system_table): Remove this variable.
Kenichi Handa <handa@m17n.org>
parents:
50121
diff
changeset
|
6940 |
b64f1af6e142
(Vchar_coding_system_table): Remove this variable.
Kenichi Handa <handa@m17n.org>
parents:
50121
diff
changeset
|
6941 work_table = Fmake_char_table (Qchar_coding_system, Qnil); |
b64f1af6e142
(Vchar_coding_system_table): Remove this variable.
Kenichi Handa <handa@m17n.org>
parents:
50121
diff
changeset
|
6942 safe_codings = Fcopy_sequence (XCDR (Vcoding_system_safe_chars)); |
b64f1af6e142
(Vchar_coding_system_table): Remove this variable.
Kenichi Handa <handa@m17n.org>
parents:
50121
diff
changeset
|
6943 |
b64f1af6e142
(Vchar_coding_system_table): Remove this variable.
Kenichi Handa <handa@m17n.org>
parents:
50121
diff
changeset
|
6944 safe_codings = find_safe_codings (p1, p1end, safe_codings, work_table, |
30487
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
6945 &single_byte_char_found); |
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
6946 if (p2 < p2end) |
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
6947 safe_codings = find_safe_codings (p2, p2end, safe_codings, work_table, |
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
6948 &single_byte_char_found); |
49539
1ad5bfbb831a
(syms_of_coding): Add `...' for symbols in the docstring of
Kenichi Handa <handa@m17n.org>
parents:
48874
diff
changeset
|
6949 if (EQ (safe_codings, XCDR (Vcoding_system_safe_chars))) |
1ad5bfbb831a
(syms_of_coding): Add `...' for symbols in the docstring of
Kenichi Handa <handa@m17n.org>
parents:
48874
diff
changeset
|
6950 safe_codings = Qt; |
1ad5bfbb831a
(syms_of_coding): Add `...' for symbols in the docstring of
Kenichi Handa <handa@m17n.org>
parents:
48874
diff
changeset
|
6951 else |
1ad5bfbb831a
(syms_of_coding): Add `...' for symbols in the docstring of
Kenichi Handa <handa@m17n.org>
parents:
48874
diff
changeset
|
6952 { |
1ad5bfbb831a
(syms_of_coding): Add `...' for symbols in the docstring of
Kenichi Handa <handa@m17n.org>
parents:
48874
diff
changeset
|
6953 /* Turn safe_codings to a list of coding systems... */ |
1ad5bfbb831a
(syms_of_coding): Add `...' for symbols in the docstring of
Kenichi Handa <handa@m17n.org>
parents:
48874
diff
changeset
|
6954 Lisp_Object val; |
1ad5bfbb831a
(syms_of_coding): Add `...' for symbols in the docstring of
Kenichi Handa <handa@m17n.org>
parents:
48874
diff
changeset
|
6955 |
1ad5bfbb831a
(syms_of_coding): Add `...' for symbols in the docstring of
Kenichi Handa <handa@m17n.org>
parents:
48874
diff
changeset
|
6956 if (single_byte_char_found) |
1ad5bfbb831a
(syms_of_coding): Add `...' for symbols in the docstring of
Kenichi Handa <handa@m17n.org>
parents:
48874
diff
changeset
|
6957 /* ... and append these for eight-bit chars. */ |
1ad5bfbb831a
(syms_of_coding): Add `...' for symbols in the docstring of
Kenichi Handa <handa@m17n.org>
parents:
48874
diff
changeset
|
6958 val = Fcons (Qraw_text, |
1ad5bfbb831a
(syms_of_coding): Add `...' for symbols in the docstring of
Kenichi Handa <handa@m17n.org>
parents:
48874
diff
changeset
|
6959 Fcons (Qemacs_mule, Fcons (Qno_conversion, Qnil))); |
1ad5bfbb831a
(syms_of_coding): Add `...' for symbols in the docstring of
Kenichi Handa <handa@m17n.org>
parents:
48874
diff
changeset
|
6960 else |
1ad5bfbb831a
(syms_of_coding): Add `...' for symbols in the docstring of
Kenichi Handa <handa@m17n.org>
parents:
48874
diff
changeset
|
6961 /* ... and append generic coding systems. */ |
1ad5bfbb831a
(syms_of_coding): Add `...' for symbols in the docstring of
Kenichi Handa <handa@m17n.org>
parents:
48874
diff
changeset
|
6962 val = Fcopy_sequence (XCAR (Vcoding_system_safe_chars)); |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49539
diff
changeset
|
6963 |
49539
1ad5bfbb831a
(syms_of_coding): Add `...' for symbols in the docstring of
Kenichi Handa <handa@m17n.org>
parents:
48874
diff
changeset
|
6964 for (; CONSP (safe_codings); safe_codings = XCDR (safe_codings)) |
1ad5bfbb831a
(syms_of_coding): Add `...' for symbols in the docstring of
Kenichi Handa <handa@m17n.org>
parents:
48874
diff
changeset
|
6965 val = Fcons (XCAR (XCAR (safe_codings)), val); |
1ad5bfbb831a
(syms_of_coding): Add `...' for symbols in the docstring of
Kenichi Handa <handa@m17n.org>
parents:
48874
diff
changeset
|
6966 safe_codings = val; |
1ad5bfbb831a
(syms_of_coding): Add `...' for symbols in the docstring of
Kenichi Handa <handa@m17n.org>
parents:
48874
diff
changeset
|
6967 } |
1ad5bfbb831a
(syms_of_coding): Add `...' for symbols in the docstring of
Kenichi Handa <handa@m17n.org>
parents:
48874
diff
changeset
|
6968 |
1ad5bfbb831a
(syms_of_coding): Add `...' for symbols in the docstring of
Kenichi Handa <handa@m17n.org>
parents:
48874
diff
changeset
|
6969 return safe_codings; |
1ad5bfbb831a
(syms_of_coding): Add `...' for symbols in the docstring of
Kenichi Handa <handa@m17n.org>
parents:
48874
diff
changeset
|
6970 } |
1ad5bfbb831a
(syms_of_coding): Add `...' for symbols in the docstring of
Kenichi Handa <handa@m17n.org>
parents:
48874
diff
changeset
|
6971 |
1ad5bfbb831a
(syms_of_coding): Add `...' for symbols in the docstring of
Kenichi Handa <handa@m17n.org>
parents:
48874
diff
changeset
|
6972 |
46859
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
6973 /* Search from position POS for such characters that are unencodable |
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
6974 accoding to SAFE_CHARS, and return a list of their positions. P |
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
6975 points where in the memory the character at POS exists. Limit the |
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
6976 search at PEND or when Nth unencodable characters are found. |
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
6977 |
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
6978 If SAFE_CHARS is a char table, an element for an unencodable |
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
6979 character is nil. |
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
6980 |
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
6981 If SAFE_CHARS is nil, all non-ASCII characters are unencodable. |
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
6982 |
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
6983 Otherwise, SAFE_CHARS is t, and only eight-bit-contrl and |
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
6984 eight-bit-graphic characters are unencodable. */ |
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
6985 |
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
6986 static Lisp_Object |
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
6987 unencodable_char_position (safe_chars, pos, p, pend, n) |
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
6988 Lisp_Object safe_chars; |
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
6989 int pos; |
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
6990 unsigned char *p, *pend; |
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
6991 int n; |
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
6992 { |
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
6993 Lisp_Object pos_list; |
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
6994 |
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
6995 pos_list = Qnil; |
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
6996 while (p < pend) |
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
6997 { |
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
6998 int len; |
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
6999 int c = STRING_CHAR_AND_LENGTH (p, MAX_MULTIBYTE_LENGTH, len); |
47942
080b4586492b
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
47791
diff
changeset
|
7000 |
46859
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
7001 if (c >= 128 |
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
7002 && (CHAR_TABLE_P (safe_chars) |
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
7003 ? NILP (CHAR_TABLE_REF (safe_chars, c)) |
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
7004 : (NILP (safe_chars) || c < 256))) |
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
7005 { |
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
7006 pos_list = Fcons (make_number (pos), pos_list); |
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
7007 if (--n <= 0) |
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
7008 break; |
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
7009 } |
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
7010 pos++; |
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
7011 p += len; |
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
7012 } |
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
7013 return Fnreverse (pos_list); |
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
7014 } |
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
7015 |
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
7016 |
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
7017 DEFUN ("unencodable-char-position", Funencodable_char_position, |
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
7018 Sunencodable_char_position, 3, 5, 0, |
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
7019 doc: /* |
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
7020 Return position of first un-encodable character in a region. |
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
7021 START and END specfiy the region and CODING-SYSTEM specifies the |
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
7022 encoding to check. Return nil if CODING-SYSTEM does encode the region. |
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
7023 |
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
7024 If optional 4th argument COUNT is non-nil, it specifies at most how |
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
7025 many un-encodable characters to search. In this case, the value is a |
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
7026 list of positions. |
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
7027 |
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
7028 If optional 5th argument STRING is non-nil, it is a string to search |
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
7029 for un-encodable characters. In that case, START and END are indexes |
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
7030 to the string. */) |
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
7031 (start, end, coding_system, count, string) |
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
7032 Lisp_Object start, end, coding_system, count, string; |
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
7033 { |
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
7034 int n; |
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
7035 Lisp_Object safe_chars; |
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
7036 struct coding_system coding; |
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
7037 Lisp_Object positions; |
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
7038 int from, to; |
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
7039 unsigned char *p, *pend; |
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
7040 |
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
7041 if (NILP (string)) |
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
7042 { |
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
7043 validate_region (&start, &end); |
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
7044 from = XINT (start); |
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
7045 to = XINT (end); |
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
7046 if (NILP (current_buffer->enable_multibyte_characters)) |
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
7047 return Qnil; |
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
7048 p = CHAR_POS_ADDR (from); |
48829
f6c59ca557c7
(Funencodable_char_position): Set pend correctly.
Kenichi Handa <handa@m17n.org>
parents:
48230
diff
changeset
|
7049 if (to == GPT) |
f6c59ca557c7
(Funencodable_char_position): Set pend correctly.
Kenichi Handa <handa@m17n.org>
parents:
48230
diff
changeset
|
7050 pend = GPT_ADDR; |
f6c59ca557c7
(Funencodable_char_position): Set pend correctly.
Kenichi Handa <handa@m17n.org>
parents:
48230
diff
changeset
|
7051 else |
f6c59ca557c7
(Funencodable_char_position): Set pend correctly.
Kenichi Handa <handa@m17n.org>
parents:
48230
diff
changeset
|
7052 pend = CHAR_POS_ADDR (to); |
46859
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
7053 } |
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
7054 else |
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
7055 { |
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
7056 CHECK_STRING (string); |
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
7057 CHECK_NATNUM (start); |
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
7058 CHECK_NATNUM (end); |
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
7059 from = XINT (start); |
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
7060 to = XINT (end); |
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
7061 if (from > to |
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
7062 || to > SCHARS (string)) |
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
7063 args_out_of_range_3 (string, start, end); |
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
7064 if (! STRING_MULTIBYTE (string)) |
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
7065 return Qnil; |
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
7066 p = SDATA (string) + string_char_to_byte (string, from); |
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
7067 pend = SDATA (string) + string_char_to_byte (string, to); |
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
7068 } |
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
7069 |
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
7070 setup_coding_system (Fcheck_coding_system (coding_system), &coding); |
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
7071 |
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
7072 if (NILP (count)) |
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
7073 n = 1; |
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
7074 else |
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
7075 { |
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
7076 CHECK_NATNUM (count); |
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
7077 n = XINT (count); |
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
7078 } |
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
7079 |
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
7080 if (coding.type == coding_type_no_conversion |
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
7081 || coding.type == coding_type_raw_text) |
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
7082 return Qnil; |
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
7083 |
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
7084 if (coding.type == coding_type_undecided) |
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
7085 safe_chars = Qnil; |
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
7086 else |
49539
1ad5bfbb831a
(syms_of_coding): Add `...' for symbols in the docstring of
Kenichi Handa <handa@m17n.org>
parents:
48874
diff
changeset
|
7087 safe_chars = coding_safe_chars (coding_system); |
46859
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
7088 |
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
7089 if (STRINGP (string) |
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
7090 || from >= GPT || to <= GPT) |
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
7091 positions = unencodable_char_position (safe_chars, from, p, pend, n); |
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
7092 else |
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
7093 { |
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
7094 Lisp_Object args[2]; |
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
7095 |
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
7096 args[0] = unencodable_char_position (safe_chars, from, p, GPT_ADDR, n); |
46875
f88c982e1f79
(Funencodable_char_position): Lisp_Object/int mixup.
Gerd Moellmann <gerd@gnu.org>
parents:
46859
diff
changeset
|
7097 n -= XINT (Flength (args[0])); |
46859
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
7098 if (n <= 0) |
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
7099 positions = args[0]; |
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
7100 else |
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
7101 { |
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
7102 args[1] = unencodable_char_position (safe_chars, GPT, GAP_END_ADDR, |
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
7103 pend, n); |
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
7104 positions = Fappend (2, args); |
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
7105 } |
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
7106 } |
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
7107 |
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
7108 return (NILP (count) ? Fcar (positions) : positions); |
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
7109 } |
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
7110 |
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
7111 |
20803
0fa2183c587d
(ENCODE_ISO_CHARACTER): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
20794
diff
changeset
|
7112 Lisp_Object |
0fa2183c587d
(ENCODE_ISO_CHARACTER): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
20794
diff
changeset
|
7113 code_convert_region1 (start, end, coding_system, encodep) |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
7114 Lisp_Object start, end, coding_system; |
20803
0fa2183c587d
(ENCODE_ISO_CHARACTER): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
20794
diff
changeset
|
7115 int encodep; |
20680
dd46027e8412
(code_convert_region): Always count chars inserted
Richard M. Stallman <rms@gnu.org>
parents:
20668
diff
changeset
|
7116 { |
dd46027e8412
(code_convert_region): Always count chars inserted
Richard M. Stallman <rms@gnu.org>
parents:
20668
diff
changeset
|
7117 struct coding_system coding; |
34988
8cd5e6ad71a2
(detect_coding_iso2022, setup_coding_system): Remove
Eli Zaretskii <eliz@gnu.org>
parents:
34892
diff
changeset
|
7118 int from, to; |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
7119 |
40656
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents:
40461
diff
changeset
|
7120 CHECK_NUMBER_COERCE_MARKER (start); |
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents:
40461
diff
changeset
|
7121 CHECK_NUMBER_COERCE_MARKER (end); |
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents:
40461
diff
changeset
|
7122 CHECK_SYMBOL (coding_system); |
20680
dd46027e8412
(code_convert_region): Always count chars inserted
Richard M. Stallman <rms@gnu.org>
parents:
20668
diff
changeset
|
7123 |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
7124 validate_region (&start, &end); |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
7125 from = XFASTINT (start); |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
7126 to = XFASTINT (end); |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
7127 |
70520
b6740a317343
(setup_coding_system): For invalid coding-system, set
Kenichi Handa <handa@m17n.org>
parents:
69995
diff
changeset
|
7128 if (NILP (coding_system)) |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
7129 return make_number (to - from); |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
7130 |
20680
dd46027e8412
(code_convert_region): Always count chars inserted
Richard M. Stallman <rms@gnu.org>
parents:
20668
diff
changeset
|
7131 if (setup_coding_system (Fcheck_coding_system (coding_system), &coding) < 0) |
46370
40db0673e6f0
Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents:
46293
diff
changeset
|
7132 error ("Invalid coding system: %s", SDATA (SYMBOL_NAME (coding_system))); |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
7133 |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
7134 coding.mode |= CODING_MODE_LAST_BLOCK; |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
7135 coding.src_multibyte = coding.dst_multibyte |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
7136 = !NILP (current_buffer->enable_multibyte_characters); |
20931
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
7137 code_convert_region (from, CHAR_TO_BYTE (from), to, CHAR_TO_BYTE (to), |
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
7138 &coding, encodep, 1); |
22020
e144ad749084
(code_convert_region1): Set Vlast_coding_system_used.
Richard M. Stallman <rms@gnu.org>
parents:
22009
diff
changeset
|
7139 Vlast_coding_system_used = coding.symbol; |
20931
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
7140 return make_number (coding.produced_char); |
20803
0fa2183c587d
(ENCODE_ISO_CHARACTER): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
20794
diff
changeset
|
7141 } |
0fa2183c587d
(ENCODE_ISO_CHARACTER): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
20794
diff
changeset
|
7142 |
0fa2183c587d
(ENCODE_ISO_CHARACTER): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
20794
diff
changeset
|
7143 DEFUN ("decode-coding-region", Fdecode_coding_region, Sdecode_coding_region, |
0fa2183c587d
(ENCODE_ISO_CHARACTER): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
20794
diff
changeset
|
7144 3, 3, "r\nzCoding system: ", |
40713
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
7145 doc: /* Decode the current region from the specified coding system. |
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
7146 When called from a program, takes three arguments: |
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
7147 START, END, and CODING-SYSTEM. START and END are buffer positions. |
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
7148 This function sets `last-coding-system-used' to the precise coding system |
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
7149 used (which may be different from CODING-SYSTEM if CODING-SYSTEM is |
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
7150 not fully specified.) |
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
7151 It returns the length of the decoded text. */) |
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
7152 (start, end, coding_system) |
20803
0fa2183c587d
(ENCODE_ISO_CHARACTER): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
20794
diff
changeset
|
7153 Lisp_Object start, end, coding_system; |
0fa2183c587d
(ENCODE_ISO_CHARACTER): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
20794
diff
changeset
|
7154 { |
0fa2183c587d
(ENCODE_ISO_CHARACTER): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
20794
diff
changeset
|
7155 return code_convert_region1 (start, end, coding_system, 0); |
20680
dd46027e8412
(code_convert_region): Always count chars inserted
Richard M. Stallman <rms@gnu.org>
parents:
20668
diff
changeset
|
7156 } |
dd46027e8412
(code_convert_region): Always count chars inserted
Richard M. Stallman <rms@gnu.org>
parents:
20668
diff
changeset
|
7157 |
dd46027e8412
(code_convert_region): Always count chars inserted
Richard M. Stallman <rms@gnu.org>
parents:
20668
diff
changeset
|
7158 DEFUN ("encode-coding-region", Fencode_coding_region, Sencode_coding_region, |
dd46027e8412
(code_convert_region): Always count chars inserted
Richard M. Stallman <rms@gnu.org>
parents:
20668
diff
changeset
|
7159 3, 3, "r\nzCoding system: ", |
40713
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
7160 doc: /* Encode the current region into the specified coding system. |
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
7161 When called from a program, takes three arguments: |
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
7162 START, END, and CODING-SYSTEM. START and END are buffer positions. |
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
7163 This function sets `last-coding-system-used' to the precise coding system |
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
7164 used (which may be different from CODING-SYSTEM if CODING-SYSTEM is |
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
7165 not fully specified.) |
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
7166 It returns the length of the encoded text. */) |
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
7167 (start, end, coding_system) |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
7168 Lisp_Object start, end, coding_system; |
20680
dd46027e8412
(code_convert_region): Always count chars inserted
Richard M. Stallman <rms@gnu.org>
parents:
20668
diff
changeset
|
7169 { |
20803
0fa2183c587d
(ENCODE_ISO_CHARACTER): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
20794
diff
changeset
|
7170 return code_convert_region1 (start, end, coding_system, 1); |
17052 | 7171 } |
7172 | |
20803
0fa2183c587d
(ENCODE_ISO_CHARACTER): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
20794
diff
changeset
|
7173 Lisp_Object |
0fa2183c587d
(ENCODE_ISO_CHARACTER): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
20794
diff
changeset
|
7174 code_convert_string1 (string, coding_system, nocopy, encodep) |
17119
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
7175 Lisp_Object string, coding_system, nocopy; |
20803
0fa2183c587d
(ENCODE_ISO_CHARACTER): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
20794
diff
changeset
|
7176 int encodep; |
17052 | 7177 { |
7178 struct coding_system coding; | |
7179 | |
40656
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents:
40461
diff
changeset
|
7180 CHECK_STRING (string); |
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents:
40461
diff
changeset
|
7181 CHECK_SYMBOL (coding_system); |
17052 | 7182 |
70520
b6740a317343
(setup_coding_system): For invalid coding-system, set
Kenichi Handa <handa@m17n.org>
parents:
69995
diff
changeset
|
7183 if (NILP (coding_system)) |
17119
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
7184 return (NILP (nocopy) ? Fcopy_sequence (string) : string); |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
7185 |
17052 | 7186 if (setup_coding_system (Fcheck_coding_system (coding_system), &coding) < 0) |
46370
40db0673e6f0
Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents:
46293
diff
changeset
|
7187 error ("Invalid coding system: %s", SDATA (SYMBOL_NAME (coding_system))); |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
7188 |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
7189 coding.mode |= CODING_MODE_LAST_BLOCK; |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
7190 string = (encodep |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
7191 ? encode_coding_string (string, &coding, !NILP (nocopy)) |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
7192 : decode_coding_string (string, &coding, !NILP (nocopy))); |
22020
e144ad749084
(code_convert_region1): Set Vlast_coding_system_used.
Richard M. Stallman <rms@gnu.org>
parents:
22009
diff
changeset
|
7193 Vlast_coding_system_used = coding.symbol; |
26847 | 7194 |
7195 return string; | |
20803
0fa2183c587d
(ENCODE_ISO_CHARACTER): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
20794
diff
changeset
|
7196 } |
0fa2183c587d
(ENCODE_ISO_CHARACTER): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
20794
diff
changeset
|
7197 |
0fa2183c587d
(ENCODE_ISO_CHARACTER): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
20794
diff
changeset
|
7198 DEFUN ("decode-coding-string", Fdecode_coding_string, Sdecode_coding_string, |
0fa2183c587d
(ENCODE_ISO_CHARACTER): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
20794
diff
changeset
|
7199 2, 3, 0, |
40713
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
7200 doc: /* Decode STRING which is encoded in CODING-SYSTEM, and return the result. |
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
7201 Optional arg NOCOPY non-nil means it is OK to return STRING itself |
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
7202 if the decoding operation is trivial. |
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
7203 This function sets `last-coding-system-used' to the precise coding system |
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
7204 used (which may be different from CODING-SYSTEM if CODING-SYSTEM is |
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
7205 not fully specified.) */) |
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
7206 (string, coding_system, nocopy) |
20803
0fa2183c587d
(ENCODE_ISO_CHARACTER): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
20794
diff
changeset
|
7207 Lisp_Object string, coding_system, nocopy; |
0fa2183c587d
(ENCODE_ISO_CHARACTER): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
20794
diff
changeset
|
7208 { |
22020
e144ad749084
(code_convert_region1): Set Vlast_coding_system_used.
Richard M. Stallman <rms@gnu.org>
parents:
22009
diff
changeset
|
7209 return code_convert_string1 (string, coding_system, nocopy, 0); |
17052 | 7210 } |
7211 | |
7212 DEFUN ("encode-coding-string", Fencode_coding_string, Sencode_coding_string, | |
17119
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
7213 2, 3, 0, |
40713
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
7214 doc: /* Encode STRING to CODING-SYSTEM, and return the result. |
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
7215 Optional arg NOCOPY non-nil means it is OK to return STRING itself |
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
7216 if the encoding operation is trivial. |
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
7217 This function sets `last-coding-system-used' to the precise coding system |
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
7218 used (which may be different from CODING-SYSTEM if CODING-SYSTEM is |
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
7219 not fully specified.) */) |
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
7220 (string, coding_system, nocopy) |
17119
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
7221 Lisp_Object string, coding_system, nocopy; |
17052 | 7222 { |
22020
e144ad749084
(code_convert_region1): Set Vlast_coding_system_used.
Richard M. Stallman <rms@gnu.org>
parents:
22009
diff
changeset
|
7223 return code_convert_string1 (string, coding_system, nocopy, 1); |
17052 | 7224 } |
20803
0fa2183c587d
(ENCODE_ISO_CHARACTER): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
20794
diff
changeset
|
7225 |
22341
572ba933a4bf
(code_convert_string_norecord): New function.
Karl Heuer <kwzh@gnu.org>
parents:
22329
diff
changeset
|
7226 /* Encode or decode STRING according to CODING_SYSTEM. |
26847 | 7227 Do not set Vlast_coding_system_used. |
7228 | |
7229 This function is called only from macros DECODE_FILE and | |
7230 ENCODE_FILE, thus we ignore character composition. */ | |
22341
572ba933a4bf
(code_convert_string_norecord): New function.
Karl Heuer <kwzh@gnu.org>
parents:
22329
diff
changeset
|
7231 |
572ba933a4bf
(code_convert_string_norecord): New function.
Karl Heuer <kwzh@gnu.org>
parents:
22329
diff
changeset
|
7232 Lisp_Object |
572ba933a4bf
(code_convert_string_norecord): New function.
Karl Heuer <kwzh@gnu.org>
parents:
22329
diff
changeset
|
7233 code_convert_string_norecord (string, coding_system, encodep) |
572ba933a4bf
(code_convert_string_norecord): New function.
Karl Heuer <kwzh@gnu.org>
parents:
22329
diff
changeset
|
7234 Lisp_Object string, coding_system; |
572ba933a4bf
(code_convert_string_norecord): New function.
Karl Heuer <kwzh@gnu.org>
parents:
22329
diff
changeset
|
7235 int encodep; |
572ba933a4bf
(code_convert_string_norecord): New function.
Karl Heuer <kwzh@gnu.org>
parents:
22329
diff
changeset
|
7236 { |
572ba933a4bf
(code_convert_string_norecord): New function.
Karl Heuer <kwzh@gnu.org>
parents:
22329
diff
changeset
|
7237 struct coding_system coding; |
572ba933a4bf
(code_convert_string_norecord): New function.
Karl Heuer <kwzh@gnu.org>
parents:
22329
diff
changeset
|
7238 |
40656
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents:
40461
diff
changeset
|
7239 CHECK_STRING (string); |
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents:
40461
diff
changeset
|
7240 CHECK_SYMBOL (coding_system); |
22341
572ba933a4bf
(code_convert_string_norecord): New function.
Karl Heuer <kwzh@gnu.org>
parents:
22329
diff
changeset
|
7241 |
70520
b6740a317343
(setup_coding_system): For invalid coding-system, set
Kenichi Handa <handa@m17n.org>
parents:
69995
diff
changeset
|
7242 if (NILP (coding_system)) |
22341
572ba933a4bf
(code_convert_string_norecord): New function.
Karl Heuer <kwzh@gnu.org>
parents:
22329
diff
changeset
|
7243 return string; |
572ba933a4bf
(code_convert_string_norecord): New function.
Karl Heuer <kwzh@gnu.org>
parents:
22329
diff
changeset
|
7244 |
572ba933a4bf
(code_convert_string_norecord): New function.
Karl Heuer <kwzh@gnu.org>
parents:
22329
diff
changeset
|
7245 if (setup_coding_system (Fcheck_coding_system (coding_system), &coding) < 0) |
46370
40db0673e6f0
Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents:
46293
diff
changeset
|
7246 error ("Invalid coding system: %s", SDATA (SYMBOL_NAME (coding_system))); |
22341
572ba933a4bf
(code_convert_string_norecord): New function.
Karl Heuer <kwzh@gnu.org>
parents:
22329
diff
changeset
|
7247 |
26847 | 7248 coding.composing = COMPOSITION_DISABLED; |
22341
572ba933a4bf
(code_convert_string_norecord): New function.
Karl Heuer <kwzh@gnu.org>
parents:
22329
diff
changeset
|
7249 coding.mode |= CODING_MODE_LAST_BLOCK; |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
7250 return (encodep |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
7251 ? encode_coding_string (string, &coding, 1) |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
7252 : decode_coding_string (string, &coding, 1)); |
22341
572ba933a4bf
(code_convert_string_norecord): New function.
Karl Heuer <kwzh@gnu.org>
parents:
22329
diff
changeset
|
7253 } |
20680
dd46027e8412
(code_convert_region): Always count chars inserted
Richard M. Stallman <rms@gnu.org>
parents:
20668
diff
changeset
|
7254 |
17052 | 7255 DEFUN ("decode-sjis-char", Fdecode_sjis_char, Sdecode_sjis_char, 1, 1, 0, |
40713
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
7256 doc: /* Decode a Japanese character which has CODE in shift_jis encoding. |
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
7257 Return the corresponding character. */) |
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
7258 (code) |
17052 | 7259 Lisp_Object code; |
7260 { | |
7261 unsigned char c1, c2, s1, s2; | |
7262 Lisp_Object val; | |
7263 | |
40656
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents:
40461
diff
changeset
|
7264 CHECK_NUMBER (code); |
17052 | 7265 s1 = (XFASTINT (code)) >> 8, s2 = (XFASTINT (code)) & 0xFF; |
24065
7e291dea6141
(Fdecode_sjis_char): Decode Japanese Katakana character
Kenichi Handa <handa@m17n.org>
parents:
24056
diff
changeset
|
7266 if (s1 == 0) |
7e291dea6141
(Fdecode_sjis_char): Decode Japanese Katakana character
Kenichi Handa <handa@m17n.org>
parents:
24056
diff
changeset
|
7267 { |
24324
2eec590faf26
(Fdecode_sjis_char, Fencode_sjis_char): Hanlde
Kenichi Handa <handa@m17n.org>
parents:
24316
diff
changeset
|
7268 if (s2 < 0x80) |
2eec590faf26
(Fdecode_sjis_char, Fencode_sjis_char): Hanlde
Kenichi Handa <handa@m17n.org>
parents:
24316
diff
changeset
|
7269 XSETFASTINT (val, s2); |
2eec590faf26
(Fdecode_sjis_char, Fencode_sjis_char): Hanlde
Kenichi Handa <handa@m17n.org>
parents:
24316
diff
changeset
|
7270 else if (s2 >= 0xA0 || s2 <= 0xDF) |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
7271 XSETFASTINT (val, MAKE_CHAR (charset_katakana_jisx0201, s2, 0)); |
24324
2eec590faf26
(Fdecode_sjis_char, Fencode_sjis_char): Hanlde
Kenichi Handa <handa@m17n.org>
parents:
24316
diff
changeset
|
7272 else |
24344
8b7ef7fb9e2e
(Fdecode_sjis_char): In case of error, use %x for
Kenichi Handa <handa@m17n.org>
parents:
24324
diff
changeset
|
7273 error ("Invalid Shift JIS code: %x", XFASTINT (code)); |
24065
7e291dea6141
(Fdecode_sjis_char): Decode Japanese Katakana character
Kenichi Handa <handa@m17n.org>
parents:
24056
diff
changeset
|
7274 } |
7e291dea6141
(Fdecode_sjis_char): Decode Japanese Katakana character
Kenichi Handa <handa@m17n.org>
parents:
24056
diff
changeset
|
7275 else |
7e291dea6141
(Fdecode_sjis_char): Decode Japanese Katakana character
Kenichi Handa <handa@m17n.org>
parents:
24056
diff
changeset
|
7276 { |
41899
5c01da9c8604
(setup_coding_system, shrink_encoding_region)
Pavel Janík <Pavel@Janik.cz>
parents:
41678
diff
changeset
|
7277 if ((s1 < 0x80 || (s1 > 0x9F && s1 < 0xE0) || s1 > 0xEF) |
24065
7e291dea6141
(Fdecode_sjis_char): Decode Japanese Katakana character
Kenichi Handa <handa@m17n.org>
parents:
24056
diff
changeset
|
7278 || (s2 < 0x40 || s2 == 0x7F || s2 > 0xFC)) |
24344
8b7ef7fb9e2e
(Fdecode_sjis_char): In case of error, use %x for
Kenichi Handa <handa@m17n.org>
parents:
24324
diff
changeset
|
7279 error ("Invalid Shift JIS code: %x", XFASTINT (code)); |
24065
7e291dea6141
(Fdecode_sjis_char): Decode Japanese Katakana character
Kenichi Handa <handa@m17n.org>
parents:
24056
diff
changeset
|
7280 DECODE_SJIS (s1, s2, c1, c2); |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
7281 XSETFASTINT (val, MAKE_CHAR (charset_jisx0208, c1, c2)); |
24065
7e291dea6141
(Fdecode_sjis_char): Decode Japanese Katakana character
Kenichi Handa <handa@m17n.org>
parents:
24056
diff
changeset
|
7282 } |
17052 | 7283 return val; |
7284 } | |
7285 | |
7286 DEFUN ("encode-sjis-char", Fencode_sjis_char, Sencode_sjis_char, 1, 1, 0, | |
73949
0d1207b43a5b
(Fencode_sjis_char, Fencode_big5_char): Improve argument/docstring consistency.
Juanma Barranquero <lekktu@gmail.com>
parents:
72552
diff
changeset
|
7287 doc: /* Encode a Japanese character CH to shift_jis encoding. |
40713
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
7288 Return the corresponding code in SJIS. */) |
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
7289 (ch) |
17052 | 7290 Lisp_Object ch; |
7291 { | |
17320
9d15bec5f47e
(detect_coding_iso2022, detect_coding_mask): Ignore
Kenichi Handa <handa@m17n.org>
parents:
17304
diff
changeset
|
7292 int charset, c1, c2, s1, s2; |
17052 | 7293 Lisp_Object val; |
7294 | |
40656
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents:
40461
diff
changeset
|
7295 CHECK_NUMBER (ch); |
17052 | 7296 SPLIT_CHAR (XFASTINT (ch), charset, c1, c2); |
24324
2eec590faf26
(Fdecode_sjis_char, Fencode_sjis_char): Hanlde
Kenichi Handa <handa@m17n.org>
parents:
24316
diff
changeset
|
7297 if (charset == CHARSET_ASCII) |
2eec590faf26
(Fdecode_sjis_char, Fencode_sjis_char): Hanlde
Kenichi Handa <handa@m17n.org>
parents:
24316
diff
changeset
|
7298 { |
2eec590faf26
(Fdecode_sjis_char, Fencode_sjis_char): Hanlde
Kenichi Handa <handa@m17n.org>
parents:
24316
diff
changeset
|
7299 val = ch; |
2eec590faf26
(Fdecode_sjis_char, Fencode_sjis_char): Hanlde
Kenichi Handa <handa@m17n.org>
parents:
24316
diff
changeset
|
7300 } |
2eec590faf26
(Fdecode_sjis_char, Fencode_sjis_char): Hanlde
Kenichi Handa <handa@m17n.org>
parents:
24316
diff
changeset
|
7301 else if (charset == charset_jisx0208 |
2eec590faf26
(Fdecode_sjis_char, Fencode_sjis_char): Hanlde
Kenichi Handa <handa@m17n.org>
parents:
24316
diff
changeset
|
7302 && c1 > 0x20 && c1 < 0x7F && c2 > 0x20 && c2 < 0x7F) |
17052 | 7303 { |
7304 ENCODE_SJIS (c1, c2, s1, s2); | |
17320
9d15bec5f47e
(detect_coding_iso2022, detect_coding_mask): Ignore
Kenichi Handa <handa@m17n.org>
parents:
17304
diff
changeset
|
7305 XSETFASTINT (val, (s1 << 8) | s2); |
17052 | 7306 } |
24065
7e291dea6141
(Fdecode_sjis_char): Decode Japanese Katakana character
Kenichi Handa <handa@m17n.org>
parents:
24056
diff
changeset
|
7307 else if (charset == charset_katakana_jisx0201 |
7e291dea6141
(Fdecode_sjis_char): Decode Japanese Katakana character
Kenichi Handa <handa@m17n.org>
parents:
24056
diff
changeset
|
7308 && c1 > 0x20 && c2 < 0xE0) |
7e291dea6141
(Fdecode_sjis_char): Decode Japanese Katakana character
Kenichi Handa <handa@m17n.org>
parents:
24056
diff
changeset
|
7309 { |
7e291dea6141
(Fdecode_sjis_char): Decode Japanese Katakana character
Kenichi Handa <handa@m17n.org>
parents:
24056
diff
changeset
|
7310 XSETFASTINT (val, c1 | 0x80); |
7e291dea6141
(Fdecode_sjis_char): Decode Japanese Katakana character
Kenichi Handa <handa@m17n.org>
parents:
24056
diff
changeset
|
7311 } |
17052 | 7312 else |
24065
7e291dea6141
(Fdecode_sjis_char): Decode Japanese Katakana character
Kenichi Handa <handa@m17n.org>
parents:
24056
diff
changeset
|
7313 error ("Can't encode to shift_jis: %d", XFASTINT (ch)); |
17052 | 7314 return val; |
7315 } | |
7316 | |
7317 DEFUN ("decode-big5-char", Fdecode_big5_char, Sdecode_big5_char, 1, 1, 0, | |
40713
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
7318 doc: /* Decode a Big5 character which has CODE in BIG5 coding system. |
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
7319 Return the corresponding character. */) |
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
7320 (code) |
17052 | 7321 Lisp_Object code; |
7322 { | |
7323 int charset; | |
7324 unsigned char b1, b2, c1, c2; | |
7325 Lisp_Object val; | |
7326 | |
40656
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents:
40461
diff
changeset
|
7327 CHECK_NUMBER (code); |
17052 | 7328 b1 = (XFASTINT (code)) >> 8, b2 = (XFASTINT (code)) & 0xFF; |
24324
2eec590faf26
(Fdecode_sjis_char, Fencode_sjis_char): Hanlde
Kenichi Handa <handa@m17n.org>
parents:
24316
diff
changeset
|
7329 if (b1 == 0) |
2eec590faf26
(Fdecode_sjis_char, Fencode_sjis_char): Hanlde
Kenichi Handa <handa@m17n.org>
parents:
24316
diff
changeset
|
7330 { |
2eec590faf26
(Fdecode_sjis_char, Fencode_sjis_char): Hanlde
Kenichi Handa <handa@m17n.org>
parents:
24316
diff
changeset
|
7331 if (b2 >= 0x80) |
24344
8b7ef7fb9e2e
(Fdecode_sjis_char): In case of error, use %x for
Kenichi Handa <handa@m17n.org>
parents:
24324
diff
changeset
|
7332 error ("Invalid BIG5 code: %x", XFASTINT (code)); |
24324
2eec590faf26
(Fdecode_sjis_char, Fencode_sjis_char): Hanlde
Kenichi Handa <handa@m17n.org>
parents:
24316
diff
changeset
|
7333 val = code; |
2eec590faf26
(Fdecode_sjis_char, Fencode_sjis_char): Hanlde
Kenichi Handa <handa@m17n.org>
parents:
24316
diff
changeset
|
7334 } |
2eec590faf26
(Fdecode_sjis_char, Fencode_sjis_char): Hanlde
Kenichi Handa <handa@m17n.org>
parents:
24316
diff
changeset
|
7335 else |
2eec590faf26
(Fdecode_sjis_char, Fencode_sjis_char): Hanlde
Kenichi Handa <handa@m17n.org>
parents:
24316
diff
changeset
|
7336 { |
2eec590faf26
(Fdecode_sjis_char, Fencode_sjis_char): Hanlde
Kenichi Handa <handa@m17n.org>
parents:
24316
diff
changeset
|
7337 if ((b1 < 0xA1 || b1 > 0xFE) |
2eec590faf26
(Fdecode_sjis_char, Fencode_sjis_char): Hanlde
Kenichi Handa <handa@m17n.org>
parents:
24316
diff
changeset
|
7338 || (b2 < 0x40 || (b2 > 0x7E && b2 < 0xA1) || b2 > 0xFE)) |
24344
8b7ef7fb9e2e
(Fdecode_sjis_char): In case of error, use %x for
Kenichi Handa <handa@m17n.org>
parents:
24324
diff
changeset
|
7339 error ("Invalid BIG5 code: %x", XFASTINT (code)); |
24324
2eec590faf26
(Fdecode_sjis_char, Fencode_sjis_char): Hanlde
Kenichi Handa <handa@m17n.org>
parents:
24316
diff
changeset
|
7340 DECODE_BIG5 (b1, b2, charset, c1, c2); |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
7341 XSETFASTINT (val, MAKE_CHAR (charset, c1, c2)); |
24324
2eec590faf26
(Fdecode_sjis_char, Fencode_sjis_char): Hanlde
Kenichi Handa <handa@m17n.org>
parents:
24316
diff
changeset
|
7342 } |
17052 | 7343 return val; |
7344 } | |
7345 | |
7346 DEFUN ("encode-big5-char", Fencode_big5_char, Sencode_big5_char, 1, 1, 0, | |
73949
0d1207b43a5b
(Fencode_sjis_char, Fencode_big5_char): Improve argument/docstring consistency.
Juanma Barranquero <lekktu@gmail.com>
parents:
72552
diff
changeset
|
7347 doc: /* Encode the Big5 character CH to BIG5 coding system. |
40713
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
7348 Return the corresponding character code in Big5. */) |
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
7349 (ch) |
17052 | 7350 Lisp_Object ch; |
7351 { | |
17320
9d15bec5f47e
(detect_coding_iso2022, detect_coding_mask): Ignore
Kenichi Handa <handa@m17n.org>
parents:
17304
diff
changeset
|
7352 int charset, c1, c2, b1, b2; |
17052 | 7353 Lisp_Object val; |
7354 | |
40656
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents:
40461
diff
changeset
|
7355 CHECK_NUMBER (ch); |
17052 | 7356 SPLIT_CHAR (XFASTINT (ch), charset, c1, c2); |
24324
2eec590faf26
(Fdecode_sjis_char, Fencode_sjis_char): Hanlde
Kenichi Handa <handa@m17n.org>
parents:
24316
diff
changeset
|
7357 if (charset == CHARSET_ASCII) |
2eec590faf26
(Fdecode_sjis_char, Fencode_sjis_char): Hanlde
Kenichi Handa <handa@m17n.org>
parents:
24316
diff
changeset
|
7358 { |
2eec590faf26
(Fdecode_sjis_char, Fencode_sjis_char): Hanlde
Kenichi Handa <handa@m17n.org>
parents:
24316
diff
changeset
|
7359 val = ch; |
2eec590faf26
(Fdecode_sjis_char, Fencode_sjis_char): Hanlde
Kenichi Handa <handa@m17n.org>
parents:
24316
diff
changeset
|
7360 } |
2eec590faf26
(Fdecode_sjis_char, Fencode_sjis_char): Hanlde
Kenichi Handa <handa@m17n.org>
parents:
24316
diff
changeset
|
7361 else if ((charset == charset_big5_1 |
2eec590faf26
(Fdecode_sjis_char, Fencode_sjis_char): Hanlde
Kenichi Handa <handa@m17n.org>
parents:
24316
diff
changeset
|
7362 && (XFASTINT (ch) >= 0x250a1 && XFASTINT (ch) <= 0x271ec)) |
2eec590faf26
(Fdecode_sjis_char, Fencode_sjis_char): Hanlde
Kenichi Handa <handa@m17n.org>
parents:
24316
diff
changeset
|
7363 || (charset == charset_big5_2 |
2eec590faf26
(Fdecode_sjis_char, Fencode_sjis_char): Hanlde
Kenichi Handa <handa@m17n.org>
parents:
24316
diff
changeset
|
7364 && XFASTINT (ch) >= 0x290a1 && XFASTINT (ch) <= 0x2bdb2)) |
17052 | 7365 { |
7366 ENCODE_BIG5 (charset, c1, c2, b1, b2); | |
17320
9d15bec5f47e
(detect_coding_iso2022, detect_coding_mask): Ignore
Kenichi Handa <handa@m17n.org>
parents:
17304
diff
changeset
|
7367 XSETFASTINT (val, (b1 << 8) | b2); |
17052 | 7368 } |
7369 else | |
24324
2eec590faf26
(Fdecode_sjis_char, Fencode_sjis_char): Hanlde
Kenichi Handa <handa@m17n.org>
parents:
24316
diff
changeset
|
7370 error ("Can't encode to Big5: %d", XFASTINT (ch)); |
17052 | 7371 return val; |
7372 } | |
20680
dd46027e8412
(code_convert_region): Always count chars inserted
Richard M. Stallman <rms@gnu.org>
parents:
20668
diff
changeset
|
7373 |
48182
9474e269efd1
Reformat some DEFUNs so that etags works.
Dave Love <fx@gnu.org>
parents:
48125
diff
changeset
|
7374 DEFUN ("set-terminal-coding-system-internal", Fset_terminal_coding_system_internal, |
83298
ed09a89e2b25
Fix UTF-8 tty input when first frame is an X frame. Steps towards multiple tty locale support.
Karoly Lorentey <lorentey@elte.hu>
parents:
83292
diff
changeset
|
7375 Sset_terminal_coding_system_internal, 1, 2, 0, |
40713
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
7376 doc: /* Internal use only. */) |
83431
76396de7f50a
Rename `struct device' to `struct terminal'. Rename some terminal-related functions similarly.
Karoly Lorentey <lorentey@elte.hu>
parents:
83423
diff
changeset
|
7377 (coding_system, terminal) |
17052 | 7378 Lisp_Object coding_system; |
83431
76396de7f50a
Rename `struct device' to `struct terminal'. Rename some terminal-related functions similarly.
Karoly Lorentey <lorentey@elte.hu>
parents:
83423
diff
changeset
|
7379 Lisp_Object terminal; |
17052 | 7380 { |
83431
76396de7f50a
Rename `struct device' to `struct terminal'. Rename some terminal-related functions similarly.
Karoly Lorentey <lorentey@elte.hu>
parents:
83423
diff
changeset
|
7381 struct coding_system *terminal_coding = TERMINAL_TERMINAL_CODING (get_terminal (terminal, 1)); |
40656
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents:
40461
diff
changeset
|
7382 CHECK_SYMBOL (coding_system); |
83127
5182815e0ee1
Make terminal_coding and keyboard_coding display-local.
Karoly Lorentey <lorentey@elte.hu>
parents:
54320
diff
changeset
|
7383 setup_coding_system (Fcheck_coding_system (coding_system), terminal_coding); |
20150
402b6e5f4b58
(encode_designation_at_bol): Fix bug of finding graphic
Kenichi Handa <handa@m17n.org>
parents:
20105
diff
changeset
|
7384 /* We had better not send unsafe characters to terminal. */ |
83127
5182815e0ee1
Make terminal_coding and keyboard_coding display-local.
Karoly Lorentey <lorentey@elte.hu>
parents:
54320
diff
changeset
|
7385 terminal_coding->mode |= CODING_MODE_INHIBIT_UNENCODABLE_CHAR; |
36087 | 7386 /* Character composition should be disabled. */ |
83127
5182815e0ee1
Make terminal_coding and keyboard_coding display-local.
Karoly Lorentey <lorentey@elte.hu>
parents:
54320
diff
changeset
|
7387 terminal_coding->composing = COMPOSITION_DISABLED; |
35531
36de5bf9969c
(ccl_coding_driver): Setup ccl->suppress_error.
Kenichi Handa <handa@m17n.org>
parents:
35053
diff
changeset
|
7388 /* Error notification should be suppressed. */ |
83127
5182815e0ee1
Make terminal_coding and keyboard_coding display-local.
Karoly Lorentey <lorentey@elte.hu>
parents:
54320
diff
changeset
|
7389 terminal_coding->suppress_error = 1; |
5182815e0ee1
Make terminal_coding and keyboard_coding display-local.
Karoly Lorentey <lorentey@elte.hu>
parents:
54320
diff
changeset
|
7390 terminal_coding->src_multibyte = 1; |
5182815e0ee1
Make terminal_coding and keyboard_coding display-local.
Karoly Lorentey <lorentey@elte.hu>
parents:
54320
diff
changeset
|
7391 terminal_coding->dst_multibyte = 0; |
17052 | 7392 return Qnil; |
7393 } | |
7394 | |
48182
9474e269efd1
Reformat some DEFUNs so that etags works.
Dave Love <fx@gnu.org>
parents:
48125
diff
changeset
|
7395 DEFUN ("set-safe-terminal-coding-system-internal", Fset_safe_terminal_coding_system_internal, |
40713
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
7396 Sset_safe_terminal_coding_system_internal, 1, 1, 0, |
41006 | 7397 doc: /* Internal use only. */) |
40713
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
7398 (coding_system) |
19280
e755044718ee
(ENCODE_ISO_CHARACTER_DIMENSION1): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
19193
diff
changeset
|
7399 Lisp_Object coding_system; |
e755044718ee
(ENCODE_ISO_CHARACTER_DIMENSION1): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
19193
diff
changeset
|
7400 { |
40656
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents:
40461
diff
changeset
|
7401 CHECK_SYMBOL (coding_system); |
19280
e755044718ee
(ENCODE_ISO_CHARACTER_DIMENSION1): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
19193
diff
changeset
|
7402 setup_coding_system (Fcheck_coding_system (coding_system), |
e755044718ee
(ENCODE_ISO_CHARACTER_DIMENSION1): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
19193
diff
changeset
|
7403 &safe_terminal_coding); |
36087 | 7404 /* Character composition should be disabled. */ |
26847 | 7405 safe_terminal_coding.composing = COMPOSITION_DISABLED; |
35531
36de5bf9969c
(ccl_coding_driver): Setup ccl->suppress_error.
Kenichi Handa <handa@m17n.org>
parents:
35053
diff
changeset
|
7406 /* Error notification should be suppressed. */ |
55759
8f316e69dd4b
(Fset_safe_terminal_coding_system_internal): Set
Kenichi Handa <handa@m17n.org>
parents:
54320
diff
changeset
|
7407 safe_terminal_coding.suppress_error = 1; |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
7408 safe_terminal_coding.src_multibyte = 1; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
7409 safe_terminal_coding.dst_multibyte = 0; |
19280
e755044718ee
(ENCODE_ISO_CHARACTER_DIMENSION1): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
19193
diff
changeset
|
7410 return Qnil; |
e755044718ee
(ENCODE_ISO_CHARACTER_DIMENSION1): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
19193
diff
changeset
|
7411 } |
e755044718ee
(ENCODE_ISO_CHARACTER_DIMENSION1): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
19193
diff
changeset
|
7412 |
48182
9474e269efd1
Reformat some DEFUNs so that etags works.
Dave Love <fx@gnu.org>
parents:
48125
diff
changeset
|
7413 DEFUN ("terminal-coding-system", Fterminal_coding_system, |
83298
ed09a89e2b25
Fix UTF-8 tty input when first frame is an X frame. Steps towards multiple tty locale support.
Karoly Lorentey <lorentey@elte.hu>
parents:
83292
diff
changeset
|
7414 Sterminal_coding_system, 0, 1, 0, |
83431
76396de7f50a
Rename `struct device' to `struct terminal'. Rename some terminal-related functions similarly.
Karoly Lorentey <lorentey@elte.hu>
parents:
83423
diff
changeset
|
7415 doc: /* Return coding system specified for terminal output on the given terminal. |
76396de7f50a
Rename `struct device' to `struct terminal'. Rename some terminal-related functions similarly.
Karoly Lorentey <lorentey@elte.hu>
parents:
83423
diff
changeset
|
7416 TERMINAL may be a terminal id, a frame, or nil for the selected |
76396de7f50a
Rename `struct device' to `struct terminal'. Rename some terminal-related functions similarly.
Karoly Lorentey <lorentey@elte.hu>
parents:
83423
diff
changeset
|
7417 frame's terminal device. */) |
76396de7f50a
Rename `struct device' to `struct terminal'. Rename some terminal-related functions similarly.
Karoly Lorentey <lorentey@elte.hu>
parents:
83423
diff
changeset
|
7418 (terminal) |
76396de7f50a
Rename `struct device' to `struct terminal'. Rename some terminal-related functions similarly.
Karoly Lorentey <lorentey@elte.hu>
parents:
83423
diff
changeset
|
7419 Lisp_Object terminal; |
17052 | 7420 { |
83431
76396de7f50a
Rename `struct device' to `struct terminal'. Rename some terminal-related functions similarly.
Karoly Lorentey <lorentey@elte.hu>
parents:
83423
diff
changeset
|
7421 return TERMINAL_TERMINAL_CODING (get_terminal (terminal, 1))->symbol; |
17052 | 7422 } |
7423 | |
48182
9474e269efd1
Reformat some DEFUNs so that etags works.
Dave Love <fx@gnu.org>
parents:
48125
diff
changeset
|
7424 DEFUN ("set-keyboard-coding-system-internal", Fset_keyboard_coding_system_internal, |
83298
ed09a89e2b25
Fix UTF-8 tty input when first frame is an X frame. Steps towards multiple tty locale support.
Karoly Lorentey <lorentey@elte.hu>
parents:
83292
diff
changeset
|
7425 Sset_keyboard_coding_system_internal, 1, 2, 0, |
40713
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
7426 doc: /* Internal use only. */) |
83431
76396de7f50a
Rename `struct device' to `struct terminal'. Rename some terminal-related functions similarly.
Karoly Lorentey <lorentey@elte.hu>
parents:
83423
diff
changeset
|
7427 (coding_system, terminal) |
17052 | 7428 Lisp_Object coding_system; |
83431
76396de7f50a
Rename `struct device' to `struct terminal'. Rename some terminal-related functions similarly.
Karoly Lorentey <lorentey@elte.hu>
parents:
83423
diff
changeset
|
7429 Lisp_Object terminal; |
17052 | 7430 { |
83431
76396de7f50a
Rename `struct device' to `struct terminal'. Rename some terminal-related functions similarly.
Karoly Lorentey <lorentey@elte.hu>
parents:
83423
diff
changeset
|
7431 struct terminal *t = get_terminal (terminal, 1); |
40656
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents:
40461
diff
changeset
|
7432 CHECK_SYMBOL (coding_system); |
83298
ed09a89e2b25
Fix UTF-8 tty input when first frame is an X frame. Steps towards multiple tty locale support.
Karoly Lorentey <lorentey@elte.hu>
parents:
83292
diff
changeset
|
7433 |
83127
5182815e0ee1
Make terminal_coding and keyboard_coding display-local.
Karoly Lorentey <lorentey@elte.hu>
parents:
54320
diff
changeset
|
7434 setup_coding_system (Fcheck_coding_system (coding_system), |
83431
76396de7f50a
Rename `struct device' to `struct terminal'. Rename some terminal-related functions similarly.
Karoly Lorentey <lorentey@elte.hu>
parents:
83423
diff
changeset
|
7435 TERMINAL_KEYBOARD_CODING (t)); |
36087 | 7436 /* Character composition should be disabled. */ |
83431
76396de7f50a
Rename `struct device' to `struct terminal'. Rename some terminal-related functions similarly.
Karoly Lorentey <lorentey@elte.hu>
parents:
83423
diff
changeset
|
7437 TERMINAL_KEYBOARD_CODING (t)->composing = COMPOSITION_DISABLED; |
17052 | 7438 return Qnil; |
7439 } | |
7440 | |
48182
9474e269efd1
Reformat some DEFUNs so that etags works.
Dave Love <fx@gnu.org>
parents:
48125
diff
changeset
|
7441 DEFUN ("keyboard-coding-system", Fkeyboard_coding_system, |
83298
ed09a89e2b25
Fix UTF-8 tty input when first frame is an X frame. Steps towards multiple tty locale support.
Karoly Lorentey <lorentey@elte.hu>
parents:
83292
diff
changeset
|
7442 Skeyboard_coding_system, 0, 1, 0, |
83431
76396de7f50a
Rename `struct device' to `struct terminal'. Rename some terminal-related functions similarly.
Karoly Lorentey <lorentey@elte.hu>
parents:
83423
diff
changeset
|
7443 doc: /* Return coding system for decoding keyboard input on TERMINAL. |
76396de7f50a
Rename `struct device' to `struct terminal'. Rename some terminal-related functions similarly.
Karoly Lorentey <lorentey@elte.hu>
parents:
83423
diff
changeset
|
7444 TERMINAL may be a terminal id, a frame, or nil for the selected |
76396de7f50a
Rename `struct device' to `struct terminal'. Rename some terminal-related functions similarly.
Karoly Lorentey <lorentey@elte.hu>
parents:
83423
diff
changeset
|
7445 frame's terminal device. */) |
76396de7f50a
Rename `struct device' to `struct terminal'. Rename some terminal-related functions similarly.
Karoly Lorentey <lorentey@elte.hu>
parents:
83423
diff
changeset
|
7446 (terminal) |
76396de7f50a
Rename `struct device' to `struct terminal'. Rename some terminal-related functions similarly.
Karoly Lorentey <lorentey@elte.hu>
parents:
83423
diff
changeset
|
7447 Lisp_Object terminal; |
17052 | 7448 { |
83431
76396de7f50a
Rename `struct device' to `struct terminal'. Rename some terminal-related functions similarly.
Karoly Lorentey <lorentey@elte.hu>
parents:
83423
diff
changeset
|
7449 return TERMINAL_KEYBOARD_CODING (get_terminal (terminal, 1))->symbol; |
17052 | 7450 } |
7451 | |
7452 | |
18536
69c0e220b626
(Vstandard_character_unification_table_for_decode):
Kenichi Handa <handa@m17n.org>
parents:
18523
diff
changeset
|
7453 DEFUN ("find-operation-coding-system", Ffind_operation_coding_system, |
69c0e220b626
(Vstandard_character_unification_table_for_decode):
Kenichi Handa <handa@m17n.org>
parents:
18523
diff
changeset
|
7454 Sfind_operation_coding_system, 1, MANY, 0, |
40713
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
7455 doc: /* Choose a coding system for an operation based on the target name. |
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
7456 The value names a pair of coding systems: (DECODING-SYSTEM . ENCODING-SYSTEM). |
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
7457 DECODING-SYSTEM is the coding system to use for decoding |
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
7458 \(in case OPERATION does decoding), and ENCODING-SYSTEM is the coding system |
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
7459 for encoding (in case OPERATION does encoding). |
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
7460 |
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
7461 The first argument OPERATION specifies an I/O primitive: |
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
7462 For file I/O, `insert-file-contents' or `write-region'. |
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
7463 For process I/O, `call-process', `call-process-region', or `start-process'. |
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
7464 For network I/O, `open-network-stream'. |
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
7465 |
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
7466 The remaining arguments should be the same arguments that were passed |
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
7467 to the primitive. Depending on which primitive, one of those arguments |
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
7468 is selected as the TARGET. For example, if OPERATION does file I/O, |
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
7469 whichever argument specifies the file name is TARGET. |
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
7470 |
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
7471 TARGET has a meaning which depends on OPERATION: |
70948
7ea8b1c11d80
(Ffind_operation_coding_system): Allow (FILENAME . BUFFER) in TARGET.
Kenichi Handa <handa@m17n.org>
parents:
70704
diff
changeset
|
7472 For file I/O, TARGET is a file name (except for the special case below). |
40713
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
7473 For process I/O, TARGET is a process name. |
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
7474 For network I/O, TARGET is a service name or a port number |
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
7475 |
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
7476 This function looks up what specified for TARGET in, |
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
7477 `file-coding-system-alist', `process-coding-system-alist', |
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
7478 or `network-coding-system-alist' depending on OPERATION. |
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
7479 They may specify a coding system, a cons of coding systems, |
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
7480 or a function symbol to call. |
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
7481 In the last case, we call the function with one argument, |
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
7482 which is a list of all the arguments given to this function. |
81611
ae42ad5f89e6
(Ffind_operation_coding_system): Docstring improved.
Kenichi Handa <handa@m17n.org>
parents:
75348
diff
changeset
|
7483 If the function can't decide a coding system, it can return |
ae42ad5f89e6
(Ffind_operation_coding_system): Docstring improved.
Kenichi Handa <handa@m17n.org>
parents:
75348
diff
changeset
|
7484 `undecided' so that the normal code-detection is performed. |
40713
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
7485 |
70948
7ea8b1c11d80
(Ffind_operation_coding_system): Allow (FILENAME . BUFFER) in TARGET.
Kenichi Handa <handa@m17n.org>
parents:
70704
diff
changeset
|
7486 If OPERATION is `insert-file-contents', the argument corresponding to |
7ea8b1c11d80
(Ffind_operation_coding_system): Allow (FILENAME . BUFFER) in TARGET.
Kenichi Handa <handa@m17n.org>
parents:
70704
diff
changeset
|
7487 TARGET may be a cons (FILENAME . BUFFER). In that case, FILENAME is a |
71084
ccef92f2f7f8
(Ffind_operation_coding_system): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
71070
diff
changeset
|
7488 file name to look up, and BUFFER is a buffer that contains the file's |
ccef92f2f7f8
(Ffind_operation_coding_system): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
71070
diff
changeset
|
7489 contents (not yet decoded). If `file-coding-system-alist' specifies a |
71070
0c8ac7192244
(Ffind_operation_coding_system): Doc fix.
Eli Zaretskii <eliz@gnu.org>
parents:
71039
diff
changeset
|
7490 function to call for FILENAME, that function should examine the |
0c8ac7192244
(Ffind_operation_coding_system): Doc fix.
Eli Zaretskii <eliz@gnu.org>
parents:
71039
diff
changeset
|
7491 contents of BUFFER instead of reading the file. |
70948
7ea8b1c11d80
(Ffind_operation_coding_system): Allow (FILENAME . BUFFER) in TARGET.
Kenichi Handa <handa@m17n.org>
parents:
70704
diff
changeset
|
7492 |
78152
5e5f359984e5
(Ffind_operation_coding_system): Doc fix.
Juanma Barranquero <lekktu@gmail.com>
parents:
75348
diff
changeset
|
7493 usage: (find-operation-coding-system OPERATION ARGUMENTS...) */) |
40713
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
7494 (nargs, args) |
17052 | 7495 int nargs; |
7496 Lisp_Object *args; | |
7497 { | |
7498 Lisp_Object operation, target_idx, target, val; | |
7499 register Lisp_Object chain; | |
7500 | |
7501 if (nargs < 2) | |
7502 error ("Too few arguments"); | |
7503 operation = args[0]; | |
7504 if (!SYMBOLP (operation) | |
7505 || !INTEGERP (target_idx = Fget (operation, Qtarget_idx))) | |
36087 | 7506 error ("Invalid first argument"); |
17052 | 7507 if (nargs < 1 + XINT (target_idx)) |
7508 error ("Too few arguments for operation: %s", | |
46370
40db0673e6f0
Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents:
46293
diff
changeset
|
7509 SDATA (SYMBOL_NAME (operation))); |
46838
395572099269
(Ffind_operation_coding_system): For write-region, if
Kenichi Handa <handa@m17n.org>
parents:
46702
diff
changeset
|
7510 /* For write-region, if the 6th argument (i.e. VISIT, the 5th |
395572099269
(Ffind_operation_coding_system): For write-region, if
Kenichi Handa <handa@m17n.org>
parents:
46702
diff
changeset
|
7511 argument to write-region) is string, it must be treated as a |
395572099269
(Ffind_operation_coding_system): For write-region, if
Kenichi Handa <handa@m17n.org>
parents:
46702
diff
changeset
|
7512 target file name. */ |
395572099269
(Ffind_operation_coding_system): For write-region, if
Kenichi Handa <handa@m17n.org>
parents:
46702
diff
changeset
|
7513 if (EQ (operation, Qwrite_region) |
395572099269
(Ffind_operation_coding_system): For write-region, if
Kenichi Handa <handa@m17n.org>
parents:
46702
diff
changeset
|
7514 && nargs > 5 |
395572099269
(Ffind_operation_coding_system): For write-region, if
Kenichi Handa <handa@m17n.org>
parents:
46702
diff
changeset
|
7515 && STRINGP (args[5])) |
46839
4acadb428f41
(Ffind_operation_coding_system): Fix Lisp_Object/int mixup.
Ken Raeburn <raeburn@raeburn.org>
parents:
46838
diff
changeset
|
7516 target_idx = make_number (4); |
17052 | 7517 target = args[XINT (target_idx) + 1]; |
7518 if (!(STRINGP (target) | |
70948
7ea8b1c11d80
(Ffind_operation_coding_system): Allow (FILENAME . BUFFER) in TARGET.
Kenichi Handa <handa@m17n.org>
parents:
70704
diff
changeset
|
7519 || (EQ (operation, Qinsert_file_contents) && CONSP (target) |
7ea8b1c11d80
(Ffind_operation_coding_system): Allow (FILENAME . BUFFER) in TARGET.
Kenichi Handa <handa@m17n.org>
parents:
70704
diff
changeset
|
7520 && STRINGP (XCAR (target)) && BUFFERP (XCDR (target))) |
17052 | 7521 || (EQ (operation, Qopen_network_stream) && INTEGERP (target)))) |
36087 | 7522 error ("Invalid argument %d", XINT (target_idx) + 1); |
70948
7ea8b1c11d80
(Ffind_operation_coding_system): Allow (FILENAME . BUFFER) in TARGET.
Kenichi Handa <handa@m17n.org>
parents:
70704
diff
changeset
|
7523 if (CONSP (target)) |
7ea8b1c11d80
(Ffind_operation_coding_system): Allow (FILENAME . BUFFER) in TARGET.
Kenichi Handa <handa@m17n.org>
parents:
70704
diff
changeset
|
7524 target = XCAR (target); |
17052 | 7525 |
18613
614b916ff5bf
Fix bugs with inappropriate mixing of Lisp_Object with int.
Richard M. Stallman <rms@gnu.org>
parents:
18536
diff
changeset
|
7526 chain = ((EQ (operation, Qinsert_file_contents) |
614b916ff5bf
Fix bugs with inappropriate mixing of Lisp_Object with int.
Richard M. Stallman <rms@gnu.org>
parents:
18536
diff
changeset
|
7527 || EQ (operation, Qwrite_region)) |
18180
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
7528 ? Vfile_coding_system_alist |
18613
614b916ff5bf
Fix bugs with inappropriate mixing of Lisp_Object with int.
Richard M. Stallman <rms@gnu.org>
parents:
18536
diff
changeset
|
7529 : (EQ (operation, Qopen_network_stream) |
18180
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
7530 ? Vnetwork_coding_system_alist |
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
7531 : Vprocess_coding_system_alist)); |
17052 | 7532 if (NILP (chain)) |
7533 return Qnil; | |
7534 | |
25662
0a7261c1d487
Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25370
diff
changeset
|
7535 for (; CONSP (chain); chain = XCDR (chain)) |
17052 | 7536 { |
19747
bed06df9cbc5
(setup_coding_system, Ffind_operation_coding_system)
Richard M. Stallman <rms@gnu.org>
parents:
19743
diff
changeset
|
7537 Lisp_Object elt; |
25662
0a7261c1d487
Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25370
diff
changeset
|
7538 elt = XCAR (chain); |
17052 | 7539 |
7540 if (CONSP (elt) | |
7541 && ((STRINGP (target) | |
25662
0a7261c1d487
Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25370
diff
changeset
|
7542 && STRINGP (XCAR (elt)) |
0a7261c1d487
Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25370
diff
changeset
|
7543 && fast_string_match (XCAR (elt), target) >= 0) |
0a7261c1d487
Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25370
diff
changeset
|
7544 || (INTEGERP (target) && EQ (target, XCAR (elt))))) |
18180
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
7545 { |
25662
0a7261c1d487
Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25370
diff
changeset
|
7546 val = XCDR (elt); |
19763
ab2fd2c85986
(Ffind_operation_coding_system): If a function in
Kenichi Handa <handa@m17n.org>
parents:
19758
diff
changeset
|
7547 /* Here, if VAL is both a valid coding system and a valid |
ab2fd2c85986
(Ffind_operation_coding_system): If a function in
Kenichi Handa <handa@m17n.org>
parents:
19758
diff
changeset
|
7548 function symbol, we return VAL as a coding system. */ |
18180
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
7549 if (CONSP (val)) |
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
7550 return val; |
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
7551 if (! SYMBOLP (val)) |
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
7552 return Qnil; |
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
7553 if (! NILP (Fcoding_system_p (val))) |
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
7554 return Fcons (val, val); |
19763
ab2fd2c85986
(Ffind_operation_coding_system): If a function in
Kenichi Handa <handa@m17n.org>
parents:
19758
diff
changeset
|
7555 if (! NILP (Ffboundp (val))) |
ab2fd2c85986
(Ffind_operation_coding_system): If a function in
Kenichi Handa <handa@m17n.org>
parents:
19758
diff
changeset
|
7556 { |
72188 | 7557 /* We use call1 rather than safe_call1 |
7558 so as to get bug reports about functions called here | |
7559 which don't handle the current interface. */ | |
72180
f3bc55b96df5
(Ffind_operation_coding_system): Revert the change from 2006-05-29.
Eli Zaretskii <eliz@gnu.org>
parents:
71972
diff
changeset
|
7560 val = call1 (val, Flist (nargs, args)); |
19763
ab2fd2c85986
(Ffind_operation_coding_system): If a function in
Kenichi Handa <handa@m17n.org>
parents:
19758
diff
changeset
|
7561 if (CONSP (val)) |
ab2fd2c85986
(Ffind_operation_coding_system): If a function in
Kenichi Handa <handa@m17n.org>
parents:
19758
diff
changeset
|
7562 return val; |
ab2fd2c85986
(Ffind_operation_coding_system): If a function in
Kenichi Handa <handa@m17n.org>
parents:
19758
diff
changeset
|
7563 if (SYMBOLP (val) && ! NILP (Fcoding_system_p (val))) |
ab2fd2c85986
(Ffind_operation_coding_system): If a function in
Kenichi Handa <handa@m17n.org>
parents:
19758
diff
changeset
|
7564 return Fcons (val, val); |
ab2fd2c85986
(Ffind_operation_coding_system): If a function in
Kenichi Handa <handa@m17n.org>
parents:
19758
diff
changeset
|
7565 } |
18180
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
7566 return Qnil; |
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
7567 } |
17052 | 7568 } |
7569 return Qnil; | |
7570 } | |
7571 | |
22874
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
7572 DEFUN ("update-coding-systems-internal", Fupdate_coding_systems_internal, |
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
7573 Supdate_coding_systems_internal, 0, 0, 0, |
40713
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
7574 doc: /* Update internal database for ISO2022 and CCL based coding systems. |
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
7575 When values of any coding categories are changed, you must |
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
7576 call this function. */) |
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
7577 () |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
7578 { |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
7579 int i; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
7580 |
28022
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
7581 for (i = CODING_CATEGORY_IDX_EMACS_MULE; i < CODING_CATEGORY_IDX_MAX; i++) |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
7582 { |
22874
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
7583 Lisp_Object val; |
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
7584 |
86228
8e5b337fea59
* coding.c (detect_coding, Fupdate_coding_systems_internal):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
85332
diff
changeset
|
7585 val = find_symbol_value (XVECTOR (Vcoding_category_table)->contents[i]); |
22874
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
7586 if (!NILP (val)) |
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
7587 { |
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
7588 if (! coding_system_table[i]) |
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
7589 coding_system_table[i] = ((struct coding_system *) |
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
7590 xmalloc (sizeof (struct coding_system))); |
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
7591 setup_coding_system (val, coding_system_table[i]); |
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
7592 } |
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
7593 else if (coding_system_table[i]) |
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
7594 { |
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
7595 xfree (coding_system_table[i]); |
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
7596 coding_system_table[i] = NULL; |
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
7597 } |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
7598 } |
22874
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
7599 |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
7600 return Qnil; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
7601 } |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
7602 |
22226
557fac086b1b
(ascii_skip_code): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22186
diff
changeset
|
7603 DEFUN ("set-coding-priority-internal", Fset_coding_priority_internal, |
557fac086b1b
(ascii_skip_code): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22186
diff
changeset
|
7604 Sset_coding_priority_internal, 0, 0, 0, |
40713
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
7605 doc: /* Update internal database for the current value of `coding-category-list'. |
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
7606 This function is internal use only. */) |
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
7607 () |
22226
557fac086b1b
(ascii_skip_code): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22186
diff
changeset
|
7608 { |
557fac086b1b
(ascii_skip_code): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22186
diff
changeset
|
7609 int i = 0, idx; |
22954
928b337d953b
Avoid using initializers for Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents:
22874
diff
changeset
|
7610 Lisp_Object val; |
928b337d953b
Avoid using initializers for Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents:
22874
diff
changeset
|
7611 |
928b337d953b
Avoid using initializers for Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents:
22874
diff
changeset
|
7612 val = Vcoding_category_list; |
22226
557fac086b1b
(ascii_skip_code): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22186
diff
changeset
|
7613 |
557fac086b1b
(ascii_skip_code): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22186
diff
changeset
|
7614 while (CONSP (val) && i < CODING_CATEGORY_IDX_MAX) |
557fac086b1b
(ascii_skip_code): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22186
diff
changeset
|
7615 { |
25662
0a7261c1d487
Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25370
diff
changeset
|
7616 if (! SYMBOLP (XCAR (val))) |
22226
557fac086b1b
(ascii_skip_code): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22186
diff
changeset
|
7617 break; |
25662
0a7261c1d487
Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25370
diff
changeset
|
7618 idx = XFASTINT (Fget (XCAR (val), Qcoding_category_index)); |
22226
557fac086b1b
(ascii_skip_code): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22186
diff
changeset
|
7619 if (idx >= CODING_CATEGORY_IDX_MAX) |
557fac086b1b
(ascii_skip_code): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22186
diff
changeset
|
7620 break; |
557fac086b1b
(ascii_skip_code): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22186
diff
changeset
|
7621 coding_priorities[i++] = (1 << idx); |
25662
0a7261c1d487
Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25370
diff
changeset
|
7622 val = XCDR (val); |
22226
557fac086b1b
(ascii_skip_code): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22186
diff
changeset
|
7623 } |
557fac086b1b
(ascii_skip_code): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22186
diff
changeset
|
7624 /* If coding-category-list is valid and contains all coding |
557fac086b1b
(ascii_skip_code): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22186
diff
changeset
|
7625 categories, `i' should be CODING_CATEGORY_IDX_MAX now. If not, |
28022
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
7626 the following code saves Emacs from crashing. */ |
22226
557fac086b1b
(ascii_skip_code): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22186
diff
changeset
|
7627 while (i < CODING_CATEGORY_IDX_MAX) |
557fac086b1b
(ascii_skip_code): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22186
diff
changeset
|
7628 coding_priorities[i++] = CODING_CATEGORY_MASK_RAW_TEXT; |
557fac086b1b
(ascii_skip_code): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22186
diff
changeset
|
7629 |
557fac086b1b
(ascii_skip_code): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22186
diff
changeset
|
7630 return Qnil; |
557fac086b1b
(ascii_skip_code): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22186
diff
changeset
|
7631 } |
557fac086b1b
(ascii_skip_code): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22186
diff
changeset
|
7632 |
49539
1ad5bfbb831a
(syms_of_coding): Add `...' for symbols in the docstring of
Kenichi Handa <handa@m17n.org>
parents:
48874
diff
changeset
|
7633 DEFUN ("define-coding-system-internal", Fdefine_coding_system_internal, |
1ad5bfbb831a
(syms_of_coding): Add `...' for symbols in the docstring of
Kenichi Handa <handa@m17n.org>
parents:
48874
diff
changeset
|
7634 Sdefine_coding_system_internal, 1, 1, 0, |
1ad5bfbb831a
(syms_of_coding): Add `...' for symbols in the docstring of
Kenichi Handa <handa@m17n.org>
parents:
48874
diff
changeset
|
7635 doc: /* Register CODING-SYSTEM as a base coding system. |
1ad5bfbb831a
(syms_of_coding): Add `...' for symbols in the docstring of
Kenichi Handa <handa@m17n.org>
parents:
48874
diff
changeset
|
7636 This function is internal use only. */) |
1ad5bfbb831a
(syms_of_coding): Add `...' for symbols in the docstring of
Kenichi Handa <handa@m17n.org>
parents:
48874
diff
changeset
|
7637 (coding_system) |
1ad5bfbb831a
(syms_of_coding): Add `...' for symbols in the docstring of
Kenichi Handa <handa@m17n.org>
parents:
48874
diff
changeset
|
7638 Lisp_Object coding_system; |
1ad5bfbb831a
(syms_of_coding): Add `...' for symbols in the docstring of
Kenichi Handa <handa@m17n.org>
parents:
48874
diff
changeset
|
7639 { |
1ad5bfbb831a
(syms_of_coding): Add `...' for symbols in the docstring of
Kenichi Handa <handa@m17n.org>
parents:
48874
diff
changeset
|
7640 Lisp_Object safe_chars, slot; |
1ad5bfbb831a
(syms_of_coding): Add `...' for symbols in the docstring of
Kenichi Handa <handa@m17n.org>
parents:
48874
diff
changeset
|
7641 |
1ad5bfbb831a
(syms_of_coding): Add `...' for symbols in the docstring of
Kenichi Handa <handa@m17n.org>
parents:
48874
diff
changeset
|
7642 if (NILP (Fcheck_coding_system (coding_system))) |
71972
eaa3c19b94d2
(Fcheck_coding_system): Use xsignal1. Remove loop.
Kim F. Storm <storm@cua.dk>
parents:
71084
diff
changeset
|
7643 xsignal1 (Qcoding_system_error, coding_system); |
eaa3c19b94d2
(Fcheck_coding_system): Use xsignal1. Remove loop.
Kim F. Storm <storm@cua.dk>
parents:
71084
diff
changeset
|
7644 |
49539
1ad5bfbb831a
(syms_of_coding): Add `...' for symbols in the docstring of
Kenichi Handa <handa@m17n.org>
parents:
48874
diff
changeset
|
7645 safe_chars = coding_safe_chars (coding_system); |
1ad5bfbb831a
(syms_of_coding): Add `...' for symbols in the docstring of
Kenichi Handa <handa@m17n.org>
parents:
48874
diff
changeset
|
7646 if (! EQ (safe_chars, Qt) && ! CHAR_TABLE_P (safe_chars)) |
1ad5bfbb831a
(syms_of_coding): Add `...' for symbols in the docstring of
Kenichi Handa <handa@m17n.org>
parents:
48874
diff
changeset
|
7647 error ("No valid safe-chars property for %s", |
1ad5bfbb831a
(syms_of_coding): Add `...' for symbols in the docstring of
Kenichi Handa <handa@m17n.org>
parents:
48874
diff
changeset
|
7648 SDATA (SYMBOL_NAME (coding_system))); |
71972
eaa3c19b94d2
(Fcheck_coding_system): Use xsignal1. Remove loop.
Kim F. Storm <storm@cua.dk>
parents:
71084
diff
changeset
|
7649 |
49539
1ad5bfbb831a
(syms_of_coding): Add `...' for symbols in the docstring of
Kenichi Handa <handa@m17n.org>
parents:
48874
diff
changeset
|
7650 if (EQ (safe_chars, Qt)) |
1ad5bfbb831a
(syms_of_coding): Add `...' for symbols in the docstring of
Kenichi Handa <handa@m17n.org>
parents:
48874
diff
changeset
|
7651 { |
1ad5bfbb831a
(syms_of_coding): Add `...' for symbols in the docstring of
Kenichi Handa <handa@m17n.org>
parents:
48874
diff
changeset
|
7652 if (NILP (Fmemq (coding_system, XCAR (Vcoding_system_safe_chars)))) |
1ad5bfbb831a
(syms_of_coding): Add `...' for symbols in the docstring of
Kenichi Handa <handa@m17n.org>
parents:
48874
diff
changeset
|
7653 XSETCAR (Vcoding_system_safe_chars, |
1ad5bfbb831a
(syms_of_coding): Add `...' for symbols in the docstring of
Kenichi Handa <handa@m17n.org>
parents:
48874
diff
changeset
|
7654 Fcons (coding_system, XCAR (Vcoding_system_safe_chars))); |
1ad5bfbb831a
(syms_of_coding): Add `...' for symbols in the docstring of
Kenichi Handa <handa@m17n.org>
parents:
48874
diff
changeset
|
7655 } |
1ad5bfbb831a
(syms_of_coding): Add `...' for symbols in the docstring of
Kenichi Handa <handa@m17n.org>
parents:
48874
diff
changeset
|
7656 else |
1ad5bfbb831a
(syms_of_coding): Add `...' for symbols in the docstring of
Kenichi Handa <handa@m17n.org>
parents:
48874
diff
changeset
|
7657 { |
1ad5bfbb831a
(syms_of_coding): Add `...' for symbols in the docstring of
Kenichi Handa <handa@m17n.org>
parents:
48874
diff
changeset
|
7658 slot = Fassq (coding_system, XCDR (Vcoding_system_safe_chars)); |
1ad5bfbb831a
(syms_of_coding): Add `...' for symbols in the docstring of
Kenichi Handa <handa@m17n.org>
parents:
48874
diff
changeset
|
7659 if (NILP (slot)) |
1ad5bfbb831a
(syms_of_coding): Add `...' for symbols in the docstring of
Kenichi Handa <handa@m17n.org>
parents:
48874
diff
changeset
|
7660 XSETCDR (Vcoding_system_safe_chars, |
1ad5bfbb831a
(syms_of_coding): Add `...' for symbols in the docstring of
Kenichi Handa <handa@m17n.org>
parents:
48874
diff
changeset
|
7661 nconc2 (XCDR (Vcoding_system_safe_chars), |
1ad5bfbb831a
(syms_of_coding): Add `...' for symbols in the docstring of
Kenichi Handa <handa@m17n.org>
parents:
48874
diff
changeset
|
7662 Fcons (Fcons (coding_system, safe_chars), Qnil))); |
1ad5bfbb831a
(syms_of_coding): Add `...' for symbols in the docstring of
Kenichi Handa <handa@m17n.org>
parents:
48874
diff
changeset
|
7663 else |
1ad5bfbb831a
(syms_of_coding): Add `...' for symbols in the docstring of
Kenichi Handa <handa@m17n.org>
parents:
48874
diff
changeset
|
7664 XSETCDR (slot, safe_chars); |
1ad5bfbb831a
(syms_of_coding): Add `...' for symbols in the docstring of
Kenichi Handa <handa@m17n.org>
parents:
48874
diff
changeset
|
7665 } |
1ad5bfbb831a
(syms_of_coding): Add `...' for symbols in the docstring of
Kenichi Handa <handa@m17n.org>
parents:
48874
diff
changeset
|
7666 return Qnil; |
1ad5bfbb831a
(syms_of_coding): Add `...' for symbols in the docstring of
Kenichi Handa <handa@m17n.org>
parents:
48874
diff
changeset
|
7667 } |
1ad5bfbb831a
(syms_of_coding): Add `...' for symbols in the docstring of
Kenichi Handa <handa@m17n.org>
parents:
48874
diff
changeset
|
7668 |
17052 | 7669 #endif /* emacs */ |
7670 | |
7671 | |
22874
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
7672 /*** 9. Post-amble ***/ |
17052 | 7673 |
21514 | 7674 void |
17052 | 7675 init_coding_once () |
7676 { | |
7677 int i; | |
7678 | |
42104
d69c2368e549
(DECODE_COMPOSITION_END): Fixed a typo in the last
Sam Steingold <sds@gnu.org>
parents:
42103
diff
changeset
|
7679 /* Emacs' internal format specific initialize routine. */ |
17052 | 7680 for (i = 0; i <= 0x20; i++) |
7681 emacs_code_class[i] = EMACS_control_code; | |
7682 emacs_code_class[0x0A] = EMACS_linefeed_code; | |
7683 emacs_code_class[0x0D] = EMACS_carriage_return_code; | |
7684 for (i = 0x21 ; i < 0x7F; i++) | |
7685 emacs_code_class[i] = EMACS_ascii_code; | |
7686 emacs_code_class[0x7F] = EMACS_control_code; | |
26847 | 7687 for (i = 0x80; i < 0xFF; i++) |
17052 | 7688 emacs_code_class[i] = EMACS_invalid_code; |
7689 emacs_code_class[LEADING_CODE_PRIVATE_11] = EMACS_leading_code_3; | |
7690 emacs_code_class[LEADING_CODE_PRIVATE_12] = EMACS_leading_code_3; | |
7691 emacs_code_class[LEADING_CODE_PRIVATE_21] = EMACS_leading_code_4; | |
7692 emacs_code_class[LEADING_CODE_PRIVATE_22] = EMACS_leading_code_4; | |
7693 | |
7694 /* ISO2022 specific initialize routine. */ | |
7695 for (i = 0; i < 0x20; i++) | |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
7696 iso_code_class[i] = ISO_control_0; |
17052 | 7697 for (i = 0x21; i < 0x7F; i++) |
7698 iso_code_class[i] = ISO_graphic_plane_0; | |
7699 for (i = 0x80; i < 0xA0; i++) | |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
7700 iso_code_class[i] = ISO_control_1; |
17052 | 7701 for (i = 0xA1; i < 0xFF; i++) |
7702 iso_code_class[i] = ISO_graphic_plane_1; | |
7703 iso_code_class[0x20] = iso_code_class[0x7F] = ISO_0x20_or_0x7F; | |
7704 iso_code_class[0xA0] = iso_code_class[0xFF] = ISO_0xA0_or_0xFF; | |
7705 iso_code_class[ISO_CODE_CR] = ISO_carriage_return; | |
7706 iso_code_class[ISO_CODE_SO] = ISO_shift_out; | |
7707 iso_code_class[ISO_CODE_SI] = ISO_shift_in; | |
7708 iso_code_class[ISO_CODE_SS2_7] = ISO_single_shift_2_7; | |
7709 iso_code_class[ISO_CODE_ESC] = ISO_escape; | |
7710 iso_code_class[ISO_CODE_SS2] = ISO_single_shift_2; | |
7711 iso_code_class[ISO_CODE_SS3] = ISO_single_shift_3; | |
7712 iso_code_class[ISO_CODE_CSI] = ISO_control_sequence_introducer; | |
7713 | |
19280
e755044718ee
(ENCODE_ISO_CHARACTER_DIMENSION1): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
19193
diff
changeset
|
7714 setup_coding_system (Qnil, &safe_terminal_coding); |
22979
ceb8e4a89a32
(default_buffer_file_coding): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22964
diff
changeset
|
7715 setup_coding_system (Qnil, &default_buffer_file_coding); |
18650
aa3f2820e2ac
(Qemacs_mule, inhibit_eol_conversion): New variables.
Kenichi Handa <handa@m17n.org>
parents:
18613
diff
changeset
|
7716 |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
7717 bzero (coding_system_table, sizeof coding_system_table); |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
7718 |
22226
557fac086b1b
(ascii_skip_code): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22186
diff
changeset
|
7719 bzero (ascii_skip_code, sizeof ascii_skip_code); |
557fac086b1b
(ascii_skip_code): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22186
diff
changeset
|
7720 for (i = 0; i < 128; i++) |
557fac086b1b
(ascii_skip_code): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22186
diff
changeset
|
7721 ascii_skip_code[i] = 1; |
557fac086b1b
(ascii_skip_code): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22186
diff
changeset
|
7722 |
18650
aa3f2820e2ac
(Qemacs_mule, inhibit_eol_conversion): New variables.
Kenichi Handa <handa@m17n.org>
parents:
18613
diff
changeset
|
7723 #if defined (MSDOS) || defined (WINDOWSNT) |
aa3f2820e2ac
(Qemacs_mule, inhibit_eol_conversion): New variables.
Kenichi Handa <handa@m17n.org>
parents:
18613
diff
changeset
|
7724 system_eol_type = CODING_EOL_CRLF; |
aa3f2820e2ac
(Qemacs_mule, inhibit_eol_conversion): New variables.
Kenichi Handa <handa@m17n.org>
parents:
18613
diff
changeset
|
7725 #else |
aa3f2820e2ac
(Qemacs_mule, inhibit_eol_conversion): New variables.
Kenichi Handa <handa@m17n.org>
parents:
18613
diff
changeset
|
7726 system_eol_type = CODING_EOL_LF; |
aa3f2820e2ac
(Qemacs_mule, inhibit_eol_conversion): New variables.
Kenichi Handa <handa@m17n.org>
parents:
18613
diff
changeset
|
7727 #endif |
26067
f54ca66e2571
(code_convert_string): Add record_unwind_protect to
Kenichi Handa <handa@m17n.org>
parents:
25860
diff
changeset
|
7728 |
f54ca66e2571
(code_convert_string): Add record_unwind_protect to
Kenichi Handa <handa@m17n.org>
parents:
25860
diff
changeset
|
7729 inhibit_pre_post_conversion = 0; |
17119
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
7730 } |
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
7731 |
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
7732 #ifdef emacs |
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
7733 |
21514 | 7734 void |
17119
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
7735 syms_of_coding () |
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
7736 { |
58637
ff8a37b5299b
(Vcode_conversion_workbuf_name): New variable.
Kenichi Handa <handa@m17n.org>
parents:
58502
diff
changeset
|
7737 staticpro (&Vcode_conversion_workbuf_name); |
ff8a37b5299b
(Vcode_conversion_workbuf_name): New variable.
Kenichi Handa <handa@m17n.org>
parents:
58502
diff
changeset
|
7738 Vcode_conversion_workbuf_name = build_string (" *code-conversion-work*"); |
ff8a37b5299b
(Vcode_conversion_workbuf_name): New variable.
Kenichi Handa <handa@m17n.org>
parents:
58502
diff
changeset
|
7739 |
17119
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
7740 Qtarget_idx = intern ("target-idx"); |
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
7741 staticpro (&Qtarget_idx); |
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
7742 |
19750
95e4e1cba6ac
(Qcoding_system_history): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
19747
diff
changeset
|
7743 Qcoding_system_history = intern ("coding-system-history"); |
95e4e1cba6ac
(Qcoding_system_history): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
19747
diff
changeset
|
7744 staticpro (&Qcoding_system_history); |
95e4e1cba6ac
(Qcoding_system_history): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
19747
diff
changeset
|
7745 Fset (Qcoding_system_history, Qnil); |
95e4e1cba6ac
(Qcoding_system_history): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
19747
diff
changeset
|
7746 |
18650
aa3f2820e2ac
(Qemacs_mule, inhibit_eol_conversion): New variables.
Kenichi Handa <handa@m17n.org>
parents:
18613
diff
changeset
|
7747 /* Target FILENAME is the first argument. */ |
17119
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
7748 Fput (Qinsert_file_contents, Qtarget_idx, make_number (0)); |
18650
aa3f2820e2ac
(Qemacs_mule, inhibit_eol_conversion): New variables.
Kenichi Handa <handa@m17n.org>
parents:
18613
diff
changeset
|
7749 /* Target FILENAME is the third argument. */ |
17119
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
7750 Fput (Qwrite_region, Qtarget_idx, make_number (2)); |
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
7751 |
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
7752 Qcall_process = intern ("call-process"); |
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
7753 staticpro (&Qcall_process); |
18650
aa3f2820e2ac
(Qemacs_mule, inhibit_eol_conversion): New variables.
Kenichi Handa <handa@m17n.org>
parents:
18613
diff
changeset
|
7754 /* Target PROGRAM is the first argument. */ |
17119
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
7755 Fput (Qcall_process, Qtarget_idx, make_number (0)); |
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
7756 |
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
7757 Qcall_process_region = intern ("call-process-region"); |
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
7758 staticpro (&Qcall_process_region); |
18650
aa3f2820e2ac
(Qemacs_mule, inhibit_eol_conversion): New variables.
Kenichi Handa <handa@m17n.org>
parents:
18613
diff
changeset
|
7759 /* Target PROGRAM is the third argument. */ |
17119
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
7760 Fput (Qcall_process_region, Qtarget_idx, make_number (2)); |
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
7761 |
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
7762 Qstart_process = intern ("start-process"); |
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
7763 staticpro (&Qstart_process); |
18650
aa3f2820e2ac
(Qemacs_mule, inhibit_eol_conversion): New variables.
Kenichi Handa <handa@m17n.org>
parents:
18613
diff
changeset
|
7764 /* Target PROGRAM is the third argument. */ |
17119
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
7765 Fput (Qstart_process, Qtarget_idx, make_number (2)); |
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
7766 |
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
7767 Qopen_network_stream = intern ("open-network-stream"); |
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
7768 staticpro (&Qopen_network_stream); |
18650
aa3f2820e2ac
(Qemacs_mule, inhibit_eol_conversion): New variables.
Kenichi Handa <handa@m17n.org>
parents:
18613
diff
changeset
|
7769 /* Target SERVICE is the fourth argument. */ |
17119
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
7770 Fput (Qopen_network_stream, Qtarget_idx, make_number (3)); |
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
7771 |
17052 | 7772 Qcoding_system = intern ("coding-system"); |
7773 staticpro (&Qcoding_system); | |
7774 | |
7775 Qeol_type = intern ("eol-type"); | |
7776 staticpro (&Qeol_type); | |
7777 | |
7778 Qbuffer_file_coding_system = intern ("buffer-file-coding-system"); | |
7779 staticpro (&Qbuffer_file_coding_system); | |
7780 | |
7781 Qpost_read_conversion = intern ("post-read-conversion"); | |
7782 staticpro (&Qpost_read_conversion); | |
7783 | |
7784 Qpre_write_conversion = intern ("pre-write-conversion"); | |
7785 staticpro (&Qpre_write_conversion); | |
7786 | |
19612
783efd6c7c1e
(Qno_conversion, Qundecided): New variables.
Kenichi Handa <handa@m17n.org>
parents:
19546
diff
changeset
|
7787 Qno_conversion = intern ("no-conversion"); |
783efd6c7c1e
(Qno_conversion, Qundecided): New variables.
Kenichi Handa <handa@m17n.org>
parents:
19546
diff
changeset
|
7788 staticpro (&Qno_conversion); |
783efd6c7c1e
(Qno_conversion, Qundecided): New variables.
Kenichi Handa <handa@m17n.org>
parents:
19546
diff
changeset
|
7789 |
783efd6c7c1e
(Qno_conversion, Qundecided): New variables.
Kenichi Handa <handa@m17n.org>
parents:
19546
diff
changeset
|
7790 Qundecided = intern ("undecided"); |
783efd6c7c1e
(Qno_conversion, Qundecided): New variables.
Kenichi Handa <handa@m17n.org>
parents:
19546
diff
changeset
|
7791 staticpro (&Qundecided); |
783efd6c7c1e
(Qno_conversion, Qundecided): New variables.
Kenichi Handa <handa@m17n.org>
parents:
19546
diff
changeset
|
7792 |
17052 | 7793 Qcoding_system_p = intern ("coding-system-p"); |
7794 staticpro (&Qcoding_system_p); | |
7795 | |
7796 Qcoding_system_error = intern ("coding-system-error"); | |
7797 staticpro (&Qcoding_system_error); | |
7798 | |
7799 Fput (Qcoding_system_error, Qerror_conditions, | |
7800 Fcons (Qcoding_system_error, Fcons (Qerror, Qnil))); | |
7801 Fput (Qcoding_system_error, Qerror_message, | |
18650
aa3f2820e2ac
(Qemacs_mule, inhibit_eol_conversion): New variables.
Kenichi Handa <handa@m17n.org>
parents:
18613
diff
changeset
|
7802 build_string ("Invalid coding system")); |
17052 | 7803 |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
7804 Qcoding_category = intern ("coding-category"); |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
7805 staticpro (&Qcoding_category); |
17052 | 7806 Qcoding_category_index = intern ("coding-category-index"); |
7807 staticpro (&Qcoding_category_index); | |
7808 | |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
7809 Vcoding_category_table |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
7810 = Fmake_vector (make_number (CODING_CATEGORY_IDX_MAX), Qnil); |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
7811 staticpro (&Vcoding_category_table); |
17052 | 7812 { |
7813 int i; | |
7814 for (i = 0; i < CODING_CATEGORY_IDX_MAX; i++) | |
7815 { | |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
7816 XVECTOR (Vcoding_category_table)->contents[i] |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
7817 = intern (coding_category_name[i]); |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
7818 Fput (XVECTOR (Vcoding_category_table)->contents[i], |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
7819 Qcoding_category_index, make_number (i)); |
17052 | 7820 } |
7821 } | |
7822 | |
49539
1ad5bfbb831a
(syms_of_coding): Add `...' for symbols in the docstring of
Kenichi Handa <handa@m17n.org>
parents:
48874
diff
changeset
|
7823 Vcoding_system_safe_chars = Fcons (Qnil, Qnil); |
1ad5bfbb831a
(syms_of_coding): Add `...' for symbols in the docstring of
Kenichi Handa <handa@m17n.org>
parents:
48874
diff
changeset
|
7824 staticpro (&Vcoding_system_safe_chars); |
1ad5bfbb831a
(syms_of_coding): Add `...' for symbols in the docstring of
Kenichi Handa <handa@m17n.org>
parents:
48874
diff
changeset
|
7825 |
22186
fc4aaf1b1772
Change term "character translation table" to "translation table".
Kenichi Handa <handa@m17n.org>
parents:
22166
diff
changeset
|
7826 Qtranslation_table = intern ("translation-table"); |
fc4aaf1b1772
Change term "character translation table" to "translation table".
Kenichi Handa <handa@m17n.org>
parents:
22166
diff
changeset
|
7827 staticpro (&Qtranslation_table); |
50765
43076e9d9aaa
(coding_system_accept_latin_extra_p): Delete this
Kenichi Handa <handa@m17n.org>
parents:
50487
diff
changeset
|
7828 Fput (Qtranslation_table, Qchar_table_extra_slots, make_number (2)); |
22186
fc4aaf1b1772
Change term "character translation table" to "translation table".
Kenichi Handa <handa@m17n.org>
parents:
22166
diff
changeset
|
7829 |
fc4aaf1b1772
Change term "character translation table" to "translation table".
Kenichi Handa <handa@m17n.org>
parents:
22166
diff
changeset
|
7830 Qtranslation_table_id = intern ("translation-table-id"); |
fc4aaf1b1772
Change term "character translation table" to "translation table".
Kenichi Handa <handa@m17n.org>
parents:
22166
diff
changeset
|
7831 staticpro (&Qtranslation_table_id); |
fc4aaf1b1772
Change term "character translation table" to "translation table".
Kenichi Handa <handa@m17n.org>
parents:
22166
diff
changeset
|
7832 |
fc4aaf1b1772
Change term "character translation table" to "translation table".
Kenichi Handa <handa@m17n.org>
parents:
22166
diff
changeset
|
7833 Qtranslation_table_for_decode = intern ("translation-table-for-decode"); |
fc4aaf1b1772
Change term "character translation table" to "translation table".
Kenichi Handa <handa@m17n.org>
parents:
22166
diff
changeset
|
7834 staticpro (&Qtranslation_table_for_decode); |
fc4aaf1b1772
Change term "character translation table" to "translation table".
Kenichi Handa <handa@m17n.org>
parents:
22166
diff
changeset
|
7835 |
fc4aaf1b1772
Change term "character translation table" to "translation table".
Kenichi Handa <handa@m17n.org>
parents:
22166
diff
changeset
|
7836 Qtranslation_table_for_encode = intern ("translation-table-for-encode"); |
fc4aaf1b1772
Change term "character translation table" to "translation table".
Kenichi Handa <handa@m17n.org>
parents:
22166
diff
changeset
|
7837 staticpro (&Qtranslation_table_for_encode); |
18536
69c0e220b626
(Vstandard_character_unification_table_for_decode):
Kenichi Handa <handa@m17n.org>
parents:
18523
diff
changeset
|
7838 |
30487
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
7839 Qsafe_chars = intern ("safe-chars"); |
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
7840 staticpro (&Qsafe_chars); |
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
7841 |
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
7842 Qchar_coding_system = intern ("char-coding-system"); |
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
7843 staticpro (&Qchar_coding_system); |
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
7844 |
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
7845 /* Intern this now in case it isn't already done. |
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
7846 Setting this variable twice is harmless. |
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
7847 But don't staticpro it here--that is done in alloc.c. */ |
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
7848 Qchar_table_extra_slots = intern ("char-table-extra-slots"); |
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
7849 Fput (Qsafe_chars, Qchar_table_extra_slots, make_number (0)); |
50185
b64f1af6e142
(Vchar_coding_system_table): Remove this variable.
Kenichi Handa <handa@m17n.org>
parents:
50121
diff
changeset
|
7850 Fput (Qchar_coding_system, Qchar_table_extra_slots, make_number (0)); |
20150
402b6e5f4b58
(encode_designation_at_bol): Fix bug of finding graphic
Kenichi Handa <handa@m17n.org>
parents:
20105
diff
changeset
|
7851 |
22874
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
7852 Qvalid_codes = intern ("valid-codes"); |
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
7853 staticpro (&Qvalid_codes); |
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
7854 |
70704
576f5c8ea6e4
(Qascii_incompatible): New variable.
Kenichi Handa <handa@m17n.org>
parents:
70520
diff
changeset
|
7855 Qascii_incompatible = intern ("ascii-incompatible"); |
576f5c8ea6e4
(Qascii_incompatible): New variable.
Kenichi Handa <handa@m17n.org>
parents:
70520
diff
changeset
|
7856 staticpro (&Qascii_incompatible); |
576f5c8ea6e4
(Qascii_incompatible): New variable.
Kenichi Handa <handa@m17n.org>
parents:
70520
diff
changeset
|
7857 |
18650
aa3f2820e2ac
(Qemacs_mule, inhibit_eol_conversion): New variables.
Kenichi Handa <handa@m17n.org>
parents:
18613
diff
changeset
|
7858 Qemacs_mule = intern ("emacs-mule"); |
aa3f2820e2ac
(Qemacs_mule, inhibit_eol_conversion): New variables.
Kenichi Handa <handa@m17n.org>
parents:
18613
diff
changeset
|
7859 staticpro (&Qemacs_mule); |
aa3f2820e2ac
(Qemacs_mule, inhibit_eol_conversion): New variables.
Kenichi Handa <handa@m17n.org>
parents:
18613
diff
changeset
|
7860 |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
7861 Qraw_text = intern ("raw-text"); |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
7862 staticpro (&Qraw_text); |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
7863 |
51406 | 7864 Qutf_8 = intern ("utf-8"); |
7865 staticpro (&Qutf_8); | |
7866 | |
52794
f4d906e31662
(Qcoding_system_define_form): New variable.
Kenichi Handa <handa@m17n.org>
parents:
52401
diff
changeset
|
7867 Qcoding_system_define_form = intern ("coding-system-define-form"); |
f4d906e31662
(Qcoding_system_define_form): New variable.
Kenichi Handa <handa@m17n.org>
parents:
52401
diff
changeset
|
7868 staticpro (&Qcoding_system_define_form); |
f4d906e31662
(Qcoding_system_define_form): New variable.
Kenichi Handa <handa@m17n.org>
parents:
52401
diff
changeset
|
7869 |
17052 | 7870 defsubr (&Scoding_system_p); |
7871 defsubr (&Sread_coding_system); | |
7872 defsubr (&Sread_non_nil_coding_system); | |
7873 defsubr (&Scheck_coding_system); | |
7874 defsubr (&Sdetect_coding_region); | |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
7875 defsubr (&Sdetect_coding_string); |
30487
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
7876 defsubr (&Sfind_coding_systems_region_internal); |
46859
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
7877 defsubr (&Sunencodable_char_position); |
17052 | 7878 defsubr (&Sdecode_coding_region); |
7879 defsubr (&Sencode_coding_region); | |
7880 defsubr (&Sdecode_coding_string); | |
7881 defsubr (&Sencode_coding_string); | |
7882 defsubr (&Sdecode_sjis_char); | |
7883 defsubr (&Sencode_sjis_char); | |
7884 defsubr (&Sdecode_big5_char); | |
7885 defsubr (&Sencode_big5_char); | |
18002
a14261786239
(encode_invocation_designation): Use macro
Kenichi Handa <handa@m17n.org>
parents:
17835
diff
changeset
|
7886 defsubr (&Sset_terminal_coding_system_internal); |
19280
e755044718ee
(ENCODE_ISO_CHARACTER_DIMENSION1): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
19193
diff
changeset
|
7887 defsubr (&Sset_safe_terminal_coding_system_internal); |
17052 | 7888 defsubr (&Sterminal_coding_system); |
18002
a14261786239
(encode_invocation_designation): Use macro
Kenichi Handa <handa@m17n.org>
parents:
17835
diff
changeset
|
7889 defsubr (&Sset_keyboard_coding_system_internal); |
17052 | 7890 defsubr (&Skeyboard_coding_system); |
18536
69c0e220b626
(Vstandard_character_unification_table_for_decode):
Kenichi Handa <handa@m17n.org>
parents:
18523
diff
changeset
|
7891 defsubr (&Sfind_operation_coding_system); |
22874
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
7892 defsubr (&Supdate_coding_systems_internal); |
22226
557fac086b1b
(ascii_skip_code): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22186
diff
changeset
|
7893 defsubr (&Sset_coding_priority_internal); |
49539
1ad5bfbb831a
(syms_of_coding): Add `...' for symbols in the docstring of
Kenichi Handa <handa@m17n.org>
parents:
48874
diff
changeset
|
7894 defsubr (&Sdefine_coding_system_internal); |
17052 | 7895 |
20105
c017642863c2
(Qcoding_system_spec): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
19824
diff
changeset
|
7896 DEFVAR_LISP ("coding-system-list", &Vcoding_system_list, |
40713
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
7897 doc: /* List of coding systems. |
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
7898 |
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
7899 Do not alter the value of this variable manually. This variable should be |
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
7900 updated by the functions `make-coding-system' and |
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
7901 `define-coding-system-alias'. */); |
20105
c017642863c2
(Qcoding_system_spec): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
19824
diff
changeset
|
7902 Vcoding_system_list = Qnil; |
c017642863c2
(Qcoding_system_spec): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
19824
diff
changeset
|
7903 |
c017642863c2
(Qcoding_system_spec): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
19824
diff
changeset
|
7904 DEFVAR_LISP ("coding-system-alist", &Vcoding_system_alist, |
40713
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
7905 doc: /* Alist of coding system names. |
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
7906 Each element is one element list of coding system name. |
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
7907 This variable is given to `completing-read' as TABLE argument. |
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
7908 |
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
7909 Do not alter the value of this variable manually. This variable should be |
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
7910 updated by the functions `make-coding-system' and |
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
7911 `define-coding-system-alias'. */); |
20105
c017642863c2
(Qcoding_system_spec): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
19824
diff
changeset
|
7912 Vcoding_system_alist = Qnil; |
c017642863c2
(Qcoding_system_spec): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
19824
diff
changeset
|
7913 |
17052 | 7914 DEFVAR_LISP ("coding-category-list", &Vcoding_category_list, |
40713
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
7915 doc: /* List of coding-categories (symbols) ordered by priority. |
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
7916 |
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
7917 On detecting a coding system, Emacs tries code detection algorithms |
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
7918 associated with each coding-category one by one in this order. When |
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
7919 one algorithm agrees with a byte sequence of source text, the coding |
60608
4b80e9c28e8f
(syms_of_coding): Docstring of coding-category-list fixed.
Kenichi Handa <handa@m17n.org>
parents:
60031
diff
changeset
|
7920 system bound to the corresponding coding-category is selected. |
4b80e9c28e8f
(syms_of_coding): Docstring of coding-category-list fixed.
Kenichi Handa <handa@m17n.org>
parents:
60031
diff
changeset
|
7921 |
61166
e3a6dd630fdf
(Vcoding_category_list): Docstring fix.
Kenichi Handa <handa@m17n.org>
parents:
60907
diff
changeset
|
7922 Don't modify this variable directly, but use `set-coding-priority'. */); |
17052 | 7923 { |
7924 int i; | |
7925 | |
7926 Vcoding_category_list = Qnil; | |
7927 for (i = CODING_CATEGORY_IDX_MAX - 1; i >= 0; i--) | |
7928 Vcoding_category_list | |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
7929 = Fcons (XVECTOR (Vcoding_category_table)->contents[i], |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
7930 Vcoding_category_list); |
17052 | 7931 } |
7932 | |
7933 DEFVAR_LISP ("coding-system-for-read", &Vcoding_system_for_read, | |
40713
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
7934 doc: /* Specify the coding system for read operations. |
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
7935 It is useful to bind this variable with `let', but do not set it globally. |
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
7936 If the value is a coding system, it is used for decoding on read operation. |
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
7937 If not, an appropriate element is used from one of the coding system alists: |
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
7938 There are three such tables, `file-coding-system-alist', |
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
7939 `process-coding-system-alist', and `network-coding-system-alist'. */); |
17052 | 7940 Vcoding_system_for_read = Qnil; |
7941 | |
7942 DEFVAR_LISP ("coding-system-for-write", &Vcoding_system_for_write, | |
40713
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
7943 doc: /* Specify the coding system for write operations. |
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
7944 Programs bind this variable with `let', but you should not set it globally. |
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
7945 If the value is a coding system, it is used for encoding of output, |
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
7946 when writing it to a file and when sending it to a file or subprocess. |
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
7947 |
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
7948 If this does not specify a coding system, an appropriate element |
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
7949 is used from one of the coding system alists: |
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
7950 There are three such tables, `file-coding-system-alist', |
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
7951 `process-coding-system-alist', and `network-coding-system-alist'. |
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
7952 For output to files, if the above procedure does not specify a coding system, |
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
7953 the value of `buffer-file-coding-system' is used. */); |
17052 | 7954 Vcoding_system_for_write = Qnil; |
7955 | |
7956 DEFVAR_LISP ("last-coding-system-used", &Vlast_coding_system_used, | |
50896
0aba658cfdd2
(Vlast_coding_system_used): Doc fix.
Dave Love <fx@gnu.org>
parents:
50765
diff
changeset
|
7957 doc: /* Coding system used in the latest file or process I/O. |
0aba658cfdd2
(Vlast_coding_system_used): Doc fix.
Dave Love <fx@gnu.org>
parents:
50765
diff
changeset
|
7958 Also set by `encode-coding-region', `decode-coding-region', |
0aba658cfdd2
(Vlast_coding_system_used): Doc fix.
Dave Love <fx@gnu.org>
parents:
50765
diff
changeset
|
7959 `encode-coding-string' and `decode-coding-string'. */); |
17052 | 7960 Vlast_coding_system_used = Qnil; |
7961 | |
18650
aa3f2820e2ac
(Qemacs_mule, inhibit_eol_conversion): New variables.
Kenichi Handa <handa@m17n.org>
parents:
18613
diff
changeset
|
7962 DEFVAR_BOOL ("inhibit-eol-conversion", &inhibit_eol_conversion, |
40713
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
7963 doc: /* *Non-nil means always inhibit code conversion of end-of-line format. |
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
7964 See info node `Coding Systems' and info node `Text and Binary' concerning |
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
7965 such conversion. */); |
18650
aa3f2820e2ac
(Qemacs_mule, inhibit_eol_conversion): New variables.
Kenichi Handa <handa@m17n.org>
parents:
18613
diff
changeset
|
7966 inhibit_eol_conversion = 0; |
aa3f2820e2ac
(Qemacs_mule, inhibit_eol_conversion): New variables.
Kenichi Handa <handa@m17n.org>
parents:
18613
diff
changeset
|
7967 |
21574
30394e3ae7f8
(syms_of_coding): Declare and define inherit-process-coding-system.
Eli Zaretskii <eliz@gnu.org>
parents:
21520
diff
changeset
|
7968 DEFVAR_BOOL ("inherit-process-coding-system", &inherit_process_coding_system, |
40713
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
7969 doc: /* Non-nil means process buffer inherits coding system of process output. |
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
7970 Bind it to t if the process output is to be treated as if it were a file |
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
7971 read from some filesystem. */); |
21574
30394e3ae7f8
(syms_of_coding): Declare and define inherit-process-coding-system.
Eli Zaretskii <eliz@gnu.org>
parents:
21520
diff
changeset
|
7972 inherit_process_coding_system = 0; |
30394e3ae7f8
(syms_of_coding): Declare and define inherit-process-coding-system.
Eli Zaretskii <eliz@gnu.org>
parents:
21520
diff
changeset
|
7973 |
18180
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
7974 DEFVAR_LISP ("file-coding-system-alist", &Vfile_coding_system_alist, |
40713
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
7975 doc: /* Alist to decide a coding system to use for a file I/O operation. |
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
7976 The format is ((PATTERN . VAL) ...), |
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
7977 where PATTERN is a regular expression matching a file name, |
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
7978 VAL is a coding system, a cons of coding systems, or a function symbol. |
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
7979 If VAL is a coding system, it is used for both decoding and encoding |
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
7980 the file contents. |
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
7981 If VAL is a cons of coding systems, the car part is used for decoding, |
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
7982 and the cdr part is used for encoding. |
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
7983 If VAL is a function symbol, the function must return a coding system |
72323
af796bc81ff0
(syms_of_coding): Improve the docstring
Kenichi Handa <handa@m17n.org>
parents:
72188
diff
changeset
|
7984 or a cons of coding systems which are used as above. The function is |
af796bc81ff0
(syms_of_coding): Improve the docstring
Kenichi Handa <handa@m17n.org>
parents:
72188
diff
changeset
|
7985 called with an argument that is a list of the arguments with which |
81611
ae42ad5f89e6
(Ffind_operation_coding_system): Docstring improved.
Kenichi Handa <handa@m17n.org>
parents:
75348
diff
changeset
|
7986 `find-operation-coding-system' was called. If the function can't decide |
ae42ad5f89e6
(Ffind_operation_coding_system): Docstring improved.
Kenichi Handa <handa@m17n.org>
parents:
75348
diff
changeset
|
7987 a coding system, it can return `undecided' so that the normal |
ae42ad5f89e6
(Ffind_operation_coding_system): Docstring improved.
Kenichi Handa <handa@m17n.org>
parents:
75348
diff
changeset
|
7988 code-detection is performed. |
40713
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
7989 |
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
7990 See also the function `find-operation-coding-system' |
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
7991 and the variable `auto-coding-alist'. */); |
18180
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
7992 Vfile_coding_system_alist = Qnil; |
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
7993 |
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
7994 DEFVAR_LISP ("process-coding-system-alist", &Vprocess_coding_system_alist, |
40713
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
7995 doc: /* Alist to decide a coding system to use for a process I/O operation. |
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
7996 The format is ((PATTERN . VAL) ...), |
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
7997 where PATTERN is a regular expression matching a program name, |
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
7998 VAL is a coding system, a cons of coding systems, or a function symbol. |
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
7999 If VAL is a coding system, it is used for both decoding what received |
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
8000 from the program and encoding what sent to the program. |
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
8001 If VAL is a cons of coding systems, the car part is used for decoding, |
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
8002 and the cdr part is used for encoding. |
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
8003 If VAL is a function symbol, the function must return a coding system |
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
8004 or a cons of coding systems which are used as above. |
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
8005 |
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
8006 See also the function `find-operation-coding-system'. */); |
18180
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
8007 Vprocess_coding_system_alist = Qnil; |
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
8008 |
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
8009 DEFVAR_LISP ("network-coding-system-alist", &Vnetwork_coding_system_alist, |
40713
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
8010 doc: /* Alist to decide a coding system to use for a network I/O operation. |
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
8011 The format is ((PATTERN . VAL) ...), |
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
8012 where PATTERN is a regular expression matching a network service name |
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
8013 or is a port number to connect to, |
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
8014 VAL is a coding system, a cons of coding systems, or a function symbol. |
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
8015 If VAL is a coding system, it is used for both decoding what received |
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
8016 from the network stream and encoding what sent to the network stream. |
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
8017 If VAL is a cons of coding systems, the car part is used for decoding, |
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
8018 and the cdr part is used for encoding. |
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
8019 If VAL is a function symbol, the function must return a coding system |
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
8020 or a cons of coding systems which are used as above. |
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
8021 |
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
8022 See also the function `find-operation-coding-system'. */); |
18180
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
8023 Vnetwork_coding_system_alist = Qnil; |
17052 | 8024 |
26088
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
26067
diff
changeset
|
8025 DEFVAR_LISP ("locale-coding-system", &Vlocale_coding_system, |
41026
6f20449b7e12
(syms_of_coding): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
41006
diff
changeset
|
8026 doc: /* Coding system to use with system messages. |
6f20449b7e12
(syms_of_coding): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
41006
diff
changeset
|
8027 Also used for decoding keyboard input on X Window system. */); |
26088
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
26067
diff
changeset
|
8028 Vlocale_coding_system = Qnil; |
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
26067
diff
changeset
|
8029 |
29182
1d1c27067af4
(encode_eol): Add null statement after label.
Dave Love <fx@gnu.org>
parents:
29172
diff
changeset
|
8030 /* The eol mnemonics are reset in startup.el system-dependently. */ |
24200
b9d9fccad516
(syms_of_coding): eol-mnemonic-* variables are now
Eli Zaretskii <eliz@gnu.org>
parents:
24178
diff
changeset
|
8031 DEFVAR_LISP ("eol-mnemonic-unix", &eol_mnemonic_unix, |
40713
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
8032 doc: /* *String displayed in mode line for UNIX-like (LF) end-of-line format. */); |
24200
b9d9fccad516
(syms_of_coding): eol-mnemonic-* variables are now
Eli Zaretskii <eliz@gnu.org>
parents:
24178
diff
changeset
|
8033 eol_mnemonic_unix = build_string (":"); |
b9d9fccad516
(syms_of_coding): eol-mnemonic-* variables are now
Eli Zaretskii <eliz@gnu.org>
parents:
24178
diff
changeset
|
8034 |
b9d9fccad516
(syms_of_coding): eol-mnemonic-* variables are now
Eli Zaretskii <eliz@gnu.org>
parents:
24178
diff
changeset
|
8035 DEFVAR_LISP ("eol-mnemonic-dos", &eol_mnemonic_dos, |
40713
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
8036 doc: /* *String displayed in mode line for DOS-like (CRLF) end-of-line format. */); |
24200
b9d9fccad516
(syms_of_coding): eol-mnemonic-* variables are now
Eli Zaretskii <eliz@gnu.org>
parents:
24178
diff
changeset
|
8037 eol_mnemonic_dos = build_string ("\\"); |
b9d9fccad516
(syms_of_coding): eol-mnemonic-* variables are now
Eli Zaretskii <eliz@gnu.org>
parents:
24178
diff
changeset
|
8038 |
b9d9fccad516
(syms_of_coding): eol-mnemonic-* variables are now
Eli Zaretskii <eliz@gnu.org>
parents:
24178
diff
changeset
|
8039 DEFVAR_LISP ("eol-mnemonic-mac", &eol_mnemonic_mac, |
40713
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
8040 doc: /* *String displayed in mode line for MAC-like (CR) end-of-line format. */); |
24200
b9d9fccad516
(syms_of_coding): eol-mnemonic-* variables are now
Eli Zaretskii <eliz@gnu.org>
parents:
24178
diff
changeset
|
8041 eol_mnemonic_mac = build_string ("/"); |
b9d9fccad516
(syms_of_coding): eol-mnemonic-* variables are now
Eli Zaretskii <eliz@gnu.org>
parents:
24178
diff
changeset
|
8042 |
b9d9fccad516
(syms_of_coding): eol-mnemonic-* variables are now
Eli Zaretskii <eliz@gnu.org>
parents:
24178
diff
changeset
|
8043 DEFVAR_LISP ("eol-mnemonic-undecided", &eol_mnemonic_undecided, |
40713
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
8044 doc: /* *String displayed in mode line when end-of-line format is not yet determined. */); |
24200
b9d9fccad516
(syms_of_coding): eol-mnemonic-* variables are now
Eli Zaretskii <eliz@gnu.org>
parents:
24178
diff
changeset
|
8045 eol_mnemonic_undecided = build_string (":"); |
17052 | 8046 |
22119
592bb8b9bcfd
Change terms unify/unification to
Kenichi Handa <handa@m17n.org>
parents:
22020
diff
changeset
|
8047 DEFVAR_LISP ("enable-character-translation", &Venable_character_translation, |
40713
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
8048 doc: /* *Non-nil enables character translation while encoding and decoding. */); |
22119
592bb8b9bcfd
Change terms unify/unification to
Kenichi Handa <handa@m17n.org>
parents:
22020
diff
changeset
|
8049 Venable_character_translation = Qt; |
592bb8b9bcfd
Change terms unify/unification to
Kenichi Handa <handa@m17n.org>
parents:
22020
diff
changeset
|
8050 |
22186
fc4aaf1b1772
Change term "character translation table" to "translation table".
Kenichi Handa <handa@m17n.org>
parents:
22166
diff
changeset
|
8051 DEFVAR_LISP ("standard-translation-table-for-decode", |
40713
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
8052 &Vstandard_translation_table_for_decode, |
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
8053 doc: /* Table for translating characters while decoding. */); |
22186
fc4aaf1b1772
Change term "character translation table" to "translation table".
Kenichi Handa <handa@m17n.org>
parents:
22166
diff
changeset
|
8054 Vstandard_translation_table_for_decode = Qnil; |
fc4aaf1b1772
Change term "character translation table" to "translation table".
Kenichi Handa <handa@m17n.org>
parents:
22166
diff
changeset
|
8055 |
fc4aaf1b1772
Change term "character translation table" to "translation table".
Kenichi Handa <handa@m17n.org>
parents:
22166
diff
changeset
|
8056 DEFVAR_LISP ("standard-translation-table-for-encode", |
40713
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
8057 &Vstandard_translation_table_for_encode, |
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
8058 doc: /* Table for translating characters while encoding. */); |
22186
fc4aaf1b1772
Change term "character translation table" to "translation table".
Kenichi Handa <handa@m17n.org>
parents:
22166
diff
changeset
|
8059 Vstandard_translation_table_for_encode = Qnil; |
17052 | 8060 |
8061 DEFVAR_LISP ("charset-revision-table", &Vcharset_revision_alist, | |
40713
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
8062 doc: /* Alist of charsets vs revision numbers. |
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
8063 While encoding, if a charset (car part of an element) is found, |
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
8064 designate it with the escape sequence identifying revision (cdr part of the element). */); |
17052 | 8065 Vcharset_revision_alist = Qnil; |
18180
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
8066 |
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
8067 DEFVAR_LISP ("default-process-coding-system", |
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
8068 &Vdefault_process_coding_system, |
40713
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
8069 doc: /* Cons of coding systems used for process I/O by default. |
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
8070 The car part is used for decoding a process output, |
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
8071 the cdr part is used for encoding a text to be sent to a process. */); |
18180
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
8072 Vdefault_process_coding_system = Qnil; |
19280
e755044718ee
(ENCODE_ISO_CHARACTER_DIMENSION1): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
19193
diff
changeset
|
8073 |
19365
d9374f5ebd3a
(CODING_FLAG_ISO_LATIN_EXTRA): New macro.
Kenichi Handa <handa@m17n.org>
parents:
19285
diff
changeset
|
8074 DEFVAR_LISP ("latin-extra-code-table", &Vlatin_extra_code_table, |
40713
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
8075 doc: /* Table of extra Latin codes in the range 128..159 (inclusive). |
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
8076 This is a vector of length 256. |
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
8077 If Nth element is non-nil, the existence of code N in a file |
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
8078 \(or output of subprocess) doesn't prevent it to be detected as |
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
8079 a coding system of ISO 2022 variant which has a flag |
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
8080 `accept-latin-extra-code' t (e.g. iso-latin-1) on reading a file |
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
8081 or reading output of a subprocess. |
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
8082 Only 128th through 159th elements has a meaning. */); |
19365
d9374f5ebd3a
(CODING_FLAG_ISO_LATIN_EXTRA): New macro.
Kenichi Handa <handa@m17n.org>
parents:
19285
diff
changeset
|
8083 Vlatin_extra_code_table = Fmake_vector (make_number (256), Qnil); |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
8084 |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
8085 DEFVAR_LISP ("select-safe-coding-system-function", |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
8086 &Vselect_safe_coding_system_function, |
40713
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
8087 doc: /* Function to call to select safe coding system for encoding a text. |
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
8088 |
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
8089 If set, this function is called to force a user to select a proper |
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
8090 coding system which can encode the text in the case that a default |
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
8091 coding system used in each operation can't encode the text. |
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
8092 |
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
8093 The default value is `select-safe-coding-system' (which see). */); |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
8094 Vselect_safe_coding_system_function = Qnil; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
8095 |
48874
3002a87cc629
(coding_system_require_warning): New variable.
Kenichi Handa <handa@m17n.org>
parents:
48829
diff
changeset
|
8096 DEFVAR_BOOL ("coding-system-require-warning", |
3002a87cc629
(coding_system_require_warning): New variable.
Kenichi Handa <handa@m17n.org>
parents:
48829
diff
changeset
|
8097 &coding_system_require_warning, |
3002a87cc629
(coding_system_require_warning): New variable.
Kenichi Handa <handa@m17n.org>
parents:
48829
diff
changeset
|
8098 doc: /* Internal use only. |
49539
1ad5bfbb831a
(syms_of_coding): Add `...' for symbols in the docstring of
Kenichi Handa <handa@m17n.org>
parents:
48874
diff
changeset
|
8099 If non-nil, on writing a file, `select-safe-coding-system-function' is |
1ad5bfbb831a
(syms_of_coding): Add `...' for symbols in the docstring of
Kenichi Handa <handa@m17n.org>
parents:
48874
diff
changeset
|
8100 called even if `coding-system-for-write' is non-nil. The command |
1ad5bfbb831a
(syms_of_coding): Add `...' for symbols in the docstring of
Kenichi Handa <handa@m17n.org>
parents:
48874
diff
changeset
|
8101 `universal-coding-system-argument' binds this variable to t temporarily. */); |
48874
3002a87cc629
(coding_system_require_warning): New variable.
Kenichi Handa <handa@m17n.org>
parents:
48829
diff
changeset
|
8102 coding_system_require_warning = 0; |
3002a87cc629
(coding_system_require_warning): New variable.
Kenichi Handa <handa@m17n.org>
parents:
48829
diff
changeset
|
8103 |
3002a87cc629
(coding_system_require_warning): New variable.
Kenichi Handa <handa@m17n.org>
parents:
48829
diff
changeset
|
8104 |
30292
14a9937df1f5
(syms_of_coding): Fix typo in spelling of variable
Gerd Moellmann <gerd@gnu.org>
parents:
30263
diff
changeset
|
8105 DEFVAR_BOOL ("inhibit-iso-escape-detection", |
30204
35aec8514228
(inhibit_iso_escape_detection): New variable.
Kenichi Handa <handa@m17n.org>
parents:
29985
diff
changeset
|
8106 &inhibit_iso_escape_detection, |
40713
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
8107 doc: /* If non-nil, Emacs ignores ISO2022's escape sequence on code detection. |
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
8108 |
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
8109 By default, on reading a file, Emacs tries to detect how the text is |
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
8110 encoded. This code detection is sensitive to escape sequences. If |
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
8111 the sequence is valid as ISO2022, the code is determined as one of |
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
8112 the ISO2022 encodings, and the file is decoded by the corresponding |
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
8113 coding system (e.g. `iso-2022-7bit'). |
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
8114 |
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
8115 However, there may be a case that you want to read escape sequences in |
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
8116 a file as is. In such a case, you can set this variable to non-nil. |
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
8117 Then, as the code detection ignores any escape sequences, no file is |
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
8118 detected as encoded in some ISO2022 encoding. The result is that all |
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
8119 escape sequences become visible in a buffer. |
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
8120 |
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
8121 The default value is nil, and it is strongly recommended not to change |
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
8122 it. That is because many Emacs Lisp source files that contain |
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
8123 non-ASCII characters are encoded by the coding system `iso-2022-7bit' |
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
8124 in Emacs's distribution, and they won't be decoded correctly on |
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
8125 reading if you suppress escape sequence detection. |
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
8126 |
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
8127 The other way to read escape sequences in a file without decoding is |
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
8128 to explicitly specify some coding system that doesn't use ISO2022's |
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
8129 escape sequence (e.g `latin-1') on reading by \\[universal-coding-system-argument]. */); |
30204
35aec8514228
(inhibit_iso_escape_detection): New variable.
Kenichi Handa <handa@m17n.org>
parents:
29985
diff
changeset
|
8130 inhibit_iso_escape_detection = 0; |
48182
9474e269efd1
Reformat some DEFUNs so that etags works.
Dave Love <fx@gnu.org>
parents:
48125
diff
changeset
|
8131 |
9474e269efd1
Reformat some DEFUNs so that etags works.
Dave Love <fx@gnu.org>
parents:
48125
diff
changeset
|
8132 DEFVAR_LISP ("translation-table-for-input", &Vtranslation_table_for_input, |
48230
c2ce8280fb97
(Vtranslation_table_for_input): New.
Dave Love <fx@gnu.org>
parents:
48182
diff
changeset
|
8133 doc: /* Char table for translating self-inserting characters. |
c2ce8280fb97
(Vtranslation_table_for_input): New.
Dave Love <fx@gnu.org>
parents:
48182
diff
changeset
|
8134 This is applied to the result of input methods, not their input. See also |
c2ce8280fb97
(Vtranslation_table_for_input): New.
Dave Love <fx@gnu.org>
parents:
48182
diff
changeset
|
8135 `keyboard-translate-table'. */); |
48182
9474e269efd1
Reformat some DEFUNs so that etags works.
Dave Love <fx@gnu.org>
parents:
48125
diff
changeset
|
8136 Vtranslation_table_for_input = Qnil; |
17052 | 8137 } |
8138 | |
26088
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
26067
diff
changeset
|
8139 char * |
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
26067
diff
changeset
|
8140 emacs_strerror (error_number) |
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
26067
diff
changeset
|
8141 int error_number; |
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
26067
diff
changeset
|
8142 { |
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
26067
diff
changeset
|
8143 char *str; |
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
26067
diff
changeset
|
8144 |
26526
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26240
diff
changeset
|
8145 synchronize_system_messages_locale (); |
26088
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
26067
diff
changeset
|
8146 str = strerror (error_number); |
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
26067
diff
changeset
|
8147 |
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
26067
diff
changeset
|
8148 if (! NILP (Vlocale_coding_system)) |
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
26067
diff
changeset
|
8149 { |
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
26067
diff
changeset
|
8150 Lisp_Object dec = code_convert_string_norecord (build_string (str), |
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
26067
diff
changeset
|
8151 Vlocale_coding_system, |
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
26067
diff
changeset
|
8152 0); |
46370
40db0673e6f0
Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents:
46293
diff
changeset
|
8153 str = (char *) SDATA (dec); |
26088
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
26067
diff
changeset
|
8154 } |
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
26067
diff
changeset
|
8155 |
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
26067
diff
changeset
|
8156 return str; |
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
26067
diff
changeset
|
8157 } |
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
26067
diff
changeset
|
8158 |
17052 | 8159 #endif /* emacs */ |
29184 | 8160 |
52401 | 8161 /* arch-tag: 3a3a2b01-5ff6-4071-9afe-f5b808d9229d |
8162 (do not change this comment) */ |