Mercurial > emacs
annotate src/coding.c @ 110415:5bbd74302c45
src/Changelog: Merge two last entries.
author | Eli Zaretskii <eliz@gnu.org> |
---|---|
date | Sat, 18 Sep 2010 16:23:29 +0200 |
parents | 41bf9b6f3b91 |
children | bec49af30c2f |
rev | line source |
---|---|
88936 | 1 /* Coding system handler (conversion, detection, 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, |
106815 | 3 2006, 2007, 2008, 2009, 2010 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, |
106815 | 5 2005, 2006, 2007, 2008, 2009, 2010 |
67658 | 6 National Institute of Advanced Industrial Science and Technology (AIST) |
7 Registration Number H14PRO021 | |
89483 | 8 Copyright (C) 2003 |
88365 | 9 National Institute of Advanced Industrial Science and Technology (AIST) |
10 Registration Number H13PRO009 | |
17052 | 11 |
17071 | 12 This file is part of GNU Emacs. |
13 | |
94963
8971ddf55736
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
94944
diff
changeset
|
14 GNU Emacs is free software: you can redistribute it and/or modify |
17071 | 15 it under the terms of the GNU General Public License as published by |
94963
8971ddf55736
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
94944
diff
changeset
|
16 the Free Software Foundation, either version 3 of the License, or |
8971ddf55736
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
94944
diff
changeset
|
17 (at your option) any later version. |
17071 | 18 |
19 GNU Emacs is distributed in the hope that it will be useful, | |
20 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
21 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
22 GNU General Public License for more details. | |
23 | |
24 You should have received a copy of the GNU General Public License | |
94963
8971ddf55736
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
94944
diff
changeset
|
25 along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ |
17052 | 26 |
27 /*** TABLE OF CONTENTS *** | |
28 | |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
29 0. General comments |
17052 | 30 1. Preamble |
88365 | 31 2. Emacs' internal format (emacs-utf-8) handlers |
32 3. UTF-8 handlers | |
33 4. UTF-16 handlers | |
34 5. Charset-base coding systems handlers | |
35 6. emacs-mule (old Emacs' internal format) handlers | |
36 7. ISO2022 handlers | |
37 8. Shift-JIS and BIG5 handlers | |
38 9. CCL handlers | |
39 10. C library functions | |
40 11. Emacs Lisp library functions | |
41 12. Postamble | |
17052 | 42 |
43 */ | |
44 | |
88365 | 45 /*** 0. General comments *** |
46 | |
47 | |
48 CODING SYSTEM | |
49 | |
88485 | 50 A coding system is an object for an encoding mechanism that contains |
51 information about how to convert byte sequences to character | |
88438
3a34b722dd71
(encode_coding_utf_8): Initialize produced_chars to 0.
Kenichi Handa <handa@m17n.org>
parents:
88430
diff
changeset
|
52 sequences and vice versa. When we say "decode", it means converting |
3a34b722dd71
(encode_coding_utf_8): Initialize produced_chars to 0.
Kenichi Handa <handa@m17n.org>
parents:
88430
diff
changeset
|
53 a byte sequence of a specific coding system into a character |
3a34b722dd71
(encode_coding_utf_8): Initialize produced_chars to 0.
Kenichi Handa <handa@m17n.org>
parents:
88430
diff
changeset
|
54 sequence that is represented by Emacs' internal coding system |
3a34b722dd71
(encode_coding_utf_8): Initialize produced_chars to 0.
Kenichi Handa <handa@m17n.org>
parents:
88430
diff
changeset
|
55 `emacs-utf-8', and when we say "encode", it means converting a |
3a34b722dd71
(encode_coding_utf_8): Initialize produced_chars to 0.
Kenichi Handa <handa@m17n.org>
parents:
88430
diff
changeset
|
56 character sequence of emacs-utf-8 to a byte sequence of a specific |
17835
f36ffb6f1208
Name change through the code:
Kenichi Handa <handa@m17n.org>
parents:
17725
diff
changeset
|
57 coding system. |
f36ffb6f1208
Name change through the code:
Kenichi Handa <handa@m17n.org>
parents:
17725
diff
changeset
|
58 |
88438
3a34b722dd71
(encode_coding_utf_8): Initialize produced_chars to 0.
Kenichi Handa <handa@m17n.org>
parents:
88430
diff
changeset
|
59 In Emacs Lisp, a coding system is represented by a Lisp symbol. In |
3a34b722dd71
(encode_coding_utf_8): Initialize produced_chars to 0.
Kenichi Handa <handa@m17n.org>
parents:
88430
diff
changeset
|
60 C level, a coding system is represented by a vector of attributes |
88485 | 61 stored in the hash table Vcharset_hash_table. The conversion from |
88438
3a34b722dd71
(encode_coding_utf_8): Initialize produced_chars to 0.
Kenichi Handa <handa@m17n.org>
parents:
88430
diff
changeset
|
62 coding system symbol to attributes vector is done by looking up |
3a34b722dd71
(encode_coding_utf_8): Initialize produced_chars to 0.
Kenichi Handa <handa@m17n.org>
parents:
88430
diff
changeset
|
63 Vcharset_hash_table by the symbol. |
3a34b722dd71
(encode_coding_utf_8): Initialize produced_chars to 0.
Kenichi Handa <handa@m17n.org>
parents:
88430
diff
changeset
|
64 |
3a34b722dd71
(encode_coding_utf_8): Initialize produced_chars to 0.
Kenichi Handa <handa@m17n.org>
parents:
88430
diff
changeset
|
65 Coding systems are classified into the following types depending on |
88485 | 66 the encoding mechanism. Here's a brief description of the types. |
88365 | 67 |
68 o UTF-8 | |
69 | |
70 o UTF-16 | |
71 | |
72 o Charset-base coding system | |
73 | |
74 A coding system defined by one or more (coded) character sets. | |
88485 | 75 Decoding and encoding are done by a code converter defined for each |
88365 | 76 character set. |
77 | |
88485 | 78 o Old Emacs internal format (emacs-mule) |
79 | |
80 The coding system adopted by old versions of Emacs (20 and 21). | |
88365 | 81 |
82 o ISO2022-base coding system | |
17052 | 83 |
84 The most famous coding system for multiple character sets. X's | |
88365 | 85 Compound Text, various EUCs (Extended Unix Code), and coding systems |
86 used in the Internet communication such as ISO-2022-JP are all | |
87 variants of ISO2022. | |
88 | |
89 o 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
|
90 |
17052 | 91 A coding system to encode character sets: ASCII, JISX0201, and |
92 JISX0208. Widely used for PC's in Japan. Details are described in | |
88365 | 93 section 8. |
94 | |
95 o BIG5 | |
96 | |
97 A coding system to encode character sets: ASCII and Big5. Widely | |
35053 | 98 used for Chinese (mainly in Taiwan and Hong Kong). Details are |
88365 | 99 described in section 8. In this file, when we write "big5" (all |
100 lowercase), we mean the coding system, and when we write "Big5" | |
101 (capitalized), we mean the character set. | |
102 | |
103 o CCL | |
104 | |
88485 | 105 If a user wants to decode/encode text encoded in a coding system |
88365 | 106 not listed above, he can supply a decoder and an encoder for it in |
107 CCL (Code Conversion Language) programs. Emacs executes the CCL | |
108 program while decoding/encoding. | |
109 | |
110 o Raw-text | |
111 | |
88771 | 112 A coding system for text containing raw eight-bit data. Emacs |
88485 | 113 treats each byte of source text as a character (except for |
88365 | 114 end-of-line conversion). |
115 | |
116 o No-conversion | |
117 | |
118 Like raw text, but don't do end-of-line conversion. | |
119 | |
120 | |
121 END-OF-LINE FORMAT | |
122 | |
88485 | 123 How text end-of-line is encoded depends on operating system. For |
88365 | 124 instance, Unix's format is just one byte of LF (line-feed) code, |
18766 | 125 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
|
126 `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
|
127 `carriage-return'. |
17052 | 128 |
35053 | 129 Since text character encoding and end-of-line encoding are |
88365 | 130 independent, any coding system described above can take any format |
131 of end-of-line (except for no-conversion). | |
17052 | 132 |
88438
3a34b722dd71
(encode_coding_utf_8): Initialize produced_chars to 0.
Kenichi Handa <handa@m17n.org>
parents:
88430
diff
changeset
|
133 STRUCT CODING_SYSTEM |
3a34b722dd71
(encode_coding_utf_8): Initialize produced_chars to 0.
Kenichi Handa <handa@m17n.org>
parents:
88430
diff
changeset
|
134 |
3a34b722dd71
(encode_coding_utf_8): Initialize produced_chars to 0.
Kenichi Handa <handa@m17n.org>
parents:
88430
diff
changeset
|
135 Before using a coding system for code conversion (i.e. decoding and |
3a34b722dd71
(encode_coding_utf_8): Initialize produced_chars to 0.
Kenichi Handa <handa@m17n.org>
parents:
88430
diff
changeset
|
136 encoding), we setup a structure of type `struct coding_system'. |
3a34b722dd71
(encode_coding_utf_8): Initialize produced_chars to 0.
Kenichi Handa <handa@m17n.org>
parents:
88430
diff
changeset
|
137 This structure keeps various information about a specific code |
88485 | 138 conversion (e.g. the location of source and destination data). |
17052 | 139 |
140 */ | |
141 | |
88365 | 142 /* COMMON MACROS */ |
143 | |
144 | |
17052 | 145 /*** GENERAL NOTES on `detect_coding_XXX ()' functions *** |
146 | |
88365 | 147 These functions check if a byte sequence specified as a source in |
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
148 CODING conforms to the format of XXX, and update the members of |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
149 DETECT_INFO. |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
150 |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
151 Return 1 if the byte sequence conforms to XXX, otherwise return 0. |
88365 | 152 |
153 Below is the template of these functions. */ | |
154 | |
17052 | 155 #if 0 |
88365 | 156 static int |
109159
3e9fdeb960d1
* coding.c, sysdep.c: Convert some more functions to standard C.
Juanma Barranquero <lekktu@gmail.com>
parents:
109158
diff
changeset
|
157 detect_coding_XXX (struct coding_system *coding, |
3e9fdeb960d1
* coding.c, sysdep.c: Convert some more functions to standard C.
Juanma Barranquero <lekktu@gmail.com>
parents:
109158
diff
changeset
|
158 struct coding_detection_info *detect_info) |
17052 | 159 { |
90070
95879cc1ed20
Revision: miles@gnu.org--gnu-2004/emacs--unicode--0--patch-81
Miles Bader <miles@gnu.org>
diff
changeset
|
160 const unsigned char *src = coding->source; |
95879cc1ed20
Revision: miles@gnu.org--gnu-2004/emacs--unicode--0--patch-81
Miles Bader <miles@gnu.org>
diff
changeset
|
161 const unsigned char *src_end = coding->source + coding->src_bytes; |
88365 | 162 int multibytep = coding->src_multibyte; |
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
163 int consumed_chars = 0; |
88365 | 164 int found = 0; |
165 ...; | |
166 | |
167 while (1) | |
168 { | |
169 /* Get one byte from the source. If the souce is exausted, jump | |
170 to no_more_source:. */ | |
171 ONE_MORE_BYTE (c); | |
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
172 |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
173 if (! __C_conforms_to_XXX___ (c)) |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
174 break; |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
175 if (! __C_strongly_suggests_XXX__ (c)) |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
176 found = CATEGORY_MASK_XXX; |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
177 } |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
178 /* The byte sequence is invalid for XXX. */ |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
179 detect_info->rejected |= CATEGORY_MASK_XXX; |
88365 | 180 return 0; |
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
181 |
88365 | 182 no_more_source: |
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
183 /* The source exausted successfully. */ |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
184 detect_info->found |= found; |
88365 | 185 return 1; |
17052 | 186 } |
187 #endif | |
188 | |
189 /*** GENERAL NOTES on `decode_coding_XXX ()' functions *** | |
190 | |
88365 | 191 These functions decode a byte sequence specified as a source by |
192 CODING. The resulting multibyte text goes to a place pointed to by | |
193 CODING->charbuf, the length of which should not exceed | |
194 CODING->charbuf_size; | |
195 | |
196 These functions set the information of original and decoded texts in | |
197 CODING->consumed, CODING->consumed_char, and CODING->charbuf_used. | |
198 They also set CODING->result to one of CODING_RESULT_XXX indicating | |
199 how the decoding is finished. | |
200 | |
201 Below is the template of these functions. */ | |
202 | |
17052 | 203 #if 0 |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
204 static void |
109159
3e9fdeb960d1
* coding.c, sysdep.c: Convert some more functions to standard C.
Juanma Barranquero <lekktu@gmail.com>
parents:
109158
diff
changeset
|
205 decode_coding_XXXX (struct coding_system *coding) |
17052 | 206 { |
90070
95879cc1ed20
Revision: miles@gnu.org--gnu-2004/emacs--unicode--0--patch-81
Miles Bader <miles@gnu.org>
diff
changeset
|
207 const unsigned char *src = coding->source + coding->consumed; |
95879cc1ed20
Revision: miles@gnu.org--gnu-2004/emacs--unicode--0--patch-81
Miles Bader <miles@gnu.org>
diff
changeset
|
208 const unsigned char *src_end = coding->source + coding->src_bytes; |
88365 | 209 /* SRC_BASE remembers the start position in source in each loop. |
210 The loop will be exited when there's not enough source code, or | |
211 when there's no room in CHARBUF for a decoded character. */ | |
90070
95879cc1ed20
Revision: miles@gnu.org--gnu-2004/emacs--unicode--0--patch-81
Miles Bader <miles@gnu.org>
diff
changeset
|
212 const unsigned char *src_base; |
88365 | 213 /* A buffer to produce decoded characters. */ |
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
214 int *charbuf = coding->charbuf + coding->charbuf_used; |
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
215 int *charbuf_end = coding->charbuf + coding->charbuf_size; |
88365 | 216 int multibytep = coding->src_multibyte; |
217 | |
218 while (1) | |
219 { | |
220 src_base = src; | |
221 if (charbuf < charbuf_end) | |
222 /* No more room to produce a decoded character. */ | |
223 break; | |
224 ONE_MORE_BYTE (c); | |
225 /* Decode it. */ | |
226 } | |
227 | |
228 no_more_source: | |
229 if (src_base < src_end | |
230 && coding->mode & CODING_MODE_LAST_BLOCK) | |
231 /* If the source ends by partial bytes to construct a character, | |
232 treat them as eight-bit raw data. */ | |
233 while (src_base < src_end && charbuf < charbuf_end) | |
234 *charbuf++ = *src_base++; | |
235 /* Remember how many bytes and characters we consumed. If the | |
236 source is multibyte, the bytes and chars are not identical. */ | |
237 coding->consumed = coding->consumed_char = src_base - coding->source; | |
238 /* Remember how many characters we produced. */ | |
239 coding->charbuf_used = charbuf - coding->charbuf; | |
17052 | 240 } |
241 #endif | |
242 | |
243 /*** GENERAL NOTES on `encode_coding_XXX ()' functions *** | |
244 | |
88365 | 245 These functions encode SRC_BYTES length text at SOURCE of Emacs' |
246 internal multibyte format by CODING. The resulting byte sequence | |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
247 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
|
248 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
|
249 |
88365 | 250 These functions set the information of original and encoded texts in |
251 the members produced, produced_char, consumed, and consumed_char of | |
252 the structure *CODING. They also set the member result to one of | |
253 CODING_RESULT_XXX indicating how the encoding finished. | |
254 | |
255 DST_BYTES zero means that source area and destination area are | |
256 overlapped, which means that we can produce a encoded text until it | |
257 reaches at the head of not-yet-encoded source text. | |
258 | |
259 Below is a template of these functions. */ | |
17052 | 260 #if 0 |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
261 static void |
109159
3e9fdeb960d1
* coding.c, sysdep.c: Convert some more functions to standard C.
Juanma Barranquero <lekktu@gmail.com>
parents:
109158
diff
changeset
|
262 encode_coding_XXX (struct coding_system *coding) |
17052 | 263 { |
88365 | 264 int multibytep = coding->dst_multibyte; |
265 int *charbuf = coding->charbuf; | |
266 int *charbuf_end = charbuf->charbuf + coding->charbuf_used; | |
267 unsigned char *dst = coding->destination + coding->produced; | |
268 unsigned char *dst_end = coding->destination + coding->dst_bytes; | |
269 unsigned char *adjusted_dst_end = dst_end - _MAX_BYTES_PRODUCED_IN_LOOP_; | |
270 int produced_chars = 0; | |
271 | |
272 for (; charbuf < charbuf_end && dst < adjusted_dst_end; charbuf++) | |
273 { | |
274 int c = *charbuf; | |
275 /* Encode C into DST, and increment DST. */ | |
276 } | |
277 label_no_more_destination: | |
278 /* How many chars and bytes we produced. */ | |
279 coding->produced_char += produced_chars; | |
280 coding->produced = dst - coding->destination; | |
17052 | 281 } |
282 #endif | |
283 | |
284 | |
285 /*** 1. Preamble ***/ | |
286 | |
26088
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
26067
diff
changeset
|
287 #include <config.h> |
17052 | 288 #include <stdio.h> |
105669
68dd71358159
* alloc.c: Do not define struct catchtag.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105179
diff
changeset
|
289 #include <setjmp.h> |
17052 | 290 |
291 #include "lisp.h" | |
292 #include "buffer.h" | |
88365 | 293 #include "character.h" |
17052 | 294 #include "charset.h" |
88365 | 295 #include "ccl.h" |
26847 | 296 #include "composite.h" |
17052 | 297 #include "coding.h" |
298 #include "window.h" | |
83127
5182815e0ee1
Make terminal_coding and keyboard_coding display-local.
Karoly Lorentey <lorentey@elte.hu>
parents:
54320
diff
changeset
|
299 #include "frame.h" |
5182815e0ee1
Make terminal_coding and keyboard_coding display-local.
Karoly Lorentey <lorentey@elte.hu>
parents:
54320
diff
changeset
|
300 #include "termhooks.h" |
17052 | 301 |
88365 | 302 Lisp_Object Vcoding_system_hash_table; |
303 | |
304 Lisp_Object Qcoding_system, Qcoding_aliases, Qeol_type; | |
88646
d3b1f30e2267
(Qmac): Remove (duplicated) definition.
Dave Love <fx@gnu.org>
parents:
88645
diff
changeset
|
305 Lisp_Object Qunix, Qdos; |
17052 | 306 Lisp_Object Qbuffer_file_coding_system; |
307 Lisp_Object Qpost_read_conversion, Qpre_write_conversion; | |
88365 | 308 Lisp_Object Qdefault_char; |
19612
783efd6c7c1e
(Qno_conversion, Qundecided): New variables.
Kenichi Handa <handa@m17n.org>
parents:
19546
diff
changeset
|
309 Lisp_Object Qno_conversion, Qundecided; |
88365 | 310 Lisp_Object Qcharset, Qiso_2022, Qutf_8, Qutf_16, Qshift_jis, Qbig5; |
89420
c3e67ce6ee0f
(Qsignature, Qendian): Delete these variables.
Kenichi Handa <handa@m17n.org>
parents:
89418
diff
changeset
|
311 Lisp_Object Qbig, Qlittle; |
19750
95e4e1cba6ac
(Qcoding_system_history): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
19747
diff
changeset
|
312 Lisp_Object Qcoding_system_history; |
22874
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
313 Lisp_Object Qvalid_codes; |
100303
3e044fa54e4f
* coding.c (QCdefault_char): Rename from QCdefalut_char.
Juanma Barranquero <lekktu@gmail.com>
parents:
100262
diff
changeset
|
314 Lisp_Object QCcategory, QCmnemonic, QCdefault_char; |
89759
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
315 Lisp_Object QCdecode_translation_table, QCencode_translation_table; |
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
316 Lisp_Object QCpost_read_conversion, QCpre_write_conversion; |
90214
460ee00505d5
(QCascii_compatible_p): New variable.
Kenichi Handa <handa@m17n.org>
parents:
90201
diff
changeset
|
317 Lisp_Object QCascii_compatible_p; |
17052 | 318 |
64251
3de1b955c31a
* coding.c (Qprocess_argument):
Kim F. Storm <storm@cua.dk>
parents:
64084
diff
changeset
|
319 Lisp_Object Qcall_process, Qcall_process_region; |
17052 | 320 Lisp_Object Qstart_process, Qopen_network_stream; |
321 Lisp_Object Qtarget_idx; | |
322 | |
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
323 Lisp_Object Qinsufficient_source, Qinconsistent_eol, Qinvalid_source; |
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
324 Lisp_Object Qinterrupted, Qinsufficient_memory; |
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
325 |
52794
f4d906e31662
(Qcoding_system_define_form): New variable.
Kenichi Handa <handa@m17n.org>
parents:
52401
diff
changeset
|
326 /* 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
|
327 symbol as a coding system. */ |
90272
f1df126ec7de
Sync to HEAD for handling autoload-coding-system.
Kenichi Handa <handa@m17n.org>
parents:
90263
diff
changeset
|
328 static Lisp_Object Qcoding_system_define_form; |
f1df126ec7de
Sync to HEAD for handling autoload-coding-system.
Kenichi Handa <handa@m17n.org>
parents:
90263
diff
changeset
|
329 |
89483 | 330 int coding_system_require_warning; |
52794
f4d906e31662
(Qcoding_system_define_form): New variable.
Kenichi Handa <handa@m17n.org>
parents:
52401
diff
changeset
|
331 |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
332 Lisp_Object Vselect_safe_coding_system_function; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
333 |
24200
b9d9fccad516
(syms_of_coding): eol-mnemonic-* variables are now
Eli Zaretskii <eliz@gnu.org>
parents:
24178
diff
changeset
|
334 /* 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
|
335 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
|
336 /* Mnemonic string to indicate format of end-of-line is not yet |
17052 | 337 decided. */ |
24200
b9d9fccad516
(syms_of_coding): eol-mnemonic-* variables are now
Eli Zaretskii <eliz@gnu.org>
parents:
24178
diff
changeset
|
338 Lisp_Object eol_mnemonic_undecided; |
17052 | 339 |
90394
263867fe7b55
(system_eol_type): Sync with HEAD.
Kenichi Handa <handa@m17n.org>
parents:
90380
diff
changeset
|
340 /* Format of end-of-line decided by system. This is Qunix on |
263867fe7b55
(system_eol_type): Sync with HEAD.
Kenichi Handa <handa@m17n.org>
parents:
90380
diff
changeset
|
341 Unix and Mac, Qdos on DOS/Windows. |
70520
b6740a317343
(setup_coding_system): For invalid coding-system, set
Kenichi Handa <handa@m17n.org>
parents:
69995
diff
changeset
|
342 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
|
343 file and process), not for in-buffer or Lisp string encoding. */ |
90394
263867fe7b55
(system_eol_type): Sync with HEAD.
Kenichi Handa <handa@m17n.org>
parents:
90380
diff
changeset
|
344 static Lisp_Object system_eol_type; |
18650
aa3f2820e2ac
(Qemacs_mule, inhibit_eol_conversion): New variables.
Kenichi Handa <handa@m17n.org>
parents:
18613
diff
changeset
|
345 |
17052 | 346 #ifdef emacs |
347 | |
20105
c017642863c2
(Qcoding_system_spec): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
19824
diff
changeset
|
348 Lisp_Object Vcoding_system_list, Vcoding_system_alist; |
c017642863c2
(Qcoding_system_spec): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
19824
diff
changeset
|
349 |
c017642863c2
(Qcoding_system_spec): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
19824
diff
changeset
|
350 Lisp_Object Qcoding_system_p, Qcoding_system_error; |
17052 | 351 |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
352 /* 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
|
353 end-of-line format. */ |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
354 Lisp_Object Qemacs_mule, Qraw_text; |
89483 | 355 Lisp_Object Qutf_8_emacs; |
51406 | 356 |
17052 | 357 /* Coding-systems are handed between Emacs Lisp programs and C internal |
358 routines by the following three variables. */ | |
359 /* Coding-system for reading files and receiving data from process. */ | |
360 Lisp_Object Vcoding_system_for_read; | |
361 /* Coding-system for writing files and sending data to process. */ | |
362 Lisp_Object Vcoding_system_for_write; | |
363 /* Coding-system actually used in the latest I/O. */ | |
364 Lisp_Object Vlast_coding_system_used; | |
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
365 /* Set to non-nil when an error is detected while code conversion. */ |
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
366 Lisp_Object Vlast_code_conversion_error; |
19280
e755044718ee
(ENCODE_ISO_CHARACTER_DIMENSION1): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
19193
diff
changeset
|
367 /* A vector of length 256 which contains information about special |
22529 | 368 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
|
369 Lisp_Object Vlatin_extra_code_table; |
19280
e755044718ee
(ENCODE_ISO_CHARACTER_DIMENSION1): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
19193
diff
changeset
|
370 |
18650
aa3f2820e2ac
(Qemacs_mule, inhibit_eol_conversion): New variables.
Kenichi Handa <handa@m17n.org>
parents:
18613
diff
changeset
|
371 /* 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
|
372 int inhibit_eol_conversion; |
aa3f2820e2ac
(Qemacs_mule, inhibit_eol_conversion): New variables.
Kenichi Handa <handa@m17n.org>
parents:
18613
diff
changeset
|
373 |
30204
35aec8514228
(inhibit_iso_escape_detection): New variable.
Kenichi Handa <handa@m17n.org>
parents:
29985
diff
changeset
|
374 /* Flag to inhibit ISO2022 escape sequence detection. */ |
35aec8514228
(inhibit_iso_escape_detection): New variable.
Kenichi Handa <handa@m17n.org>
parents:
29985
diff
changeset
|
375 int inhibit_iso_escape_detection; |
35aec8514228
(inhibit_iso_escape_detection): New variable.
Kenichi Handa <handa@m17n.org>
parents:
29985
diff
changeset
|
376 |
101040 | 377 /* Flag to inhibit detection of binary files through null bytes. */ |
378 int inhibit_null_byte_detection; | |
379 | |
21574
30394e3ae7f8
(syms_of_coding): Declare and define inherit-process-coding-system.
Eli Zaretskii <eliz@gnu.org>
parents:
21520
diff
changeset
|
380 /* 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
|
381 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
|
382 |
19280
e755044718ee
(ENCODE_ISO_CHARACTER_DIMENSION1): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
19193
diff
changeset
|
383 /* 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
|
384 terminal coding system is nil. */ |
e755044718ee
(ENCODE_ISO_CHARACTER_DIMENSION1): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
19193
diff
changeset
|
385 struct coding_system safe_terminal_coding; |
e755044718ee
(ENCODE_ISO_CHARACTER_DIMENSION1): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
19193
diff
changeset
|
386 |
18180
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
387 Lisp_Object Vfile_coding_system_alist; |
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
388 Lisp_Object Vprocess_coding_system_alist; |
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
389 Lisp_Object Vnetwork_coding_system_alist; |
17052 | 390 |
26088
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
26067
diff
changeset
|
391 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
|
392 |
17052 | 393 #endif /* emacs */ |
394 | |
22186
fc4aaf1b1772
Change term "character translation table" to "translation table".
Kenichi Handa <handa@m17n.org>
parents:
22166
diff
changeset
|
395 /* 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
|
396 conversion. */ |
22119
592bb8b9bcfd
Change terms unify/unification to
Kenichi Handa <handa@m17n.org>
parents:
22020
diff
changeset
|
397 Lisp_Object Venable_character_translation; |
22186
fc4aaf1b1772
Change term "character translation table" to "translation table".
Kenichi Handa <handa@m17n.org>
parents:
22166
diff
changeset
|
398 /* 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
|
399 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
|
400 /* 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
|
401 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
|
402 |
fc4aaf1b1772
Change term "character translation table" to "translation table".
Kenichi Handa <handa@m17n.org>
parents:
22166
diff
changeset
|
403 Lisp_Object Qtranslation_table; |
fc4aaf1b1772
Change term "character translation table" to "translation table".
Kenichi Handa <handa@m17n.org>
parents:
22166
diff
changeset
|
404 Lisp_Object Qtranslation_table_id; |
fc4aaf1b1772
Change term "character translation table" to "translation table".
Kenichi Handa <handa@m17n.org>
parents:
22166
diff
changeset
|
405 Lisp_Object Qtranslation_table_for_decode; |
fc4aaf1b1772
Change term "character translation table" to "translation table".
Kenichi Handa <handa@m17n.org>
parents:
22166
diff
changeset
|
406 Lisp_Object Qtranslation_table_for_encode; |
17052 | 407 |
408 /* Alist of charsets vs revision number. */ | |
88365 | 409 static Lisp_Object Vcharset_revision_table; |
17052 | 410 |
18180
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
411 /* Default coding systems used for process I/O. */ |
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
412 Lisp_Object Vdefault_process_coding_system; |
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
413 |
48182
9474e269efd1
Reformat some DEFUNs so that etags works.
Dave Love <fx@gnu.org>
parents:
48125
diff
changeset
|
414 /* 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
|
415 Lisp_Object Vtranslation_table_for_input; |
9474e269efd1
Reformat some DEFUNs so that etags works.
Dave Love <fx@gnu.org>
parents:
48125
diff
changeset
|
416 |
88365 | 417 /* Two special coding systems. */ |
418 Lisp_Object Vsjis_coding_system; | |
419 Lisp_Object Vbig5_coding_system; | |
420 | |
421 /* ISO2022 section */ | |
422 | |
423 #define CODING_ISO_INITIAL(coding, reg) \ | |
424 (XINT (AREF (AREF (CODING_ID_ATTRS ((coding)->id), \ | |
425 coding_attr_iso_initial), \ | |
426 reg))) | |
427 | |
428 | |
102186
a12d39ca6870
* coding.h (struct coding_system): Make safe_charsets a pointer to
Andreas Schwab <schwab@suse.de>
parents:
102115
diff
changeset
|
429 #define CODING_ISO_REQUEST(coding, charset_id) \ |
a12d39ca6870
* coding.h (struct coding_system): Make safe_charsets a pointer to
Andreas Schwab <schwab@suse.de>
parents:
102115
diff
changeset
|
430 (((charset_id) <= (coding)->max_charset_id \ |
a12d39ca6870
* coding.h (struct coding_system): Make safe_charsets a pointer to
Andreas Schwab <schwab@suse.de>
parents:
102115
diff
changeset
|
431 ? ((coding)->safe_charsets[charset_id] != 255 \ |
a12d39ca6870
* coding.h (struct coding_system): Make safe_charsets a pointer to
Andreas Schwab <schwab@suse.de>
parents:
102115
diff
changeset
|
432 ? (coding)->safe_charsets[charset_id] \ |
a12d39ca6870
* coding.h (struct coding_system): Make safe_charsets a pointer to
Andreas Schwab <schwab@suse.de>
parents:
102115
diff
changeset
|
433 : -1) \ |
88365 | 434 : -1)) |
435 | |
436 | |
437 #define CODING_ISO_FLAGS(coding) \ | |
438 ((coding)->spec.iso_2022.flags) | |
439 #define CODING_ISO_DESIGNATION(coding, reg) \ | |
440 ((coding)->spec.iso_2022.current_designation[reg]) | |
441 #define CODING_ISO_INVOCATION(coding, plane) \ | |
442 ((coding)->spec.iso_2022.current_invocation[plane]) | |
443 #define CODING_ISO_SINGLE_SHIFTING(coding) \ | |
444 ((coding)->spec.iso_2022.single_shifting) | |
445 #define CODING_ISO_BOL(coding) \ | |
446 ((coding)->spec.iso_2022.bol) | |
447 #define CODING_ISO_INVOKED_CHARSET(coding, plane) \ | |
448 CODING_ISO_DESIGNATION ((coding), CODING_ISO_INVOCATION ((coding), (plane))) | |
102422
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
449 #define CODING_ISO_CMP_STATUS(coding) \ |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
450 (&(coding)->spec.iso_2022.cmp_status) |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
451 #define CODING_ISO_EXTSEGMENT_LEN(coding) \ |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
452 ((coding)->spec.iso_2022.ctext_extended_segment_len) |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
453 #define CODING_ISO_EMBEDDED_UTF_8(coding) \ |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
454 ((coding)->spec.iso_2022.embedded_utf_8) |
88365 | 455 |
456 /* Control characters of ISO2022. */ | |
457 /* code */ /* function */ | |
458 #define ISO_CODE_LF 0x0A /* line-feed */ | |
459 #define ISO_CODE_CR 0x0D /* carriage-return */ | |
460 #define ISO_CODE_SO 0x0E /* shift-out */ | |
461 #define ISO_CODE_SI 0x0F /* shift-in */ | |
462 #define ISO_CODE_SS2_7 0x19 /* single-shift-2 for 7-bit code */ | |
463 #define ISO_CODE_ESC 0x1B /* escape */ | |
464 #define ISO_CODE_SS2 0x8E /* single-shift-2 */ | |
465 #define ISO_CODE_SS3 0x8F /* single-shift-3 */ | |
466 #define ISO_CODE_CSI 0x9B /* control-sequence-introducer */ | |
467 | |
468 /* All code (1-byte) of ISO2022 is classified into one of the | |
469 followings. */ | |
470 enum iso_code_class_type | |
471 { | |
472 ISO_control_0, /* Control codes in the range | |
473 0x00..0x1F and 0x7F, except for the | |
474 following 5 codes. */ | |
475 ISO_shift_out, /* ISO_CODE_SO (0x0E) */ | |
476 ISO_shift_in, /* ISO_CODE_SI (0x0F) */ | |
477 ISO_single_shift_2_7, /* ISO_CODE_SS2_7 (0x19) */ | |
478 ISO_escape, /* ISO_CODE_SO (0x1B) */ | |
479 ISO_control_1, /* Control codes in the range | |
480 0x80..0x9F, except for the | |
481 following 3 codes. */ | |
482 ISO_single_shift_2, /* ISO_CODE_SS2 (0x8E) */ | |
483 ISO_single_shift_3, /* ISO_CODE_SS3 (0x8F) */ | |
484 ISO_control_sequence_introducer, /* ISO_CODE_CSI (0x9B) */ | |
485 ISO_0x20_or_0x7F, /* Codes of the values 0x20 or 0x7F. */ | |
486 ISO_graphic_plane_0, /* Graphic codes in the range 0x21..0x7E. */ | |
487 ISO_0xA0_or_0xFF, /* Codes of the values 0xA0 or 0xFF. */ | |
488 ISO_graphic_plane_1 /* Graphic codes in the range 0xA1..0xFE. */ | |
489 }; | |
490 | |
491 /** The macros CODING_ISO_FLAG_XXX defines a flag bit of the | |
492 `iso-flags' attribute of an iso2022 coding system. */ | |
493 | |
494 /* If set, produce long-form designation sequence (e.g. ESC $ ( A) | |
495 instead of the correct short-form sequence (e.g. ESC $ A). */ | |
496 #define CODING_ISO_FLAG_LONG_FORM 0x0001 | |
497 | |
498 /* If set, reset graphic planes and registers at end-of-line to the | |
499 initial state. */ | |
500 #define CODING_ISO_FLAG_RESET_AT_EOL 0x0002 | |
501 | |
502 /* If set, reset graphic planes and registers before any control | |
503 characters to the initial state. */ | |
504 #define CODING_ISO_FLAG_RESET_AT_CNTL 0x0004 | |
505 | |
506 /* If set, encode by 7-bit environment. */ | |
507 #define CODING_ISO_FLAG_SEVEN_BITS 0x0008 | |
508 | |
509 /* If set, use locking-shift function. */ | |
510 #define CODING_ISO_FLAG_LOCKING_SHIFT 0x0010 | |
511 | |
512 /* If set, use single-shift function. Overwrite | |
513 CODING_ISO_FLAG_LOCKING_SHIFT. */ | |
514 #define CODING_ISO_FLAG_SINGLE_SHIFT 0x0020 | |
515 | |
516 /* If set, use designation escape sequence. */ | |
517 #define CODING_ISO_FLAG_DESIGNATION 0x0040 | |
518 | |
519 /* If set, produce revision number sequence. */ | |
520 #define CODING_ISO_FLAG_REVISION 0x0080 | |
521 | |
522 /* If set, produce ISO6429's direction specifying sequence. */ | |
523 #define CODING_ISO_FLAG_DIRECTION 0x0100 | |
524 | |
525 /* If set, assume designation states are reset at beginning of line on | |
526 output. */ | |
527 #define CODING_ISO_FLAG_INIT_AT_BOL 0x0200 | |
528 | |
529 /* If set, designation sequence should be placed at beginning of line | |
530 on output. */ | |
531 #define CODING_ISO_FLAG_DESIGNATE_AT_BOL 0x0400 | |
532 | |
533 /* If set, do not encode unsafe charactes on output. */ | |
534 #define CODING_ISO_FLAG_SAFE 0x0800 | |
535 | |
536 /* If set, extra latin codes (128..159) are accepted as a valid code | |
537 on input. */ | |
538 #define CODING_ISO_FLAG_LATIN_EXTRA 0x1000 | |
539 | |
540 #define CODING_ISO_FLAG_COMPOSITION 0x2000 | |
541 | |
542 #define CODING_ISO_FLAG_EUC_TW_SHIFT 0x4000 | |
543 | |
88681
2cdfbffa8a0d
(CODING_ISO_FLAG_USE_ROMAN): New macro
Kenichi Handa <handa@m17n.org>
parents:
88669
diff
changeset
|
544 #define CODING_ISO_FLAG_USE_ROMAN 0x8000 |
2cdfbffa8a0d
(CODING_ISO_FLAG_USE_ROMAN): New macro
Kenichi Handa <handa@m17n.org>
parents:
88669
diff
changeset
|
545 |
2cdfbffa8a0d
(CODING_ISO_FLAG_USE_ROMAN): New macro
Kenichi Handa <handa@m17n.org>
parents:
88669
diff
changeset
|
546 #define CODING_ISO_FLAG_USE_OLDJIS 0x10000 |
2cdfbffa8a0d
(CODING_ISO_FLAG_USE_ROMAN): New macro
Kenichi Handa <handa@m17n.org>
parents:
88669
diff
changeset
|
547 |
2cdfbffa8a0d
(CODING_ISO_FLAG_USE_ROMAN): New macro
Kenichi Handa <handa@m17n.org>
parents:
88669
diff
changeset
|
548 #define CODING_ISO_FLAG_FULL_SUPPORT 0x100000 |
88365 | 549 |
550 /* A character to be produced on output if encoding of the original | |
551 character is prohibited by CODING_ISO_FLAG_SAFE. */ | |
552 #define CODING_INHIBIT_CHARACTER_SUBSTITUTION '?' | |
553 | |
95397
c99f0a16c077
(CODING_UTF_8_BOM): New macro.
Kenichi Handa <handa@m17n.org>
parents:
95356
diff
changeset
|
554 /* UTF-8 section */ |
c99f0a16c077
(CODING_UTF_8_BOM): New macro.
Kenichi Handa <handa@m17n.org>
parents:
95356
diff
changeset
|
555 #define CODING_UTF_8_BOM(coding) \ |
c99f0a16c077
(CODING_UTF_8_BOM): New macro.
Kenichi Handa <handa@m17n.org>
parents:
95356
diff
changeset
|
556 ((coding)->spec.utf_8_bom) |
88365 | 557 |
558 /* UTF-16 section */ | |
559 #define CODING_UTF_16_BOM(coding) \ | |
560 ((coding)->spec.utf_16.bom) | |
561 | |
562 #define CODING_UTF_16_ENDIAN(coding) \ | |
563 ((coding)->spec.utf_16.endian) | |
564 | |
565 #define CODING_UTF_16_SURROGATE(coding) \ | |
566 ((coding)->spec.utf_16.surrogate) | |
567 | |
568 | |
569 /* CCL section */ | |
570 #define CODING_CCL_DECODER(coding) \ | |
571 AREF (CODING_ID_ATTRS ((coding)->id), coding_attr_ccl_decoder) | |
572 #define CODING_CCL_ENCODER(coding) \ | |
573 AREF (CODING_ID_ATTRS ((coding)->id), coding_attr_ccl_encoder) | |
574 #define CODING_CCL_VALIDS(coding) \ | |
89483 | 575 (SDATA (AREF (CODING_ID_ATTRS ((coding)->id), coding_attr_ccl_valids))) |
88365 | 576 |
88771 | 577 /* Index for each coding category in `coding_categories' */ |
88365 | 578 |
579 enum coding_category | |
580 { | |
581 coding_category_iso_7, | |
582 coding_category_iso_7_tight, | |
583 coding_category_iso_8_1, | |
584 coding_category_iso_8_2, | |
585 coding_category_iso_7_else, | |
586 coding_category_iso_8_else, | |
95397
c99f0a16c077
(CODING_UTF_8_BOM): New macro.
Kenichi Handa <handa@m17n.org>
parents:
95356
diff
changeset
|
587 coding_category_utf_8_auto, |
c99f0a16c077
(CODING_UTF_8_BOM): New macro.
Kenichi Handa <handa@m17n.org>
parents:
95356
diff
changeset
|
588 coding_category_utf_8_nosig, |
c99f0a16c077
(CODING_UTF_8_BOM): New macro.
Kenichi Handa <handa@m17n.org>
parents:
95356
diff
changeset
|
589 coding_category_utf_8_sig, |
88365 | 590 coding_category_utf_16_auto, |
591 coding_category_utf_16_be, | |
592 coding_category_utf_16_le, | |
593 coding_category_utf_16_be_nosig, | |
594 coding_category_utf_16_le_nosig, | |
595 coding_category_charset, | |
596 coding_category_sjis, | |
597 coding_category_big5, | |
598 coding_category_ccl, | |
599 coding_category_emacs_mule, | |
600 /* All above are targets of code detection. */ | |
601 coding_category_raw_text, | |
602 coding_category_undecided, | |
603 coding_category_max | |
604 }; | |
605 | |
606 /* Definitions of flag bits used in detect_coding_XXXX. */ | |
607 #define CATEGORY_MASK_ISO_7 (1 << coding_category_iso_7) | |
608 #define CATEGORY_MASK_ISO_7_TIGHT (1 << coding_category_iso_7_tight) | |
609 #define CATEGORY_MASK_ISO_8_1 (1 << coding_category_iso_8_1) | |
610 #define CATEGORY_MASK_ISO_8_2 (1 << coding_category_iso_8_2) | |
611 #define CATEGORY_MASK_ISO_7_ELSE (1 << coding_category_iso_7_else) | |
612 #define CATEGORY_MASK_ISO_8_ELSE (1 << coding_category_iso_8_else) | |
95397
c99f0a16c077
(CODING_UTF_8_BOM): New macro.
Kenichi Handa <handa@m17n.org>
parents:
95356
diff
changeset
|
613 #define CATEGORY_MASK_UTF_8_AUTO (1 << coding_category_utf_8_auto) |
c99f0a16c077
(CODING_UTF_8_BOM): New macro.
Kenichi Handa <handa@m17n.org>
parents:
95356
diff
changeset
|
614 #define CATEGORY_MASK_UTF_8_NOSIG (1 << coding_category_utf_8_nosig) |
c99f0a16c077
(CODING_UTF_8_BOM): New macro.
Kenichi Handa <handa@m17n.org>
parents:
95356
diff
changeset
|
615 #define CATEGORY_MASK_UTF_8_SIG (1 << coding_category_utf_8_sig) |
89420
c3e67ce6ee0f
(Qsignature, Qendian): Delete these variables.
Kenichi Handa <handa@m17n.org>
parents:
89418
diff
changeset
|
616 #define CATEGORY_MASK_UTF_16_AUTO (1 << coding_category_utf_16_auto) |
88365 | 617 #define CATEGORY_MASK_UTF_16_BE (1 << coding_category_utf_16_be) |
618 #define CATEGORY_MASK_UTF_16_LE (1 << coding_category_utf_16_le) | |
619 #define CATEGORY_MASK_UTF_16_BE_NOSIG (1 << coding_category_utf_16_be_nosig) | |
620 #define CATEGORY_MASK_UTF_16_LE_NOSIG (1 << coding_category_utf_16_le_nosig) | |
621 #define CATEGORY_MASK_CHARSET (1 << coding_category_charset) | |
622 #define CATEGORY_MASK_SJIS (1 << coding_category_sjis) | |
623 #define CATEGORY_MASK_BIG5 (1 << coding_category_big5) | |
624 #define CATEGORY_MASK_CCL (1 << coding_category_ccl) | |
625 #define CATEGORY_MASK_EMACS_MULE (1 << coding_category_emacs_mule) | |
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
626 #define CATEGORY_MASK_RAW_TEXT (1 << coding_category_raw_text) |
88365 | 627 |
628 /* This value is returned if detect_coding_mask () find nothing other | |
629 than ASCII characters. */ | |
630 #define CATEGORY_MASK_ANY \ | |
631 (CATEGORY_MASK_ISO_7 \ | |
632 | CATEGORY_MASK_ISO_7_TIGHT \ | |
633 | CATEGORY_MASK_ISO_8_1 \ | |
634 | CATEGORY_MASK_ISO_8_2 \ | |
635 | CATEGORY_MASK_ISO_7_ELSE \ | |
636 | CATEGORY_MASK_ISO_8_ELSE \ | |
95397
c99f0a16c077
(CODING_UTF_8_BOM): New macro.
Kenichi Handa <handa@m17n.org>
parents:
95356
diff
changeset
|
637 | CATEGORY_MASK_UTF_8_AUTO \ |
c99f0a16c077
(CODING_UTF_8_BOM): New macro.
Kenichi Handa <handa@m17n.org>
parents:
95356
diff
changeset
|
638 | CATEGORY_MASK_UTF_8_NOSIG \ |
c99f0a16c077
(CODING_UTF_8_BOM): New macro.
Kenichi Handa <handa@m17n.org>
parents:
95356
diff
changeset
|
639 | CATEGORY_MASK_UTF_8_SIG \ |
93595
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
640 | CATEGORY_MASK_UTF_16_AUTO \ |
88365 | 641 | CATEGORY_MASK_UTF_16_BE \ |
642 | CATEGORY_MASK_UTF_16_LE \ | |
643 | CATEGORY_MASK_UTF_16_BE_NOSIG \ | |
644 | CATEGORY_MASK_UTF_16_LE_NOSIG \ | |
645 | CATEGORY_MASK_CHARSET \ | |
646 | CATEGORY_MASK_SJIS \ | |
647 | CATEGORY_MASK_BIG5 \ | |
648 | CATEGORY_MASK_CCL \ | |
649 | CATEGORY_MASK_EMACS_MULE) | |
650 | |
651 | |
652 #define CATEGORY_MASK_ISO_7BIT \ | |
653 (CATEGORY_MASK_ISO_7 | CATEGORY_MASK_ISO_7_TIGHT) | |
654 | |
655 #define CATEGORY_MASK_ISO_8BIT \ | |
656 (CATEGORY_MASK_ISO_8_1 | CATEGORY_MASK_ISO_8_2) | |
657 | |
658 #define CATEGORY_MASK_ISO_ELSE \ | |
659 (CATEGORY_MASK_ISO_7_ELSE | CATEGORY_MASK_ISO_8_ELSE) | |
660 | |
661 #define CATEGORY_MASK_ISO_ESCAPE \ | |
662 (CATEGORY_MASK_ISO_7 \ | |
663 | CATEGORY_MASK_ISO_7_TIGHT \ | |
664 | CATEGORY_MASK_ISO_7_ELSE \ | |
665 | CATEGORY_MASK_ISO_8_ELSE) | |
666 | |
667 #define CATEGORY_MASK_ISO \ | |
668 ( CATEGORY_MASK_ISO_7BIT \ | |
669 | CATEGORY_MASK_ISO_8BIT \ | |
670 | CATEGORY_MASK_ISO_ELSE) | |
671 | |
672 #define CATEGORY_MASK_UTF_16 \ | |
93595
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
673 (CATEGORY_MASK_UTF_16_AUTO \ |
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
674 | CATEGORY_MASK_UTF_16_BE \ |
88365 | 675 | CATEGORY_MASK_UTF_16_LE \ |
676 | CATEGORY_MASK_UTF_16_BE_NOSIG \ | |
677 | CATEGORY_MASK_UTF_16_LE_NOSIG) | |
678 | |
95397
c99f0a16c077
(CODING_UTF_8_BOM): New macro.
Kenichi Handa <handa@m17n.org>
parents:
95356
diff
changeset
|
679 #define CATEGORY_MASK_UTF_8 \ |
c99f0a16c077
(CODING_UTF_8_BOM): New macro.
Kenichi Handa <handa@m17n.org>
parents:
95356
diff
changeset
|
680 (CATEGORY_MASK_UTF_8_AUTO \ |
c99f0a16c077
(CODING_UTF_8_BOM): New macro.
Kenichi Handa <handa@m17n.org>
parents:
95356
diff
changeset
|
681 | CATEGORY_MASK_UTF_8_NOSIG \ |
c99f0a16c077
(CODING_UTF_8_BOM): New macro.
Kenichi Handa <handa@m17n.org>
parents:
95356
diff
changeset
|
682 | CATEGORY_MASK_UTF_8_SIG) |
88365 | 683 |
684 /* List of symbols `coding-category-xxx' ordered by priority. This | |
685 variable is exposed to Emacs Lisp. */ | |
686 static Lisp_Object Vcoding_category_list; | |
687 | |
688 /* Table of coding categories (Lisp symbols). This variable is for | |
689 internal use oly. */ | |
690 static Lisp_Object Vcoding_category_table; | |
691 | |
692 /* Table of coding-categories ordered by priority. */ | |
693 static enum coding_category coding_priorities[coding_category_max]; | |
694 | |
695 /* Nth element is a coding context for the coding system bound to the | |
696 Nth coding category. */ | |
697 static struct coding_system coding_categories[coding_category_max]; | |
698 | |
699 /*** Commonly used macros and functions ***/ | |
700 | |
701 #ifndef min | |
702 #define min(a, b) ((a) < (b) ? (a) : (b)) | |
703 #endif | |
704 #ifndef max | |
705 #define max(a, b) ((a) > (b) ? (a) : (b)) | |
706 #endif | |
707 | |
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
708 #define CODING_GET_INFO(coding, attrs, charset_list) \ |
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
709 do { \ |
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
710 (attrs) = CODING_ID_ATTRS ((coding)->id); \ |
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
711 (charset_list) = CODING_ATTR_CHARSET_LIST (attrs); \ |
88365 | 712 } while (0) |
713 | |
714 | |
715 /* Safely get one byte from the source text pointed by SRC which ends | |
716 at SRC_END, and set C to that byte. If there are not enough bytes | |
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
717 in the source, it jumps to `no_more_source'. If multibytep is |
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
718 nonzero, and a multibyte character is found at SRC, set C to the |
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
719 negative value of the character code. The caller should declare |
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
720 and set these variables appropriately in advance: |
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
721 src, src_end, multibytep */ |
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
722 |
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
723 #define ONE_MORE_BYTE(c) \ |
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
724 do { \ |
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
725 if (src == src_end) \ |
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
726 { \ |
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
727 if (src_base < src) \ |
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
728 record_conversion_result \ |
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
729 (coding, CODING_RESULT_INSUFFICIENT_SRC); \ |
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
730 goto no_more_source; \ |
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
731 } \ |
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
732 c = *src++; \ |
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
733 if (multibytep && (c & 0x80)) \ |
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
734 { \ |
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
735 if ((c & 0xFE) == 0xC0) \ |
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
736 c = ((c & 1) << 6) | *src++; \ |
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
737 else \ |
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
738 { \ |
90214
460ee00505d5
(QCascii_compatible_p): New variable.
Kenichi Handa <handa@m17n.org>
parents:
90201
diff
changeset
|
739 src--; \ |
460ee00505d5
(QCascii_compatible_p): New variable.
Kenichi Handa <handa@m17n.org>
parents:
90201
diff
changeset
|
740 c = - string_char (src, &src, NULL); \ |
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
741 record_conversion_result \ |
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
742 (coding, CODING_RESULT_INVALID_SRC); \ |
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
743 } \ |
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
744 } \ |
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
745 consumed_chars++; \ |
88365 | 746 } while (0) |
747 | |
101172
674e67257137
(TWO_MORE_BYTES): New macro.
Kenichi Handa <handa@m17n.org>
parents:
101040
diff
changeset
|
748 /* Safely get two bytes from the source text pointed by SRC which ends |
101174 | 749 at SRC_END, and set C1 and C2 to those bytes while skipping the |
750 heading multibyte characters. If there are not enough bytes in the | |
751 source, it jumps to `no_more_source'. If multibytep is nonzero and | |
752 a multibyte character is found for C2, set C2 to the negative value | |
753 of the character code. The caller should declare and set these | |
754 variables appropriately in advance: | |
101172
674e67257137
(TWO_MORE_BYTES): New macro.
Kenichi Handa <handa@m17n.org>
parents:
101040
diff
changeset
|
755 src, src_end, multibytep |
674e67257137
(TWO_MORE_BYTES): New macro.
Kenichi Handa <handa@m17n.org>
parents:
101040
diff
changeset
|
756 It is intended that this macro is used in detect_coding_utf_16. */ |
674e67257137
(TWO_MORE_BYTES): New macro.
Kenichi Handa <handa@m17n.org>
parents:
101040
diff
changeset
|
757 |
101174 | 758 #define TWO_MORE_BYTES(c1, c2) \ |
759 do { \ | |
760 do { \ | |
761 if (src == src_end) \ | |
762 goto no_more_source; \ | |
763 c1 = *src++; \ | |
764 if (multibytep && (c1 & 0x80)) \ | |
765 { \ | |
766 if ((c1 & 0xFE) == 0xC0) \ | |
767 c1 = ((c1 & 1) << 6) | *src++; \ | |
768 else \ | |
769 { \ | |
770 src += BYTES_BY_CHAR_HEAD (c1) - 1; \ | |
771 c1 = -1; \ | |
772 } \ | |
773 } \ | |
774 } while (c1 < 0); \ | |
775 if (src == src_end) \ | |
776 goto no_more_source; \ | |
777 c2 = *src++; \ | |
778 if (multibytep && (c2 & 0x80)) \ | |
779 { \ | |
780 if ((c2 & 0xFE) == 0xC0) \ | |
781 c2 = ((c2 & 1) << 6) | *src++; \ | |
782 else \ | |
783 c2 = -1; \ | |
784 } \ | |
101172
674e67257137
(TWO_MORE_BYTES): New macro.
Kenichi Handa <handa@m17n.org>
parents:
101040
diff
changeset
|
785 } while (0) |
674e67257137
(TWO_MORE_BYTES): New macro.
Kenichi Handa <handa@m17n.org>
parents:
101040
diff
changeset
|
786 |
88365 | 787 |
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
788 #define ONE_MORE_BYTE_NO_CHECK(c) \ |
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
789 do { \ |
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
790 c = *src++; \ |
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
791 if (multibytep && (c & 0x80)) \ |
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
792 { \ |
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
793 if ((c & 0xFE) == 0xC0) \ |
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
794 c = ((c & 1) << 6) | *src++; \ |
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
795 else \ |
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
796 { \ |
90214
460ee00505d5
(QCascii_compatible_p): New variable.
Kenichi Handa <handa@m17n.org>
parents:
90201
diff
changeset
|
797 src--; \ |
460ee00505d5
(QCascii_compatible_p): New variable.
Kenichi Handa <handa@m17n.org>
parents:
90201
diff
changeset
|
798 c = - string_char (src, &src, NULL); \ |
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
799 record_conversion_result \ |
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
800 (coding, CODING_RESULT_INVALID_SRC); \ |
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
801 } \ |
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
802 } \ |
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
803 consumed_chars++; \ |
88365 | 804 } while (0) |
805 | |
806 | |
807 /* Store a byte C in the place pointed by DST and increment DST to the | |
808 next free point, and increment PRODUCED_CHARS. The caller should | |
809 assure that C is 0..127, and declare and set the variable `dst' | |
810 appropriately in advance. | |
811 */ | |
812 | |
813 | |
814 #define EMIT_ONE_ASCII_BYTE(c) \ | |
815 do { \ | |
816 produced_chars++; \ | |
817 *dst++ = (c); \ | |
818 } while (0) | |
819 | |
820 | |
821 /* Like EMIT_ONE_ASCII_BYTE byt store two bytes; C1 and C2. */ | |
822 | |
823 #define EMIT_TWO_ASCII_BYTES(c1, c2) \ | |
824 do { \ | |
825 produced_chars += 2; \ | |
826 *dst++ = (c1), *dst++ = (c2); \ | |
827 } while (0) | |
828 | |
829 | |
830 /* Store a byte C in the place pointed by DST and increment DST to the | |
831 next free point, and increment PRODUCED_CHARS. If MULTIBYTEP is | |
832 nonzero, store in an appropriate multibyte from. The caller should | |
833 declare and set the variables `dst' and `multibytep' appropriately | |
834 in advance. */ | |
835 | |
836 #define EMIT_ONE_BYTE(c) \ | |
837 do { \ | |
838 produced_chars++; \ | |
839 if (multibytep) \ | |
840 { \ | |
841 int ch = (c); \ | |
842 if (ch >= 0x80) \ | |
843 ch = BYTE8_TO_CHAR (ch); \ | |
844 CHAR_STRING_ADVANCE (ch, dst); \ | |
845 } \ | |
846 else \ | |
847 *dst++ = (c); \ | |
848 } while (0) | |
849 | |
850 | |
851 /* Like EMIT_ONE_BYTE, but emit two bytes; C1 and C2. */ | |
852 | |
88438
3a34b722dd71
(encode_coding_utf_8): Initialize produced_chars to 0.
Kenichi Handa <handa@m17n.org>
parents:
88430
diff
changeset
|
853 #define EMIT_TWO_BYTES(c1, c2) \ |
3a34b722dd71
(encode_coding_utf_8): Initialize produced_chars to 0.
Kenichi Handa <handa@m17n.org>
parents:
88430
diff
changeset
|
854 do { \ |
3a34b722dd71
(encode_coding_utf_8): Initialize produced_chars to 0.
Kenichi Handa <handa@m17n.org>
parents:
88430
diff
changeset
|
855 produced_chars += 2; \ |
3a34b722dd71
(encode_coding_utf_8): Initialize produced_chars to 0.
Kenichi Handa <handa@m17n.org>
parents:
88430
diff
changeset
|
856 if (multibytep) \ |
3a34b722dd71
(encode_coding_utf_8): Initialize produced_chars to 0.
Kenichi Handa <handa@m17n.org>
parents:
88430
diff
changeset
|
857 { \ |
3a34b722dd71
(encode_coding_utf_8): Initialize produced_chars to 0.
Kenichi Handa <handa@m17n.org>
parents:
88430
diff
changeset
|
858 int ch; \ |
3a34b722dd71
(encode_coding_utf_8): Initialize produced_chars to 0.
Kenichi Handa <handa@m17n.org>
parents:
88430
diff
changeset
|
859 \ |
3a34b722dd71
(encode_coding_utf_8): Initialize produced_chars to 0.
Kenichi Handa <handa@m17n.org>
parents:
88430
diff
changeset
|
860 ch = (c1); \ |
3a34b722dd71
(encode_coding_utf_8): Initialize produced_chars to 0.
Kenichi Handa <handa@m17n.org>
parents:
88430
diff
changeset
|
861 if (ch >= 0x80) \ |
3a34b722dd71
(encode_coding_utf_8): Initialize produced_chars to 0.
Kenichi Handa <handa@m17n.org>
parents:
88430
diff
changeset
|
862 ch = BYTE8_TO_CHAR (ch); \ |
3a34b722dd71
(encode_coding_utf_8): Initialize produced_chars to 0.
Kenichi Handa <handa@m17n.org>
parents:
88430
diff
changeset
|
863 CHAR_STRING_ADVANCE (ch, dst); \ |
3a34b722dd71
(encode_coding_utf_8): Initialize produced_chars to 0.
Kenichi Handa <handa@m17n.org>
parents:
88430
diff
changeset
|
864 ch = (c2); \ |
3a34b722dd71
(encode_coding_utf_8): Initialize produced_chars to 0.
Kenichi Handa <handa@m17n.org>
parents:
88430
diff
changeset
|
865 if (ch >= 0x80) \ |
3a34b722dd71
(encode_coding_utf_8): Initialize produced_chars to 0.
Kenichi Handa <handa@m17n.org>
parents:
88430
diff
changeset
|
866 ch = BYTE8_TO_CHAR (ch); \ |
3a34b722dd71
(encode_coding_utf_8): Initialize produced_chars to 0.
Kenichi Handa <handa@m17n.org>
parents:
88430
diff
changeset
|
867 CHAR_STRING_ADVANCE (ch, dst); \ |
3a34b722dd71
(encode_coding_utf_8): Initialize produced_chars to 0.
Kenichi Handa <handa@m17n.org>
parents:
88430
diff
changeset
|
868 } \ |
3a34b722dd71
(encode_coding_utf_8): Initialize produced_chars to 0.
Kenichi Handa <handa@m17n.org>
parents:
88430
diff
changeset
|
869 else \ |
3a34b722dd71
(encode_coding_utf_8): Initialize produced_chars to 0.
Kenichi Handa <handa@m17n.org>
parents:
88430
diff
changeset
|
870 { \ |
3a34b722dd71
(encode_coding_utf_8): Initialize produced_chars to 0.
Kenichi Handa <handa@m17n.org>
parents:
88430
diff
changeset
|
871 *dst++ = (c1); \ |
3a34b722dd71
(encode_coding_utf_8): Initialize produced_chars to 0.
Kenichi Handa <handa@m17n.org>
parents:
88430
diff
changeset
|
872 *dst++ = (c2); \ |
3a34b722dd71
(encode_coding_utf_8): Initialize produced_chars to 0.
Kenichi Handa <handa@m17n.org>
parents:
88430
diff
changeset
|
873 } \ |
88365 | 874 } while (0) |
875 | |
876 | |
877 #define EMIT_THREE_BYTES(c1, c2, c3) \ | |
878 do { \ | |
879 EMIT_ONE_BYTE (c1); \ | |
880 EMIT_TWO_BYTES (c2, c3); \ | |
881 } while (0) | |
882 | |
883 | |
884 #define EMIT_FOUR_BYTES(c1, c2, c3, c4) \ | |
885 do { \ | |
886 EMIT_TWO_BYTES (c1, c2); \ | |
887 EMIT_TWO_BYTES (c3, c4); \ | |
888 } while (0) | |
889 | |
890 | |
89863
428fc37b2ae6
Add many prototypes for static functions.
Kenichi Handa <handa@m17n.org>
parents:
89861
diff
changeset
|
891 /* Prototypes for static functions. */ |
109100
2bc9a0c04c87
Remove __P and P_ from .c and .m files and definition of P_
Jan D <jan.h.d@swipnet.se>
parents:
107984
diff
changeset
|
892 static void record_conversion_result (struct coding_system *coding, |
2bc9a0c04c87
Remove __P and P_ from .c and .m files and definition of P_
Jan D <jan.h.d@swipnet.se>
parents:
107984
diff
changeset
|
893 enum coding_result_code result); |
2bc9a0c04c87
Remove __P and P_ from .c and .m files and definition of P_
Jan D <jan.h.d@swipnet.se>
parents:
107984
diff
changeset
|
894 static int detect_coding_utf_8 (struct coding_system *, |
2bc9a0c04c87
Remove __P and P_ from .c and .m files and definition of P_
Jan D <jan.h.d@swipnet.se>
parents:
107984
diff
changeset
|
895 struct coding_detection_info *info); |
2bc9a0c04c87
Remove __P and P_ from .c and .m files and definition of P_
Jan D <jan.h.d@swipnet.se>
parents:
107984
diff
changeset
|
896 static void decode_coding_utf_8 (struct coding_system *); |
2bc9a0c04c87
Remove __P and P_ from .c and .m files and definition of P_
Jan D <jan.h.d@swipnet.se>
parents:
107984
diff
changeset
|
897 static int encode_coding_utf_8 (struct coding_system *); |
2bc9a0c04c87
Remove __P and P_ from .c and .m files and definition of P_
Jan D <jan.h.d@swipnet.se>
parents:
107984
diff
changeset
|
898 |
2bc9a0c04c87
Remove __P and P_ from .c and .m files and definition of P_
Jan D <jan.h.d@swipnet.se>
parents:
107984
diff
changeset
|
899 static int detect_coding_utf_16 (struct coding_system *, |
2bc9a0c04c87
Remove __P and P_ from .c and .m files and definition of P_
Jan D <jan.h.d@swipnet.se>
parents:
107984
diff
changeset
|
900 struct coding_detection_info *info); |
2bc9a0c04c87
Remove __P and P_ from .c and .m files and definition of P_
Jan D <jan.h.d@swipnet.se>
parents:
107984
diff
changeset
|
901 static void decode_coding_utf_16 (struct coding_system *); |
2bc9a0c04c87
Remove __P and P_ from .c and .m files and definition of P_
Jan D <jan.h.d@swipnet.se>
parents:
107984
diff
changeset
|
902 static int encode_coding_utf_16 (struct coding_system *); |
2bc9a0c04c87
Remove __P and P_ from .c and .m files and definition of P_
Jan D <jan.h.d@swipnet.se>
parents:
107984
diff
changeset
|
903 |
2bc9a0c04c87
Remove __P and P_ from .c and .m files and definition of P_
Jan D <jan.h.d@swipnet.se>
parents:
107984
diff
changeset
|
904 static int detect_coding_iso_2022 (struct coding_system *, |
2bc9a0c04c87
Remove __P and P_ from .c and .m files and definition of P_
Jan D <jan.h.d@swipnet.se>
parents:
107984
diff
changeset
|
905 struct coding_detection_info *info); |
2bc9a0c04c87
Remove __P and P_ from .c and .m files and definition of P_
Jan D <jan.h.d@swipnet.se>
parents:
107984
diff
changeset
|
906 static void decode_coding_iso_2022 (struct coding_system *); |
2bc9a0c04c87
Remove __P and P_ from .c and .m files and definition of P_
Jan D <jan.h.d@swipnet.se>
parents:
107984
diff
changeset
|
907 static int encode_coding_iso_2022 (struct coding_system *); |
2bc9a0c04c87
Remove __P and P_ from .c and .m files and definition of P_
Jan D <jan.h.d@swipnet.se>
parents:
107984
diff
changeset
|
908 |
2bc9a0c04c87
Remove __P and P_ from .c and .m files and definition of P_
Jan D <jan.h.d@swipnet.se>
parents:
107984
diff
changeset
|
909 static int detect_coding_emacs_mule (struct coding_system *, |
2bc9a0c04c87
Remove __P and P_ from .c and .m files and definition of P_
Jan D <jan.h.d@swipnet.se>
parents:
107984
diff
changeset
|
910 struct coding_detection_info *info); |
2bc9a0c04c87
Remove __P and P_ from .c and .m files and definition of P_
Jan D <jan.h.d@swipnet.se>
parents:
107984
diff
changeset
|
911 static void decode_coding_emacs_mule (struct coding_system *); |
2bc9a0c04c87
Remove __P and P_ from .c and .m files and definition of P_
Jan D <jan.h.d@swipnet.se>
parents:
107984
diff
changeset
|
912 static int encode_coding_emacs_mule (struct coding_system *); |
2bc9a0c04c87
Remove __P and P_ from .c and .m files and definition of P_
Jan D <jan.h.d@swipnet.se>
parents:
107984
diff
changeset
|
913 |
2bc9a0c04c87
Remove __P and P_ from .c and .m files and definition of P_
Jan D <jan.h.d@swipnet.se>
parents:
107984
diff
changeset
|
914 static int detect_coding_sjis (struct coding_system *, |
2bc9a0c04c87
Remove __P and P_ from .c and .m files and definition of P_
Jan D <jan.h.d@swipnet.se>
parents:
107984
diff
changeset
|
915 struct coding_detection_info *info); |
2bc9a0c04c87
Remove __P and P_ from .c and .m files and definition of P_
Jan D <jan.h.d@swipnet.se>
parents:
107984
diff
changeset
|
916 static void decode_coding_sjis (struct coding_system *); |
2bc9a0c04c87
Remove __P and P_ from .c and .m files and definition of P_
Jan D <jan.h.d@swipnet.se>
parents:
107984
diff
changeset
|
917 static int encode_coding_sjis (struct coding_system *); |
2bc9a0c04c87
Remove __P and P_ from .c and .m files and definition of P_
Jan D <jan.h.d@swipnet.se>
parents:
107984
diff
changeset
|
918 |
2bc9a0c04c87
Remove __P and P_ from .c and .m files and definition of P_
Jan D <jan.h.d@swipnet.se>
parents:
107984
diff
changeset
|
919 static int detect_coding_big5 (struct coding_system *, |
2bc9a0c04c87
Remove __P and P_ from .c and .m files and definition of P_
Jan D <jan.h.d@swipnet.se>
parents:
107984
diff
changeset
|
920 struct coding_detection_info *info); |
2bc9a0c04c87
Remove __P and P_ from .c and .m files and definition of P_
Jan D <jan.h.d@swipnet.se>
parents:
107984
diff
changeset
|
921 static void decode_coding_big5 (struct coding_system *); |
2bc9a0c04c87
Remove __P and P_ from .c and .m files and definition of P_
Jan D <jan.h.d@swipnet.se>
parents:
107984
diff
changeset
|
922 static int encode_coding_big5 (struct coding_system *); |
2bc9a0c04c87
Remove __P and P_ from .c and .m files and definition of P_
Jan D <jan.h.d@swipnet.se>
parents:
107984
diff
changeset
|
923 |
2bc9a0c04c87
Remove __P and P_ from .c and .m files and definition of P_
Jan D <jan.h.d@swipnet.se>
parents:
107984
diff
changeset
|
924 static int detect_coding_ccl (struct coding_system *, |
2bc9a0c04c87
Remove __P and P_ from .c and .m files and definition of P_
Jan D <jan.h.d@swipnet.se>
parents:
107984
diff
changeset
|
925 struct coding_detection_info *info); |
2bc9a0c04c87
Remove __P and P_ from .c and .m files and definition of P_
Jan D <jan.h.d@swipnet.se>
parents:
107984
diff
changeset
|
926 static void decode_coding_ccl (struct coding_system *); |
2bc9a0c04c87
Remove __P and P_ from .c and .m files and definition of P_
Jan D <jan.h.d@swipnet.se>
parents:
107984
diff
changeset
|
927 static int encode_coding_ccl (struct coding_system *); |
2bc9a0c04c87
Remove __P and P_ from .c and .m files and definition of P_
Jan D <jan.h.d@swipnet.se>
parents:
107984
diff
changeset
|
928 |
2bc9a0c04c87
Remove __P and P_ from .c and .m files and definition of P_
Jan D <jan.h.d@swipnet.se>
parents:
107984
diff
changeset
|
929 static void decode_coding_raw_text (struct coding_system *); |
2bc9a0c04c87
Remove __P and P_ from .c and .m files and definition of P_
Jan D <jan.h.d@swipnet.se>
parents:
107984
diff
changeset
|
930 static int encode_coding_raw_text (struct coding_system *); |
2bc9a0c04c87
Remove __P and P_ from .c and .m files and definition of P_
Jan D <jan.h.d@swipnet.se>
parents:
107984
diff
changeset
|
931 |
2bc9a0c04c87
Remove __P and P_ from .c and .m files and definition of P_
Jan D <jan.h.d@swipnet.se>
parents:
107984
diff
changeset
|
932 static void coding_set_source (struct coding_system *); |
2bc9a0c04c87
Remove __P and P_ from .c and .m files and definition of P_
Jan D <jan.h.d@swipnet.se>
parents:
107984
diff
changeset
|
933 static void coding_set_destination (struct coding_system *); |
2bc9a0c04c87
Remove __P and P_ from .c and .m files and definition of P_
Jan D <jan.h.d@swipnet.se>
parents:
107984
diff
changeset
|
934 static void coding_alloc_by_realloc (struct coding_system *, EMACS_INT); |
2bc9a0c04c87
Remove __P and P_ from .c and .m files and definition of P_
Jan D <jan.h.d@swipnet.se>
parents:
107984
diff
changeset
|
935 static void coding_alloc_by_making_gap (struct coding_system *, |
2bc9a0c04c87
Remove __P and P_ from .c and .m files and definition of P_
Jan D <jan.h.d@swipnet.se>
parents:
107984
diff
changeset
|
936 EMACS_INT, EMACS_INT); |
2bc9a0c04c87
Remove __P and P_ from .c and .m files and definition of P_
Jan D <jan.h.d@swipnet.se>
parents:
107984
diff
changeset
|
937 static unsigned char *alloc_destination (struct coding_system *, |
2bc9a0c04c87
Remove __P and P_ from .c and .m files and definition of P_
Jan D <jan.h.d@swipnet.se>
parents:
107984
diff
changeset
|
938 EMACS_INT, unsigned char *); |
2bc9a0c04c87
Remove __P and P_ from .c and .m files and definition of P_
Jan D <jan.h.d@swipnet.se>
parents:
107984
diff
changeset
|
939 static void setup_iso_safe_charsets (Lisp_Object); |
2bc9a0c04c87
Remove __P and P_ from .c and .m files and definition of P_
Jan D <jan.h.d@swipnet.se>
parents:
107984
diff
changeset
|
940 static unsigned char *encode_designation_at_bol (struct coding_system *, |
2bc9a0c04c87
Remove __P and P_ from .c and .m files and definition of P_
Jan D <jan.h.d@swipnet.se>
parents:
107984
diff
changeset
|
941 int *, int *, |
2bc9a0c04c87
Remove __P and P_ from .c and .m files and definition of P_
Jan D <jan.h.d@swipnet.se>
parents:
107984
diff
changeset
|
942 unsigned char *); |
2bc9a0c04c87
Remove __P and P_ from .c and .m files and definition of P_
Jan D <jan.h.d@swipnet.se>
parents:
107984
diff
changeset
|
943 static int detect_eol (const unsigned char *, |
2bc9a0c04c87
Remove __P and P_ from .c and .m files and definition of P_
Jan D <jan.h.d@swipnet.se>
parents:
107984
diff
changeset
|
944 EMACS_INT, enum coding_category); |
2bc9a0c04c87
Remove __P and P_ from .c and .m files and definition of P_
Jan D <jan.h.d@swipnet.se>
parents:
107984
diff
changeset
|
945 static Lisp_Object adjust_coding_eol_type (struct coding_system *, int); |
2bc9a0c04c87
Remove __P and P_ from .c and .m files and definition of P_
Jan D <jan.h.d@swipnet.se>
parents:
107984
diff
changeset
|
946 static void decode_eol (struct coding_system *); |
2bc9a0c04c87
Remove __P and P_ from .c and .m files and definition of P_
Jan D <jan.h.d@swipnet.se>
parents:
107984
diff
changeset
|
947 static Lisp_Object get_translation_table (Lisp_Object, int, int *); |
2bc9a0c04c87
Remove __P and P_ from .c and .m files and definition of P_
Jan D <jan.h.d@swipnet.se>
parents:
107984
diff
changeset
|
948 static Lisp_Object get_translation (Lisp_Object, int *, int *); |
2bc9a0c04c87
Remove __P and P_ from .c and .m files and definition of P_
Jan D <jan.h.d@swipnet.se>
parents:
107984
diff
changeset
|
949 static int produce_chars (struct coding_system *, Lisp_Object, int); |
2bc9a0c04c87
Remove __P and P_ from .c and .m files and definition of P_
Jan D <jan.h.d@swipnet.se>
parents:
107984
diff
changeset
|
950 static INLINE void produce_charset (struct coding_system *, int *, |
2bc9a0c04c87
Remove __P and P_ from .c and .m files and definition of P_
Jan D <jan.h.d@swipnet.se>
parents:
107984
diff
changeset
|
951 EMACS_INT); |
2bc9a0c04c87
Remove __P and P_ from .c and .m files and definition of P_
Jan D <jan.h.d@swipnet.se>
parents:
107984
diff
changeset
|
952 static void produce_annotation (struct coding_system *, EMACS_INT); |
2bc9a0c04c87
Remove __P and P_ from .c and .m files and definition of P_
Jan D <jan.h.d@swipnet.se>
parents:
107984
diff
changeset
|
953 static int decode_coding (struct coding_system *); |
2bc9a0c04c87
Remove __P and P_ from .c and .m files and definition of P_
Jan D <jan.h.d@swipnet.se>
parents:
107984
diff
changeset
|
954 static INLINE int *handle_composition_annotation (EMACS_INT, EMACS_INT, |
2bc9a0c04c87
Remove __P and P_ from .c and .m files and definition of P_
Jan D <jan.h.d@swipnet.se>
parents:
107984
diff
changeset
|
955 struct coding_system *, |
2bc9a0c04c87
Remove __P and P_ from .c and .m files and definition of P_
Jan D <jan.h.d@swipnet.se>
parents:
107984
diff
changeset
|
956 int *, EMACS_INT *); |
2bc9a0c04c87
Remove __P and P_ from .c and .m files and definition of P_
Jan D <jan.h.d@swipnet.se>
parents:
107984
diff
changeset
|
957 static INLINE int *handle_charset_annotation (EMACS_INT, EMACS_INT, |
2bc9a0c04c87
Remove __P and P_ from .c and .m files and definition of P_
Jan D <jan.h.d@swipnet.se>
parents:
107984
diff
changeset
|
958 struct coding_system *, |
2bc9a0c04c87
Remove __P and P_ from .c and .m files and definition of P_
Jan D <jan.h.d@swipnet.se>
parents:
107984
diff
changeset
|
959 int *, EMACS_INT *); |
2bc9a0c04c87
Remove __P and P_ from .c and .m files and definition of P_
Jan D <jan.h.d@swipnet.se>
parents:
107984
diff
changeset
|
960 static void consume_chars (struct coding_system *, Lisp_Object, int); |
2bc9a0c04c87
Remove __P and P_ from .c and .m files and definition of P_
Jan D <jan.h.d@swipnet.se>
parents:
107984
diff
changeset
|
961 static int encode_coding (struct coding_system *); |
2bc9a0c04c87
Remove __P and P_ from .c and .m files and definition of P_
Jan D <jan.h.d@swipnet.se>
parents:
107984
diff
changeset
|
962 static Lisp_Object make_conversion_work_buffer (int); |
2bc9a0c04c87
Remove __P and P_ from .c and .m files and definition of P_
Jan D <jan.h.d@swipnet.se>
parents:
107984
diff
changeset
|
963 static Lisp_Object code_conversion_restore (Lisp_Object); |
2bc9a0c04c87
Remove __P and P_ from .c and .m files and definition of P_
Jan D <jan.h.d@swipnet.se>
parents:
107984
diff
changeset
|
964 static INLINE int char_encodable_p (int, Lisp_Object); |
2bc9a0c04c87
Remove __P and P_ from .c and .m files and definition of P_
Jan D <jan.h.d@swipnet.se>
parents:
107984
diff
changeset
|
965 static Lisp_Object make_subsidiaries (Lisp_Object); |
89863
428fc37b2ae6
Add many prototypes for static functions.
Kenichi Handa <handa@m17n.org>
parents:
89861
diff
changeset
|
966 |
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
967 static void |
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
968 record_conversion_result (struct coding_system *coding, |
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
969 enum coding_result_code result) |
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
970 { |
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
971 coding->result = result; |
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
972 switch (result) |
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
973 { |
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
974 case CODING_RESULT_INSUFFICIENT_SRC: |
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
975 Vlast_code_conversion_error = Qinsufficient_source; |
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
976 break; |
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
977 case CODING_RESULT_INCONSISTENT_EOL: |
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
978 Vlast_code_conversion_error = Qinconsistent_eol; |
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
979 break; |
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
980 case CODING_RESULT_INVALID_SRC: |
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
981 Vlast_code_conversion_error = Qinvalid_source; |
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
982 break; |
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
983 case CODING_RESULT_INTERRUPT: |
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
984 Vlast_code_conversion_error = Qinterrupted; |
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
985 break; |
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
986 case CODING_RESULT_INSUFFICIENT_MEM: |
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
987 Vlast_code_conversion_error = Qinsufficient_memory; |
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
988 break; |
107174
e98bd64897e0
Fix handling of CODING_RESULT_INSUFFICIENT_DST.
Kenichi Handa <handa@m17n.org>
parents:
107171
diff
changeset
|
989 case CODING_RESULT_INSUFFICIENT_DST: |
e98bd64897e0
Fix handling of CODING_RESULT_INSUFFICIENT_DST.
Kenichi Handa <handa@m17n.org>
parents:
107171
diff
changeset
|
990 /* Don't record this error in Vlast_code_conversion_error |
e98bd64897e0
Fix handling of CODING_RESULT_INSUFFICIENT_DST.
Kenichi Handa <handa@m17n.org>
parents:
107171
diff
changeset
|
991 because it happens just temporarily and is resolved when the |
e98bd64897e0
Fix handling of CODING_RESULT_INSUFFICIENT_DST.
Kenichi Handa <handa@m17n.org>
parents:
107171
diff
changeset
|
992 whole conversion is finished. */ |
e98bd64897e0
Fix handling of CODING_RESULT_INSUFFICIENT_DST.
Kenichi Handa <handa@m17n.org>
parents:
107171
diff
changeset
|
993 break; |
103133
2f7395806731
(record_conversion_result): Don't modify
Andreas Schwab <schwab@linux-m68k.org>
parents:
103052
diff
changeset
|
994 case CODING_RESULT_SUCCESS: |
2f7395806731
(record_conversion_result): Don't modify
Andreas Schwab <schwab@linux-m68k.org>
parents:
103052
diff
changeset
|
995 break; |
90214
460ee00505d5
(QCascii_compatible_p): New variable.
Kenichi Handa <handa@m17n.org>
parents:
90201
diff
changeset
|
996 default: |
460ee00505d5
(QCascii_compatible_p): New variable.
Kenichi Handa <handa@m17n.org>
parents:
90201
diff
changeset
|
997 Vlast_code_conversion_error = intern ("Unknown error"); |
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
998 } |
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
999 } |
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1000 |
107321
9b814b3ee348
Fix bug in decoding emacs-mule encoding.
Eli Zaretskii <eliz@gnu.org>
parents:
107174
diff
changeset
|
1001 /* This wrapper macro is used to preserve validity of pointers into |
9b814b3ee348
Fix bug in decoding emacs-mule encoding.
Eli Zaretskii <eliz@gnu.org>
parents:
107174
diff
changeset
|
1002 buffer text across calls to decode_char, which could cause |
9b814b3ee348
Fix bug in decoding emacs-mule encoding.
Eli Zaretskii <eliz@gnu.org>
parents:
107174
diff
changeset
|
1003 relocation of buffers if it loads a charset map, because loading a |
9b814b3ee348
Fix bug in decoding emacs-mule encoding.
Eli Zaretskii <eliz@gnu.org>
parents:
107174
diff
changeset
|
1004 charset map allocates large structures. */ |
88365 | 1005 #define CODING_DECODE_CHAR(coding, src, src_base, src_end, charset, code, c) \ |
1006 do { \ | |
1007 charset_map_loaded = 0; \ | |
1008 c = DECODE_CHAR (charset, code); \ | |
1009 if (charset_map_loaded) \ | |
1010 { \ | |
89483 | 1011 const unsigned char *orig = coding->source; \ |
88365 | 1012 EMACS_INT offset; \ |
1013 \ | |
1014 coding_set_source (coding); \ | |
1015 offset = coding->source - orig; \ | |
1016 src += offset; \ | |
1017 src_base += offset; \ | |
1018 src_end += offset; \ | |
1019 } \ | |
1020 } while (0) | |
1021 | |
1022 | |
92399
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
1023 /* If there are at least BYTES length of room at dst, allocate memory |
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
1024 for coding->destination and update dst and dst_end. We don't have |
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
1025 to take care of coding->source which will be relocated. It is |
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
1026 handled by calling coding_set_source in encode_coding. */ |
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
1027 |
88365 | 1028 #define ASSURE_DESTINATION(bytes) \ |
1029 do { \ | |
1030 if (dst + (bytes) >= dst_end) \ | |
1031 { \ | |
1032 int more_bytes = charbuf_end - charbuf + (bytes); \ | |
1033 \ | |
1034 dst = alloc_destination (coding, more_bytes, dst); \ | |
1035 dst_end = coding->destination + coding->dst_bytes; \ | |
1036 } \ | |
1037 } while (0) | |
1038 | |
1039 | |
92992
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
1040 /* Store multibyte form of the character C in P, and advance P to the |
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
1041 end of the multibyte form. This is like CHAR_STRING_ADVANCE but it |
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
1042 never calls MAYBE_UNIFY_CHAR. */ |
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
1043 |
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
1044 #define CHAR_STRING_ADVANCE_NO_UNIFY(c, p) \ |
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
1045 do { \ |
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
1046 if ((c) <= MAX_1_BYTE_CHAR) \ |
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
1047 *(p)++ = (c); \ |
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
1048 else if ((c) <= MAX_2_BYTE_CHAR) \ |
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
1049 *(p)++ = (0xC0 | ((c) >> 6)), \ |
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
1050 *(p)++ = (0x80 | ((c) & 0x3F)); \ |
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
1051 else if ((c) <= MAX_3_BYTE_CHAR) \ |
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
1052 *(p)++ = (0xE0 | ((c) >> 12)), \ |
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
1053 *(p)++ = (0x80 | (((c) >> 6) & 0x3F)), \ |
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
1054 *(p)++ = (0x80 | ((c) & 0x3F)); \ |
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
1055 else if ((c) <= MAX_4_BYTE_CHAR) \ |
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
1056 *(p)++ = (0xF0 | (c >> 18)), \ |
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
1057 *(p)++ = (0x80 | ((c >> 12) & 0x3F)), \ |
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
1058 *(p)++ = (0x80 | ((c >> 6) & 0x3F)), \ |
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
1059 *(p)++ = (0x80 | (c & 0x3F)); \ |
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
1060 else if ((c) <= MAX_5_BYTE_CHAR) \ |
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
1061 *(p)++ = 0xF8, \ |
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
1062 *(p)++ = (0x80 | ((c >> 18) & 0x0F)), \ |
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
1063 *(p)++ = (0x80 | ((c >> 12) & 0x3F)), \ |
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
1064 *(p)++ = (0x80 | ((c >> 6) & 0x3F)), \ |
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
1065 *(p)++ = (0x80 | (c & 0x3F)); \ |
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
1066 else \ |
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
1067 (p) += BYTE8_STRING ((c) - 0x3FFF80, p); \ |
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
1068 } while (0) |
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
1069 |
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
1070 |
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
1071 /* Return the character code of character whose multibyte form is at |
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
1072 P, and advance P to the end of the multibyte form. This is like |
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
1073 STRING_CHAR_ADVANCE, but it never calls MAYBE_UNIFY_CHAR. */ |
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
1074 |
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
1075 #define STRING_CHAR_ADVANCE_NO_UNIFY(p) \ |
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
1076 (!((p)[0] & 0x80) \ |
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
1077 ? *(p)++ \ |
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
1078 : ! ((p)[0] & 0x20) \ |
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
1079 ? ((p) += 2, \ |
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
1080 ((((p)[-2] & 0x1F) << 6) \ |
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
1081 | ((p)[-1] & 0x3F) \ |
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
1082 | ((unsigned char) ((p)[-2]) < 0xC2 ? 0x3FFF80 : 0))) \ |
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
1083 : ! ((p)[0] & 0x10) \ |
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
1084 ? ((p) += 3, \ |
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
1085 ((((p)[-3] & 0x0F) << 12) \ |
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
1086 | (((p)[-2] & 0x3F) << 6) \ |
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
1087 | ((p)[-1] & 0x3F))) \ |
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
1088 : ! ((p)[0] & 0x08) \ |
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
1089 ? ((p) += 4, \ |
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
1090 ((((p)[-4] & 0xF) << 18) \ |
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
1091 | (((p)[-3] & 0x3F) << 12) \ |
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
1092 | (((p)[-2] & 0x3F) << 6) \ |
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
1093 | ((p)[-1] & 0x3F))) \ |
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
1094 : ((p) += 5, \ |
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
1095 ((((p)[-4] & 0x3F) << 18) \ |
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
1096 | (((p)[-3] & 0x3F) << 12) \ |
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
1097 | (((p)[-2] & 0x3F) << 6) \ |
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
1098 | ((p)[-1] & 0x3F)))) |
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
1099 |
88365 | 1100 |
1101 static void | |
109126
aec1143e8d85
Convert (most) functions in src to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109100
diff
changeset
|
1102 coding_set_source (struct coding_system *coding) |
88365 | 1103 { |
1104 if (BUFFERP (coding->src_object)) | |
1105 { | |
89418
a9c2b3712863
(coding_set_source): Fix for the case that the current
Kenichi Handa <handa@m17n.org>
parents:
89404
diff
changeset
|
1106 struct buffer *buf = XBUFFER (coding->src_object); |
a9c2b3712863
(coding_set_source): Fix for the case that the current
Kenichi Handa <handa@m17n.org>
parents:
89404
diff
changeset
|
1107 |
88365 | 1108 if (coding->src_pos < 0) |
89418
a9c2b3712863
(coding_set_source): Fix for the case that the current
Kenichi Handa <handa@m17n.org>
parents:
89404
diff
changeset
|
1109 coding->source = BUF_GAP_END_ADDR (buf) + coding->src_pos_byte; |
88365 | 1110 else |
89418
a9c2b3712863
(coding_set_source): Fix for the case that the current
Kenichi Handa <handa@m17n.org>
parents:
89404
diff
changeset
|
1111 coding->source = BUF_BYTE_ADDRESS (buf, coding->src_pos_byte); |
88365 | 1112 } |
1113 else if (STRINGP (coding->src_object)) | |
1114 { | |
89483 | 1115 coding->source = SDATA (coding->src_object) + coding->src_pos_byte; |
88365 | 1116 } |
1117 else | |
1118 /* Otherwise, the source is C string and is never relocated | |
1119 automatically. Thus we don't have to update anything. */ | |
1120 ; | |
1121 } | |
1122 | |
1123 static void | |
109126
aec1143e8d85
Convert (most) functions in src to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109100
diff
changeset
|
1124 coding_set_destination (struct coding_system *coding) |
30487
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
1125 { |
88365 | 1126 if (BUFFERP (coding->dst_object)) |
1127 { | |
1128 if (coding->src_pos < 0) | |
89042
2b9f8973f240
(coding_set_destination): Fix coding->destination for
Kenichi Handa <handa@m17n.org>
parents:
88977
diff
changeset
|
1129 { |
91807
507bcfb4342c
* coding.c (coding_set_destination): Use BEG_BYTE rather than hardcoding 1.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91622
diff
changeset
|
1130 coding->destination = BEG_ADDR + coding->dst_pos_byte - BEG_BYTE; |
89042
2b9f8973f240
(coding_set_destination): Fix coding->destination for
Kenichi Handa <handa@m17n.org>
parents:
88977
diff
changeset
|
1131 coding->dst_bytes = (GAP_END_ADDR |
2b9f8973f240
(coding_set_destination): Fix coding->destination for
Kenichi Handa <handa@m17n.org>
parents:
88977
diff
changeset
|
1132 - (coding->src_bytes - coding->consumed) |
2b9f8973f240
(coding_set_destination): Fix coding->destination for
Kenichi Handa <handa@m17n.org>
parents:
88977
diff
changeset
|
1133 - coding->destination); |
2b9f8973f240
(coding_set_destination): Fix coding->destination for
Kenichi Handa <handa@m17n.org>
parents:
88977
diff
changeset
|
1134 } |
88365 | 1135 else |
89042
2b9f8973f240
(coding_set_destination): Fix coding->destination for
Kenichi Handa <handa@m17n.org>
parents:
88977
diff
changeset
|
1136 { |
2b9f8973f240
(coding_set_destination): Fix coding->destination for
Kenichi Handa <handa@m17n.org>
parents:
88977
diff
changeset
|
1137 /* We are sure that coding->dst_pos_byte is before the gap |
2b9f8973f240
(coding_set_destination): Fix coding->destination for
Kenichi Handa <handa@m17n.org>
parents:
88977
diff
changeset
|
1138 of the buffer. */ |
2b9f8973f240
(coding_set_destination): Fix coding->destination for
Kenichi Handa <handa@m17n.org>
parents:
88977
diff
changeset
|
1139 coding->destination = (BUF_BEG_ADDR (XBUFFER (coding->dst_object)) |
91807
507bcfb4342c
* coding.c (coding_set_destination): Use BEG_BYTE rather than hardcoding 1.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91622
diff
changeset
|
1140 + coding->dst_pos_byte - BEG_BYTE); |
89042
2b9f8973f240
(coding_set_destination): Fix coding->destination for
Kenichi Handa <handa@m17n.org>
parents:
88977
diff
changeset
|
1141 coding->dst_bytes = (BUF_GAP_END_ADDR (XBUFFER (coding->dst_object)) |
2b9f8973f240
(coding_set_destination): Fix coding->destination for
Kenichi Handa <handa@m17n.org>
parents:
88977
diff
changeset
|
1142 - coding->destination); |
2b9f8973f240
(coding_set_destination): Fix coding->destination for
Kenichi Handa <handa@m17n.org>
parents:
88977
diff
changeset
|
1143 } |
88365 | 1144 } |
1145 else | |
1146 /* Otherwise, the destination is C string and is never relocated | |
1147 automatically. Thus we don't have to update anything. */ | |
1148 ; | |
1149 } | |
1150 | |
1151 | |
1152 static void | |
109126
aec1143e8d85
Convert (most) functions in src to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109100
diff
changeset
|
1153 coding_alloc_by_realloc (struct coding_system *coding, EMACS_INT bytes) |
88365 | 1154 { |
1155 coding->destination = (unsigned char *) xrealloc (coding->destination, | |
1156 coding->dst_bytes + bytes); | |
1157 coding->dst_bytes += bytes; | |
30487
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
1158 } |
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
1159 |
88365 | 1160 static void |
109159
3e9fdeb960d1
* coding.c, sysdep.c: Convert some more functions to standard C.
Juanma Barranquero <lekktu@gmail.com>
parents:
109158
diff
changeset
|
1161 coding_alloc_by_making_gap (struct coding_system *coding, |
3e9fdeb960d1
* coding.c, sysdep.c: Convert some more functions to standard C.
Juanma Barranquero <lekktu@gmail.com>
parents:
109158
diff
changeset
|
1162 EMACS_INT gap_head_used, EMACS_INT bytes) |
92992
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
1163 { |
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
1164 if (EQ (coding->src_object, coding->dst_object)) |
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
1165 { |
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
1166 /* The gap may contain the produced data at the head and not-yet |
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
1167 consumed data at the tail. To preserve those data, we at |
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
1168 first make the gap size to zero, then increase the gap |
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
1169 size. */ |
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
1170 EMACS_INT add = GAP_SIZE; |
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
1171 |
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
1172 GPT += gap_head_used, GPT_BYTE += gap_head_used; |
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
1173 GAP_SIZE = 0; ZV += add; Z += add; ZV_BYTE += add; Z_BYTE += add; |
88365 | 1174 make_gap (bytes); |
1175 GAP_SIZE += add; ZV -= add; Z -= add; ZV_BYTE -= add; Z_BYTE -= add; | |
92992
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
1176 GPT -= gap_head_used, GPT_BYTE -= gap_head_used; |
88365 | 1177 } |
90292
697c08d95af7
Cancel incorrect synching with HEAD.
Kenichi Handa <handa@m17n.org>
parents:
90291
diff
changeset
|
1178 else |
88365 | 1179 { |
88456
a7b309f72920
(coding_alloc_by_making_gap): Check the case that the
Kenichi Handa <handa@m17n.org>
parents:
88443
diff
changeset
|
1180 Lisp_Object this_buffer; |
a7b309f72920
(coding_alloc_by_making_gap): Check the case that the
Kenichi Handa <handa@m17n.org>
parents:
88443
diff
changeset
|
1181 |
a7b309f72920
(coding_alloc_by_making_gap): Check the case that the
Kenichi Handa <handa@m17n.org>
parents:
88443
diff
changeset
|
1182 this_buffer = Fcurrent_buffer (); |
88365 | 1183 set_buffer_internal (XBUFFER (coding->dst_object)); |
1184 make_gap (bytes); | |
1185 set_buffer_internal (XBUFFER (this_buffer)); | |
1186 } | |
1187 } | |
89483 | 1188 |
88365 | 1189 |
1190 static unsigned char * | |
109159
3e9fdeb960d1
* coding.c, sysdep.c: Convert some more functions to standard C.
Juanma Barranquero <lekktu@gmail.com>
parents:
109158
diff
changeset
|
1191 alloc_destination (struct coding_system *coding, EMACS_INT nbytes, |
3e9fdeb960d1
* coding.c, sysdep.c: Convert some more functions to standard C.
Juanma Barranquero <lekktu@gmail.com>
parents:
109158
diff
changeset
|
1192 unsigned char *dst) |
88365 | 1193 { |
1194 EMACS_INT offset = dst - coding->destination; | |
1195 | |
1196 if (BUFFERP (coding->dst_object)) | |
92992
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
1197 { |
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
1198 struct buffer *buf = XBUFFER (coding->dst_object); |
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
1199 |
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
1200 coding_alloc_by_making_gap (coding, dst - BUF_GPT_ADDR (buf), nbytes); |
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
1201 } |
88365 | 1202 else |
1203 coding_alloc_by_realloc (coding, nbytes); | |
1204 coding_set_destination (coding); | |
1205 dst = coding->destination + offset; | |
1206 return dst; | |
1207 } | |
1208 | |
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1209 /** Macros for annotations. */ |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1210 |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1211 /* An annotation data is stored in the array coding->charbuf in this |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1212 format: |
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
1213 [ -LENGTH ANNOTATION_MASK NCHARS ... ] |
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1214 LENGTH is the number of elements in the annotation. |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1215 ANNOTATION_MASK is one of CODING_ANNOTATE_XXX_MASK. |
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
1216 NCHARS is the number of characters in the text annotated. |
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1217 |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1218 The format of the following elements depend on ANNOTATION_MASK. |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1219 |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1220 In the case of CODING_ANNOTATE_COMPOSITION_MASK, these elements |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1221 follows: |
102422
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
1222 ... NBYTES METHOD [ COMPOSITION-COMPONENTS ... ] |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
1223 |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
1224 NBYTES is the number of bytes specified in the header part of |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
1225 old-style emacs-mule encoding, or 0 for the other kind of |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
1226 composition. |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
1227 |
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1228 METHOD is one of enum composition_method. |
102422
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
1229 |
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1230 Optionnal COMPOSITION-COMPONENTS are characters and composition |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1231 rules. |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1232 |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1233 In the case of CODING_ANNOTATE_CHARSET_MASK, one element CHARSET-ID |
102422
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
1234 follows. |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
1235 |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
1236 If ANNOTATION_MASK is 0, this annotation is just a space holder to |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
1237 recover from an invalid annotation, and should be skipped by |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
1238 produce_annotation. */ |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
1239 |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
1240 /* Maximum length of the header of annotation data. */ |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
1241 #define MAX_ANNOTATION_LENGTH 5 |
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1242 |
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
1243 #define ADD_ANNOTATION_DATA(buf, len, mask, nchars) \ |
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1244 do { \ |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1245 *(buf)++ = -(len); \ |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1246 *(buf)++ = (mask); \ |
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
1247 *(buf)++ = (nchars); \ |
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1248 coding->annotated = 1; \ |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1249 } while (0); |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1250 |
102422
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
1251 #define ADD_COMPOSITION_DATA(buf, nchars, nbytes, method) \ |
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
1252 do { \ |
102422
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
1253 ADD_ANNOTATION_DATA (buf, 5, CODING_ANNOTATE_COMPOSITION_MASK, nchars); \ |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
1254 *buf++ = nbytes; \ |
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
1255 *buf++ = method; \ |
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1256 } while (0) |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1257 |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1258 |
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
1259 #define ADD_CHARSET_DATA(buf, nchars, id) \ |
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
1260 do { \ |
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
1261 ADD_ANNOTATION_DATA (buf, 4, CODING_ANNOTATE_CHARSET_MASK, nchars); \ |
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
1262 *buf++ = id; \ |
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1263 } while (0) |
30487
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
1264 |
17052 | 1265 |
88365 | 1266 /*** 2. Emacs' internal format (emacs-utf-8) ***/ |
1267 | |
1268 | |
30487
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
1269 |
17052 | 1270 |
88365 | 1271 /*** 3. UTF-8 ***/ |
1272 | |
1273 /* See the above "GENERAL NOTES on `detect_coding_XXX ()' functions". | |
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1274 Check if a text is encoded in UTF-8. If it is, return 1, else |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1275 return 0. */ |
88365 | 1276 |
1277 #define UTF_8_1_OCTET_P(c) ((c) < 0x80) | |
1278 #define UTF_8_EXTRA_OCTET_P(c) (((c) & 0xC0) == 0x80) | |
1279 #define UTF_8_2_OCTET_LEADING_P(c) (((c) & 0xE0) == 0xC0) | |
1280 #define UTF_8_3_OCTET_LEADING_P(c) (((c) & 0xF0) == 0xE0) | |
1281 #define UTF_8_4_OCTET_LEADING_P(c) (((c) & 0xF8) == 0xF0) | |
1282 #define UTF_8_5_OCTET_LEADING_P(c) (((c) & 0xFC) == 0xF8) | |
1283 | |
95397
c99f0a16c077
(CODING_UTF_8_BOM): New macro.
Kenichi Handa <handa@m17n.org>
parents:
95356
diff
changeset
|
1284 #define UTF_BOM 0xFEFF |
c99f0a16c077
(CODING_UTF_8_BOM): New macro.
Kenichi Handa <handa@m17n.org>
parents:
95356
diff
changeset
|
1285 #define UTF_8_BOM_1 0xEF |
c99f0a16c077
(CODING_UTF_8_BOM): New macro.
Kenichi Handa <handa@m17n.org>
parents:
95356
diff
changeset
|
1286 #define UTF_8_BOM_2 0xBB |
c99f0a16c077
(CODING_UTF_8_BOM): New macro.
Kenichi Handa <handa@m17n.org>
parents:
95356
diff
changeset
|
1287 #define UTF_8_BOM_3 0xBF |
c99f0a16c077
(CODING_UTF_8_BOM): New macro.
Kenichi Handa <handa@m17n.org>
parents:
95356
diff
changeset
|
1288 |
88365 | 1289 static int |
109159
3e9fdeb960d1
* coding.c, sysdep.c: Convert some more functions to standard C.
Juanma Barranquero <lekktu@gmail.com>
parents:
109158
diff
changeset
|
1290 detect_coding_utf_8 (struct coding_system *coding, |
3e9fdeb960d1
* coding.c, sysdep.c: Convert some more functions to standard C.
Juanma Barranquero <lekktu@gmail.com>
parents:
109158
diff
changeset
|
1291 struct coding_detection_info *detect_info) |
88365 | 1292 { |
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1293 const unsigned char *src = coding->source, *src_base; |
89483 | 1294 const unsigned char *src_end = coding->source + coding->src_bytes; |
88365 | 1295 int multibytep = coding->src_multibyte; |
1296 int consumed_chars = 0; | |
95397
c99f0a16c077
(CODING_UTF_8_BOM): New macro.
Kenichi Handa <handa@m17n.org>
parents:
95356
diff
changeset
|
1297 int bom_found = 0; |
88365 | 1298 int found = 0; |
1299 | |
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1300 detect_info->checked |= CATEGORY_MASK_UTF_8; |
88365 | 1301 /* A coding system of this category is always ASCII compatible. */ |
1302 src += coding->head_ascii; | |
1303 | |
1304 while (1) | |
1305 { | |
1306 int c, c1, c2, c3, c4; | |
1307 | |
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1308 src_base = src; |
88365 | 1309 ONE_MORE_BYTE (c); |
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1310 if (c < 0 || UTF_8_1_OCTET_P (c)) |
88365 | 1311 continue; |
1312 ONE_MORE_BYTE (c1); | |
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1313 if (c1 < 0 || ! UTF_8_EXTRA_OCTET_P (c1)) |
88365 | 1314 break; |
1315 if (UTF_8_2_OCTET_LEADING_P (c)) | |
1316 { | |
95397
c99f0a16c077
(CODING_UTF_8_BOM): New macro.
Kenichi Handa <handa@m17n.org>
parents:
95356
diff
changeset
|
1317 found = 1; |
88365 | 1318 continue; |
1319 } | |
1320 ONE_MORE_BYTE (c2); | |
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1321 if (c2 < 0 || ! UTF_8_EXTRA_OCTET_P (c2)) |
88365 | 1322 break; |
1323 if (UTF_8_3_OCTET_LEADING_P (c)) | |
1324 { | |
95397
c99f0a16c077
(CODING_UTF_8_BOM): New macro.
Kenichi Handa <handa@m17n.org>
parents:
95356
diff
changeset
|
1325 found = 1; |
c99f0a16c077
(CODING_UTF_8_BOM): New macro.
Kenichi Handa <handa@m17n.org>
parents:
95356
diff
changeset
|
1326 if (src_base == coding->source |
c99f0a16c077
(CODING_UTF_8_BOM): New macro.
Kenichi Handa <handa@m17n.org>
parents:
95356
diff
changeset
|
1327 && c == UTF_8_BOM_1 && c1 == UTF_8_BOM_2 && c2 == UTF_8_BOM_3) |
c99f0a16c077
(CODING_UTF_8_BOM): New macro.
Kenichi Handa <handa@m17n.org>
parents:
95356
diff
changeset
|
1328 bom_found = 1; |
88365 | 1329 continue; |
1330 } | |
1331 ONE_MORE_BYTE (c3); | |
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1332 if (c3 < 0 || ! UTF_8_EXTRA_OCTET_P (c3)) |
88365 | 1333 break; |
1334 if (UTF_8_4_OCTET_LEADING_P (c)) | |
1335 { | |
95397
c99f0a16c077
(CODING_UTF_8_BOM): New macro.
Kenichi Handa <handa@m17n.org>
parents:
95356
diff
changeset
|
1336 found = 1; |
88365 | 1337 continue; |
1338 } | |
1339 ONE_MORE_BYTE (c4); | |
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1340 if (c4 < 0 || ! UTF_8_EXTRA_OCTET_P (c4)) |
88365 | 1341 break; |
1342 if (UTF_8_5_OCTET_LEADING_P (c)) | |
1343 { | |
95397
c99f0a16c077
(CODING_UTF_8_BOM): New macro.
Kenichi Handa <handa@m17n.org>
parents:
95356
diff
changeset
|
1344 found = 1; |
88365 | 1345 continue; |
1346 } | |
1347 break; | |
1348 } | |
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1349 detect_info->rejected |= CATEGORY_MASK_UTF_8; |
88365 | 1350 return 0; |
1351 | |
1352 no_more_source: | |
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1353 if (src_base < src && coding->mode & CODING_MODE_LAST_BLOCK) |
89193
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
1354 { |
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1355 detect_info->rejected |= CATEGORY_MASK_UTF_8; |
89193
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
1356 return 0; |
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
1357 } |
95397
c99f0a16c077
(CODING_UTF_8_BOM): New macro.
Kenichi Handa <handa@m17n.org>
parents:
95356
diff
changeset
|
1358 if (bom_found) |
c99f0a16c077
(CODING_UTF_8_BOM): New macro.
Kenichi Handa <handa@m17n.org>
parents:
95356
diff
changeset
|
1359 { |
c99f0a16c077
(CODING_UTF_8_BOM): New macro.
Kenichi Handa <handa@m17n.org>
parents:
95356
diff
changeset
|
1360 /* The first character 0xFFFE doesn't necessarily mean a BOM. */ |
c99f0a16c077
(CODING_UTF_8_BOM): New macro.
Kenichi Handa <handa@m17n.org>
parents:
95356
diff
changeset
|
1361 detect_info->found |= CATEGORY_MASK_UTF_8_SIG | CATEGORY_MASK_UTF_8_NOSIG; |
c99f0a16c077
(CODING_UTF_8_BOM): New macro.
Kenichi Handa <handa@m17n.org>
parents:
95356
diff
changeset
|
1362 } |
c99f0a16c077
(CODING_UTF_8_BOM): New macro.
Kenichi Handa <handa@m17n.org>
parents:
95356
diff
changeset
|
1363 else |
c99f0a16c077
(CODING_UTF_8_BOM): New macro.
Kenichi Handa <handa@m17n.org>
parents:
95356
diff
changeset
|
1364 { |
c99f0a16c077
(CODING_UTF_8_BOM): New macro.
Kenichi Handa <handa@m17n.org>
parents:
95356
diff
changeset
|
1365 detect_info->rejected |= CATEGORY_MASK_UTF_8_SIG; |
96571
a3f2a5a4b492
(detect_coding_utf_8): Set detect_info->found only when
Kenichi Handa <handa@m17n.org>
parents:
95585
diff
changeset
|
1366 if (found) |
a3f2a5a4b492
(detect_coding_utf_8): Set detect_info->found only when
Kenichi Handa <handa@m17n.org>
parents:
95585
diff
changeset
|
1367 detect_info->found |= CATEGORY_MASK_UTF_8_NOSIG; |
95397
c99f0a16c077
(CODING_UTF_8_BOM): New macro.
Kenichi Handa <handa@m17n.org>
parents:
95356
diff
changeset
|
1368 } |
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1369 return 1; |
88365 | 1370 } |
1371 | |
1372 | |
1373 static void | |
109126
aec1143e8d85
Convert (most) functions in src to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109100
diff
changeset
|
1374 decode_coding_utf_8 (struct coding_system *coding) |
88365 | 1375 { |
89483 | 1376 const unsigned char *src = coding->source + coding->consumed; |
1377 const unsigned char *src_end = coding->source + coding->src_bytes; | |
1378 const unsigned char *src_base; | |
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
1379 int *charbuf = coding->charbuf + coding->charbuf_used; |
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
1380 int *charbuf_end = coding->charbuf + coding->charbuf_size; |
100133
bca35d7cb3ac
(decode_coding_utf_8): Likewise.
Kenichi Handa <handa@m17n.org>
parents:
100131
diff
changeset
|
1381 int consumed_chars = 0, consumed_chars_base = 0; |
88365 | 1382 int multibytep = coding->src_multibyte; |
95397
c99f0a16c077
(CODING_UTF_8_BOM): New macro.
Kenichi Handa <handa@m17n.org>
parents:
95356
diff
changeset
|
1383 enum utf_bom_type bom = CODING_UTF_8_BOM (coding); |
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
1384 Lisp_Object attr, charset_list; |
102334
7baaea85626e
(decode_coding_utf_8, decode_coding_utf_16, decode_coding_emacs_mule,
Eli Zaretskii <eliz@gnu.org>
parents:
102327
diff
changeset
|
1385 int eol_crlf = |
7baaea85626e
(decode_coding_utf_8, decode_coding_utf_16, decode_coding_emacs_mule,
Eli Zaretskii <eliz@gnu.org>
parents:
102327
diff
changeset
|
1386 !inhibit_eol_conversion && EQ (CODING_ID_EOL_TYPE (coding->id), Qdos); |
92399
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
1387 int byte_after_cr = -1; |
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
1388 |
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
1389 CODING_GET_INFO (coding, attr, charset_list); |
88365 | 1390 |
95397
c99f0a16c077
(CODING_UTF_8_BOM): New macro.
Kenichi Handa <handa@m17n.org>
parents:
95356
diff
changeset
|
1391 if (bom != utf_without_bom) |
c99f0a16c077
(CODING_UTF_8_BOM): New macro.
Kenichi Handa <handa@m17n.org>
parents:
95356
diff
changeset
|
1392 { |
c99f0a16c077
(CODING_UTF_8_BOM): New macro.
Kenichi Handa <handa@m17n.org>
parents:
95356
diff
changeset
|
1393 int c1, c2, c3; |
c99f0a16c077
(CODING_UTF_8_BOM): New macro.
Kenichi Handa <handa@m17n.org>
parents:
95356
diff
changeset
|
1394 |
c99f0a16c077
(CODING_UTF_8_BOM): New macro.
Kenichi Handa <handa@m17n.org>
parents:
95356
diff
changeset
|
1395 src_base = src; |
c99f0a16c077
(CODING_UTF_8_BOM): New macro.
Kenichi Handa <handa@m17n.org>
parents:
95356
diff
changeset
|
1396 ONE_MORE_BYTE (c1); |
c99f0a16c077
(CODING_UTF_8_BOM): New macro.
Kenichi Handa <handa@m17n.org>
parents:
95356
diff
changeset
|
1397 if (! UTF_8_3_OCTET_LEADING_P (c1)) |
c99f0a16c077
(CODING_UTF_8_BOM): New macro.
Kenichi Handa <handa@m17n.org>
parents:
95356
diff
changeset
|
1398 src = src_base; |
c99f0a16c077
(CODING_UTF_8_BOM): New macro.
Kenichi Handa <handa@m17n.org>
parents:
95356
diff
changeset
|
1399 else |
c99f0a16c077
(CODING_UTF_8_BOM): New macro.
Kenichi Handa <handa@m17n.org>
parents:
95356
diff
changeset
|
1400 { |
99074
10cd979d05ca
(make_conversion_work_buffer): Check that Vcode_conversion_reused_workbuf
Noah Friedman <friedman@splode.com>
parents:
98992
diff
changeset
|
1401 ONE_MORE_BYTE (c2); |
95397
c99f0a16c077
(CODING_UTF_8_BOM): New macro.
Kenichi Handa <handa@m17n.org>
parents:
95356
diff
changeset
|
1402 if (! UTF_8_EXTRA_OCTET_P (c2)) |
c99f0a16c077
(CODING_UTF_8_BOM): New macro.
Kenichi Handa <handa@m17n.org>
parents:
95356
diff
changeset
|
1403 src = src_base; |
c99f0a16c077
(CODING_UTF_8_BOM): New macro.
Kenichi Handa <handa@m17n.org>
parents:
95356
diff
changeset
|
1404 else |
c99f0a16c077
(CODING_UTF_8_BOM): New macro.
Kenichi Handa <handa@m17n.org>
parents:
95356
diff
changeset
|
1405 { |
99074
10cd979d05ca
(make_conversion_work_buffer): Check that Vcode_conversion_reused_workbuf
Noah Friedman <friedman@splode.com>
parents:
98992
diff
changeset
|
1406 ONE_MORE_BYTE (c3); |
95397
c99f0a16c077
(CODING_UTF_8_BOM): New macro.
Kenichi Handa <handa@m17n.org>
parents:
95356
diff
changeset
|
1407 if (! UTF_8_EXTRA_OCTET_P (c3)) |
c99f0a16c077
(CODING_UTF_8_BOM): New macro.
Kenichi Handa <handa@m17n.org>
parents:
95356
diff
changeset
|
1408 src = src_base; |
c99f0a16c077
(CODING_UTF_8_BOM): New macro.
Kenichi Handa <handa@m17n.org>
parents:
95356
diff
changeset
|
1409 else |
c99f0a16c077
(CODING_UTF_8_BOM): New macro.
Kenichi Handa <handa@m17n.org>
parents:
95356
diff
changeset
|
1410 { |
c99f0a16c077
(CODING_UTF_8_BOM): New macro.
Kenichi Handa <handa@m17n.org>
parents:
95356
diff
changeset
|
1411 if ((c1 != UTF_8_BOM_1) |
c99f0a16c077
(CODING_UTF_8_BOM): New macro.
Kenichi Handa <handa@m17n.org>
parents:
95356
diff
changeset
|
1412 || (c2 != UTF_8_BOM_2) || (c3 != UTF_8_BOM_3)) |
c99f0a16c077
(CODING_UTF_8_BOM): New macro.
Kenichi Handa <handa@m17n.org>
parents:
95356
diff
changeset
|
1413 src = src_base; |
c99f0a16c077
(CODING_UTF_8_BOM): New macro.
Kenichi Handa <handa@m17n.org>
parents:
95356
diff
changeset
|
1414 else |
c99f0a16c077
(CODING_UTF_8_BOM): New macro.
Kenichi Handa <handa@m17n.org>
parents:
95356
diff
changeset
|
1415 CODING_UTF_8_BOM (coding) = utf_without_bom; |
c99f0a16c077
(CODING_UTF_8_BOM): New macro.
Kenichi Handa <handa@m17n.org>
parents:
95356
diff
changeset
|
1416 } |
c99f0a16c077
(CODING_UTF_8_BOM): New macro.
Kenichi Handa <handa@m17n.org>
parents:
95356
diff
changeset
|
1417 } |
c99f0a16c077
(CODING_UTF_8_BOM): New macro.
Kenichi Handa <handa@m17n.org>
parents:
95356
diff
changeset
|
1418 } |
c99f0a16c077
(CODING_UTF_8_BOM): New macro.
Kenichi Handa <handa@m17n.org>
parents:
95356
diff
changeset
|
1419 } |
c99f0a16c077
(CODING_UTF_8_BOM): New macro.
Kenichi Handa <handa@m17n.org>
parents:
95356
diff
changeset
|
1420 CODING_UTF_8_BOM (coding) = utf_without_bom; |
c99f0a16c077
(CODING_UTF_8_BOM): New macro.
Kenichi Handa <handa@m17n.org>
parents:
95356
diff
changeset
|
1421 |
88365 | 1422 while (1) |
1423 { | |
1424 int c, c1, c2, c3, c4, c5; | |
1425 | |
1426 src_base = src; | |
1427 consumed_chars_base = consumed_chars; | |
1428 | |
1429 if (charbuf >= charbuf_end) | |
100936
5c5e6d041634
(decode_coding_utf_8): Check byte_after_cr before breaking the loop.
Kenichi Handa <handa@m17n.org>
parents:
100587
diff
changeset
|
1430 { |
5c5e6d041634
(decode_coding_utf_8): Check byte_after_cr before breaking the loop.
Kenichi Handa <handa@m17n.org>
parents:
100587
diff
changeset
|
1431 if (byte_after_cr >= 0) |
5c5e6d041634
(decode_coding_utf_8): Check byte_after_cr before breaking the loop.
Kenichi Handa <handa@m17n.org>
parents:
100587
diff
changeset
|
1432 src_base--; |
5c5e6d041634
(decode_coding_utf_8): Check byte_after_cr before breaking the loop.
Kenichi Handa <handa@m17n.org>
parents:
100587
diff
changeset
|
1433 break; |
5c5e6d041634
(decode_coding_utf_8): Check byte_after_cr before breaking the loop.
Kenichi Handa <handa@m17n.org>
parents:
100587
diff
changeset
|
1434 } |
88365 | 1435 |
92399
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
1436 if (byte_after_cr >= 0) |
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
1437 c1 = byte_after_cr, byte_after_cr = -1; |
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
1438 else |
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
1439 ONE_MORE_BYTE (c1); |
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1440 if (c1 < 0) |
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1441 { |
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1442 c = - c1; |
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1443 } |
109158
6175ebc3b6ce
* coding.c: Use SPECPDL_INDEX, DOS_NT.
Juanma Barranquero <lekktu@gmail.com>
parents:
109126
diff
changeset
|
1444 else if (UTF_8_1_OCTET_P (c1)) |
88365 | 1445 { |
92399
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
1446 if (eol_crlf && c1 == '\r') |
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
1447 ONE_MORE_BYTE (byte_after_cr); |
88365 | 1448 c = c1; |
1449 } | |
1450 else | |
1451 { | |
1452 ONE_MORE_BYTE (c2); | |
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1453 if (c2 < 0 || ! UTF_8_EXTRA_OCTET_P (c2)) |
88365 | 1454 goto invalid_code; |
1455 if (UTF_8_2_OCTET_LEADING_P (c1)) | |
88669
0bc5868f9f61
(decode_coding_utf_8): Reject overlong sequences.
Dave Love <fx@gnu.org>
parents:
88646
diff
changeset
|
1456 { |
0bc5868f9f61
(decode_coding_utf_8): Reject overlong sequences.
Dave Love <fx@gnu.org>
parents:
88646
diff
changeset
|
1457 c = ((c1 & 0x1F) << 6) | (c2 & 0x3F); |
0bc5868f9f61
(decode_coding_utf_8): Reject overlong sequences.
Dave Love <fx@gnu.org>
parents:
88646
diff
changeset
|
1458 /* Reject overlong sequences here and below. Encoders |
0bc5868f9f61
(decode_coding_utf_8): Reject overlong sequences.
Dave Love <fx@gnu.org>
parents:
88646
diff
changeset
|
1459 producing them are incorrect, they can be misleading, |
0bc5868f9f61
(decode_coding_utf_8): Reject overlong sequences.
Dave Love <fx@gnu.org>
parents:
88646
diff
changeset
|
1460 and they mess up read/write invariance. */ |
0bc5868f9f61
(decode_coding_utf_8): Reject overlong sequences.
Dave Love <fx@gnu.org>
parents:
88646
diff
changeset
|
1461 if (c < 128) |
0bc5868f9f61
(decode_coding_utf_8): Reject overlong sequences.
Dave Love <fx@gnu.org>
parents:
88646
diff
changeset
|
1462 goto invalid_code; |
0bc5868f9f61
(decode_coding_utf_8): Reject overlong sequences.
Dave Love <fx@gnu.org>
parents:
88646
diff
changeset
|
1463 } |
88365 | 1464 else |
1465 { | |
1466 ONE_MORE_BYTE (c3); | |
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1467 if (c3 < 0 || ! UTF_8_EXTRA_OCTET_P (c3)) |
88365 | 1468 goto invalid_code; |
1469 if (UTF_8_3_OCTET_LEADING_P (c1)) | |
88669
0bc5868f9f61
(decode_coding_utf_8): Reject overlong sequences.
Dave Love <fx@gnu.org>
parents:
88646
diff
changeset
|
1470 { |
0bc5868f9f61
(decode_coding_utf_8): Reject overlong sequences.
Dave Love <fx@gnu.org>
parents:
88646
diff
changeset
|
1471 c = (((c1 & 0xF) << 12) |
0bc5868f9f61
(decode_coding_utf_8): Reject overlong sequences.
Dave Love <fx@gnu.org>
parents:
88646
diff
changeset
|
1472 | ((c2 & 0x3F) << 6) | (c3 & 0x3F)); |
89184
88a9e962e183
(decode_coding_utf_8): Treat surrogates as invalid.
Dave Love <fx@gnu.org>
parents:
89042
diff
changeset
|
1473 if (c < 0x800 |
88a9e962e183
(decode_coding_utf_8): Treat surrogates as invalid.
Dave Love <fx@gnu.org>
parents:
89042
diff
changeset
|
1474 || (c >= 0xd800 && c < 0xe000)) /* surrogates (invalid) */ |
88669
0bc5868f9f61
(decode_coding_utf_8): Reject overlong sequences.
Dave Love <fx@gnu.org>
parents:
88646
diff
changeset
|
1475 goto invalid_code; |
0bc5868f9f61
(decode_coding_utf_8): Reject overlong sequences.
Dave Love <fx@gnu.org>
parents:
88646
diff
changeset
|
1476 } |
88365 | 1477 else |
1478 { | |
1479 ONE_MORE_BYTE (c4); | |
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1480 if (c4 < 0 || ! UTF_8_EXTRA_OCTET_P (c4)) |
88365 | 1481 goto invalid_code; |
1482 if (UTF_8_4_OCTET_LEADING_P (c1)) | |
88669
0bc5868f9f61
(decode_coding_utf_8): Reject overlong sequences.
Dave Love <fx@gnu.org>
parents:
88646
diff
changeset
|
1483 { |
88365 | 1484 c = (((c1 & 0x7) << 18) | ((c2 & 0x3F) << 12) |
1485 | ((c3 & 0x3F) << 6) | (c4 & 0x3F)); | |
88669
0bc5868f9f61
(decode_coding_utf_8): Reject overlong sequences.
Dave Love <fx@gnu.org>
parents:
88646
diff
changeset
|
1486 if (c < 0x10000) |
0bc5868f9f61
(decode_coding_utf_8): Reject overlong sequences.
Dave Love <fx@gnu.org>
parents:
88646
diff
changeset
|
1487 goto invalid_code; |
0bc5868f9f61
(decode_coding_utf_8): Reject overlong sequences.
Dave Love <fx@gnu.org>
parents:
88646
diff
changeset
|
1488 } |
88365 | 1489 else |
1490 { | |
1491 ONE_MORE_BYTE (c5); | |
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1492 if (c5 < 0 || ! UTF_8_EXTRA_OCTET_P (c5)) |
88365 | 1493 goto invalid_code; |
1494 if (UTF_8_5_OCTET_LEADING_P (c1)) | |
1495 { | |
1496 c = (((c1 & 0x3) << 24) | ((c2 & 0x3F) << 18) | |
1497 | ((c3 & 0x3F) << 12) | ((c4 & 0x3F) << 6) | |
1498 | (c5 & 0x3F)); | |
88669
0bc5868f9f61
(decode_coding_utf_8): Reject overlong sequences.
Dave Love <fx@gnu.org>
parents:
88646
diff
changeset
|
1499 if ((c > MAX_CHAR) || (c < 0x200000)) |
88365 | 1500 goto invalid_code; |
1501 } | |
1502 else | |
1503 goto invalid_code; | |
1504 } | |
1505 } | |
1506 } | |
1507 } | |
1508 | |
1509 *charbuf++ = c; | |
1510 continue; | |
1511 | |
1512 invalid_code: | |
1513 src = src_base; | |
1514 consumed_chars = consumed_chars_base; | |
1515 ONE_MORE_BYTE (c); | |
1516 *charbuf++ = ASCII_BYTE_P (c) ? c : BYTE8_TO_CHAR (c); | |
1517 coding->errors++; | |
1518 } | |
1519 | |
1520 no_more_source: | |
1521 coding->consumed_char += consumed_chars_base; | |
1522 coding->consumed = src_base - coding->source; | |
1523 coding->charbuf_used = charbuf - coding->charbuf; | |
1524 } | |
1525 | |
1526 | |
1527 static int | |
109126
aec1143e8d85
Convert (most) functions in src to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109100
diff
changeset
|
1528 encode_coding_utf_8 (struct coding_system *coding) |
88365 | 1529 { |
1530 int multibytep = coding->dst_multibyte; | |
1531 int *charbuf = coding->charbuf; | |
1532 int *charbuf_end = charbuf + coding->charbuf_used; | |
1533 unsigned char *dst = coding->destination + coding->produced; | |
1534 unsigned char *dst_end = coding->destination + coding->dst_bytes; | |
88438
3a34b722dd71
(encode_coding_utf_8): Initialize produced_chars to 0.
Kenichi Handa <handa@m17n.org>
parents:
88430
diff
changeset
|
1535 int produced_chars = 0; |
88365 | 1536 int c; |
1537 | |
95397
c99f0a16c077
(CODING_UTF_8_BOM): New macro.
Kenichi Handa <handa@m17n.org>
parents:
95356
diff
changeset
|
1538 if (CODING_UTF_8_BOM (coding) == utf_with_bom) |
c99f0a16c077
(CODING_UTF_8_BOM): New macro.
Kenichi Handa <handa@m17n.org>
parents:
95356
diff
changeset
|
1539 { |
c99f0a16c077
(CODING_UTF_8_BOM): New macro.
Kenichi Handa <handa@m17n.org>
parents:
95356
diff
changeset
|
1540 ASSURE_DESTINATION (3); |
c99f0a16c077
(CODING_UTF_8_BOM): New macro.
Kenichi Handa <handa@m17n.org>
parents:
95356
diff
changeset
|
1541 EMIT_THREE_BYTES (UTF_8_BOM_1, UTF_8_BOM_2, UTF_8_BOM_3); |
c99f0a16c077
(CODING_UTF_8_BOM): New macro.
Kenichi Handa <handa@m17n.org>
parents:
95356
diff
changeset
|
1542 CODING_UTF_8_BOM (coding) = utf_without_bom; |
c99f0a16c077
(CODING_UTF_8_BOM): New macro.
Kenichi Handa <handa@m17n.org>
parents:
95356
diff
changeset
|
1543 } |
c99f0a16c077
(CODING_UTF_8_BOM): New macro.
Kenichi Handa <handa@m17n.org>
parents:
95356
diff
changeset
|
1544 |
88365 | 1545 if (multibytep) |
1546 { | |
1547 int safe_room = MAX_MULTIBYTE_LENGTH * 2; | |
1548 | |
1549 while (charbuf < charbuf_end) | |
1550 { | |
1551 unsigned char str[MAX_MULTIBYTE_LENGTH], *p, *pend = str; | |
89483 | 1552 |
88365 | 1553 ASSURE_DESTINATION (safe_room); |
1554 c = *charbuf++; | |
89042
2b9f8973f240
(coding_set_destination): Fix coding->destination for
Kenichi Handa <handa@m17n.org>
parents:
88977
diff
changeset
|
1555 if (CHAR_BYTE8_P (c)) |
2b9f8973f240
(coding_set_destination): Fix coding->destination for
Kenichi Handa <handa@m17n.org>
parents:
88977
diff
changeset
|
1556 { |
2b9f8973f240
(coding_set_destination): Fix coding->destination for
Kenichi Handa <handa@m17n.org>
parents:
88977
diff
changeset
|
1557 c = CHAR_TO_BYTE8 (c); |
2b9f8973f240
(coding_set_destination): Fix coding->destination for
Kenichi Handa <handa@m17n.org>
parents:
88977
diff
changeset
|
1558 EMIT_ONE_BYTE (c); |
2b9f8973f240
(coding_set_destination): Fix coding->destination for
Kenichi Handa <handa@m17n.org>
parents:
88977
diff
changeset
|
1559 } |
2b9f8973f240
(coding_set_destination): Fix coding->destination for
Kenichi Handa <handa@m17n.org>
parents:
88977
diff
changeset
|
1560 else |
2b9f8973f240
(coding_set_destination): Fix coding->destination for
Kenichi Handa <handa@m17n.org>
parents:
88977
diff
changeset
|
1561 { |
92992
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
1562 CHAR_STRING_ADVANCE_NO_UNIFY (c, pend); |
89042
2b9f8973f240
(coding_set_destination): Fix coding->destination for
Kenichi Handa <handa@m17n.org>
parents:
88977
diff
changeset
|
1563 for (p = str; p < pend; p++) |
2b9f8973f240
(coding_set_destination): Fix coding->destination for
Kenichi Handa <handa@m17n.org>
parents:
88977
diff
changeset
|
1564 EMIT_ONE_BYTE (*p); |
2b9f8973f240
(coding_set_destination): Fix coding->destination for
Kenichi Handa <handa@m17n.org>
parents:
88977
diff
changeset
|
1565 } |
88365 | 1566 } |
1567 } | |
1568 else | |
1569 { | |
1570 int safe_room = MAX_MULTIBYTE_LENGTH; | |
1571 | |
1572 while (charbuf < charbuf_end) | |
1573 { | |
1574 ASSURE_DESTINATION (safe_room); | |
1575 c = *charbuf++; | |
89917
1763eef5ad02
(encode_coding_utf_8): Fix handling of raw-byte char.
Kenichi Handa <handa@m17n.org>
parents:
89905
diff
changeset
|
1576 if (CHAR_BYTE8_P (c)) |
1763eef5ad02
(encode_coding_utf_8): Fix handling of raw-byte char.
Kenichi Handa <handa@m17n.org>
parents:
89905
diff
changeset
|
1577 *dst++ = CHAR_TO_BYTE8 (c); |
1763eef5ad02
(encode_coding_utf_8): Fix handling of raw-byte char.
Kenichi Handa <handa@m17n.org>
parents:
89905
diff
changeset
|
1578 else |
92992
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
1579 CHAR_STRING_ADVANCE_NO_UNIFY (c, dst); |
88365 | 1580 produced_chars++; |
1581 } | |
1582 } | |
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1583 record_conversion_result (coding, CODING_RESULT_SUCCESS); |
88365 | 1584 coding->produced_char += produced_chars; |
1585 coding->produced = dst - coding->destination; | |
1586 return 0; | |
1587 } | |
1588 | |
1589 | |
1590 /* See the above "GENERAL NOTES on `detect_coding_XXX ()' functions". | |
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1591 Check if a text is encoded in one of UTF-16 based coding systems. |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1592 If it is, return 1, else return 0. */ |
88365 | 1593 |
1594 #define UTF_16_HIGH_SURROGATE_P(val) \ | |
1595 (((val) & 0xFC00) == 0xD800) | |
1596 | |
1597 #define UTF_16_LOW_SURROGATE_P(val) \ | |
1598 (((val) & 0xFC00) == 0xDC00) | |
1599 | |
1600 #define UTF_16_INVALID_P(val) \ | |
1601 (((val) == 0xFFFE) \ | |
1602 || ((val) == 0xFFFF) \ | |
1603 || UTF_16_LOW_SURROGATE_P (val)) | |
1604 | |
1605 | |
1606 static int | |
109159
3e9fdeb960d1
* coding.c, sysdep.c: Convert some more functions to standard C.
Juanma Barranquero <lekktu@gmail.com>
parents:
109158
diff
changeset
|
1607 detect_coding_utf_16 (struct coding_system *coding, |
3e9fdeb960d1
* coding.c, sysdep.c: Convert some more functions to standard C.
Juanma Barranquero <lekktu@gmail.com>
parents:
109158
diff
changeset
|
1608 struct coding_detection_info *detect_info) |
88365 | 1609 { |
89483 | 1610 const unsigned char *src = coding->source, *src_base = src; |
1611 const unsigned char *src_end = coding->source + coding->src_bytes; | |
88365 | 1612 int multibytep = coding->src_multibyte; |
1613 int consumed_chars = 0; | |
1614 int c1, c2; | |
1615 | |
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1616 detect_info->checked |= CATEGORY_MASK_UTF_16; |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1617 if (coding->mode & CODING_MODE_LAST_BLOCK |
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
1618 && (coding->src_chars & 1)) |
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1619 { |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1620 detect_info->rejected |= CATEGORY_MASK_UTF_16; |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1621 return 0; |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1622 } |
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
1623 |
101172
674e67257137
(TWO_MORE_BYTES): New macro.
Kenichi Handa <handa@m17n.org>
parents:
101040
diff
changeset
|
1624 TWO_MORE_BYTES (c1, c2); |
88365 | 1625 if ((c1 == 0xFF) && (c2 == 0xFE)) |
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1626 { |
89420
c3e67ce6ee0f
(Qsignature, Qendian): Delete these variables.
Kenichi Handa <handa@m17n.org>
parents:
89418
diff
changeset
|
1627 detect_info->found |= (CATEGORY_MASK_UTF_16_LE |
c3e67ce6ee0f
(Qsignature, Qendian): Delete these variables.
Kenichi Handa <handa@m17n.org>
parents:
89418
diff
changeset
|
1628 | CATEGORY_MASK_UTF_16_AUTO); |
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
1629 detect_info->rejected |= (CATEGORY_MASK_UTF_16_BE |
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
1630 | CATEGORY_MASK_UTF_16_BE_NOSIG |
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
1631 | CATEGORY_MASK_UTF_16_LE_NOSIG); |
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1632 } |
88365 | 1633 else if ((c1 == 0xFE) && (c2 == 0xFF)) |
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1634 { |
89420
c3e67ce6ee0f
(Qsignature, Qendian): Delete these variables.
Kenichi Handa <handa@m17n.org>
parents:
89418
diff
changeset
|
1635 detect_info->found |= (CATEGORY_MASK_UTF_16_BE |
c3e67ce6ee0f
(Qsignature, Qendian): Delete these variables.
Kenichi Handa <handa@m17n.org>
parents:
89418
diff
changeset
|
1636 | CATEGORY_MASK_UTF_16_AUTO); |
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
1637 detect_info->rejected |= (CATEGORY_MASK_UTF_16_LE |
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
1638 | CATEGORY_MASK_UTF_16_BE_NOSIG |
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
1639 | CATEGORY_MASK_UTF_16_LE_NOSIG); |
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
1640 } |
101174 | 1641 else if (c2 < 0) |
101172
674e67257137
(TWO_MORE_BYTES): New macro.
Kenichi Handa <handa@m17n.org>
parents:
101040
diff
changeset
|
1642 { |
674e67257137
(TWO_MORE_BYTES): New macro.
Kenichi Handa <handa@m17n.org>
parents:
101040
diff
changeset
|
1643 detect_info->rejected |= CATEGORY_MASK_UTF_16; |
674e67257137
(TWO_MORE_BYTES): New macro.
Kenichi Handa <handa@m17n.org>
parents:
101040
diff
changeset
|
1644 return 0; |
674e67257137
(TWO_MORE_BYTES): New macro.
Kenichi Handa <handa@m17n.org>
parents:
101040
diff
changeset
|
1645 } |
93595
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
1646 else |
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
1647 { |
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
1648 /* We check the dispersion of Eth and Oth bytes where E is even and |
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
1649 O is odd. If both are high, we assume binary data.*/ |
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
1650 unsigned char e[256], o[256]; |
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
1651 unsigned e_num = 1, o_num = 1; |
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
1652 |
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
1653 memset (e, 0, 256); |
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
1654 memset (o, 0, 256); |
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
1655 e[c1] = 1; |
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
1656 o[c2] = 1; |
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
1657 |
103442
db4ec1a977bd
(detect_coding_utf_16): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
103441
diff
changeset
|
1658 detect_info->rejected |= (CATEGORY_MASK_UTF_16_AUTO |
db4ec1a977bd
(detect_coding_utf_16): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
103441
diff
changeset
|
1659 |CATEGORY_MASK_UTF_16_BE |
db4ec1a977bd
(detect_coding_utf_16): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
103441
diff
changeset
|
1660 | CATEGORY_MASK_UTF_16_LE); |
db4ec1a977bd
(detect_coding_utf_16): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
103441
diff
changeset
|
1661 |
103448
73e7271dee09
(detect_coding_utf_16): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
103442
diff
changeset
|
1662 while ((detect_info->rejected & CATEGORY_MASK_UTF_16) |
73e7271dee09
(detect_coding_utf_16): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
103442
diff
changeset
|
1663 != CATEGORY_MASK_UTF_16) |
93595
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
1664 { |
101172
674e67257137
(TWO_MORE_BYTES): New macro.
Kenichi Handa <handa@m17n.org>
parents:
101040
diff
changeset
|
1665 TWO_MORE_BYTES (c1, c2); |
101174 | 1666 if (c2 < 0) |
101172
674e67257137
(TWO_MORE_BYTES): New macro.
Kenichi Handa <handa@m17n.org>
parents:
101040
diff
changeset
|
1667 break; |
93595
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
1668 if (! e[c1]) |
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
1669 { |
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
1670 e[c1] = 1; |
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
1671 e_num++; |
103442
db4ec1a977bd
(detect_coding_utf_16): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
103441
diff
changeset
|
1672 if (e_num >= 128) |
db4ec1a977bd
(detect_coding_utf_16): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
103441
diff
changeset
|
1673 detect_info->rejected |= CATEGORY_MASK_UTF_16_BE_NOSIG; |
93595
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
1674 } |
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
1675 if (! o[c2]) |
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
1676 { |
103435
45564d023acc
(detect_coding_utf_16): Fix typo counting odd bytes.
Andreas Schwab <schwab@linux-m68k.org>
parents:
103306
diff
changeset
|
1677 o[c2] = 1; |
93595
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
1678 o_num++; |
103442
db4ec1a977bd
(detect_coding_utf_16): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
103441
diff
changeset
|
1679 if (o_num >= 128) |
db4ec1a977bd
(detect_coding_utf_16): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
103441
diff
changeset
|
1680 detect_info->rejected |= CATEGORY_MASK_UTF_16_LE_NOSIG; |
93595
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
1681 } |
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
1682 } |
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
1683 return 0; |
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
1684 } |
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
1685 |
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1686 no_more_source: |
89193
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
1687 return 1; |
88365 | 1688 } |
1689 | |
1690 static void | |
109126
aec1143e8d85
Convert (most) functions in src to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109100
diff
changeset
|
1691 decode_coding_utf_16 (struct coding_system *coding) |
88365 | 1692 { |
89483 | 1693 const unsigned char *src = coding->source + coding->consumed; |
1694 const unsigned char *src_end = coding->source + coding->src_bytes; | |
1695 const unsigned char *src_base; | |
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
1696 int *charbuf = coding->charbuf + coding->charbuf_used; |
103035
6e443d717c7b
(decode_coding_utf_16): Reduce charbuf_end for the
Kenichi Handa <handa@m17n.org>
parents:
102738
diff
changeset
|
1697 /* We may produces at most 3 chars in one loop. */ |
6e443d717c7b
(decode_coding_utf_16): Reduce charbuf_end for the
Kenichi Handa <handa@m17n.org>
parents:
102738
diff
changeset
|
1698 int *charbuf_end = coding->charbuf + coding->charbuf_size - 2; |
100131
0e4115b39b5d
(decode_coding_utf_16): Initialize consumed_chars_base
Kenichi Handa <handa@m17n.org>
parents:
99753
diff
changeset
|
1699 int consumed_chars = 0, consumed_chars_base = 0; |
88365 | 1700 int multibytep = coding->src_multibyte; |
95397
c99f0a16c077
(CODING_UTF_8_BOM): New macro.
Kenichi Handa <handa@m17n.org>
parents:
95356
diff
changeset
|
1701 enum utf_bom_type bom = CODING_UTF_16_BOM (coding); |
88365 | 1702 enum utf_16_endian_type endian = CODING_UTF_16_ENDIAN (coding); |
1703 int surrogate = CODING_UTF_16_SURROGATE (coding); | |
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
1704 Lisp_Object attr, charset_list; |
102334
7baaea85626e
(decode_coding_utf_8, decode_coding_utf_16, decode_coding_emacs_mule,
Eli Zaretskii <eliz@gnu.org>
parents:
102327
diff
changeset
|
1705 int eol_crlf = |
7baaea85626e
(decode_coding_utf_8, decode_coding_utf_16, decode_coding_emacs_mule,
Eli Zaretskii <eliz@gnu.org>
parents:
102327
diff
changeset
|
1706 !inhibit_eol_conversion && EQ (CODING_ID_EOL_TYPE (coding->id), Qdos); |
92399
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
1707 int byte_after_cr1 = -1, byte_after_cr2 = -1; |
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
1708 |
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
1709 CODING_GET_INFO (coding, attr, charset_list); |
88365 | 1710 |
95397
c99f0a16c077
(CODING_UTF_8_BOM): New macro.
Kenichi Handa <handa@m17n.org>
parents:
95356
diff
changeset
|
1711 if (bom == utf_with_bom) |
88365 | 1712 { |
1713 int c, c1, c2; | |
1714 | |
1715 src_base = src; | |
1716 ONE_MORE_BYTE (c1); | |
1717 ONE_MORE_BYTE (c2); | |
88438
3a34b722dd71
(encode_coding_utf_8): Initialize produced_chars to 0.
Kenichi Handa <handa@m17n.org>
parents:
88430
diff
changeset
|
1718 c = (c1 << 8) | c2; |
89420
c3e67ce6ee0f
(Qsignature, Qendian): Delete these variables.
Kenichi Handa <handa@m17n.org>
parents:
89418
diff
changeset
|
1719 |
c3e67ce6ee0f
(Qsignature, Qendian): Delete these variables.
Kenichi Handa <handa@m17n.org>
parents:
89418
diff
changeset
|
1720 if (endian == utf_16_big_endian |
c3e67ce6ee0f
(Qsignature, Qendian): Delete these variables.
Kenichi Handa <handa@m17n.org>
parents:
89418
diff
changeset
|
1721 ? c != 0xFEFF : c != 0xFFFE) |
88365 | 1722 { |
89420
c3e67ce6ee0f
(Qsignature, Qendian): Delete these variables.
Kenichi Handa <handa@m17n.org>
parents:
89418
diff
changeset
|
1723 /* The first two bytes are not BOM. Treat them as bytes |
c3e67ce6ee0f
(Qsignature, Qendian): Delete these variables.
Kenichi Handa <handa@m17n.org>
parents:
89418
diff
changeset
|
1724 for a normal character. */ |
c3e67ce6ee0f
(Qsignature, Qendian): Delete these variables.
Kenichi Handa <handa@m17n.org>
parents:
89418
diff
changeset
|
1725 src = src_base; |
c3e67ce6ee0f
(Qsignature, Qendian): Delete these variables.
Kenichi Handa <handa@m17n.org>
parents:
89418
diff
changeset
|
1726 coding->errors++; |
88365 | 1727 } |
95397
c99f0a16c077
(CODING_UTF_8_BOM): New macro.
Kenichi Handa <handa@m17n.org>
parents:
95356
diff
changeset
|
1728 CODING_UTF_16_BOM (coding) = utf_without_bom; |
c99f0a16c077
(CODING_UTF_8_BOM): New macro.
Kenichi Handa <handa@m17n.org>
parents:
95356
diff
changeset
|
1729 } |
c99f0a16c077
(CODING_UTF_8_BOM): New macro.
Kenichi Handa <handa@m17n.org>
parents:
95356
diff
changeset
|
1730 else if (bom == utf_detect_bom) |
89420
c3e67ce6ee0f
(Qsignature, Qendian): Delete these variables.
Kenichi Handa <handa@m17n.org>
parents:
89418
diff
changeset
|
1731 { |
c3e67ce6ee0f
(Qsignature, Qendian): Delete these variables.
Kenichi Handa <handa@m17n.org>
parents:
89418
diff
changeset
|
1732 /* We have already tried to detect BOM and failed in |
c3e67ce6ee0f
(Qsignature, Qendian): Delete these variables.
Kenichi Handa <handa@m17n.org>
parents:
89418
diff
changeset
|
1733 detect_coding. */ |
95397
c99f0a16c077
(CODING_UTF_8_BOM): New macro.
Kenichi Handa <handa@m17n.org>
parents:
95356
diff
changeset
|
1734 CODING_UTF_16_BOM (coding) = utf_without_bom; |
88365 | 1735 } |
1736 | |
1737 while (1) | |
1738 { | |
1739 int c, c1, c2; | |
1740 | |
1741 src_base = src; | |
1742 consumed_chars_base = consumed_chars; | |
1743 | |
103035
6e443d717c7b
(decode_coding_utf_16): Reduce charbuf_end for the
Kenichi Handa <handa@m17n.org>
parents:
102738
diff
changeset
|
1744 if (charbuf >= charbuf_end) |
100936
5c5e6d041634
(decode_coding_utf_8): Check byte_after_cr before breaking the loop.
Kenichi Handa <handa@m17n.org>
parents:
100587
diff
changeset
|
1745 { |
5c5e6d041634
(decode_coding_utf_8): Check byte_after_cr before breaking the loop.
Kenichi Handa <handa@m17n.org>
parents:
100587
diff
changeset
|
1746 if (byte_after_cr1 >= 0) |
5c5e6d041634
(decode_coding_utf_8): Check byte_after_cr before breaking the loop.
Kenichi Handa <handa@m17n.org>
parents:
100587
diff
changeset
|
1747 src_base -= 2; |
5c5e6d041634
(decode_coding_utf_8): Check byte_after_cr before breaking the loop.
Kenichi Handa <handa@m17n.org>
parents:
100587
diff
changeset
|
1748 break; |
5c5e6d041634
(decode_coding_utf_8): Check byte_after_cr before breaking the loop.
Kenichi Handa <handa@m17n.org>
parents:
100587
diff
changeset
|
1749 } |
88365 | 1750 |
92399
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
1751 if (byte_after_cr1 >= 0) |
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
1752 c1 = byte_after_cr1, byte_after_cr1 = -1; |
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
1753 else |
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
1754 ONE_MORE_BYTE (c1); |
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1755 if (c1 < 0) |
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1756 { |
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1757 *charbuf++ = -c1; |
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1758 continue; |
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1759 } |
92399
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
1760 if (byte_after_cr2 >= 0) |
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
1761 c2 = byte_after_cr2, byte_after_cr2 = -1; |
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
1762 else |
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
1763 ONE_MORE_BYTE (c2); |
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1764 if (c2 < 0) |
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1765 { |
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1766 *charbuf++ = ASCII_BYTE_P (c1) ? c1 : BYTE8_TO_CHAR (c1); |
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1767 *charbuf++ = -c2; |
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1768 continue; |
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1769 } |
88365 | 1770 c = (endian == utf_16_big_endian |
88438
3a34b722dd71
(encode_coding_utf_8): Initialize produced_chars to 0.
Kenichi Handa <handa@m17n.org>
parents:
88430
diff
changeset
|
1771 ? ((c1 << 8) | c2) : ((c2 << 8) | c1)); |
92399
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
1772 |
88365 | 1773 if (surrogate) |
1774 { | |
1775 if (! UTF_16_LOW_SURROGATE_P (c)) | |
1776 { | |
1777 if (endian == utf_16_big_endian) | |
1778 c1 = surrogate >> 8, c2 = surrogate & 0xFF; | |
1779 else | |
1780 c1 = surrogate & 0xFF, c2 = surrogate >> 8; | |
1781 *charbuf++ = c1; | |
1782 *charbuf++ = c2; | |
1783 coding->errors++; | |
1784 if (UTF_16_HIGH_SURROGATE_P (c)) | |
1785 CODING_UTF_16_SURROGATE (coding) = surrogate = c; | |
1786 else | |
1787 *charbuf++ = c; | |
1788 } | |
1789 else | |
1790 { | |
1791 c = ((surrogate - 0xD800) << 10) | (c - 0xDC00); | |
1792 CODING_UTF_16_SURROGATE (coding) = surrogate = 0; | |
89842
b5f22f538c1f
(decode_coding_utf_16): Fix handling of surrogate pare.
Kenichi Handa <handa@m17n.org>
parents:
89780
diff
changeset
|
1793 *charbuf++ = 0x10000 + c; |
88365 | 1794 } |
1795 } | |
1796 else | |
1797 { | |
1798 if (UTF_16_HIGH_SURROGATE_P (c)) | |
1799 CODING_UTF_16_SURROGATE (coding) = surrogate = c; | |
1800 else | |
92399
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
1801 { |
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
1802 if (eol_crlf && c == '\r') |
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
1803 { |
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
1804 ONE_MORE_BYTE (byte_after_cr1); |
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
1805 ONE_MORE_BYTE (byte_after_cr2); |
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
1806 } |
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
1807 *charbuf++ = c; |
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
1808 } |
89483 | 1809 } |
88365 | 1810 } |
1811 | |
1812 no_more_source: | |
1813 coding->consumed_char += consumed_chars_base; | |
1814 coding->consumed = src_base - coding->source; | |
1815 coding->charbuf_used = charbuf - coding->charbuf; | |
1816 } | |
1817 | |
1818 static int | |
109126
aec1143e8d85
Convert (most) functions in src to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109100
diff
changeset
|
1819 encode_coding_utf_16 (struct coding_system *coding) |
88365 | 1820 { |
1821 int multibytep = coding->dst_multibyte; | |
1822 int *charbuf = coding->charbuf; | |
1823 int *charbuf_end = charbuf + coding->charbuf_used; | |
1824 unsigned char *dst = coding->destination + coding->produced; | |
1825 unsigned char *dst_end = coding->destination + coding->dst_bytes; | |
1826 int safe_room = 8; | |
95397
c99f0a16c077
(CODING_UTF_8_BOM): New macro.
Kenichi Handa <handa@m17n.org>
parents:
95356
diff
changeset
|
1827 enum utf_bom_type bom = CODING_UTF_16_BOM (coding); |
88365 | 1828 int big_endian = CODING_UTF_16_ENDIAN (coding) == utf_16_big_endian; |
1829 int produced_chars = 0; | |
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
1830 Lisp_Object attrs, charset_list; |
88365 | 1831 int c; |
1832 | |
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
1833 CODING_GET_INFO (coding, attrs, charset_list); |
88365 | 1834 |
95397
c99f0a16c077
(CODING_UTF_8_BOM): New macro.
Kenichi Handa <handa@m17n.org>
parents:
95356
diff
changeset
|
1835 if (bom != utf_without_bom) |
88365 | 1836 { |
1837 ASSURE_DESTINATION (safe_room); | |
1838 if (big_endian) | |
89404
3e1d187b52c3
(Qutf_16_be_nosig, Qutf_16_be, Qutf_16_le_nosig)
Kenichi Handa <handa@m17n.org>
parents:
89394
diff
changeset
|
1839 EMIT_TWO_BYTES (0xFE, 0xFF); |
88365 | 1840 else |
89404
3e1d187b52c3
(Qutf_16_be_nosig, Qutf_16_be, Qutf_16_le_nosig)
Kenichi Handa <handa@m17n.org>
parents:
89394
diff
changeset
|
1841 EMIT_TWO_BYTES (0xFF, 0xFE); |
95397
c99f0a16c077
(CODING_UTF_8_BOM): New macro.
Kenichi Handa <handa@m17n.org>
parents:
95356
diff
changeset
|
1842 CODING_UTF_16_BOM (coding) = utf_without_bom; |
88365 | 1843 } |
1844 | |
1845 while (charbuf < charbuf_end) | |
1846 { | |
1847 ASSURE_DESTINATION (safe_room); | |
1848 c = *charbuf++; | |
104636
bc74846b9a54
(encode_coding_utf_16): Fix checking of an Unicode character.
Kenichi Handa <handa@m17n.org>
parents:
103762
diff
changeset
|
1849 if (c > MAX_UNICODE_CHAR) |
88438
3a34b722dd71
(encode_coding_utf_8): Initialize produced_chars to 0.
Kenichi Handa <handa@m17n.org>
parents:
88430
diff
changeset
|
1850 c = coding->default_char; |
88365 | 1851 |
1852 if (c < 0x10000) | |
1853 { | |
1854 if (big_endian) | |
1855 EMIT_TWO_BYTES (c >> 8, c & 0xFF); | |
1856 else | |
1857 EMIT_TWO_BYTES (c & 0xFF, c >> 8); | |
1858 } | |
1859 else | |
1860 { | |
1861 int c1, c2; | |
1862 | |
1863 c -= 0x10000; | |
1864 c1 = (c >> 10) + 0xD800; | |
1865 c2 = (c & 0x3FF) + 0xDC00; | |
1866 if (big_endian) | |
1867 EMIT_FOUR_BYTES (c1 >> 8, c1 & 0xFF, c2 >> 8, c2 & 0xFF); | |
1868 else | |
1869 EMIT_FOUR_BYTES (c1 & 0xFF, c1 >> 8, c2 & 0xFF, c2 >> 8); | |
1870 } | |
1871 } | |
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1872 record_conversion_result (coding, CODING_RESULT_SUCCESS); |
88365 | 1873 coding->produced = dst - coding->destination; |
1874 coding->produced_char += produced_chars; | |
1875 return 0; | |
1876 } | |
1877 | |
1878 | |
1879 /*** 6. Old Emacs' internal format (emacs-mule) ***/ | |
17052 | 1880 |
34888
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1881 /* Emacs' internal format for representation of multiple character |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1882 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
|
1883 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
|
1884 |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1885 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
|
1886 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
|
1887 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
|
1888 |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1889 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
|
1890 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
|
1891 code + 0x20). |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1892 |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1893 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
|
1894 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
|
1895 |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1896 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
|
1897 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
|
1898 `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
|
1899 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
|
1900 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
|
1901 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
|
1902 and position-code. |
18766 | 1903 |
17052 | 1904 --- 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
|
1905 character set range |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1906 ------------- ----- |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1907 ascii 0x00..0x7F |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1908 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
|
1909 eight-bit-graphic 0xA0..0xBF |
34888
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1910 ELSE 0x81..0x9D + [0xA0..0xFF]+ |
17052 | 1911 --------------------------------------------- |
1912 | |
34888
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1913 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
|
1914 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
|
1915 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
|
1916 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
|
1917 |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1918 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
|
1919 form. |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1920 |
88365 | 1921 At first, 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
|
1922 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
|
1923 |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1924 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
|
1925 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
|
1926 where, |
102422
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
1927 METHOD is 0xF2 plus one of composition method (enum |
34888
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1928 composition_method), |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1929 |
88365 | 1930 BYTES is 0xA0 plus a byte length of this composition data, |
1931 | |
102422
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
1932 CHARS is 0xA0 plus a number of characters composed by this |
34888
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1933 data, |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1934 |
88365 | 1935 COMPONENTs are characters of multibye form or composition |
34888
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1936 rules encoded by two-byte of ASCII codes. |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1937 |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1938 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
|
1939 also recognized as composition data on decoding. |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1940 |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1941 0x80 MSEQ ... |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1942 0x80 0xFF MSEQ RULE MSEQ RULE ... MSEQ |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1943 |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1944 Here, |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1945 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
|
1946 ASCII: 0xA0 ASCII_CODE+0x80, |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1947 other: LEADING_CODE+0x20 FOLLOWING-BYTE ..., |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1948 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
|
1949 represents a composition rule. |
17052 | 1950 */ |
1951 | |
88365 | 1952 char emacs_mule_bytes[256]; |
1953 | |
102422
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
1954 |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
1955 /* See the above "GENERAL NOTES on `detect_coding_XXX ()' functions". |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
1956 Check if a text is encoded in `emacs-mule'. If it is, return 1, |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
1957 else return 0. */ |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
1958 |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
1959 static int |
109159
3e9fdeb960d1
* coding.c, sysdep.c: Convert some more functions to standard C.
Juanma Barranquero <lekktu@gmail.com>
parents:
109158
diff
changeset
|
1960 detect_coding_emacs_mule (struct coding_system *coding, |
3e9fdeb960d1
* coding.c, sysdep.c: Convert some more functions to standard C.
Juanma Barranquero <lekktu@gmail.com>
parents:
109158
diff
changeset
|
1961 struct coding_detection_info *detect_info) |
102422
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
1962 { |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
1963 const unsigned char *src = coding->source, *src_base; |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
1964 const unsigned char *src_end = coding->source + coding->src_bytes; |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
1965 int multibytep = coding->src_multibyte; |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
1966 int consumed_chars = 0; |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
1967 int c; |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
1968 int found = 0; |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
1969 |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
1970 detect_info->checked |= CATEGORY_MASK_EMACS_MULE; |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
1971 /* A coding system of this category is always ASCII compatible. */ |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
1972 src += coding->head_ascii; |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
1973 |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
1974 while (1) |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
1975 { |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
1976 src_base = src; |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
1977 ONE_MORE_BYTE (c); |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
1978 if (c < 0) |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
1979 continue; |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
1980 if (c == 0x80) |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
1981 { |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
1982 /* Perhaps the start of composite character. We simply skip |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
1983 it because analyzing it is too heavy for detecting. But, |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
1984 at least, we check that the composite character |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
1985 constitutes of more than 4 bytes. */ |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
1986 const unsigned char *src_base; |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
1987 |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
1988 repeat: |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
1989 src_base = src; |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
1990 do |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
1991 { |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
1992 ONE_MORE_BYTE (c); |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
1993 } |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
1994 while (c >= 0xA0); |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
1995 |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
1996 if (src - src_base <= 4) |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
1997 break; |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
1998 found = CATEGORY_MASK_EMACS_MULE; |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
1999 if (c == 0x80) |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2000 goto repeat; |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2001 } |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2002 |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2003 if (c < 0x80) |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2004 { |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2005 if (c < 0x20 |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2006 && (c == ISO_CODE_ESC || c == ISO_CODE_SI || c == ISO_CODE_SO)) |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2007 break; |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2008 } |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2009 else |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2010 { |
110334
4ad4f097835e
coding.c (detect_coding_emacs_mule): Fix checking of multibyte sequence when the source is multibyte.
Kenichi Handa <handa@m17n.org>
parents:
109710
diff
changeset
|
2011 int more_bytes = emacs_mule_bytes[c] - 1; |
102422
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2012 |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2013 while (more_bytes > 0) |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2014 { |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2015 ONE_MORE_BYTE (c); |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2016 if (c < 0xA0) |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2017 { |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2018 src--; /* Unread the last byte. */ |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2019 break; |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2020 } |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2021 more_bytes--; |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2022 } |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2023 if (more_bytes != 0) |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2024 break; |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2025 found = CATEGORY_MASK_EMACS_MULE; |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2026 } |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2027 } |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2028 detect_info->rejected |= CATEGORY_MASK_EMACS_MULE; |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2029 return 0; |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2030 |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2031 no_more_source: |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2032 if (src_base < src && coding->mode & CODING_MODE_LAST_BLOCK) |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2033 { |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2034 detect_info->rejected |= CATEGORY_MASK_EMACS_MULE; |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2035 return 0; |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2036 } |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2037 detect_info->found |= found; |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2038 return 1; |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2039 } |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2040 |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2041 |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2042 /* Parse emacs-mule multibyte sequence at SRC and return the decoded |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2043 character. If CMP_STATUS indicates that we must expect MSEQ or |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2044 RULE described above, decode it and return the negative value of |
107323
ebc10ed88b5c
(emacs_mule_char): Fix a typo in commentary.
Eli Zaretskii <eliz@gnu.org>
parents:
107321
diff
changeset
|
2045 the decoded character or rule. If an invalid byte is found, return |
102422
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2046 -1. If SRC is too short, return -2. */ |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2047 |
88365 | 2048 int |
109159
3e9fdeb960d1
* coding.c, sysdep.c: Convert some more functions to standard C.
Juanma Barranquero <lekktu@gmail.com>
parents:
109158
diff
changeset
|
2049 emacs_mule_char (struct coding_system *coding, const unsigned char *src, |
3e9fdeb960d1
* coding.c, sysdep.c: Convert some more functions to standard C.
Juanma Barranquero <lekktu@gmail.com>
parents:
109158
diff
changeset
|
2050 int *nbytes, int *nchars, int *id, |
3e9fdeb960d1
* coding.c, sysdep.c: Convert some more functions to standard C.
Juanma Barranquero <lekktu@gmail.com>
parents:
109158
diff
changeset
|
2051 struct composition_status *cmp_status) |
88365 | 2052 { |
89483 | 2053 const unsigned char *src_end = coding->source + coding->src_bytes; |
2054 const unsigned char *src_base = src; | |
88365 | 2055 int multibytep = coding->src_multibyte; |
2056 struct charset *charset; | |
2057 unsigned code; | |
2058 int c; | |
2059 int consumed_chars = 0; | |
102422
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2060 int mseq_found = 0; |
88365 | 2061 |
2062 ONE_MORE_BYTE (c); | |
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
2063 if (c < 0) |
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
2064 { |
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
2065 c = -c; |
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
2066 charset = emacs_mule_charset[0]; |
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
2067 } |
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
2068 else |
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
2069 { |
90354
450fb16a4bf4
(DECODE_COMPOSITION_START): If the source is short, set
Kenichi Handa <handa@m17n.org>
parents:
90350
diff
changeset
|
2070 if (c >= 0xA0) |
450fb16a4bf4
(DECODE_COMPOSITION_START): If the source is short, set
Kenichi Handa <handa@m17n.org>
parents:
90350
diff
changeset
|
2071 { |
102422
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2072 if (cmp_status->state != COMPOSING_NO |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2073 && cmp_status->old_form) |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2074 { |
102422
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2075 if (cmp_status->state == COMPOSING_CHAR) |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2076 { |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2077 if (c == 0xA0) |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2078 { |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2079 ONE_MORE_BYTE (c); |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2080 c -= 0x80; |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2081 if (c < 0) |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2082 goto invalid_code; |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2083 } |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2084 else |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2085 c -= 0x20; |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2086 mseq_found = 1; |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2087 } |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2088 else |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2089 { |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2090 *nbytes = src - src_base; |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2091 *nchars = consumed_chars; |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2092 return -c; |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2093 } |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2094 } |
17052 | 2095 else |
102422
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2096 goto invalid_code; |
17052 | 2097 } |
2098 | |
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
2099 switch (emacs_mule_bytes[c]) |
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
2100 { |
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
2101 case 2: |
88365 | 2102 if (! (charset = emacs_mule_charset[c])) |
2103 goto invalid_code; | |
2104 ONE_MORE_BYTE (c); | |
17052 | 2105 if (c < 0xA0) |
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
2106 goto invalid_code; |
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
2107 code = c & 0x7F; |
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
2108 break; |
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
2109 |
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
2110 case 3: |
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
2111 if (c == EMACS_MULE_LEADING_CODE_PRIVATE_11 |
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
2112 || c == EMACS_MULE_LEADING_CODE_PRIVATE_12) |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2113 { |
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
2114 ONE_MORE_BYTE (c); |
89892 | 2115 if (c < 0xA0 || ! (charset = emacs_mule_charset[c])) |
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
2116 goto invalid_code; |
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
2117 ONE_MORE_BYTE (c); |
89892 | 2118 if (c < 0xA0) |
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
2119 goto invalid_code; |
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
2120 code = c & 0x7F; |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2121 } |
26847 | 2122 else |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2123 { |
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
2124 if (! (charset = emacs_mule_charset[c])) |
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
2125 goto invalid_code; |
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
2126 ONE_MORE_BYTE (c); |
89892 | 2127 if (c < 0xA0) |
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
2128 goto invalid_code; |
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
2129 code = (c & 0x7F) << 8; |
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
2130 ONE_MORE_BYTE (c); |
89892 | 2131 if (c < 0xA0) |
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
2132 goto invalid_code; |
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
2133 code |= c & 0x7F; |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2134 } |
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
2135 break; |
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
2136 |
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
2137 case 4: |
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
2138 ONE_MORE_BYTE (c); |
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
2139 if (c < 0 || ! (charset = emacs_mule_charset[c])) |
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
2140 goto invalid_code; |
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
2141 ONE_MORE_BYTE (c); |
89892 | 2142 if (c < 0xA0) |
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
2143 goto invalid_code; |
88585
c7772f702227
(ONE_MORE_BYTE_NO_CHECK): Increment consumed_chars.
Kenichi Handa <handa@m17n.org>
parents:
88573
diff
changeset
|
2144 code = (c & 0x7F) << 8; |
88365 | 2145 ONE_MORE_BYTE (c); |
89892 | 2146 if (c < 0xA0) |
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
2147 goto invalid_code; |
88365 | 2148 code |= c & 0x7F; |
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
2149 break; |
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
2150 |
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
2151 case 1: |
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
2152 code = c; |
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
2153 charset = CHARSET_FROM_ID (ASCII_BYTE_P (code) |
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
2154 ? charset_ascii : charset_eight_bit); |
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
2155 break; |
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
2156 |
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
2157 default: |
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
2158 abort (); |
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
2159 } |
107321
9b814b3ee348
Fix bug in decoding emacs-mule encoding.
Eli Zaretskii <eliz@gnu.org>
parents:
107174
diff
changeset
|
2160 CODING_DECODE_CHAR (coding, src, src_base, src_end, charset, code, c); |
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
2161 if (c < 0) |
88365 | 2162 goto invalid_code; |
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
2163 } |
88365 | 2164 *nbytes = src - src_base; |
2165 *nchars = consumed_chars; | |
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2166 if (id) |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2167 *id = charset->id; |
102422
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2168 return (mseq_found ? -c : c); |
88365 | 2169 |
2170 no_more_source: | |
2171 return -2; | |
2172 | |
2173 invalid_code: | |
2174 return -1; | |
2175 } | |
2176 | |
17052 | 2177 |
88365 | 2178 /* See the above "GENERAL NOTES on `decode_coding_XXX ()' functions". */ |
34888
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
2179 |
102422
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2180 /* Handle these composition sequence ('|': the end of header elements, |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2181 BYTES and CHARS >= 0xA0): |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2182 |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2183 (1) relative composition: 0x80 0xF2 BYTES CHARS | CHAR ... |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2184 (2) altchar composition: 0x80 0xF4 BYTES CHARS | ALT ... ALT CHAR ... |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2185 (3) alt&rule composition: 0x80 0xF5 BYTES CHARS | ALT RULE ... ALT CHAR ... |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2186 |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2187 and these old form: |
109158
6175ebc3b6ce
* coding.c: Use SPECPDL_INDEX, DOS_NT.
Juanma Barranquero <lekktu@gmail.com>
parents:
109126
diff
changeset
|
2188 |
102422
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2189 (4) relative composition: 0x80 | MSEQ ... MSEQ |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2190 (5) rulebase composition: 0x80 0xFF | MSEQ MRULE ... MSEQ |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2191 |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2192 When the starter 0x80 and the following header elements are found, |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2193 this annotation header is produced. |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2194 |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2195 [ -LENGTH(==-5) CODING_ANNOTATE_COMPOSITION_MASK NCHARS NBYTES METHOD ] |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2196 |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2197 NCHARS is CHARS - 0xA0 for (1), (2), (3), and 0 for (4), (5). |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2198 NBYTES is BYTES - 0xA0 for (1), (2), (3), and 0 for (4), (5). |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2199 |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2200 Then, upon reading the following elements, these codes are produced |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2201 until the composition end is found: |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2202 |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2203 (1) CHAR ... CHAR |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2204 (2) ALT ... ALT CHAR ... CHAR |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2205 (3) ALT -2 DECODED-RULE ALT -2 DECODED-RULE ... ALT CHAR ... CHAR |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2206 (4) CHAR ... CHAR |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2207 (5) CHAR -2 DECODED-RULE CHAR -2 DECODED-RULE ... CHAR |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2208 |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2209 When the composition end is found, LENGTH and NCHARS in the |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2210 annotation header is updated as below: |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2211 |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2212 (1) LENGTH: unchanged, NCHARS: unchanged |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2213 (2) LENGTH: length of the whole sequence minus NCHARS, NCHARS: unchanged |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2214 (3) LENGTH: length of the whole sequence minus NCHARS, NCHARS: unchanged |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2215 (4) LENGTH: unchanged, NCHARS: number of CHARs |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2216 (5) LENGTH: unchanged, NCHARS: number of CHARs |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2217 |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2218 If an error is found while composing, the annotation header is |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2219 changed to the original composition header (plus filler -1s) as |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2220 below: |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2221 |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2222 (1),(2),(3) [ 0x80 0xF2+METHOD BYTES CHARS -1 ] |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2223 (5) [ 0x80 0xFF -1 -1- -1 ] |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2224 |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2225 and the sequence [ -2 DECODED-RULE ] is changed to the original |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2226 byte sequence as below: |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2227 o the original byte sequence is B: [ B -1 ] |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2228 o the original byte sequence is B1 B2: [ B1 B2 ] |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2229 |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2230 Most of the routines are implemented by macros because many |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2231 variables and labels in the caller decode_coding_emacs_mule must be |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2232 accessible, and they are usually called just once (thus doesn't |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2233 increase the size of compiled object). */ |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2234 |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2235 /* Decode a composition rule represented by C as a component of |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2236 composition sequence of Emacs 20 style. Set RULE to the decoded |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2237 rule. */ |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2238 |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2239 #define DECODE_EMACS_MULE_COMPOSITION_RULE_20(c, rule) \ |
34888
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
2240 do { \ |
102422
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2241 int gref, nref; \ |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2242 \ |
90354
450fb16a4bf4
(DECODE_COMPOSITION_START): If the source is short, set
Kenichi Handa <handa@m17n.org>
parents:
90350
diff
changeset
|
2243 c -= 0xA0; \ |
34888
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
2244 if (c < 0 || c >= 81) \ |
88365 | 2245 goto invalid_code; \ |
2246 gref = c / 9, nref = c % 9; \ | |
102422
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2247 if (gref == 4) gref = 10; \ |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2248 if (nref == 4) nref = 10; \ |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2249 rule = COMPOSITION_ENCODE_RULE (gref, nref); \ |
34888
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
2250 } while (0) |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
2251 |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
2252 |
102422
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2253 /* Decode a composition rule represented by C and the following byte |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2254 at SRC as a component of composition sequence of Emacs 21 style. |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2255 Set RULE to the decoded rule. */ |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2256 |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2257 #define DECODE_EMACS_MULE_COMPOSITION_RULE_21(c, rule) \ |
34888
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
2258 do { \ |
88585
c7772f702227
(ONE_MORE_BYTE_NO_CHECK): Increment consumed_chars.
Kenichi Handa <handa@m17n.org>
parents:
88573
diff
changeset
|
2259 int gref, nref; \ |
102422
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2260 \ |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2261 gref = c - 0x20; \ |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2262 if (gref < 0 || gref >= 81) \ |
88585
c7772f702227
(ONE_MORE_BYTE_NO_CHECK): Increment consumed_chars.
Kenichi Handa <handa@m17n.org>
parents:
88573
diff
changeset
|
2263 goto invalid_code; \ |
102422
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2264 ONE_MORE_BYTE (c); \ |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2265 nref = c - 0x20; \ |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2266 if (nref < 0 || nref >= 81) \ |
88585
c7772f702227
(ONE_MORE_BYTE_NO_CHECK): Increment consumed_chars.
Kenichi Handa <handa@m17n.org>
parents:
88573
diff
changeset
|
2267 goto invalid_code; \ |
102422
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2268 rule = COMPOSITION_ENCODE_RULE (gref, nref); \ |
34888
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
2269 } while (0) |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
2270 |
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
2271 |
102422
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2272 /* Start of Emacs 21 style format. The first three bytes at SRC are |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2273 (METHOD - 0xF2), (BYTES - 0xA0), (CHARS - 0xA0), where BYTES is the |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2274 byte length of this composition information, CHARS is the number of |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2275 characters composed by this composition. */ |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2276 |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2277 #define DECODE_EMACS_MULE_21_COMPOSITION() \ |
88365 | 2278 do { \ |
88585
c7772f702227
(ONE_MORE_BYTE_NO_CHECK): Increment consumed_chars.
Kenichi Handa <handa@m17n.org>
parents:
88573
diff
changeset
|
2279 enum composition_method method = c - 0xF2; \ |
c7772f702227
(ONE_MORE_BYTE_NO_CHECK): Increment consumed_chars.
Kenichi Handa <handa@m17n.org>
parents:
88573
diff
changeset
|
2280 int *charbuf_base = charbuf; \ |
88365 | 2281 int nbytes, nchars; \ |
102422
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2282 \ |
88365 | 2283 ONE_MORE_BYTE (c); \ |
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
2284 if (c < 0) \ |
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
2285 goto invalid_code; \ |
88365 | 2286 nbytes = c - 0xA0; \ |
102422
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2287 if (nbytes < 3 || (method == COMPOSITION_RELATIVE && nbytes != 4)) \ |
88365 | 2288 goto invalid_code; \ |
2289 ONE_MORE_BYTE (c); \ | |
102422
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2290 nchars = c - 0xA0; \ |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2291 if (nchars <= 0 || nchars >= MAX_COMPOSITION_COMPONENTS) \ |
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
2292 goto invalid_code; \ |
102422
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2293 cmp_status->old_form = 0; \ |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2294 cmp_status->method = method; \ |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2295 if (method == COMPOSITION_RELATIVE) \ |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2296 cmp_status->state = COMPOSING_CHAR; \ |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2297 else \ |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2298 cmp_status->state = COMPOSING_COMPONENT_CHAR; \ |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2299 cmp_status->length = MAX_ANNOTATION_LENGTH; \ |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2300 cmp_status->nchars = nchars; \ |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2301 cmp_status->ncomps = nbytes - 4; \ |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2302 ADD_COMPOSITION_DATA (charbuf, nchars, nbytes, method); \ |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2303 } while (0) |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2304 |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2305 |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2306 /* Start of Emacs 20 style format for relative composition. */ |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2307 |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2308 #define DECODE_EMACS_MULE_20_RELATIVE_COMPOSITION() \ |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2309 do { \ |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2310 cmp_status->old_form = 1; \ |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2311 cmp_status->method = COMPOSITION_RELATIVE; \ |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2312 cmp_status->state = COMPOSING_CHAR; \ |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2313 cmp_status->length = MAX_ANNOTATION_LENGTH; \ |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2314 cmp_status->nchars = cmp_status->ncomps = 0; \ |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2315 ADD_COMPOSITION_DATA (charbuf, 0, 0, cmp_status->method); \ |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2316 } while (0) |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2317 |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2318 |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2319 /* Start of Emacs 20 style format for rule-base composition. */ |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2320 |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2321 #define DECODE_EMACS_MULE_20_RULEBASE_COMPOSITION() \ |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2322 do { \ |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2323 cmp_status->old_form = 1; \ |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2324 cmp_status->method = COMPOSITION_WITH_RULE; \ |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2325 cmp_status->state = COMPOSING_CHAR; \ |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2326 cmp_status->length = MAX_ANNOTATION_LENGTH; \ |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2327 cmp_status->nchars = cmp_status->ncomps = 0; \ |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2328 ADD_COMPOSITION_DATA (charbuf, 0, 0, cmp_status->method); \ |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2329 } while (0) |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2330 |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2331 |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2332 #define DECODE_EMACS_MULE_COMPOSITION_START() \ |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2333 do { \ |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2334 const unsigned char *current_src = src; \ |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2335 \ |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2336 ONE_MORE_BYTE (c); \ |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2337 if (c < 0) \ |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2338 goto invalid_code; \ |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2339 if (c - 0xF2 >= COMPOSITION_RELATIVE \ |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2340 && c - 0xF2 <= COMPOSITION_WITH_RULE_ALTCHARS) \ |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2341 DECODE_EMACS_MULE_21_COMPOSITION (); \ |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2342 else if (c < 0xA0) \ |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2343 goto invalid_code; \ |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2344 else if (c < 0xC0) \ |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2345 { \ |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2346 DECODE_EMACS_MULE_20_RELATIVE_COMPOSITION (); \ |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2347 /* Re-read C as a composition component. */ \ |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2348 src = current_src; \ |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2349 } \ |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2350 else if (c == 0xFF) \ |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2351 DECODE_EMACS_MULE_20_RULEBASE_COMPOSITION (); \ |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2352 else \ |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2353 goto invalid_code; \ |
88365 | 2354 } while (0) |
2355 | |
102422
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2356 #define EMACS_MULE_COMPOSITION_END() \ |
88365 | 2357 do { \ |
102422
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2358 int idx = - cmp_status->length; \ |
90354
450fb16a4bf4
(DECODE_COMPOSITION_START): If the source is short, set
Kenichi Handa <handa@m17n.org>
parents:
90350
diff
changeset
|
2359 \ |
102422
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2360 if (cmp_status->old_form) \ |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2361 charbuf[idx + 2] = cmp_status->nchars; \ |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2362 else if (cmp_status->method > COMPOSITION_RELATIVE) \ |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2363 charbuf[idx] = charbuf[idx + 2] - cmp_status->length; \ |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2364 cmp_status->state = COMPOSING_NO; \ |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2365 } while (0) |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2366 |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2367 |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2368 static int |
109159
3e9fdeb960d1
* coding.c, sysdep.c: Convert some more functions to standard C.
Juanma Barranquero <lekktu@gmail.com>
parents:
109158
diff
changeset
|
2369 emacs_mule_finish_composition (int *charbuf, |
3e9fdeb960d1
* coding.c, sysdep.c: Convert some more functions to standard C.
Juanma Barranquero <lekktu@gmail.com>
parents:
109158
diff
changeset
|
2370 struct composition_status *cmp_status) |
102422
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2371 { |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2372 int idx = - cmp_status->length; |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2373 int new_chars; |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2374 |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2375 if (cmp_status->old_form && cmp_status->nchars > 0) |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2376 { |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2377 charbuf[idx + 2] = cmp_status->nchars; |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2378 new_chars = 0; |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2379 if (cmp_status->method == COMPOSITION_WITH_RULE |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2380 && cmp_status->state == COMPOSING_CHAR) |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2381 { |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2382 /* The last rule was invalid. */ |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2383 int rule = charbuf[-1] + 0xA0; |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2384 |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2385 charbuf[-2] = BYTE8_TO_CHAR (rule); |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2386 charbuf[-1] = -1; |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2387 new_chars = 1; |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2388 } |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2389 } |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2390 else |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2391 { |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2392 charbuf[idx++] = BYTE8_TO_CHAR (0x80); |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2393 |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2394 if (cmp_status->method == COMPOSITION_WITH_RULE) |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2395 { |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2396 charbuf[idx++] = BYTE8_TO_CHAR (0xFF); |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2397 charbuf[idx++] = -3; |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2398 charbuf[idx++] = 0; |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2399 new_chars = 1; |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2400 } |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2401 else |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2402 { |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2403 int nchars = charbuf[idx + 1] + 0xA0; |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2404 int nbytes = charbuf[idx + 2] + 0xA0; |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2405 |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2406 charbuf[idx++] = BYTE8_TO_CHAR (0xF2 + cmp_status->method); |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2407 charbuf[idx++] = BYTE8_TO_CHAR (nbytes); |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2408 charbuf[idx++] = BYTE8_TO_CHAR (nchars); |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2409 charbuf[idx++] = -1; |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2410 new_chars = 4; |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2411 } |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2412 } |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2413 cmp_status->state = COMPOSING_NO; |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2414 return new_chars; |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2415 } |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2416 |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2417 #define EMACS_MULE_MAYBE_FINISH_COMPOSITION() \ |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2418 do { \ |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2419 if (cmp_status->state != COMPOSING_NO) \ |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2420 char_offset += emacs_mule_finish_composition (charbuf, cmp_status); \ |
88365 | 2421 } while (0) |
2422 | |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2423 |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2424 static void |
109126
aec1143e8d85
Convert (most) functions in src to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109100
diff
changeset
|
2425 decode_coding_emacs_mule (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
|
2426 { |
89483 | 2427 const unsigned char *src = coding->source + coding->consumed; |
2428 const unsigned char *src_end = coding->source + coding->src_bytes; | |
59168
0345f2b10f1d
(decode_coding_XXX, decode_composition_emacs_mule)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
59095
diff
changeset
|
2429 const unsigned char *src_base; |
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
2430 int *charbuf = coding->charbuf + coding->charbuf_used; |
103035
6e443d717c7b
(decode_coding_utf_16): Reduce charbuf_end for the
Kenichi Handa <handa@m17n.org>
parents:
102738
diff
changeset
|
2431 /* We may produce two annocations (charset and composition) in one |
6e443d717c7b
(decode_coding_utf_16): Reduce charbuf_end for the
Kenichi Handa <handa@m17n.org>
parents:
102738
diff
changeset
|
2432 loop and one more charset annocation at the end. */ |
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
2433 int *charbuf_end |
103035
6e443d717c7b
(decode_coding_utf_16): Reduce charbuf_end for the
Kenichi Handa <handa@m17n.org>
parents:
102738
diff
changeset
|
2434 = coding->charbuf + coding->charbuf_size - (MAX_ANNOTATION_LENGTH * 3); |
88365 | 2435 int consumed_chars = 0, consumed_chars_base; |
2436 int multibytep = coding->src_multibyte; | |
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
2437 Lisp_Object attrs, charset_list; |
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2438 int char_offset = coding->produced_char; |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2439 int last_offset = char_offset; |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2440 int last_id = charset_ascii; |
102334
7baaea85626e
(decode_coding_utf_8, decode_coding_utf_16, decode_coding_emacs_mule,
Eli Zaretskii <eliz@gnu.org>
parents:
102327
diff
changeset
|
2441 int eol_crlf = |
7baaea85626e
(decode_coding_utf_8, decode_coding_utf_16, decode_coding_emacs_mule,
Eli Zaretskii <eliz@gnu.org>
parents:
102327
diff
changeset
|
2442 !inhibit_eol_conversion && EQ (CODING_ID_EOL_TYPE (coding->id), Qdos); |
92399
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
2443 int byte_after_cr = -1; |
102422
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2444 struct composition_status *cmp_status = &coding->spec.emacs_mule.cmp_status; |
88365 | 2445 |
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
2446 CODING_GET_INFO (coding, attrs, charset_list); |
88365 | 2447 |
102422
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2448 if (cmp_status->state != COMPOSING_NO) |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2449 { |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2450 int i; |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2451 |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2452 for (i = 0; i < cmp_status->length; i++) |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2453 *charbuf++ = cmp_status->carryover[i]; |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2454 coding->annotated = 1; |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2455 } |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2456 |
88365 | 2457 while (1) |
2458 { | |
102422
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2459 int c, id; |
88365 | 2460 |
2461 src_base = src; | |
2462 consumed_chars_base = consumed_chars; | |
2463 | |
2464 if (charbuf >= charbuf_end) | |
100936
5c5e6d041634
(decode_coding_utf_8): Check byte_after_cr before breaking the loop.
Kenichi Handa <handa@m17n.org>
parents:
100587
diff
changeset
|
2465 { |
5c5e6d041634
(decode_coding_utf_8): Check byte_after_cr before breaking the loop.
Kenichi Handa <handa@m17n.org>
parents:
100587
diff
changeset
|
2466 if (byte_after_cr >= 0) |
5c5e6d041634
(decode_coding_utf_8): Check byte_after_cr before breaking the loop.
Kenichi Handa <handa@m17n.org>
parents:
100587
diff
changeset
|
2467 src_base--; |
5c5e6d041634
(decode_coding_utf_8): Check byte_after_cr before breaking the loop.
Kenichi Handa <handa@m17n.org>
parents:
100587
diff
changeset
|
2468 break; |
5c5e6d041634
(decode_coding_utf_8): Check byte_after_cr before breaking the loop.
Kenichi Handa <handa@m17n.org>
parents:
100587
diff
changeset
|
2469 } |
88365 | 2470 |
92399
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
2471 if (byte_after_cr >= 0) |
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
2472 c = byte_after_cr, byte_after_cr = -1; |
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
2473 else |
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
2474 ONE_MORE_BYTE (c); |
102422
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2475 |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2476 if (c < 0 || c == 0x80) |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2477 { |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2478 EMACS_MULE_MAYBE_FINISH_COMPOSITION (); |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2479 if (c < 0) |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2480 { |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2481 *charbuf++ = -c; |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2482 char_offset++; |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2483 } |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2484 else |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2485 DECODE_EMACS_MULE_COMPOSITION_START (); |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2486 continue; |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2487 } |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2488 |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2489 if (c < 0x80) |
32806
9502d0a5b2ad
(decode_coding_emacs_mule): If coding->eol_type is CR
Eli Zaretskii <eliz@gnu.org>
parents:
32745
diff
changeset
|
2490 { |
92399
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
2491 if (eol_crlf && c == '\r') |
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
2492 ONE_MORE_BYTE (byte_after_cr); |
102422
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2493 id = charset_ascii; |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2494 if (cmp_status->state != COMPOSING_NO) |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2495 { |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2496 if (cmp_status->old_form) |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2497 EMACS_MULE_MAYBE_FINISH_COMPOSITION (); |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2498 else if (cmp_status->state >= COMPOSING_COMPONENT_CHAR) |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2499 cmp_status->ncomps--; |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2500 } |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2501 } |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2502 else |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2503 { |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2504 int nchars, nbytes; |
107321
9b814b3ee348
Fix bug in decoding emacs-mule encoding.
Eli Zaretskii <eliz@gnu.org>
parents:
107174
diff
changeset
|
2505 /* emacs_mule_char can load a charset map from a file, which |
9b814b3ee348
Fix bug in decoding emacs-mule encoding.
Eli Zaretskii <eliz@gnu.org>
parents:
107174
diff
changeset
|
2506 allocates a large structure and might cause buffer text |
9b814b3ee348
Fix bug in decoding emacs-mule encoding.
Eli Zaretskii <eliz@gnu.org>
parents:
107174
diff
changeset
|
2507 to be relocated as result. Thus, we need to remember the |
9b814b3ee348
Fix bug in decoding emacs-mule encoding.
Eli Zaretskii <eliz@gnu.org>
parents:
107174
diff
changeset
|
2508 original pointer to buffer text, and fixup all related |
9b814b3ee348
Fix bug in decoding emacs-mule encoding.
Eli Zaretskii <eliz@gnu.org>
parents:
107174
diff
changeset
|
2509 pointers after the call. */ |
9b814b3ee348
Fix bug in decoding emacs-mule encoding.
Eli Zaretskii <eliz@gnu.org>
parents:
107174
diff
changeset
|
2510 const unsigned char *orig = coding->source; |
9b814b3ee348
Fix bug in decoding emacs-mule encoding.
Eli Zaretskii <eliz@gnu.org>
parents:
107174
diff
changeset
|
2511 EMACS_INT offset; |
102422
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2512 |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2513 c = emacs_mule_char (coding, src_base, &nbytes, &nchars, &id, |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2514 cmp_status); |
107321
9b814b3ee348
Fix bug in decoding emacs-mule encoding.
Eli Zaretskii <eliz@gnu.org>
parents:
107174
diff
changeset
|
2515 offset = coding->source - orig; |
9b814b3ee348
Fix bug in decoding emacs-mule encoding.
Eli Zaretskii <eliz@gnu.org>
parents:
107174
diff
changeset
|
2516 if (offset) |
9b814b3ee348
Fix bug in decoding emacs-mule encoding.
Eli Zaretskii <eliz@gnu.org>
parents:
107174
diff
changeset
|
2517 { |
9b814b3ee348
Fix bug in decoding emacs-mule encoding.
Eli Zaretskii <eliz@gnu.org>
parents:
107174
diff
changeset
|
2518 src += offset; |
9b814b3ee348
Fix bug in decoding emacs-mule encoding.
Eli Zaretskii <eliz@gnu.org>
parents:
107174
diff
changeset
|
2519 src_base += offset; |
9b814b3ee348
Fix bug in decoding emacs-mule encoding.
Eli Zaretskii <eliz@gnu.org>
parents:
107174
diff
changeset
|
2520 src_end += offset; |
9b814b3ee348
Fix bug in decoding emacs-mule encoding.
Eli Zaretskii <eliz@gnu.org>
parents:
107174
diff
changeset
|
2521 } |
88365 | 2522 if (c < 0) |
32806
9502d0a5b2ad
(decode_coding_emacs_mule): If coding->eol_type is CR
Eli Zaretskii <eliz@gnu.org>
parents:
32745
diff
changeset
|
2523 { |
102422
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2524 if (c == -1) |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2525 goto invalid_code; |
88365 | 2526 if (c == -2) |
2527 break; | |
32806
9502d0a5b2ad
(decode_coding_emacs_mule): If coding->eol_type is CR
Eli Zaretskii <eliz@gnu.org>
parents:
32745
diff
changeset
|
2528 } |
102422
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2529 src = src_base + nbytes; |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2530 consumed_chars = consumed_chars_base + nchars; |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2531 if (cmp_status->state >= COMPOSING_COMPONENT_CHAR) |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2532 cmp_status->ncomps -= nchars; |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2533 } |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2534 |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2535 /* Now if C >= 0, we found a normally encoded characer, if C < |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2536 0, we found an old-style composition component character or |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2537 rule. */ |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2538 |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2539 if (cmp_status->state == COMPOSING_NO) |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2540 { |
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2541 if (last_id != id) |
32806
9502d0a5b2ad
(decode_coding_emacs_mule): If coding->eol_type is CR
Eli Zaretskii <eliz@gnu.org>
parents:
32745
diff
changeset
|
2542 { |
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2543 if (last_id != charset_ascii) |
102422
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2544 ADD_CHARSET_DATA (charbuf, char_offset - last_offset, |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2545 last_id); |
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2546 last_id = id; |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2547 last_offset = char_offset; |
32806
9502d0a5b2ad
(decode_coding_emacs_mule): If coding->eol_type is CR
Eli Zaretskii <eliz@gnu.org>
parents:
32745
diff
changeset
|
2548 } |
88365 | 2549 *charbuf++ = c; |
2550 char_offset++; | |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2551 } |
102422
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2552 else if (cmp_status->state == COMPOSING_CHAR) |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2553 { |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2554 if (cmp_status->old_form) |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2555 { |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2556 if (c >= 0) |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2557 { |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2558 EMACS_MULE_MAYBE_FINISH_COMPOSITION (); |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2559 *charbuf++ = c; |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2560 char_offset++; |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2561 } |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2562 else |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2563 { |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2564 *charbuf++ = -c; |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2565 cmp_status->nchars++; |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2566 cmp_status->length++; |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2567 if (cmp_status->nchars == MAX_COMPOSITION_COMPONENTS) |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2568 EMACS_MULE_COMPOSITION_END (); |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2569 else if (cmp_status->method == COMPOSITION_WITH_RULE) |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2570 cmp_status->state = COMPOSING_RULE; |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2571 } |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2572 } |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2573 else |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2574 { |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2575 *charbuf++ = c; |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2576 cmp_status->length++; |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2577 cmp_status->nchars--; |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2578 if (cmp_status->nchars == 0) |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2579 EMACS_MULE_COMPOSITION_END (); |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2580 } |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2581 } |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2582 else if (cmp_status->state == COMPOSING_RULE) |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2583 { |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2584 int rule; |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2585 |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2586 if (c >= 0) |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2587 { |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2588 EMACS_MULE_COMPOSITION_END (); |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2589 *charbuf++ = c; |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2590 char_offset++; |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2591 } |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2592 else |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2593 { |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2594 c = -c; |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2595 DECODE_EMACS_MULE_COMPOSITION_RULE_20 (c, rule); |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2596 if (rule < 0) |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2597 goto invalid_code; |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2598 *charbuf++ = -2; |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2599 *charbuf++ = rule; |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2600 cmp_status->length += 2; |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2601 cmp_status->state = COMPOSING_CHAR; |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2602 } |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2603 } |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2604 else if (cmp_status->state == COMPOSING_COMPONENT_CHAR) |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2605 { |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2606 *charbuf++ = c; |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2607 cmp_status->length++; |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2608 if (cmp_status->ncomps == 0) |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2609 cmp_status->state = COMPOSING_CHAR; |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2610 else if (cmp_status->ncomps > 0) |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2611 { |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2612 if (cmp_status->method == COMPOSITION_WITH_RULE_ALTCHARS) |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2613 cmp_status->state = COMPOSING_COMPONENT_RULE; |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2614 } |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2615 else |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2616 EMACS_MULE_MAYBE_FINISH_COMPOSITION (); |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2617 } |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2618 else /* COMPOSING_COMPONENT_RULE */ |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2619 { |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2620 int rule; |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2621 |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2622 DECODE_EMACS_MULE_COMPOSITION_RULE_21 (c, rule); |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2623 if (rule < 0) |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2624 goto invalid_code; |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2625 *charbuf++ = -2; |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2626 *charbuf++ = rule; |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2627 cmp_status->length += 2; |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2628 cmp_status->ncomps--; |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2629 if (cmp_status->ncomps > 0) |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2630 cmp_status->state = COMPOSING_COMPONENT_CHAR; |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2631 else |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2632 EMACS_MULE_MAYBE_FINISH_COMPOSITION (); |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2633 } |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2634 continue; |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2635 |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2636 retry: |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2637 src = src_base; |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2638 consumed_chars = consumed_chars_base; |
88365 | 2639 continue; |
2640 | |
2641 invalid_code: | |
102422
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2642 EMACS_MULE_MAYBE_FINISH_COMPOSITION (); |
88365 | 2643 src = src_base; |
2644 consumed_chars = consumed_chars_base; | |
2645 ONE_MORE_BYTE (c); | |
2646 *charbuf++ = ASCII_BYTE_P (c) ? c : BYTE8_TO_CHAR (c); | |
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2647 char_offset++; |
88365 | 2648 coding->errors++; |
2649 } | |
2650 | |
2651 no_more_source: | |
102422
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2652 if (cmp_status->state != COMPOSING_NO) |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2653 { |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2654 if (coding->mode & CODING_MODE_LAST_BLOCK) |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2655 EMACS_MULE_MAYBE_FINISH_COMPOSITION (); |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2656 else |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2657 { |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2658 int i; |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2659 |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2660 charbuf -= cmp_status->length; |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2661 for (i = 0; i < cmp_status->length; i++) |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2662 cmp_status->carryover[i] = charbuf[i]; |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2663 } |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
2664 } |
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2665 if (last_id != charset_ascii) |
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
2666 ADD_CHARSET_DATA (charbuf, char_offset - last_offset, last_id); |
88365 | 2667 coding->consumed_char += consumed_chars_base; |
2668 coding->consumed = src_base - coding->source; | |
2669 coding->charbuf_used = charbuf - coding->charbuf; | |
2670 } | |
2671 | |
2672 | |
2673 #define EMACS_MULE_LEADING_CODES(id, codes) \ | |
2674 do { \ | |
2675 if (id < 0xA0) \ | |
2676 codes[0] = id, codes[1] = 0; \ | |
2677 else if (id < 0xE0) \ | |
2678 codes[0] = 0x9A, codes[1] = id; \ | |
2679 else if (id < 0xF0) \ | |
2680 codes[0] = 0x9B, codes[1] = id; \ | |
2681 else if (id < 0xF5) \ | |
2682 codes[0] = 0x9C, codes[1] = id; \ | |
2683 else \ | |
2684 codes[0] = 0x9D, codes[1] = id; \ | |
2685 } while (0); | |
2686 | |
2687 | |
2688 static int | |
109126
aec1143e8d85
Convert (most) functions in src to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109100
diff
changeset
|
2689 encode_coding_emacs_mule (struct coding_system *coding) |
88365 | 2690 { |
2691 int multibytep = coding->dst_multibyte; | |
2692 int *charbuf = coding->charbuf; | |
2693 int *charbuf_end = charbuf + coding->charbuf_used; | |
2694 unsigned char *dst = coding->destination + coding->produced; | |
2695 unsigned char *dst_end = coding->destination + coding->dst_bytes; | |
2696 int safe_room = 8; | |
2697 int produced_chars = 0; | |
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
2698 Lisp_Object attrs, charset_list; |
88365 | 2699 int c; |
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2700 int preferred_charset_id = -1; |
88365 | 2701 |
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
2702 CODING_GET_INFO (coding, attrs, charset_list); |
89644
fc9cda144ffc
(encode_coding_emacs_mule): Resync charset_list to
Kenichi Handa <handa@m17n.org>
parents:
89642
diff
changeset
|
2703 if (! EQ (charset_list, Vemacs_mule_charset_list)) |
fc9cda144ffc
(encode_coding_emacs_mule): Resync charset_list to
Kenichi Handa <handa@m17n.org>
parents:
89642
diff
changeset
|
2704 { |
fc9cda144ffc
(encode_coding_emacs_mule): Resync charset_list to
Kenichi Handa <handa@m17n.org>
parents:
89642
diff
changeset
|
2705 CODING_ATTR_CHARSET_LIST (attrs) |
fc9cda144ffc
(encode_coding_emacs_mule): Resync charset_list to
Kenichi Handa <handa@m17n.org>
parents:
89642
diff
changeset
|
2706 = charset_list = Vemacs_mule_charset_list; |
fc9cda144ffc
(encode_coding_emacs_mule): Resync charset_list to
Kenichi Handa <handa@m17n.org>
parents:
89642
diff
changeset
|
2707 } |
88365 | 2708 |
2709 while (charbuf < charbuf_end) | |
2710 { | |
2711 ASSURE_DESTINATION (safe_room); | |
2712 c = *charbuf++; | |
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2713 |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2714 if (c < 0) |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2715 { |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2716 /* Handle an annotation. */ |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2717 switch (*charbuf) |
54320
a7e59b39de35
(decode_coding_emacs_mule): Handle insufficent source correctly.
Kenichi Handa <handa@m17n.org>
parents:
54303
diff
changeset
|
2718 { |
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2719 case CODING_ANNOTATE_COMPOSITION_MASK: |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2720 /* Not yet implemented. */ |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2721 break; |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2722 case CODING_ANNOTATE_CHARSET_MASK: |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2723 preferred_charset_id = charbuf[3]; |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2724 if (preferred_charset_id >= 0 |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2725 && NILP (Fmemq (make_number (preferred_charset_id), |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2726 charset_list))) |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2727 preferred_charset_id = -1; |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2728 break; |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2729 default: |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2730 abort (); |
54320
a7e59b39de35
(decode_coding_emacs_mule): Handle insufficent source correctly.
Kenichi Handa <handa@m17n.org>
parents:
54303
diff
changeset
|
2731 } |
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2732 charbuf += -c - 1; |
32806
9502d0a5b2ad
(decode_coding_emacs_mule): If coding->eol_type is CR
Eli Zaretskii <eliz@gnu.org>
parents:
32745
diff
changeset
|
2733 continue; |
9502d0a5b2ad
(decode_coding_emacs_mule): If coding->eol_type is CR
Eli Zaretskii <eliz@gnu.org>
parents:
32745
diff
changeset
|
2734 } |
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2735 |
88365 | 2736 if (ASCII_CHAR_P (c)) |
2737 EMIT_ONE_ASCII_BYTE (c); | |
88690
7f284ac55b07
(encode_coding_emacs_mule): Pay attention to raw-8-bit chars.
Kenichi Handa <handa@m17n.org>
parents:
88681
diff
changeset
|
2738 else if (CHAR_BYTE8_P (c)) |
7f284ac55b07
(encode_coding_emacs_mule): Pay attention to raw-8-bit chars.
Kenichi Handa <handa@m17n.org>
parents:
88681
diff
changeset
|
2739 { |
7f284ac55b07
(encode_coding_emacs_mule): Pay attention to raw-8-bit chars.
Kenichi Handa <handa@m17n.org>
parents:
88681
diff
changeset
|
2740 c = CHAR_TO_BYTE8 (c); |
7f284ac55b07
(encode_coding_emacs_mule): Pay attention to raw-8-bit chars.
Kenichi Handa <handa@m17n.org>
parents:
88681
diff
changeset
|
2741 EMIT_ONE_BYTE (c); |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2742 } |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2743 else |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2744 { |
88365 | 2745 struct charset *charset; |
2746 unsigned code; | |
2747 int dimension; | |
2748 int emacs_mule_id; | |
2749 unsigned char leading_codes[2]; | |
2750 | |
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2751 if (preferred_charset_id >= 0) |
54320
a7e59b39de35
(decode_coding_emacs_mule): Handle insufficent source correctly.
Kenichi Handa <handa@m17n.org>
parents:
54303
diff
changeset
|
2752 { |
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2753 charset = CHARSET_FROM_ID (preferred_charset_id); |
100176
5706ca7c3d02
(encode_coding_emacs_mule): Be sure to set `code'.
Kenichi Handa <handa@m17n.org>
parents:
100170
diff
changeset
|
2754 if (CHAR_CHARSET_P (c, charset)) |
5706ca7c3d02
(encode_coding_emacs_mule): Be sure to set `code'.
Kenichi Handa <handa@m17n.org>
parents:
100170
diff
changeset
|
2755 code = ENCODE_CHAR (charset, c); |
5706ca7c3d02
(encode_coding_emacs_mule): Be sure to set `code'.
Kenichi Handa <handa@m17n.org>
parents:
100170
diff
changeset
|
2756 else |
5706ca7c3d02
(encode_coding_emacs_mule): Be sure to set `code'.
Kenichi Handa <handa@m17n.org>
parents:
100170
diff
changeset
|
2757 charset = char_charset (c, charset_list, &code); |
54320
a7e59b39de35
(decode_coding_emacs_mule): Handle insufficent source correctly.
Kenichi Handa <handa@m17n.org>
parents:
54303
diff
changeset
|
2758 } |
a7e59b39de35
(decode_coding_emacs_mule): Handle insufficent source correctly.
Kenichi Handa <handa@m17n.org>
parents:
54303
diff
changeset
|
2759 else |
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2760 charset = char_charset (c, charset_list, &code); |
88365 | 2761 if (! charset) |
54320
a7e59b39de35
(decode_coding_emacs_mule): Handle insufficent source correctly.
Kenichi Handa <handa@m17n.org>
parents:
54303
diff
changeset
|
2762 { |
88365 | 2763 c = coding->default_char; |
2764 if (ASCII_CHAR_P (c)) | |
2765 { | |
2766 EMIT_ONE_ASCII_BYTE (c); | |
2767 continue; | |
2768 } | |
2769 charset = char_charset (c, charset_list, &code); | |
54320
a7e59b39de35
(decode_coding_emacs_mule): Handle insufficent source correctly.
Kenichi Handa <handa@m17n.org>
parents:
54303
diff
changeset
|
2770 } |
88365 | 2771 dimension = CHARSET_DIMENSION (charset); |
2772 emacs_mule_id = CHARSET_EMACS_MULE_ID (charset); | |
2773 EMACS_MULE_LEADING_CODES (emacs_mule_id, leading_codes); | |
2774 EMIT_ONE_BYTE (leading_codes[0]); | |
2775 if (leading_codes[1]) | |
2776 EMIT_ONE_BYTE (leading_codes[1]); | |
2777 if (dimension == 1) | |
89642
e97441b6244b
(encode_coding_emacs_mule): Emit bytes with MSB.
Kenichi Handa <handa@m17n.org>
parents:
89575
diff
changeset
|
2778 EMIT_ONE_BYTE (code | 0x80); |
54320
a7e59b39de35
(decode_coding_emacs_mule): Handle insufficent source correctly.
Kenichi Handa <handa@m17n.org>
parents:
54303
diff
changeset
|
2779 else |
a7e59b39de35
(decode_coding_emacs_mule): Handle insufficent source correctly.
Kenichi Handa <handa@m17n.org>
parents:
54303
diff
changeset
|
2780 { |
89642
e97441b6244b
(encode_coding_emacs_mule): Emit bytes with MSB.
Kenichi Handa <handa@m17n.org>
parents:
89575
diff
changeset
|
2781 code |= 0x8080; |
88365 | 2782 EMIT_ONE_BYTE (code >> 8); |
2783 EMIT_ONE_BYTE (code & 0xFF); | |
54320
a7e59b39de35
(decode_coding_emacs_mule): Handle insufficent source correctly.
Kenichi Handa <handa@m17n.org>
parents:
54303
diff
changeset
|
2784 } |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2785 } |
88365 | 2786 } |
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
2787 record_conversion_result (coding, CODING_RESULT_SUCCESS); |
88365 | 2788 coding->produced_char += produced_chars; |
2789 coding->produced = dst - coding->destination; | |
2790 return 0; | |
34888
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
2791 } |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2792 |
17052 | 2793 |
88365 | 2794 /*** 7. ISO2022 handlers ***/ |
17052 | 2795 |
2796 /* 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
|
2797 Since the intention of this note is to help understand the |
35053 | 2798 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
|
2799 SIMPLIFIED. For thorough understanding, please refer to the |
35053 | 2800 original document of ISO2022. This is equivalent to the standard |
2801 ECMA-35, obtainable from <URL:http://www.ecma.ch/> (*). | |
17052 | 2802 |
2803 ISO2022 provides many mechanisms to encode several character sets | |
35053 | 2804 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
|
2805 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
|
2806 text a little bit longer, but the text passes more easily through |
35053 | 2807 several types of gateway, some of which strip off the MSB (Most |
36087 | 2808 Significant Bit). |
35053 | 2809 |
2810 There are two kinds of character sets: control character sets and | |
2811 graphic character sets. The former contain control characters such | |
17052 | 2812 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
|
2813 functions are also provided by escape sequences). The latter |
35053 | 2814 contain graphic characters such as 'A' and '-'. Emacs recognizes |
17052 | 2815 two control character sets and many graphic character sets. |
2816 | |
2817 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
|
2818 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
|
2819 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
|
2820 - DIMENSION1_CHARS94 |
61c6b3be1d51
Comment for ISO 2022 encoding mechanism modified.
Kenichi Handa <handa@m17n.org>
parents:
24344
diff
changeset
|
2821 - DIMENSION1_CHARS96 |
61c6b3be1d51
Comment for ISO 2022 encoding mechanism modified.
Kenichi Handa <handa@m17n.org>
parents:
24344
diff
changeset
|
2822 - DIMENSION2_CHARS94 |
61c6b3be1d51
Comment for ISO 2022 encoding mechanism modified.
Kenichi Handa <handa@m17n.org>
parents:
24344
diff
changeset
|
2823 - DIMENSION2_CHARS96 |
61c6b3be1d51
Comment for ISO 2022 encoding mechanism modified.
Kenichi Handa <handa@m17n.org>
parents:
24344
diff
changeset
|
2824 |
61c6b3be1d51
Comment for ISO 2022 encoding mechanism modified.
Kenichi Handa <handa@m17n.org>
parents:
24344
diff
changeset
|
2825 In addition, each character set is assigned an identification tag, |
35053 | 2826 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
|
2827 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
|
2828 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
|
2829 (0x30..0x3F are for private use only). |
17052 | 2830 |
2831 Note (*): ECMA = European Computer Manufacturers Association | |
2832 | |
35053 | 2833 Here are examples of graphic character sets [NAME(<F>)]: |
17052 | 2834 o DIMENSION1_CHARS94 -- ASCII('B'), right-half-of-JISX0201('I'), ... |
2835 o DIMENSION1_CHARS96 -- right-half-of-ISO8859-1('A'), ... | |
2836 o DIMENSION2_CHARS94 -- GB2312('A'), JISX0208('B'), ... | |
2837 o DIMENSION2_CHARS96 -- none for the moment | |
2838 | |
24425
61c6b3be1d51
Comment for ISO 2022 encoding mechanism modified.
Kenichi Handa <handa@m17n.org>
parents:
24344
diff
changeset
|
2839 A code area (1 byte=8 bits) is divided into 4 areas, C0, GL, C1, and GR. |
17052 | 2840 C0 [0x00..0x1F] -- control character plane 0 |
2841 GL [0x20..0x7F] -- graphic character plane 0 | |
2842 C1 [0x80..0x9F] -- control character plane 1 | |
2843 GR [0xA0..0xFF] -- graphic character plane 1 | |
2844 | |
2845 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
|
2846 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
|
2847 - 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
|
2848 - 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
|
2849 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
|
2850 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
|
2851 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
|
2852 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
|
2853 defined to have corresponding escape sequences. |
17052 | 2854 |
2855 A graphic character set is at first designated to one of four | |
2856 graphic registers (G0 through G3), then these graphic registers are | |
2857 invoked to GL or GR. These designations and invocations can be | |
2858 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
|
2859 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
|
2860 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
|
2861 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
|
2862 |
61c6b3be1d51
Comment for ISO 2022 encoding mechanism modified.
Kenichi Handa <handa@m17n.org>
parents:
24344
diff
changeset
|
2863 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
|
2864 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
|
2865 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
|
2866 be used. |
17052 | 2867 |
2868 There are two ways of invocation: locking-shift and single-shift. | |
2869 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
|
2870 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
|
2871 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
|
2872 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
|
2873 escape sequences: |
17052 | 2874 |
2875 ---------------------------------------------------------------------- | |
24425
61c6b3be1d51
Comment for ISO 2022 encoding mechanism modified.
Kenichi Handa <handa@m17n.org>
parents:
24344
diff
changeset
|
2876 abbrev function cntrl escape seq description |
17052 | 2877 ---------------------------------------------------------------------- |
24425
61c6b3be1d51
Comment for ISO 2022 encoding mechanism modified.
Kenichi Handa <handa@m17n.org>
parents:
24344
diff
changeset
|
2878 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
|
2879 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
|
2880 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
|
2881 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
|
2882 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
|
2883 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
|
2884 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
|
2885 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
|
2886 SS3 (single-shift-3) 0x8F ESC 'O' invoke G3 for one char |
17052 | 2887 ---------------------------------------------------------------------- |
24425
61c6b3be1d51
Comment for ISO 2022 encoding mechanism modified.
Kenichi Handa <handa@m17n.org>
parents:
24344
diff
changeset
|
2888 (*) 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
|
2889 |
61c6b3be1d51
Comment for ISO 2022 encoding mechanism modified.
Kenichi Handa <handa@m17n.org>
parents:
24344
diff
changeset
|
2890 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
|
2891 ISO_CODE_XXX in `coding.h'. |
61c6b3be1d51
Comment for ISO 2022 encoding mechanism modified.
Kenichi Handa <handa@m17n.org>
parents:
24344
diff
changeset
|
2892 |
61c6b3be1d51
Comment for ISO 2022 encoding mechanism modified.
Kenichi Handa <handa@m17n.org>
parents:
24344
diff
changeset
|
2893 Designations are done by the following escape sequences: |
17052 | 2894 ---------------------------------------------------------------------- |
2895 escape sequence description | |
2896 ---------------------------------------------------------------------- | |
2897 ESC '(' <F> designate DIMENSION1_CHARS94<F> to G0 | |
2898 ESC ')' <F> designate DIMENSION1_CHARS94<F> to G1 | |
2899 ESC '*' <F> designate DIMENSION1_CHARS94<F> to G2 | |
2900 ESC '+' <F> designate DIMENSION1_CHARS94<F> to G3 | |
2901 ESC ',' <F> designate DIMENSION1_CHARS96<F> to G0 (*) | |
2902 ESC '-' <F> designate DIMENSION1_CHARS96<F> to G1 | |
2903 ESC '.' <F> designate DIMENSION1_CHARS96<F> to G2 | |
2904 ESC '/' <F> designate DIMENSION1_CHARS96<F> to G3 | |
2905 ESC '$' '(' <F> designate DIMENSION2_CHARS94<F> to G0 (**) | |
2906 ESC '$' ')' <F> designate DIMENSION2_CHARS94<F> to G1 | |
2907 ESC '$' '*' <F> designate DIMENSION2_CHARS94<F> to G2 | |
2908 ESC '$' '+' <F> designate DIMENSION2_CHARS94<F> to G3 | |
2909 ESC '$' ',' <F> designate DIMENSION2_CHARS96<F> to G0 (*) | |
2910 ESC '$' '-' <F> designate DIMENSION2_CHARS96<F> to G1 | |
2911 ESC '$' '.' <F> designate DIMENSION2_CHARS96<F> to G2 | |
2912 ESC '$' '/' <F> designate DIMENSION2_CHARS96<F> to G3 | |
2913 ---------------------------------------------------------------------- | |
2914 | |
2915 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
|
2916 of dimension 1, chars 94, and final character <F>, etc... |
17052 | 2917 |
2918 Note (*): Although these designations are not allowed in ISO2022, | |
2919 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
|
2920 CHARS96 character sets in a coding system which is characterized as |
17052 | 2921 7-bit environment, non-locking-shift, and non-single-shift. |
2922 | |
2923 Note (**): If <F> is '@', 'A', or 'B', the intermediate character | |
88365 | 2924 '(' must be omitted. We refer to this as "short-form" hereafter. |
17052 | 2925 |
35053 | 2926 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
|
2927 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
|
2928 coding systems such as Compound Text (used in X11's inter client |
36087 | 2929 communication, ISO-2022-JP (used in Japanese Internet), ISO-2022-KR |
2930 (used in Korean Internet), EUC (Extended UNIX Code, used in Asian | |
17052 | 2931 localized platforms), and all of these are variants of ISO2022. |
2932 | |
2933 In addition to the above, Emacs handles two more kinds of escape | |
2934 sequences: ISO6429's direction specification and Emacs' private | |
2935 sequence for specifying character composition. | |
2936 | |
24425
61c6b3be1d51
Comment for ISO 2022 encoding mechanism modified.
Kenichi Handa <handa@m17n.org>
parents:
24344
diff
changeset
|
2937 ISO6429's direction specification takes the following form: |
17052 | 2938 o CSI ']' -- end of the current direction |
2939 o CSI '0' ']' -- end of the current direction | |
2940 o CSI '1' ']' -- start of left-to-right text | |
2941 o CSI '2' ']' -- start of right-to-left text | |
2942 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
|
2943 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
|
2944 |
61c6b3be1d51
Comment for ISO 2022 encoding mechanism modified.
Kenichi Handa <handa@m17n.org>
parents:
24344
diff
changeset
|
2945 Character composition specification takes the following form: |
26847 | 2946 o ESC '0' -- start relative composition |
2947 o ESC '1' -- end composition | |
2948 o ESC '2' -- start rule-base composition (*) | |
2949 o ESC '3' -- start relative composition with alternate chars (**) | |
2950 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
|
2951 Since these are not standard escape sequences of any ISO standard, |
35053 | 2952 the use of them with these meanings is restricted to Emacs only. |
2953 | |
88771 | 2954 (*) This form is used only in Emacs 20.7 and older versions, |
2955 but newer versions can safely decode it. | |
35053 | 2956 (**) This form is used only in Emacs 21.1 and newer versions, |
88771 | 2957 and older versions can't decode it. |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2958 |
35053 | 2959 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
|
2960 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
|
2961 |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2962 COMPOSITION_RELATIVE: |
26847 | 2963 ESC 0 CHAR [ CHAR ] ESC 1 |
36087 | 2964 COMPOSITION_WITH_RULE: |
26847 | 2965 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
|
2966 COMPOSITION_WITH_ALTCHARS: |
26847 | 2967 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
|
2968 COMPOSITION_WITH_RULE_ALTCHARS: |
26847 | 2969 ESC 4 ALTCHAR [ RULE ALTCHAR ] ESC 0 CHAR [ CHAR ] ESC 1 */ |
17052 | 2970 |
2971 enum iso_code_class_type iso_code_class[256]; | |
2972 | |
88365 | 2973 #define SAFE_CHARSET_P(coding, id) \ |
2974 ((id) <= (coding)->max_charset_id \ | |
102186
a12d39ca6870
* coding.h (struct coding_system): Make safe_charsets a pointer to
Andreas Schwab <schwab@suse.de>
parents:
102115
diff
changeset
|
2975 && (coding)->safe_charsets[id] != 255) |
88365 | 2976 |
2977 | |
2978 #define SHIFT_OUT_OK(category) \ | |
2979 (CODING_ISO_INITIAL (&coding_categories[category], 1) >= 0) | |
2980 | |
2981 static void | |
109126
aec1143e8d85
Convert (most) functions in src to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109100
diff
changeset
|
2982 setup_iso_safe_charsets (Lisp_Object attrs) |
88365 | 2983 { |
2984 Lisp_Object charset_list, safe_charsets; | |
2985 Lisp_Object request; | |
2986 Lisp_Object reg_usage; | |
2987 Lisp_Object tail; | |
2988 int reg94, reg96; | |
2989 int flags = XINT (AREF (attrs, coding_attr_iso_flags)); | |
2990 int max_charset_id; | |
2991 | |
2992 charset_list = CODING_ATTR_CHARSET_LIST (attrs); | |
2993 if ((flags & CODING_ISO_FLAG_FULL_SUPPORT) | |
2994 && ! EQ (charset_list, Viso_2022_charset_list)) | |
2995 { | |
2996 CODING_ATTR_CHARSET_LIST (attrs) | |
2997 = charset_list = Viso_2022_charset_list; | |
2998 ASET (attrs, coding_attr_safe_charsets, Qnil); | |
2999 } | |
3000 | |
3001 if (STRINGP (AREF (attrs, coding_attr_safe_charsets))) | |
3002 return; | |
3003 | |
3004 max_charset_id = 0; | |
3005 for (tail = charset_list; CONSP (tail); tail = XCDR (tail)) | |
3006 { | |
3007 int id = XINT (XCAR (tail)); | |
3008 if (max_charset_id < id) | |
3009 max_charset_id = id; | |
3010 } | |
3011 | |
102186
a12d39ca6870
* coding.h (struct coding_system): Make safe_charsets a pointer to
Andreas Schwab <schwab@suse.de>
parents:
102115
diff
changeset
|
3012 safe_charsets = make_uninit_string (max_charset_id + 1); |
a12d39ca6870
* coding.h (struct coding_system): Make safe_charsets a pointer to
Andreas Schwab <schwab@suse.de>
parents:
102115
diff
changeset
|
3013 memset (SDATA (safe_charsets), 255, max_charset_id + 1); |
88365 | 3014 request = AREF (attrs, coding_attr_iso_request); |
3015 reg_usage = AREF (attrs, coding_attr_iso_usage); | |
3016 reg94 = XINT (XCAR (reg_usage)); | |
3017 reg96 = XINT (XCDR (reg_usage)); | |
3018 | |
3019 for (tail = charset_list; CONSP (tail); tail = XCDR (tail)) | |
3020 { | |
3021 Lisp_Object id; | |
3022 Lisp_Object reg; | |
3023 struct charset *charset; | |
3024 | |
3025 id = XCAR (tail); | |
3026 charset = CHARSET_FROM_ID (XINT (id)); | |
88681
2cdfbffa8a0d
(CODING_ISO_FLAG_USE_ROMAN): New macro
Kenichi Handa <handa@m17n.org>
parents:
88669
diff
changeset
|
3027 reg = Fcdr (Fassq (id, request)); |
88365 | 3028 if (! NILP (reg)) |
89483 | 3029 SSET (safe_charsets, XINT (id), XINT (reg)); |
88365 | 3030 else if (charset->iso_chars_96) |
3031 { | |
3032 if (reg96 < 4) | |
89483 | 3033 SSET (safe_charsets, XINT (id), reg96); |
88365 | 3034 } |
3035 else | |
3036 { | |
3037 if (reg94 < 4) | |
89483 | 3038 SSET (safe_charsets, XINT (id), reg94); |
88365 | 3039 } |
3040 } | |
3041 ASET (attrs, coding_attr_safe_charsets, safe_charsets); | |
3042 } | |
3043 | |
50047
8e17fbb2ac77
(CODING_ADD_COMPOSITION_COMPONENT): If the number of
Kenichi Handa <handa@m17n.org>
parents:
49600
diff
changeset
|
3044 |
17052 | 3045 /* See the above "GENERAL NOTES on `detect_coding_XXX ()' functions". |
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3046 Check if a text is encoded in one of ISO-2022 based codig systems. |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3047 If it is, return 1, else return 0. */ |
17052 | 3048 |
34531
37f85e931855
(ONE_MORE_BYTE_CHECK_MULTIBYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34197
diff
changeset
|
3049 static int |
109159
3e9fdeb960d1
* coding.c, sysdep.c: Convert some more functions to standard C.
Juanma Barranquero <lekktu@gmail.com>
parents:
109158
diff
changeset
|
3050 detect_coding_iso_2022 (struct coding_system *coding, |
3e9fdeb960d1
* coding.c, sysdep.c: Convert some more functions to standard C.
Juanma Barranquero <lekktu@gmail.com>
parents:
109158
diff
changeset
|
3051 struct coding_detection_info *detect_info) |
17052 | 3052 { |
89483 | 3053 const unsigned char *src = coding->source, *src_base = src; |
3054 const unsigned char *src_end = coding->source + coding->src_bytes; | |
88365 | 3055 int multibytep = coding->src_multibyte; |
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3056 int single_shifting = 0; |
88365 | 3057 int id; |
3058 int c, c1; | |
3059 int consumed_chars = 0; | |
3060 int i; | |
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3061 int rejected = 0; |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3062 int found = 0; |
99753
c457d1e5edff
(detect_coding_iso_2022): Reject invalid composition
Kenichi Handa <handa@m17n.org>
parents:
99074
diff
changeset
|
3063 int composition_count = -1; |
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3064 |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3065 detect_info->checked |= CATEGORY_MASK_ISO; |
88365 | 3066 |
3067 for (i = coding_category_iso_7; i <= coding_category_iso_8_else; i++) | |
3068 { | |
3069 struct coding_system *this = &(coding_categories[i]); | |
3070 Lisp_Object attrs, val; | |
3071 | |
94944
c16046e21b90
(detect_coding_iso_2022): Ignore a coding category that
Kenichi Handa <handa@m17n.org>
parents:
93877
diff
changeset
|
3072 if (this->id < 0) |
c16046e21b90
(detect_coding_iso_2022): Ignore a coding category that
Kenichi Handa <handa@m17n.org>
parents:
93877
diff
changeset
|
3073 continue; |
88365 | 3074 attrs = CODING_ID_ATTRS (this->id); |
3075 if (CODING_ISO_FLAGS (this) & CODING_ISO_FLAG_FULL_SUPPORT | |
102186
a12d39ca6870
* coding.h (struct coding_system): Make safe_charsets a pointer to
Andreas Schwab <schwab@suse.de>
parents:
102115
diff
changeset
|
3076 && ! EQ (CODING_ATTR_CHARSET_LIST (attrs), Viso_2022_charset_list)) |
88365 | 3077 setup_iso_safe_charsets (attrs); |
3078 val = CODING_ATTR_SAFE_CHARSETS (attrs); | |
89483 | 3079 this->max_charset_id = SCHARS (val) - 1; |
102186
a12d39ca6870
* coding.h (struct coding_system): Make safe_charsets a pointer to
Andreas Schwab <schwab@suse.de>
parents:
102115
diff
changeset
|
3080 this->safe_charsets = SDATA (val); |
88365 | 3081 } |
3082 | |
3083 /* A coding system of this category is always ASCII compatible. */ | |
3084 src += coding->head_ascii; | |
3085 | |
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3086 while (rejected != CATEGORY_MASK_ISO) |
88365 | 3087 { |
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
3088 src_base = src; |
88365 | 3089 ONE_MORE_BYTE (c); |
17052 | 3090 switch (c) |
3091 { | |
3092 case ISO_CODE_ESC: | |
30204
35aec8514228
(inhibit_iso_escape_detection): New variable.
Kenichi Handa <handa@m17n.org>
parents:
29985
diff
changeset
|
3093 if (inhibit_iso_escape_detection) |
35aec8514228
(inhibit_iso_escape_detection): New variable.
Kenichi Handa <handa@m17n.org>
parents:
29985
diff
changeset
|
3094 break; |
23088
45c36d636f66
(detect_coding_iso2022): Don't check the byte length of
Kenichi Handa <handa@m17n.org>
parents:
23082
diff
changeset
|
3095 single_shifting = 0; |
88365 | 3096 ONE_MORE_BYTE (c); |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3097 if (c >= '(' && c <= '/') |
19134
8fa6e23f8d22
(detect_coding_iso2022): Do not exclude posibility of
Kenichi Handa <handa@m17n.org>
parents:
19118
diff
changeset
|
3098 { |
8fa6e23f8d22
(detect_coding_iso2022): Do not exclude posibility of
Kenichi Handa <handa@m17n.org>
parents:
19118
diff
changeset
|
3099 /* Designation sequence for a charset of dimension 1. */ |
88365 | 3100 ONE_MORE_BYTE (c1); |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3101 if (c1 < ' ' || c1 >= 0x80 |
88365 | 3102 || (id = iso_charset_table[0][c >= ','][c1]) < 0) |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3103 /* Invalid designation sequence. Just ignore. */ |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3104 break; |
19134
8fa6e23f8d22
(detect_coding_iso2022): Do not exclude posibility of
Kenichi Handa <handa@m17n.org>
parents:
19118
diff
changeset
|
3105 } |
8fa6e23f8d22
(detect_coding_iso2022): Do not exclude posibility of
Kenichi Handa <handa@m17n.org>
parents:
19118
diff
changeset
|
3106 else if (c == '$') |
17052 | 3107 { |
19134
8fa6e23f8d22
(detect_coding_iso2022): Do not exclude posibility of
Kenichi Handa <handa@m17n.org>
parents:
19118
diff
changeset
|
3108 /* Designation sequence for a charset of dimension 2. */ |
88365 | 3109 ONE_MORE_BYTE (c); |
19134
8fa6e23f8d22
(detect_coding_iso2022): Do not exclude posibility of
Kenichi Handa <handa@m17n.org>
parents:
19118
diff
changeset
|
3110 if (c >= '@' && c <= 'B') |
8fa6e23f8d22
(detect_coding_iso2022): Do not exclude posibility of
Kenichi Handa <handa@m17n.org>
parents:
19118
diff
changeset
|
3111 /* Designation for JISX0208.1978, GB2312, or JISX0208. */ |
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3112 id = 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
|
3113 else if (c >= '(' && c <= '/') |
17320
9d15bec5f47e
(detect_coding_iso2022, detect_coding_mask): Ignore
Kenichi Handa <handa@m17n.org>
parents:
17304
diff
changeset
|
3114 { |
88365 | 3115 ONE_MORE_BYTE (c1); |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3116 if (c1 < ' ' || c1 >= 0x80 |
88365 | 3117 || (id = iso_charset_table[1][c >= ','][c1]) < 0) |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3118 /* Invalid designation sequence. Just ignore. */ |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3119 break; |
17320
9d15bec5f47e
(detect_coding_iso2022, detect_coding_mask): Ignore
Kenichi Handa <handa@m17n.org>
parents:
17304
diff
changeset
|
3120 } |
19134
8fa6e23f8d22
(detect_coding_iso2022): Do not exclude posibility of
Kenichi Handa <handa@m17n.org>
parents:
19118
diff
changeset
|
3121 else |
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3122 /* Invalid designation sequence. Just ignore it. */ |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3123 break; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3124 } |
23116
6736da064f4a
(detect_coding_iso2022): Handle ESC N and ESC O
Kenichi Handa <handa@m17n.org>
parents:
23089
diff
changeset
|
3125 else if (c == 'N' || c == 'O') |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3126 { |
23116
6736da064f4a
(detect_coding_iso2022): Handle ESC N and ESC O
Kenichi Handa <handa@m17n.org>
parents:
23089
diff
changeset
|
3127 /* ESC <Fe> for SS2 or SS3. */ |
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3128 single_shifting = 1; |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3129 rejected |= CATEGORY_MASK_ISO_7BIT | CATEGORY_MASK_ISO_8BIT; |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3130 break; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3131 } |
99753
c457d1e5edff
(detect_coding_iso_2022): Reject invalid composition
Kenichi Handa <handa@m17n.org>
parents:
99074
diff
changeset
|
3132 else if (c == '1') |
c457d1e5edff
(detect_coding_iso_2022): Reject invalid composition
Kenichi Handa <handa@m17n.org>
parents:
99074
diff
changeset
|
3133 { |
c457d1e5edff
(detect_coding_iso_2022): Reject invalid composition
Kenichi Handa <handa@m17n.org>
parents:
99074
diff
changeset
|
3134 /* End of composition. */ |
c457d1e5edff
(detect_coding_iso_2022): Reject invalid composition
Kenichi Handa <handa@m17n.org>
parents:
99074
diff
changeset
|
3135 if (composition_count < 0 |
c457d1e5edff
(detect_coding_iso_2022): Reject invalid composition
Kenichi Handa <handa@m17n.org>
parents:
99074
diff
changeset
|
3136 || composition_count > MAX_COMPOSITION_COMPONENTS) |
c457d1e5edff
(detect_coding_iso_2022): Reject invalid composition
Kenichi Handa <handa@m17n.org>
parents:
99074
diff
changeset
|
3137 /* Invalid */ |
c457d1e5edff
(detect_coding_iso_2022): Reject invalid composition
Kenichi Handa <handa@m17n.org>
parents:
99074
diff
changeset
|
3138 break; |
c457d1e5edff
(detect_coding_iso_2022): Reject invalid composition
Kenichi Handa <handa@m17n.org>
parents:
99074
diff
changeset
|
3139 composition_count = -1; |
c457d1e5edff
(detect_coding_iso_2022): Reject invalid composition
Kenichi Handa <handa@m17n.org>
parents:
99074
diff
changeset
|
3140 found |= CATEGORY_MASK_ISO; |
c457d1e5edff
(detect_coding_iso_2022): Reject invalid composition
Kenichi Handa <handa@m17n.org>
parents:
99074
diff
changeset
|
3141 } |
26847 | 3142 else if (c >= '0' && c <= '4') |
3143 { | |
3144 /* ESC <Fp> for start/end composition. */ | |
99753
c457d1e5edff
(detect_coding_iso_2022): Reject invalid composition
Kenichi Handa <handa@m17n.org>
parents:
99074
diff
changeset
|
3145 composition_count = 0; |
26847 | 3146 break; |
3147 } | |
19134
8fa6e23f8d22
(detect_coding_iso2022): Do not exclude posibility of
Kenichi Handa <handa@m17n.org>
parents:
19118
diff
changeset
|
3148 else |
88365 | 3149 { |
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3150 /* Invalid escape sequence. Just ignore it. */ |
88365 | 3151 break; |
3152 } | |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3153 |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3154 /* We found a valid designation sequence for CHARSET. */ |
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3155 rejected |= CATEGORY_MASK_ISO_8BIT; |
88365 | 3156 if (SAFE_CHARSET_P (&coding_categories[coding_category_iso_7], |
3157 id)) | |
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3158 found |= CATEGORY_MASK_ISO_7; |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3159 else |
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3160 rejected |= CATEGORY_MASK_ISO_7; |
88365 | 3161 if (SAFE_CHARSET_P (&coding_categories[coding_category_iso_7_tight], |
3162 id)) | |
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3163 found |= CATEGORY_MASK_ISO_7_TIGHT; |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3164 else |
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3165 rejected |= CATEGORY_MASK_ISO_7_TIGHT; |
88365 | 3166 if (SAFE_CHARSET_P (&coding_categories[coding_category_iso_7_else], |
3167 id)) | |
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3168 found |= CATEGORY_MASK_ISO_7_ELSE; |
23116
6736da064f4a
(detect_coding_iso2022): Handle ESC N and ESC O
Kenichi Handa <handa@m17n.org>
parents:
23089
diff
changeset
|
3169 else |
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3170 rejected |= CATEGORY_MASK_ISO_7_ELSE; |
88365 | 3171 if (SAFE_CHARSET_P (&coding_categories[coding_category_iso_8_else], |
3172 id)) | |
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3173 found |= CATEGORY_MASK_ISO_8_ELSE; |
23116
6736da064f4a
(detect_coding_iso2022): Handle ESC N and ESC O
Kenichi Handa <handa@m17n.org>
parents:
23089
diff
changeset
|
3174 else |
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3175 rejected |= CATEGORY_MASK_ISO_8_ELSE; |
17052 | 3176 break; |
3177 | |
3178 case ISO_CODE_SO: | |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3179 case ISO_CODE_SI: |
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3180 /* Locking shift out/in. */ |
30204
35aec8514228
(inhibit_iso_escape_detection): New variable.
Kenichi Handa <handa@m17n.org>
parents:
29985
diff
changeset
|
3181 if (inhibit_iso_escape_detection) |
35aec8514228
(inhibit_iso_escape_detection): New variable.
Kenichi Handa <handa@m17n.org>
parents:
29985
diff
changeset
|
3182 break; |
23088
45c36d636f66
(detect_coding_iso2022): Don't check the byte length of
Kenichi Handa <handa@m17n.org>
parents:
23082
diff
changeset
|
3183 single_shifting = 0; |
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3184 rejected |= CATEGORY_MASK_ISO_7BIT | CATEGORY_MASK_ISO_8BIT; |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3185 break; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3186 |
17052 | 3187 case ISO_CODE_CSI: |
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3188 /* Control sequence introducer. */ |
23088
45c36d636f66
(detect_coding_iso2022): Don't check the byte length of
Kenichi Handa <handa@m17n.org>
parents:
23082
diff
changeset
|
3189 single_shifting = 0; |
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3190 rejected |= CATEGORY_MASK_ISO_7BIT | CATEGORY_MASK_ISO_7_ELSE; |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3191 found |= CATEGORY_MASK_ISO_8_ELSE; |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3192 goto check_extra_latin; |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3193 |
17052 | 3194 case ISO_CODE_SS2: |
3195 case ISO_CODE_SS3: | |
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3196 /* Single shift. */ |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3197 if (inhibit_iso_escape_detection) |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3198 break; |
89780
a53cb5864a40
(detect_coding_iso_2022): Fix handling of SS2 and SS3.
Kenichi Handa <handa@m17n.org>
parents:
89779
diff
changeset
|
3199 single_shifting = 0; |
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3200 rejected |= CATEGORY_MASK_ISO_7BIT; |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3201 if (CODING_ISO_FLAGS (&coding_categories[coding_category_iso_8_1]) |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3202 & CODING_ISO_FLAG_SINGLE_SHIFT) |
89780
a53cb5864a40
(detect_coding_iso_2022): Fix handling of SS2 and SS3.
Kenichi Handa <handa@m17n.org>
parents:
89779
diff
changeset
|
3203 found |= CATEGORY_MASK_ISO_8_1, single_shifting = 1; |
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3204 if (CODING_ISO_FLAGS (&coding_categories[coding_category_iso_8_2]) |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3205 & CODING_ISO_FLAG_SINGLE_SHIFT) |
89780
a53cb5864a40
(detect_coding_iso_2022): Fix handling of SS2 and SS3.
Kenichi Handa <handa@m17n.org>
parents:
89779
diff
changeset
|
3206 found |= CATEGORY_MASK_ISO_8_2, single_shifting = 1; |
a53cb5864a40
(detect_coding_iso_2022): Fix handling of SS2 and SS3.
Kenichi Handa <handa@m17n.org>
parents:
89779
diff
changeset
|
3207 if (single_shifting) |
a53cb5864a40
(detect_coding_iso_2022): Fix handling of SS2 and SS3.
Kenichi Handa <handa@m17n.org>
parents:
89779
diff
changeset
|
3208 break; |
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3209 goto check_extra_latin; |
17052 | 3210 |
3211 default: | |
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
3212 if (c < 0) |
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
3213 continue; |
17052 | 3214 if (c < 0x80) |
23088
45c36d636f66
(detect_coding_iso2022): Don't check the byte length of
Kenichi Handa <handa@m17n.org>
parents:
23082
diff
changeset
|
3215 { |
99753
c457d1e5edff
(detect_coding_iso_2022): Reject invalid composition
Kenichi Handa <handa@m17n.org>
parents:
99074
diff
changeset
|
3216 if (composition_count >= 0) |
c457d1e5edff
(detect_coding_iso_2022): Reject invalid composition
Kenichi Handa <handa@m17n.org>
parents:
99074
diff
changeset
|
3217 composition_count++; |
23088
45c36d636f66
(detect_coding_iso2022): Don't check the byte length of
Kenichi Handa <handa@m17n.org>
parents:
23082
diff
changeset
|
3218 single_shifting = 0; |
45c36d636f66
(detect_coding_iso2022): Don't check the byte length of
Kenichi Handa <handa@m17n.org>
parents:
23082
diff
changeset
|
3219 break; |
45c36d636f66
(detect_coding_iso2022): Don't check the byte length of
Kenichi Handa <handa@m17n.org>
parents:
23082
diff
changeset
|
3220 } |
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3221 if (c >= 0xA0) |
19280
e755044718ee
(ENCODE_ISO_CHARACTER_DIMENSION1): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
19193
diff
changeset
|
3222 { |
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3223 rejected |= CATEGORY_MASK_ISO_7BIT | CATEGORY_MASK_ISO_7_ELSE; |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3224 found |= 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
|
3225 /* Check the length of succeeding codes of the range |
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3226 0xA0..0FF. If the byte length is even, we include |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3227 CATEGORY_MASK_ISO_8_2 in `found'. We can check this |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3228 only when we are not single shifting. */ |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3229 if (! single_shifting |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3230 && ! (rejected & 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
|
3231 { |
29299
b33b38d81020
(detect_coding_iso2022): Fix code for checking
Kenichi Handa <handa@m17n.org>
parents:
29275
diff
changeset
|
3232 int i = 1; |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3233 while (src < src_end) |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3234 { |
106826
64cd76243389
Fix handling of euc-xx coding systems.
Kenichi Handa <handa@m17n.org>
parents:
106815
diff
changeset
|
3235 src_base = src; |
88365 | 3236 ONE_MORE_BYTE (c); |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3237 if (c < 0xA0) |
106826
64cd76243389
Fix handling of euc-xx coding systems.
Kenichi Handa <handa@m17n.org>
parents:
106815
diff
changeset
|
3238 { |
64cd76243389
Fix handling of euc-xx coding systems.
Kenichi Handa <handa@m17n.org>
parents:
106815
diff
changeset
|
3239 src = src_base; |
64cd76243389
Fix handling of euc-xx coding systems.
Kenichi Handa <handa@m17n.org>
parents:
106815
diff
changeset
|
3240 break; |
64cd76243389
Fix handling of euc-xx coding systems.
Kenichi Handa <handa@m17n.org>
parents:
106815
diff
changeset
|
3241 } |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3242 i++; |
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 |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3245 if (i & 1 && src < src_end) |
99753
c457d1e5edff
(detect_coding_iso_2022): Reject invalid composition
Kenichi Handa <handa@m17n.org>
parents:
99074
diff
changeset
|
3246 { |
c457d1e5edff
(detect_coding_iso_2022): Reject invalid composition
Kenichi Handa <handa@m17n.org>
parents:
99074
diff
changeset
|
3247 rejected |= CATEGORY_MASK_ISO_8_2; |
c457d1e5edff
(detect_coding_iso_2022): Reject invalid composition
Kenichi Handa <handa@m17n.org>
parents:
99074
diff
changeset
|
3248 if (composition_count >= 0) |
c457d1e5edff
(detect_coding_iso_2022): Reject invalid composition
Kenichi Handa <handa@m17n.org>
parents:
99074
diff
changeset
|
3249 composition_count += i; |
c457d1e5edff
(detect_coding_iso_2022): Reject invalid composition
Kenichi Handa <handa@m17n.org>
parents:
99074
diff
changeset
|
3250 } |
23088
45c36d636f66
(detect_coding_iso2022): Don't check the byte length of
Kenichi Handa <handa@m17n.org>
parents:
23082
diff
changeset
|
3251 else |
99753
c457d1e5edff
(detect_coding_iso_2022): Reject invalid composition
Kenichi Handa <handa@m17n.org>
parents:
99074
diff
changeset
|
3252 { |
c457d1e5edff
(detect_coding_iso_2022): Reject invalid composition
Kenichi Handa <handa@m17n.org>
parents:
99074
diff
changeset
|
3253 found |= CATEGORY_MASK_ISO_8_2; |
c457d1e5edff
(detect_coding_iso_2022): Reject invalid composition
Kenichi Handa <handa@m17n.org>
parents:
99074
diff
changeset
|
3254 if (composition_count >= 0) |
c457d1e5edff
(detect_coding_iso_2022): Reject invalid composition
Kenichi Handa <handa@m17n.org>
parents:
99074
diff
changeset
|
3255 composition_count += i / 2; |
c457d1e5edff
(detect_coding_iso_2022): Reject invalid composition
Kenichi Handa <handa@m17n.org>
parents:
99074
diff
changeset
|
3256 } |
23088
45c36d636f66
(detect_coding_iso2022): Don't check the byte length of
Kenichi Handa <handa@m17n.org>
parents:
23082
diff
changeset
|
3257 } |
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3258 break; |
17052 | 3259 } |
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3260 check_extra_latin: |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3261 single_shifting = 0; |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3262 if (! VECTORP (Vlatin_extra_code_table) |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3263 || NILP (XVECTOR (Vlatin_extra_code_table)->contents[c])) |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3264 { |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3265 rejected = CATEGORY_MASK_ISO; |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3266 break; |
17052 | 3267 } |
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3268 if (CODING_ISO_FLAGS (&coding_categories[coding_category_iso_8_1]) |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3269 & CODING_ISO_FLAG_LATIN_EXTRA) |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3270 found |= CATEGORY_MASK_ISO_8_1; |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3271 else |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3272 rejected |= CATEGORY_MASK_ISO_8_1; |
89780
a53cb5864a40
(detect_coding_iso_2022): Fix handling of SS2 and SS3.
Kenichi Handa <handa@m17n.org>
parents:
89779
diff
changeset
|
3273 rejected |= CATEGORY_MASK_ISO_8_2; |
17052 | 3274 } |
3275 } | |
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3276 detect_info->rejected |= CATEGORY_MASK_ISO; |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3277 return 0; |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3278 |
88365 | 3279 no_more_source: |
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3280 detect_info->rejected |= rejected; |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3281 detect_info->found |= (found & ~rejected); |
88365 | 3282 return 1; |
17052 | 3283 } |
3284 | |
3285 | |
89873
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
3286 /* Set designation state into CODING. Set CHARS_96 to -1 if the |
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
3287 escape sequence should be kept. */ |
88365 | 3288 #define DECODE_DESIGNATION(reg, dim, chars_96, final) \ |
3289 do { \ | |
3290 int id, prev; \ | |
3291 \ | |
3292 if (final < '0' || final >= 128 \ | |
3293 || ((id = ISO_CHARSET_TABLE (dim, chars_96, final)) < 0) \ | |
3294 || !SAFE_CHARSET_P (coding, id)) \ | |
3295 { \ | |
3296 CODING_ISO_DESIGNATION (coding, reg) = -2; \ | |
89873
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
3297 chars_96 = -1; \ |
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
3298 break; \ |
88365 | 3299 } \ |
3300 prev = CODING_ISO_DESIGNATION (coding, reg); \ | |
88681
2cdfbffa8a0d
(CODING_ISO_FLAG_USE_ROMAN): New macro
Kenichi Handa <handa@m17n.org>
parents:
88669
diff
changeset
|
3301 if (id == charset_jisx0201_roman) \ |
2cdfbffa8a0d
(CODING_ISO_FLAG_USE_ROMAN): New macro
Kenichi Handa <handa@m17n.org>
parents:
88669
diff
changeset
|
3302 { \ |
2cdfbffa8a0d
(CODING_ISO_FLAG_USE_ROMAN): New macro
Kenichi Handa <handa@m17n.org>
parents:
88669
diff
changeset
|
3303 if (CODING_ISO_FLAGS (coding) & CODING_ISO_FLAG_USE_ROMAN) \ |
2cdfbffa8a0d
(CODING_ISO_FLAG_USE_ROMAN): New macro
Kenichi Handa <handa@m17n.org>
parents:
88669
diff
changeset
|
3304 id = charset_ascii; \ |
2cdfbffa8a0d
(CODING_ISO_FLAG_USE_ROMAN): New macro
Kenichi Handa <handa@m17n.org>
parents:
88669
diff
changeset
|
3305 } \ |
2cdfbffa8a0d
(CODING_ISO_FLAG_USE_ROMAN): New macro
Kenichi Handa <handa@m17n.org>
parents:
88669
diff
changeset
|
3306 else if (id == charset_jisx0208_1978) \ |
2cdfbffa8a0d
(CODING_ISO_FLAG_USE_ROMAN): New macro
Kenichi Handa <handa@m17n.org>
parents:
88669
diff
changeset
|
3307 { \ |
2cdfbffa8a0d
(CODING_ISO_FLAG_USE_ROMAN): New macro
Kenichi Handa <handa@m17n.org>
parents:
88669
diff
changeset
|
3308 if (CODING_ISO_FLAGS (coding) & CODING_ISO_FLAG_USE_OLDJIS) \ |
2cdfbffa8a0d
(CODING_ISO_FLAG_USE_ROMAN): New macro
Kenichi Handa <handa@m17n.org>
parents:
88669
diff
changeset
|
3309 id = charset_jisx0208; \ |
2cdfbffa8a0d
(CODING_ISO_FLAG_USE_ROMAN): New macro
Kenichi Handa <handa@m17n.org>
parents:
88669
diff
changeset
|
3310 } \ |
88365 | 3311 CODING_ISO_DESIGNATION (coding, reg) = id; \ |
3312 /* If there was an invalid designation to REG previously, and this \ | |
3313 designation is ASCII to REG, we should keep this designation \ | |
3314 sequence. */ \ | |
3315 if (prev == -2 && id == charset_ascii) \ | |
89873
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
3316 chars_96 = -1; \ |
17052 | 3317 } while (0) |
3318 | |
88365 | 3319 |
102422
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3320 /* Handle these composition sequence (ALT: alternate char): |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3321 |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3322 (1) relative composition: ESC 0 CHAR ... ESC 1 |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3323 (2) rulebase composition: ESC 2 CHAR RULE CHAR RULE ... CHAR ESC 1 |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3324 (3) altchar composition: ESC 3 ALT ... ALT ESC 0 CHAR ... ESC 1 |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3325 (4) alt&rule composition: ESC 4 ALT RULE ... ALT ESC 0 CHAR ... ESC 1 |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3326 |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3327 When the start sequence (ESC 0/2/3/4) is found, this annotation |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3328 header is produced. |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3329 |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3330 [ -LENGTH(==-5) CODING_ANNOTATE_COMPOSITION_MASK NCHARS(==0) 0 METHOD ] |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3331 |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3332 Then, upon reading CHAR or RULE (one or two bytes), these codes are |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3333 produced until the end sequence (ESC 1) is found: |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3334 |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3335 (1) CHAR ... CHAR |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3336 (2) CHAR -2 DECODED-RULE CHAR -2 DECODED-RULE ... CHAR |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3337 (3) ALT ... ALT -1 -1 CHAR ... CHAR |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3338 (4) ALT -2 DECODED-RULE ALT -2 DECODED-RULE ... ALT -1 -1 CHAR ... CHAR |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3339 |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3340 When the end sequence (ESC 1) is found, LENGTH and NCHARS in the |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3341 annotation header is updated as below: |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3342 |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3343 (1) LENGTH: unchanged, NCHARS: number of CHARs |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3344 (2) LENGTH: unchanged, NCHARS: number of CHARs |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3345 (3) LENGTH: += number of ALTs + 2, NCHARS: number of CHARs |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3346 (4) LENGTH: += number of ALTs * 3, NCHARS: number of CHARs |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3347 |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3348 If an error is found while composing, the annotation header is |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3349 changed to: |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3350 |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3351 [ ESC '0'/'2'/'3'/'4' -2 0 ] |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3352 |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3353 and the sequence [ -2 DECODED-RULE ] is changed to the original |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3354 byte sequence as below: |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3355 o the original byte sequence is B: [ B -1 ] |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3356 o the original byte sequence is B1 B2: [ B1 B2 ] |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3357 and the sequence [ -1 -1 ] is changed to the original byte |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3358 sequence: |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3359 [ ESC '0' ] |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3360 */ |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3361 |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3362 /* Decode a composition rule C1 and maybe one more byte from the |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3363 source, and set RULE to the encoded composition rule, NBYTES to the |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3364 length of the composition rule. If the rule is invalid, set RULE |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3365 to some negative value. */ |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3366 |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3367 #define DECODE_COMPOSITION_RULE(rule, nbytes) \ |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3368 do { \ |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3369 rule = c1 - 32; \ |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3370 if (rule < 0) \ |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3371 break; \ |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3372 if (rule < 81) /* old format (before ver.21) */ \ |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3373 { \ |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3374 int gref = (rule) / 9; \ |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3375 int nref = (rule) % 9; \ |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3376 if (gref == 4) gref = 10; \ |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3377 if (nref == 4) nref = 10; \ |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3378 rule = COMPOSITION_ENCODE_RULE (gref, nref); \ |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3379 nbytes = 1; \ |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3380 } \ |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3381 else /* new format (after ver.21) */ \ |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3382 { \ |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3383 int c; \ |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3384 \ |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3385 ONE_MORE_BYTE (c); \ |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3386 rule = COMPOSITION_ENCODE_RULE (rule - 81, c - 32); \ |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3387 if (rule >= 0) \ |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3388 rule += 0x100; /* to destinguish it from the old format */ \ |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3389 nbytes = 2; \ |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3390 } \ |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3391 } while (0) |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3392 |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3393 #define ENCODE_COMPOSITION_RULE(rule) \ |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3394 do { \ |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3395 int gref = (rule % 0x100) / 12, nref = (rule % 0x100) % 12; \ |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3396 \ |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3397 if (rule < 0x100) /* old format */ \ |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3398 { \ |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3399 if (gref == 10) gref = 4; \ |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3400 if (nref == 10) nref = 4; \ |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3401 charbuf[idx] = 32 + gref * 9 + nref; \ |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3402 charbuf[idx + 1] = -1; \ |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3403 new_chars++; \ |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3404 } \ |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3405 else /* new format */ \ |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3406 { \ |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3407 charbuf[idx] = 32 + 81 + gref; \ |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3408 charbuf[idx + 1] = 32 + nref; \ |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3409 new_chars += 2; \ |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3410 } \ |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3411 } while (0) |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3412 |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3413 /* Finish the current composition as invalid. */ |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3414 |
109100
2bc9a0c04c87
Remove __P and P_ from .c and .m files and definition of P_
Jan D <jan.h.d@swipnet.se>
parents:
107984
diff
changeset
|
3415 static int finish_composition (int *, struct composition_status *); |
102422
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3416 |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3417 static int |
109126
aec1143e8d85
Convert (most) functions in src to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109100
diff
changeset
|
3418 finish_composition (int *charbuf, struct composition_status *cmp_status) |
102422
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3419 { |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3420 int idx = - cmp_status->length; |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3421 int new_chars; |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3422 |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3423 /* Recover the original ESC sequence */ |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3424 charbuf[idx++] = ISO_CODE_ESC; |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3425 charbuf[idx++] = (cmp_status->method == COMPOSITION_RELATIVE ? '0' |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3426 : cmp_status->method == COMPOSITION_WITH_RULE ? '2' |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3427 : cmp_status->method == COMPOSITION_WITH_ALTCHARS ? '3' |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3428 /* cmp_status->method == COMPOSITION_WITH_RULE_ALTCHARS */ |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3429 : '4'); |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3430 charbuf[idx++] = -2; |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3431 charbuf[idx++] = 0; |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3432 charbuf[idx++] = -1; |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3433 new_chars = cmp_status->nchars; |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3434 if (cmp_status->method >= COMPOSITION_WITH_RULE) |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3435 for (; idx < 0; idx++) |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3436 { |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3437 int elt = charbuf[idx]; |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3438 |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3439 if (elt == -2) |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3440 { |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3441 ENCODE_COMPOSITION_RULE (charbuf[idx + 1]); |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3442 idx++; |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3443 } |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3444 else if (elt == -1) |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3445 { |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3446 charbuf[idx++] = ISO_CODE_ESC; |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3447 charbuf[idx] = '0'; |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3448 new_chars += 2; |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3449 } |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3450 } |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3451 cmp_status->state = COMPOSING_NO; |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3452 return new_chars; |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3453 } |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3454 |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3455 /* If characers are under composition, finish the composition. */ |
88365 | 3456 #define MAYBE_FINISH_COMPOSITION() \ |
3457 do { \ | |
102422
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3458 if (cmp_status->state != COMPOSING_NO) \ |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3459 char_offset += finish_composition (charbuf, cmp_status); \ |
88365 | 3460 } while (0) |
3461 | |
34888
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
3462 /* Handle composition start sequence ESC 0, ESC 2, ESC 3, or ESC 4. |
102422
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3463 |
34888
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
3464 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
|
3465 ESC 2 : rulebase composition : ESC 2 CHAR RULE CHAR RULE ... CHAR ESC 1 |
88365 | 3466 ESC 3 : altchar composition : ESC 3 CHAR ... ESC 0 CHAR ... ESC 1 |
3467 ESC 4 : alt&rule composition : ESC 4 CHAR RULE ... CHAR ESC 0 CHAR ... ESC 1 | |
102422
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3468 |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3469 Produce this annotation sequence now: |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3470 |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3471 [ -LENGTH(==-4) CODING_ANNOTATE_COMPOSITION_MASK NCHARS(==0) METHOD ] |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3472 */ |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3473 |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3474 #define DECODE_COMPOSITION_START(c1) \ |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3475 do { \ |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3476 if (c1 == '0' \ |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3477 && ((cmp_status->state == COMPOSING_COMPONENT_CHAR \ |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3478 && cmp_status->method == COMPOSITION_WITH_ALTCHARS) \ |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3479 || (cmp_status->state == COMPOSING_COMPONENT_RULE \ |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3480 && cmp_status->method == COMPOSITION_WITH_RULE_ALTCHARS))) \ |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3481 { \ |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3482 *charbuf++ = -1; \ |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3483 *charbuf++= -1; \ |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3484 cmp_status->state = COMPOSING_CHAR; \ |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3485 cmp_status->length += 2; \ |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3486 } \ |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3487 else \ |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3488 { \ |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3489 MAYBE_FINISH_COMPOSITION (); \ |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3490 cmp_status->method = (c1 == '0' ? COMPOSITION_RELATIVE \ |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3491 : c1 == '2' ? COMPOSITION_WITH_RULE \ |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3492 : c1 == '3' ? COMPOSITION_WITH_ALTCHARS \ |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3493 : COMPOSITION_WITH_RULE_ALTCHARS); \ |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3494 cmp_status->state \ |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3495 = (c1 <= '2' ? COMPOSING_CHAR : COMPOSING_COMPONENT_CHAR); \ |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3496 ADD_COMPOSITION_DATA (charbuf, 0, 0, cmp_status->method); \ |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3497 cmp_status->length = MAX_ANNOTATION_LENGTH; \ |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3498 cmp_status->nchars = cmp_status->ncomps = 0; \ |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3499 coding->annotated = 1; \ |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3500 } \ |
26847 | 3501 } while (0) |
3502 | |
88365 | 3503 |
102422
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3504 /* Handle composition end sequence ESC 1. */ |
88365 | 3505 |
3506 #define DECODE_COMPOSITION_END() \ | |
3507 do { \ | |
102422
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3508 if (cmp_status->nchars == 0 \ |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3509 || ((cmp_status->state == COMPOSING_CHAR) \ |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3510 == (cmp_status->method == COMPOSITION_WITH_RULE))) \ |
88365 | 3511 { \ |
102422
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3512 MAYBE_FINISH_COMPOSITION (); \ |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3513 goto invalid_code; \ |
88365 | 3514 } \ |
102422
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3515 if (cmp_status->method == COMPOSITION_WITH_ALTCHARS) \ |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3516 charbuf[- cmp_status->length] -= cmp_status->ncomps + 2; \ |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3517 else if (cmp_status->method == COMPOSITION_WITH_RULE_ALTCHARS) \ |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3518 charbuf[- cmp_status->length] -= cmp_status->ncomps * 3; \ |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3519 charbuf[- cmp_status->length + 2] = cmp_status->nchars; \ |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3520 char_offset += cmp_status->nchars; \ |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3521 cmp_status->state = COMPOSING_NO; \ |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3522 } while (0) |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3523 |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3524 /* Store a composition rule RULE in charbuf, and update cmp_status. */ |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3525 |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3526 #define STORE_COMPOSITION_RULE(rule) \ |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3527 do { \ |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3528 *charbuf++ = -2; \ |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3529 *charbuf++ = rule; \ |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3530 cmp_status->length += 2; \ |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3531 cmp_status->state--; \ |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3532 } while (0) |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3533 |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3534 /* Store a composed char or a component char C in charbuf, and update |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3535 cmp_status. */ |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3536 |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3537 #define STORE_COMPOSITION_CHAR(c) \ |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3538 do { \ |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3539 *charbuf++ = (c); \ |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3540 cmp_status->length++; \ |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3541 if (cmp_status->state == COMPOSING_CHAR) \ |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3542 cmp_status->nchars++; \ |
88365 | 3543 else \ |
102422
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3544 cmp_status->ncomps++; \ |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3545 if (cmp_status->method == COMPOSITION_WITH_RULE \ |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3546 || (cmp_status->method == COMPOSITION_WITH_RULE_ALTCHARS \ |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3547 && cmp_status->state == COMPOSING_COMPONENT_CHAR)) \ |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3548 cmp_status->state++; \ |
26847 | 3549 } while (0) |
3550 | |
3551 | |
17052 | 3552 /* See the above "GENERAL NOTES on `decode_coding_XXX ()' functions". */ |
3553 | |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3554 static void |
109126
aec1143e8d85
Convert (most) functions in src to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109100
diff
changeset
|
3555 decode_coding_iso_2022 (struct coding_system *coding) |
17052 | 3556 { |
89483 | 3557 const unsigned char *src = coding->source + coding->consumed; |
3558 const unsigned char *src_end = coding->source + coding->src_bytes; | |
3559 const unsigned char *src_base; | |
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
3560 int *charbuf = coding->charbuf + coding->charbuf_used; |
103035
6e443d717c7b
(decode_coding_utf_16): Reduce charbuf_end for the
Kenichi Handa <handa@m17n.org>
parents:
102738
diff
changeset
|
3561 /* We may produce two annocations (charset and composition) in one |
6e443d717c7b
(decode_coding_utf_16): Reduce charbuf_end for the
Kenichi Handa <handa@m17n.org>
parents:
102738
diff
changeset
|
3562 loop and one more charset annocation at the end. */ |
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3563 int *charbuf_end |
103035
6e443d717c7b
(decode_coding_utf_16): Reduce charbuf_end for the
Kenichi Handa <handa@m17n.org>
parents:
102738
diff
changeset
|
3564 = coding->charbuf + coding->charbuf_size - (MAX_ANNOTATION_LENGTH * 3); |
88365 | 3565 int consumed_chars = 0, consumed_chars_base; |
3566 int multibytep = coding->src_multibyte; | |
17052 | 3567 /* Charsets invoked to graphic plane 0 and 1 respectively. */ |
88365 | 3568 int charset_id_0 = CODING_ISO_INVOKED_CHARSET (coding, 0); |
3569 int charset_id_1 = CODING_ISO_INVOKED_CHARSET (coding, 1); | |
89873
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
3570 int charset_id_2, charset_id_3; |
88365 | 3571 struct charset *charset; |
3572 int c; | |
102422
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3573 struct composition_status *cmp_status = CODING_ISO_CMP_STATUS (coding); |
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
3574 Lisp_Object attrs, charset_list; |
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3575 int char_offset = coding->produced_char; |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3576 int last_offset = char_offset; |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3577 int last_id = charset_ascii; |
102334
7baaea85626e
(decode_coding_utf_8, decode_coding_utf_16, decode_coding_emacs_mule,
Eli Zaretskii <eliz@gnu.org>
parents:
102327
diff
changeset
|
3578 int eol_crlf = |
7baaea85626e
(decode_coding_utf_8, decode_coding_utf_16, decode_coding_emacs_mule,
Eli Zaretskii <eliz@gnu.org>
parents:
102327
diff
changeset
|
3579 !inhibit_eol_conversion && EQ (CODING_ID_EOL_TYPE (coding->id), Qdos); |
92399
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
3580 int byte_after_cr = -1; |
102422
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3581 int i; |
88365 | 3582 |
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
3583 CODING_GET_INFO (coding, attrs, charset_list); |
88365 | 3584 setup_iso_safe_charsets (attrs); |
90772
b15334b4a9c3
(coding_alloc_by_making_gap): New arg offset.
Kenichi Handa <handa@m17n.org>
parents:
90737
diff
changeset
|
3585 /* Charset list may have been changed. */ |
b15334b4a9c3
(coding_alloc_by_making_gap): New arg offset.
Kenichi Handa <handa@m17n.org>
parents:
90737
diff
changeset
|
3586 charset_list = CODING_ATTR_CHARSET_LIST (attrs); |
102186
a12d39ca6870
* coding.h (struct coding_system): Make safe_charsets a pointer to
Andreas Schwab <schwab@suse.de>
parents:
102115
diff
changeset
|
3587 coding->safe_charsets = SDATA (CODING_ATTR_SAFE_CHARSETS (attrs)); |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3588 |
102422
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3589 if (cmp_status->state != COMPOSING_NO) |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3590 { |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3591 for (i = 0; i < cmp_status->length; i++) |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3592 *charbuf++ = cmp_status->carryover[i]; |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3593 coding->annotated = 1; |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3594 } |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3595 |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3596 while (1) |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3597 { |
103474
7ead50363544
(decode_coding_iso_2022): Check MSB of bytes more rigidly.
Kenichi Handa <handa@m17n.org>
parents:
103448
diff
changeset
|
3598 int c1, c2, c3; |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3599 |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3600 src_base = src; |
88365 | 3601 consumed_chars_base = consumed_chars; |
3602 | |
3603 if (charbuf >= charbuf_end) | |
100936
5c5e6d041634
(decode_coding_utf_8): Check byte_after_cr before breaking the loop.
Kenichi Handa <handa@m17n.org>
parents:
100587
diff
changeset
|
3604 { |
5c5e6d041634
(decode_coding_utf_8): Check byte_after_cr before breaking the loop.
Kenichi Handa <handa@m17n.org>
parents:
100587
diff
changeset
|
3605 if (byte_after_cr >= 0) |
5c5e6d041634
(decode_coding_utf_8): Check byte_after_cr before breaking the loop.
Kenichi Handa <handa@m17n.org>
parents:
100587
diff
changeset
|
3606 src_base--; |
5c5e6d041634
(decode_coding_utf_8): Check byte_after_cr before breaking the loop.
Kenichi Handa <handa@m17n.org>
parents:
100587
diff
changeset
|
3607 break; |
5c5e6d041634
(decode_coding_utf_8): Check byte_after_cr before breaking the loop.
Kenichi Handa <handa@m17n.org>
parents:
100587
diff
changeset
|
3608 } |
88365 | 3609 |
92399
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
3610 if (byte_after_cr >= 0) |
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
3611 c1 = byte_after_cr, byte_after_cr = -1; |
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
3612 else |
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
3613 ONE_MORE_BYTE (c1); |
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
3614 if (c1 < 0) |
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
3615 goto invalid_code; |
17052 | 3616 |
102422
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3617 if (CODING_ISO_EXTSEGMENT_LEN (coding) > 0) |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3618 { |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3619 *charbuf++ = ASCII_BYTE_P (c1) ? c1 : BYTE8_TO_CHAR (c1); |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3620 char_offset++; |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3621 CODING_ISO_EXTSEGMENT_LEN (coding)--; |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3622 continue; |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3623 } |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3624 |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3625 if (CODING_ISO_EMBEDDED_UTF_8 (coding)) |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3626 { |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3627 if (c1 == ISO_CODE_ESC) |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3628 { |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3629 if (src + 1 >= src_end) |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3630 goto no_more_source; |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3631 *charbuf++ = ISO_CODE_ESC; |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3632 char_offset++; |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3633 if (src[0] == '%' && src[1] == '@') |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3634 { |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3635 src += 2; |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3636 consumed_chars += 2; |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3637 char_offset += 2; |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3638 /* We are sure charbuf can contain two more chars. */ |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3639 *charbuf++ = '%'; |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3640 *charbuf++ = '@'; |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3641 CODING_ISO_EMBEDDED_UTF_8 (coding) = 0; |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3642 } |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3643 } |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3644 else |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3645 { |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3646 *charbuf++ = ASCII_BYTE_P (c1) ? c1 : BYTE8_TO_CHAR (c1); |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3647 char_offset++; |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3648 } |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3649 continue; |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3650 } |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3651 |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3652 if ((cmp_status->state == COMPOSING_RULE |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3653 || cmp_status->state == COMPOSING_COMPONENT_RULE) |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3654 && c1 != ISO_CODE_ESC) |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3655 { |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3656 int rule, nbytes; |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3657 |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3658 DECODE_COMPOSITION_RULE (rule, nbytes); |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3659 if (rule < 0) |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3660 goto invalid_code; |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3661 STORE_COMPOSITION_RULE (rule); |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3662 continue; |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3663 } |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3664 |
89279
1fd77c471ee6
(decode_coding_utf_8): When eol_type is Qdos, handle
Kenichi Handa <handa@m17n.org>
parents:
89227
diff
changeset
|
3665 /* We produce at most one character. */ |
17052 | 3666 switch (iso_code_class [c1]) |
3667 { | |
3668 case ISO_0x20_or_0x7F: | |
88365 | 3669 if (charset_id_0 < 0 |
3670 || ! CHARSET_ISO_CHARS_96 (CHARSET_FROM_ID (charset_id_0))) | |
88585
c7772f702227
(ONE_MORE_BYTE_NO_CHECK): Increment consumed_chars.
Kenichi Handa <handa@m17n.org>
parents:
88573
diff
changeset
|
3671 /* This is SPACE or DEL. */ |
c7772f702227
(ONE_MORE_BYTE_NO_CHECK): Increment consumed_chars.
Kenichi Handa <handa@m17n.org>
parents:
88573
diff
changeset
|
3672 charset = CHARSET_FROM_ID (charset_ascii); |
c7772f702227
(ONE_MORE_BYTE_NO_CHECK): Increment consumed_chars.
Kenichi Handa <handa@m17n.org>
parents:
88573
diff
changeset
|
3673 else |
c7772f702227
(ONE_MORE_BYTE_NO_CHECK): Increment consumed_chars.
Kenichi Handa <handa@m17n.org>
parents:
88573
diff
changeset
|
3674 charset = CHARSET_FROM_ID (charset_id_0); |
c7772f702227
(ONE_MORE_BYTE_NO_CHECK): Increment consumed_chars.
Kenichi Handa <handa@m17n.org>
parents:
88573
diff
changeset
|
3675 break; |
17052 | 3676 |
3677 case ISO_graphic_plane_0: | |
89873
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
3678 if (charset_id_0 < 0) |
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
3679 charset = CHARSET_FROM_ID (charset_ascii); |
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
3680 else |
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
3681 charset = CHARSET_FROM_ID (charset_id_0); |
17052 | 3682 break; |
3683 | |
3684 case ISO_0xA0_or_0xFF: | |
88365 | 3685 if (charset_id_1 < 0 |
3686 || ! CHARSET_ISO_CHARS_96 (CHARSET_FROM_ID (charset_id_1)) | |
3687 || CODING_ISO_FLAGS (coding) & CODING_ISO_FLAG_SEVEN_BITS) | |
3688 goto invalid_code; | |
17052 | 3689 /* This is a graphic character, we fall down ... */ |
3690 | |
3691 case ISO_graphic_plane_1: | |
88365 | 3692 if (charset_id_1 < 0) |
3693 goto invalid_code; | |
3694 charset = CHARSET_FROM_ID (charset_id_1); | |
17052 | 3695 break; |
3696 | |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3697 case ISO_control_0: |
92399
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
3698 if (eol_crlf && c1 == '\r') |
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
3699 ONE_MORE_BYTE (byte_after_cr); |
88365 | 3700 MAYBE_FINISH_COMPOSITION (); |
3701 charset = CHARSET_FROM_ID (charset_ascii); | |
17052 | 3702 break; |
3703 | |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3704 case ISO_control_1: |
88365 | 3705 goto invalid_code; |
17052 | 3706 |
3707 case ISO_shift_out: | |
88365 | 3708 if (! (CODING_ISO_FLAGS (coding) & CODING_ISO_FLAG_LOCKING_SHIFT) |
3709 || CODING_ISO_DESIGNATION (coding, 1) < 0) | |
3710 goto invalid_code; | |
3711 CODING_ISO_INVOCATION (coding, 0) = 1; | |
3712 charset_id_0 = CODING_ISO_INVOKED_CHARSET (coding, 0); | |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3713 continue; |
17052 | 3714 |
3715 case ISO_shift_in: | |
88365 | 3716 if (! (CODING_ISO_FLAGS (coding) & CODING_ISO_FLAG_LOCKING_SHIFT)) |
3717 goto invalid_code; | |
3718 CODING_ISO_INVOCATION (coding, 0) = 0; | |
3719 charset_id_0 = CODING_ISO_INVOKED_CHARSET (coding, 0); | |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3720 continue; |
17052 | 3721 |
3722 case ISO_single_shift_2_7: | |
106564
fea46c7aca79
(decode_coding_iso_2022): Ignore ISO_CODE_SS2_7 (0x19)
Kenichi Handa <handa@m17n.org>
parents:
105959
diff
changeset
|
3723 if (! (CODING_ISO_FLAGS (coding) & CODING_ISO_FLAG_SEVEN_BITS)) |
fea46c7aca79
(decode_coding_iso_2022): Ignore ISO_CODE_SS2_7 (0x19)
Kenichi Handa <handa@m17n.org>
parents:
105959
diff
changeset
|
3724 goto invalid_code; |
17052 | 3725 case ISO_single_shift_2: |
88365 | 3726 if (! (CODING_ISO_FLAGS (coding) & CODING_ISO_FLAG_SINGLE_SHIFT)) |
3727 goto invalid_code; | |
17052 | 3728 /* SS2 is handled as an escape sequence of ESC 'N' */ |
3729 c1 = 'N'; | |
3730 goto label_escape_sequence; | |
3731 | |
3732 case ISO_single_shift_3: | |
88365 | 3733 if (! (CODING_ISO_FLAGS (coding) & CODING_ISO_FLAG_SINGLE_SHIFT)) |
3734 goto invalid_code; | |
17052 | 3735 /* SS2 is handled as an escape sequence of ESC 'O' */ |
3736 c1 = 'O'; | |
3737 goto label_escape_sequence; | |
3738 | |
3739 case ISO_control_sequence_introducer: | |
3740 /* CSI is handled as an escape sequence of ESC '[' ... */ | |
3741 c1 = '['; | |
3742 goto label_escape_sequence; | |
3743 | |
3744 case ISO_escape: | |
3745 ONE_MORE_BYTE (c1); | |
3746 label_escape_sequence: | |
88365 | 3747 /* Escape sequences handled here are invocation, |
17052 | 3748 designation, direction specification, and character |
3749 composition specification. */ | |
3750 switch (c1) | |
3751 { | |
3752 case '&': /* revision of following character set */ | |
3753 ONE_MORE_BYTE (c1); | |
3754 if (!(c1 >= '@' && c1 <= '~')) | |
88365 | 3755 goto invalid_code; |
17052 | 3756 ONE_MORE_BYTE (c1); |
3757 if (c1 != ISO_CODE_ESC) | |
88365 | 3758 goto invalid_code; |
17052 | 3759 ONE_MORE_BYTE (c1); |
3760 goto label_escape_sequence; | |
3761 | |
3762 case '$': /* designation of 2-byte character set */ | |
88365 | 3763 if (! (CODING_ISO_FLAGS (coding) & CODING_ISO_FLAG_DESIGNATION)) |
3764 goto invalid_code; | |
89873
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
3765 { |
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
3766 int reg, chars96; |
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
3767 |
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
3768 ONE_MORE_BYTE (c1); |
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
3769 if (c1 >= '@' && c1 <= 'B') |
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
3770 { /* 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
|
3771 or JISX0208.1980 */ |
89873
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
3772 reg = 0, chars96 = 0; |
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
3773 } |
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
3774 else if (c1 >= 0x28 && c1 <= 0x2B) |
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
3775 { /* designation of DIMENSION2_CHARS94 character set */ |
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
3776 reg = c1 - 0x28, chars96 = 0; |
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
3777 ONE_MORE_BYTE (c1); |
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
3778 } |
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
3779 else if (c1 >= 0x2C && c1 <= 0x2F) |
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
3780 { /* designation of DIMENSION2_CHARS96 character set */ |
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
3781 reg = c1 - 0x2C, chars96 = 1; |
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
3782 ONE_MORE_BYTE (c1); |
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
3783 } |
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
3784 else |
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
3785 goto invalid_code; |
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
3786 DECODE_DESIGNATION (reg, 2, chars96, c1); |
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
3787 /* We must update these variables now. */ |
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
3788 if (reg == 0) |
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
3789 charset_id_0 = CODING_ISO_INVOKED_CHARSET (coding, 0); |
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
3790 else if (reg == 1) |
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
3791 charset_id_1 = CODING_ISO_INVOKED_CHARSET (coding, 1); |
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
3792 if (chars96 < 0) |
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
3793 goto invalid_code; |
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
3794 } |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3795 continue; |
17052 | 3796 |
3797 case 'n': /* invocation of locking-shift-2 */ | |
88365 | 3798 if (! (CODING_ISO_FLAGS (coding) & CODING_ISO_FLAG_LOCKING_SHIFT) |
3799 || CODING_ISO_DESIGNATION (coding, 2) < 0) | |
3800 goto invalid_code; | |
3801 CODING_ISO_INVOCATION (coding, 0) = 2; | |
3802 charset_id_0 = CODING_ISO_INVOKED_CHARSET (coding, 0); | |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3803 continue; |
17052 | 3804 |
3805 case 'o': /* invocation of locking-shift-3 */ | |
88365 | 3806 if (! (CODING_ISO_FLAGS (coding) & CODING_ISO_FLAG_LOCKING_SHIFT) |
3807 || CODING_ISO_DESIGNATION (coding, 3) < 0) | |
3808 goto invalid_code; | |
3809 CODING_ISO_INVOCATION (coding, 0) = 3; | |
3810 charset_id_0 = CODING_ISO_INVOKED_CHARSET (coding, 0); | |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3811 continue; |
17052 | 3812 |
3813 case 'N': /* invocation of single-shift-2 */ | |
88365 | 3814 if (! (CODING_ISO_FLAGS (coding) & CODING_ISO_FLAG_SINGLE_SHIFT) |
3815 || CODING_ISO_DESIGNATION (coding, 2) < 0) | |
3816 goto invalid_code; | |
89873
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
3817 charset_id_2 = CODING_ISO_DESIGNATION (coding, 2); |
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
3818 if (charset_id_2 < 0) |
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
3819 charset = CHARSET_FROM_ID (charset_ascii); |
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
3820 else |
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
3821 charset = CHARSET_FROM_ID (charset_id_2); |
17052 | 3822 ONE_MORE_BYTE (c1); |
30578
705b94e152b1
(decode_coding_iso2022): More strict check for handling single
Kenichi Handa <handa@m17n.org>
parents:
30487
diff
changeset
|
3823 if (c1 < 0x20 || (c1 >= 0x80 && c1 < 0xA0)) |
88365 | 3824 goto invalid_code; |
17052 | 3825 break; |
3826 | |
3827 case 'O': /* invocation of single-shift-3 */ | |
88365 | 3828 if (! (CODING_ISO_FLAGS (coding) & CODING_ISO_FLAG_SINGLE_SHIFT) |
3829 || CODING_ISO_DESIGNATION (coding, 3) < 0) | |
3830 goto invalid_code; | |
89873
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
3831 charset_id_3 = CODING_ISO_DESIGNATION (coding, 3); |
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
3832 if (charset_id_3 < 0) |
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
3833 charset = CHARSET_FROM_ID (charset_ascii); |
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
3834 else |
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
3835 charset = CHARSET_FROM_ID (charset_id_3); |
17052 | 3836 ONE_MORE_BYTE (c1); |
30578
705b94e152b1
(decode_coding_iso2022): More strict check for handling single
Kenichi Handa <handa@m17n.org>
parents:
30487
diff
changeset
|
3837 if (c1 < 0x20 || (c1 >= 0x80 && c1 < 0xA0)) |
88365 | 3838 goto invalid_code; |
17052 | 3839 break; |
3840 | |
26847 | 3841 case '0': case '2': case '3': case '4': /* start composition */ |
88365 | 3842 if (! (coding->common_flags & CODING_ANNOTATE_COMPOSITION_MASK)) |
3843 goto invalid_code; | |
102422
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3844 if (last_id != charset_ascii) |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3845 { |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3846 ADD_CHARSET_DATA (charbuf, char_offset- last_offset, last_id); |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3847 last_id = charset_ascii; |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3848 last_offset = char_offset; |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3849 } |
26847 | 3850 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
|
3851 continue; |
17052 | 3852 |
26847 | 3853 case '1': /* end composition */ |
102422
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3854 if (cmp_status->state == COMPOSING_NO) |
88365 | 3855 goto invalid_code; |
3856 DECODE_COMPOSITION_END (); | |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3857 continue; |
17052 | 3858 |
3859 case '[': /* specification of direction */ | |
105179
8143cdf4806f
(decode_coding_iso_2022): Fix operator precedence.
Andreas Schwab <schwab@linux-m68k.org>
parents:
104636
diff
changeset
|
3860 if (! (CODING_ISO_FLAGS (coding) & CODING_ISO_FLAG_DIRECTION)) |
88365 | 3861 goto invalid_code; |
17052 | 3862 /* 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
|
3863 So, `coding->mode & CODING_MODE_DIRECTION' zero means |
88365 | 3864 left-to-right, and nozero means right-to-left. */ |
17052 | 3865 ONE_MORE_BYTE (c1); |
3866 switch (c1) | |
3867 { | |
3868 case ']': /* end of the current direction */ | |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3869 coding->mode &= ~CODING_MODE_DIRECTION; |
17052 | 3870 |
3871 case '0': /* end of the current direction */ | |
3872 case '1': /* start of left-to-right direction */ | |
3873 ONE_MORE_BYTE (c1); | |
3874 if (c1 == ']') | |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3875 coding->mode &= ~CODING_MODE_DIRECTION; |
17052 | 3876 else |
88365 | 3877 goto invalid_code; |
17052 | 3878 break; |
3879 | |
3880 case '2': /* start of right-to-left direction */ | |
3881 ONE_MORE_BYTE (c1); | |
3882 if (c1 == ']') | |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3883 coding->mode |= CODING_MODE_DIRECTION; |
17052 | 3884 else |
88365 | 3885 goto invalid_code; |
17052 | 3886 break; |
3887 | |
3888 default: | |
88365 | 3889 goto invalid_code; |
17052 | 3890 } |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3891 continue; |
17052 | 3892 |
51311 | 3893 case '%': |
3894 ONE_MORE_BYTE (c1); | |
3895 if (c1 == '/') | |
3896 { | |
3897 /* CTEXT extended segment: | |
3898 ESC % / [0-4] M L --ENCODING-NAME-- \002 --BYTES-- | |
3899 We keep these bytes as is for the moment. | |
3900 They may be decoded by post-read-conversion. */ | |
3901 int dim, M, L; | |
89442
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
3902 int size; |
56191 | 3903 |
51311 | 3904 ONE_MORE_BYTE (dim); |
109710
62d9702eb261
Improve the encoding by compound-text-with-extensions.
Kenichi Handa <handa@etlken>
parents:
107507
diff
changeset
|
3905 if (dim < '0' || dim > '4') |
102422
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3906 goto invalid_code; |
51311 | 3907 ONE_MORE_BYTE (M); |
102422
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3908 if (M < 128) |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3909 goto invalid_code; |
51311 | 3910 ONE_MORE_BYTE (L); |
102422
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3911 if (L < 128) |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3912 goto invalid_code; |
51311 | 3913 size = ((M - 128) * 128) + (L - 128); |
102422
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3914 if (charbuf + 6 > charbuf_end) |
89442
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
3915 goto break_loop; |
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
3916 *charbuf++ = ISO_CODE_ESC; |
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
3917 *charbuf++ = '%'; |
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
3918 *charbuf++ = '/'; |
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
3919 *charbuf++ = dim; |
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
3920 *charbuf++ = BYTE8_TO_CHAR (M); |
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
3921 *charbuf++ = BYTE8_TO_CHAR (L); |
102422
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3922 CODING_ISO_EXTSEGMENT_LEN (coding) = size; |
51311 | 3923 } |
3924 else if (c1 == 'G') | |
3925 { | |
3926 /* XFree86 extension for embedding UTF-8 in CTEXT: | |
3927 ESC % G --UTF-8-BYTES-- ESC % @ | |
3928 We keep these bytes as is for the moment. | |
3929 They may be decoded by post-read-conversion. */ | |
102422
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3930 if (charbuf + 3 > charbuf_end) |
89442
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
3931 goto break_loop; |
102422
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3932 *charbuf++ = ISO_CODE_ESC; |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3933 *charbuf++ = '%'; |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3934 *charbuf++ = 'G'; |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3935 CODING_ISO_EMBEDDED_UTF_8 (coding) = 1; |
51311 | 3936 } |
3937 else | |
89442
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
3938 goto invalid_code; |
51311 | 3939 continue; |
89442
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
3940 break; |
51311 | 3941 |
17052 | 3942 default: |
88365 | 3943 if (! (CODING_ISO_FLAGS (coding) & CODING_ISO_FLAG_DESIGNATION)) |
3944 goto invalid_code; | |
89873
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
3945 { |
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
3946 int reg, chars96; |
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
3947 |
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
3948 if (c1 >= 0x28 && c1 <= 0x2B) |
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
3949 { /* designation of DIMENSION1_CHARS94 character set */ |
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
3950 reg = c1 - 0x28, chars96 = 0; |
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
3951 ONE_MORE_BYTE (c1); |
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
3952 } |
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
3953 else if (c1 >= 0x2C && c1 <= 0x2F) |
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
3954 { /* designation of DIMENSION1_CHARS96 character set */ |
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
3955 reg = c1 - 0x2C, chars96 = 1; |
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
3956 ONE_MORE_BYTE (c1); |
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
3957 } |
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
3958 else |
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
3959 goto invalid_code; |
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
3960 DECODE_DESIGNATION (reg, 1, chars96, c1); |
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
3961 /* We must update these variables now. */ |
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
3962 if (reg == 0) |
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
3963 charset_id_0 = CODING_ISO_INVOKED_CHARSET (coding, 0); |
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
3964 else if (reg == 1) |
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
3965 charset_id_1 = CODING_ISO_INVOKED_CHARSET (coding, 1); |
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
3966 if (chars96 < 0) |
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
3967 goto invalid_code; |
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
3968 } |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3969 continue; |
17052 | 3970 } |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3971 } |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3972 |
102422
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3973 if (cmp_status->state == COMPOSING_NO |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
3974 && charset->id != charset_ascii |
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3975 && last_id != charset->id) |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3976 { |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3977 if (last_id != charset_ascii) |
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
3978 ADD_CHARSET_DATA (charbuf, char_offset - last_offset, last_id); |
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3979 last_id = charset->id; |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3980 last_offset = char_offset; |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3981 } |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3982 |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3983 /* Now we know CHARSET and 1st position code C1 of a character. |
103474
7ead50363544
(decode_coding_iso_2022): Check MSB of bytes more rigidly.
Kenichi Handa <handa@m17n.org>
parents:
103448
diff
changeset
|
3984 Produce a decoded character while getting 2nd and 3rd |
7ead50363544
(decode_coding_iso_2022): Check MSB of bytes more rigidly.
Kenichi Handa <handa@m17n.org>
parents:
103448
diff
changeset
|
3985 position codes C2, C3 if necessary. */ |
88365 | 3986 if (CHARSET_DIMENSION (charset) > 1) |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3987 { |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3988 ONE_MORE_BYTE (c2); |
103474
7ead50363544
(decode_coding_iso_2022): Check MSB of bytes more rigidly.
Kenichi Handa <handa@m17n.org>
parents:
103448
diff
changeset
|
3989 if (c2 < 0x20 || (c2 >= 0x80 && c2 < 0xA0) |
7ead50363544
(decode_coding_iso_2022): Check MSB of bytes more rigidly.
Kenichi Handa <handa@m17n.org>
parents:
103448
diff
changeset
|
3990 || ((c1 & 0x80) != (c2 & 0x80))) |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3991 /* C2 is not in a valid range. */ |
88365 | 3992 goto invalid_code; |
103474
7ead50363544
(decode_coding_iso_2022): Check MSB of bytes more rigidly.
Kenichi Handa <handa@m17n.org>
parents:
103448
diff
changeset
|
3993 if (CHARSET_DIMENSION (charset) == 2) |
7ead50363544
(decode_coding_iso_2022): Check MSB of bytes more rigidly.
Kenichi Handa <handa@m17n.org>
parents:
103448
diff
changeset
|
3994 c1 = (c1 << 8) | c2; |
7ead50363544
(decode_coding_iso_2022): Check MSB of bytes more rigidly.
Kenichi Handa <handa@m17n.org>
parents:
103448
diff
changeset
|
3995 else |
88365 | 3996 { |
103474
7ead50363544
(decode_coding_iso_2022): Check MSB of bytes more rigidly.
Kenichi Handa <handa@m17n.org>
parents:
103448
diff
changeset
|
3997 ONE_MORE_BYTE (c3); |
7ead50363544
(decode_coding_iso_2022): Check MSB of bytes more rigidly.
Kenichi Handa <handa@m17n.org>
parents:
103448
diff
changeset
|
3998 if (c3 < 0x20 || (c3 >= 0x80 && c3 < 0xA0) |
7ead50363544
(decode_coding_iso_2022): Check MSB of bytes more rigidly.
Kenichi Handa <handa@m17n.org>
parents:
103448
diff
changeset
|
3999 || ((c1 & 0x80) != (c3 & 0x80))) |
7ead50363544
(decode_coding_iso_2022): Check MSB of bytes more rigidly.
Kenichi Handa <handa@m17n.org>
parents:
103448
diff
changeset
|
4000 /* C3 is not in a valid range. */ |
88365 | 4001 goto invalid_code; |
103474
7ead50363544
(decode_coding_iso_2022): Check MSB of bytes more rigidly.
Kenichi Handa <handa@m17n.org>
parents:
103448
diff
changeset
|
4002 c1 = (c1 << 16) | (c2 << 8) | c2; |
88365 | 4003 } |
17052 | 4004 } |
103474
7ead50363544
(decode_coding_iso_2022): Check MSB of bytes more rigidly.
Kenichi Handa <handa@m17n.org>
parents:
103448
diff
changeset
|
4005 c1 &= 0x7F7F7F; |
88365 | 4006 CODING_DECODE_CHAR (coding, src, src_base, src_end, charset, c1, c); |
4007 if (c < 0) | |
4008 { | |
4009 MAYBE_FINISH_COMPOSITION (); | |
4010 for (; src_base < src; src_base++, char_offset++) | |
4011 { | |
4012 if (ASCII_BYTE_P (*src_base)) | |
4013 *charbuf++ = *src_base; | |
4014 else | |
4015 *charbuf++ = BYTE8_TO_CHAR (*src_base); | |
4016 } | |
4017 } | |
102422
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
4018 else if (cmp_status->state == COMPOSING_NO) |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
4019 { |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
4020 *charbuf++ = c; |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
4021 char_offset++; |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
4022 } |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
4023 else if ((cmp_status->state == COMPOSING_CHAR |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
4024 ? cmp_status->nchars |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
4025 : cmp_status->ncomps) |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
4026 >= MAX_COMPOSITION_COMPONENTS) |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
4027 { |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
4028 /* Too long composition. */ |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
4029 MAYBE_FINISH_COMPOSITION (); |
88365 | 4030 *charbuf++ = c; |
4031 char_offset++; | |
4032 } | |
4033 else | |
102422
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
4034 STORE_COMPOSITION_CHAR (c); |
17052 | 4035 continue; |
4036 | |
88365 | 4037 invalid_code: |
4038 MAYBE_FINISH_COMPOSITION (); | |
4039 src = src_base; | |
4040 consumed_chars = consumed_chars_base; | |
4041 ONE_MORE_BYTE (c); | |
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
4042 *charbuf++ = c < 0 ? -c : ASCII_BYTE_P (c) ? c : BYTE8_TO_CHAR (c); |
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
4043 char_offset++; |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4044 coding->errors++; |
89442
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
4045 continue; |
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
4046 |
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
4047 break_loop: |
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
4048 break; |
88365 | 4049 } |
4050 | |
4051 no_more_source: | |
102422
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
4052 if (cmp_status->state != COMPOSING_NO) |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
4053 { |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
4054 if (coding->mode & CODING_MODE_LAST_BLOCK) |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
4055 MAYBE_FINISH_COMPOSITION (); |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
4056 else |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
4057 { |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
4058 charbuf -= cmp_status->length; |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
4059 for (i = 0; i < cmp_status->length; i++) |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
4060 cmp_status->carryover[i] = charbuf[i]; |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
4061 } |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
4062 } |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
4063 else if (last_id != charset_ascii) |
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
4064 ADD_CHARSET_DATA (charbuf, char_offset - last_offset, last_id); |
88365 | 4065 coding->consumed_char += consumed_chars_base; |
4066 coding->consumed = src_base - coding->source; | |
4067 coding->charbuf_used = charbuf - coding->charbuf; | |
17052 | 4068 } |
4069 | |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4070 |
18766 | 4071 /* ISO2022 encoding stuff. */ |
17052 | 4072 |
4073 /* | |
18766 | 4074 It is not enough to say just "ISO2022" on encoding, we have to |
88365 | 4075 specify more details. In Emacs, each coding system of ISO2022 |
17052 | 4076 variant has the following specifications: |
88365 | 4077 1. Initial designation to G0 thru G3. |
17052 | 4078 2. Allows short-form designation? |
4079 3. ASCII should be designated to G0 before control characters? | |
4080 4. ASCII should be designated to G0 at end of line? | |
4081 5. 7-bit environment or 8-bit environment? | |
4082 6. Use locking-shift? | |
4083 7. Use Single-shift? | |
4084 And the following two are only for Japanese: | |
4085 8. Use ASCII in place of JIS0201-1976-Roman? | |
4086 9. Use JISX0208-1983 in place of JISX0208-1978? | |
88365 | 4087 These specifications are encoded in CODING_ISO_FLAGS (coding) as flag bits |
4088 defined by macros CODING_ISO_FLAG_XXX. See `coding.h' for more | |
18766 | 4089 details. |
17052 | 4090 */ |
4091 | |
4092 /* 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
|
4093 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
|
4094 '@', '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
|
4095 designation sequence of short-form. */ |
17052 | 4096 |
4097 #define ENCODE_DESIGNATION(charset, reg, coding) \ | |
4098 do { \ | |
88365 | 4099 unsigned char final_char = CHARSET_ISO_FINAL (charset); \ |
109717
8949aad5e992
Use const char* instead of char*.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109573
diff
changeset
|
4100 const char *intermediate_char_94 = "()*+"; \ |
8949aad5e992
Use const char* instead of char*.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109573
diff
changeset
|
4101 const char *intermediate_char_96 = ",-./"; \ |
88365 | 4102 int revision = -1; \ |
4103 int c; \ | |
4104 \ | |
4105 if (CODING_ISO_FLAGS (coding) & CODING_ISO_FLAG_REVISION) \ | |
88856 | 4106 revision = CHARSET_ISO_REVISION (charset); \ |
88365 | 4107 \ |
4108 if (revision >= 0) \ | |
20150
402b6e5f4b58
(encode_designation_at_bol): Fix bug of finding graphic
Kenichi Handa <handa@m17n.org>
parents:
20105
diff
changeset
|
4109 { \ |
88365 | 4110 EMIT_TWO_ASCII_BYTES (ISO_CODE_ESC, '&'); \ |
4111 EMIT_ONE_BYTE ('@' + revision); \ | |
17052 | 4112 } \ |
88365 | 4113 EMIT_ONE_ASCII_BYTE (ISO_CODE_ESC); \ |
17052 | 4114 if (CHARSET_DIMENSION (charset) == 1) \ |
4115 { \ | |
88365 | 4116 if (! CHARSET_ISO_CHARS_96 (charset)) \ |
4117 c = intermediate_char_94[reg]; \ | |
17052 | 4118 else \ |
88365 | 4119 c = intermediate_char_96[reg]; \ |
4120 EMIT_ONE_ASCII_BYTE (c); \ | |
17052 | 4121 } \ |
4122 else \ | |
4123 { \ | |
88365 | 4124 EMIT_ONE_ASCII_BYTE ('$'); \ |
4125 if (! CHARSET_ISO_CHARS_96 (charset)) \ | |
17052 | 4126 { \ |
88365 | 4127 if (CODING_ISO_FLAGS (coding) & CODING_ISO_FLAG_LONG_FORM \ |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4128 || reg != 0 \ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4129 || final_char < '@' || final_char > 'B') \ |
88365 | 4130 EMIT_ONE_ASCII_BYTE (intermediate_char_94[reg]); \ |
17052 | 4131 } \ |
4132 else \ | |
88365 | 4133 EMIT_ONE_ASCII_BYTE (intermediate_char_96[reg]); \ |
17052 | 4134 } \ |
88365 | 4135 EMIT_ONE_ASCII_BYTE (final_char); \ |
4136 \ | |
4137 CODING_ISO_DESIGNATION (coding, reg) = CHARSET_ID (charset); \ | |
17052 | 4138 } while (0) |
4139 | |
88365 | 4140 |
17052 | 4141 /* The following two macros produce codes (control character or escape |
4142 sequence) for ISO2022 single-shift functions (single-shift-2 and | |
4143 single-shift-3). */ | |
4144 | |
88365 | 4145 #define ENCODE_SINGLE_SHIFT_2 \ |
4146 do { \ | |
4147 if (CODING_ISO_FLAGS (coding) & CODING_ISO_FLAG_SEVEN_BITS) \ | |
4148 EMIT_TWO_ASCII_BYTES (ISO_CODE_ESC, 'N'); \ | |
4149 else \ | |
4150 EMIT_ONE_BYTE (ISO_CODE_SS2); \ | |
4151 CODING_ISO_SINGLE_SHIFTING (coding) = 1; \ | |
17052 | 4152 } while (0) |
4153 | |
88365 | 4154 |
4155 #define ENCODE_SINGLE_SHIFT_3 \ | |
4156 do { \ | |
4157 if (CODING_ISO_FLAGS (coding) & CODING_ISO_FLAG_SEVEN_BITS) \ | |
4158 EMIT_TWO_ASCII_BYTES (ISO_CODE_ESC, 'O'); \ | |
4159 else \ | |
4160 EMIT_ONE_BYTE (ISO_CODE_SS3); \ | |
4161 CODING_ISO_SINGLE_SHIFTING (coding) = 1; \ | |
17052 | 4162 } while (0) |
4163 | |
88365 | 4164 |
17052 | 4165 /* The following four macros produce codes (control character or |
4166 escape sequence) for ISO2022 locking-shift functions (shift-in, | |
4167 shift-out, locking-shift-2, and locking-shift-3). */ | |
4168 | |
88365 | 4169 #define ENCODE_SHIFT_IN \ |
4170 do { \ | |
4171 EMIT_ONE_ASCII_BYTE (ISO_CODE_SI); \ | |
4172 CODING_ISO_INVOCATION (coding, 0) = 0; \ | |
17052 | 4173 } while (0) |
4174 | |
88365 | 4175 |
4176 #define ENCODE_SHIFT_OUT \ | |
4177 do { \ | |
4178 EMIT_ONE_ASCII_BYTE (ISO_CODE_SO); \ | |
4179 CODING_ISO_INVOCATION (coding, 0) = 1; \ | |
17052 | 4180 } while (0) |
4181 | |
88365 | 4182 |
4183 #define ENCODE_LOCKING_SHIFT_2 \ | |
4184 do { \ | |
4185 EMIT_TWO_ASCII_BYTES (ISO_CODE_ESC, 'n'); \ | |
4186 CODING_ISO_INVOCATION (coding, 0) = 2; \ | |
17052 | 4187 } while (0) |
4188 | |
88365 | 4189 |
4190 #define ENCODE_LOCKING_SHIFT_3 \ | |
4191 do { \ | |
4192 EMIT_TWO_ASCII_BYTES (ISO_CODE_ESC, 'n'); \ | |
4193 CODING_ISO_INVOCATION (coding, 0) = 3; \ | |
17052 | 4194 } while (0) |
4195 | |
88365 | 4196 |
18766 | 4197 /* Produce codes for a DIMENSION1 character whose character set is |
4198 CHARSET and whose position-code is C1. Designation and invocation | |
17052 | 4199 sequences are also produced in advance if necessary. */ |
4200 | |
19285
af3d00fde172
(Fset_terminal_coding_system_internal): Set
Kenichi Handa <handa@m17n.org>
parents:
19280
diff
changeset
|
4201 #define ENCODE_ISO_CHARACTER_DIMENSION1(charset, c1) \ |
af3d00fde172
(Fset_terminal_coding_system_internal): Set
Kenichi Handa <handa@m17n.org>
parents:
19280
diff
changeset
|
4202 do { \ |
88365 | 4203 int id = CHARSET_ID (charset); \ |
88681
2cdfbffa8a0d
(CODING_ISO_FLAG_USE_ROMAN): New macro
Kenichi Handa <handa@m17n.org>
parents:
88669
diff
changeset
|
4204 \ |
2cdfbffa8a0d
(CODING_ISO_FLAG_USE_ROMAN): New macro
Kenichi Handa <handa@m17n.org>
parents:
88669
diff
changeset
|
4205 if ((CODING_ISO_FLAGS (coding) & CODING_ISO_FLAG_USE_ROMAN) \ |
2cdfbffa8a0d
(CODING_ISO_FLAG_USE_ROMAN): New macro
Kenichi Handa <handa@m17n.org>
parents:
88669
diff
changeset
|
4206 && id == charset_ascii) \ |
19285
af3d00fde172
(Fset_terminal_coding_system_internal): Set
Kenichi Handa <handa@m17n.org>
parents:
19280
diff
changeset
|
4207 { \ |
88681
2cdfbffa8a0d
(CODING_ISO_FLAG_USE_ROMAN): New macro
Kenichi Handa <handa@m17n.org>
parents:
88669
diff
changeset
|
4208 id = charset_jisx0201_roman; \ |
2cdfbffa8a0d
(CODING_ISO_FLAG_USE_ROMAN): New macro
Kenichi Handa <handa@m17n.org>
parents:
88669
diff
changeset
|
4209 charset = CHARSET_FROM_ID (id); \ |
19285
af3d00fde172
(Fset_terminal_coding_system_internal): Set
Kenichi Handa <handa@m17n.org>
parents:
19280
diff
changeset
|
4210 } \ |
88681
2cdfbffa8a0d
(CODING_ISO_FLAG_USE_ROMAN): New macro
Kenichi Handa <handa@m17n.org>
parents:
88669
diff
changeset
|
4211 \ |
88365 | 4212 if (CODING_ISO_SINGLE_SHIFTING (coding)) \ |
19285
af3d00fde172
(Fset_terminal_coding_system_internal): Set
Kenichi Handa <handa@m17n.org>
parents:
19280
diff
changeset
|
4213 { \ |
88365 | 4214 if (CODING_ISO_FLAGS (coding) & CODING_ISO_FLAG_SEVEN_BITS) \ |
4215 EMIT_ONE_ASCII_BYTE (c1 & 0x7F); \ | |
19285
af3d00fde172
(Fset_terminal_coding_system_internal): Set
Kenichi Handa <handa@m17n.org>
parents:
19280
diff
changeset
|
4216 else \ |
88365 | 4217 EMIT_ONE_BYTE (c1 | 0x80); \ |
4218 CODING_ISO_SINGLE_SHIFTING (coding) = 0; \ | |
19285
af3d00fde172
(Fset_terminal_coding_system_internal): Set
Kenichi Handa <handa@m17n.org>
parents:
19280
diff
changeset
|
4219 break; \ |
af3d00fde172
(Fset_terminal_coding_system_internal): Set
Kenichi Handa <handa@m17n.org>
parents:
19280
diff
changeset
|
4220 } \ |
88365 | 4221 else if (id == CODING_ISO_INVOKED_CHARSET (coding, 0)) \ |
19285
af3d00fde172
(Fset_terminal_coding_system_internal): Set
Kenichi Handa <handa@m17n.org>
parents:
19280
diff
changeset
|
4222 { \ |
88365 | 4223 EMIT_ONE_ASCII_BYTE (c1 & 0x7F); \ |
19285
af3d00fde172
(Fset_terminal_coding_system_internal): Set
Kenichi Handa <handa@m17n.org>
parents:
19280
diff
changeset
|
4224 break; \ |
af3d00fde172
(Fset_terminal_coding_system_internal): Set
Kenichi Handa <handa@m17n.org>
parents:
19280
diff
changeset
|
4225 } \ |
88365 | 4226 else if (id == CODING_ISO_INVOKED_CHARSET (coding, 1)) \ |
19285
af3d00fde172
(Fset_terminal_coding_system_internal): Set
Kenichi Handa <handa@m17n.org>
parents:
19280
diff
changeset
|
4227 { \ |
88365 | 4228 EMIT_ONE_BYTE (c1 | 0x80); \ |
19285
af3d00fde172
(Fset_terminal_coding_system_internal): Set
Kenichi Handa <handa@m17n.org>
parents:
19280
diff
changeset
|
4229 break; \ |
af3d00fde172
(Fset_terminal_coding_system_internal): Set
Kenichi Handa <handa@m17n.org>
parents:
19280
diff
changeset
|
4230 } \ |
af3d00fde172
(Fset_terminal_coding_system_internal): Set
Kenichi Handa <handa@m17n.org>
parents:
19280
diff
changeset
|
4231 else \ |
af3d00fde172
(Fset_terminal_coding_system_internal): Set
Kenichi Handa <handa@m17n.org>
parents:
19280
diff
changeset
|
4232 /* 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
|
4233 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
|
4234 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
|
4235 character. */ \ |
88365 | 4236 dst = encode_invocation_designation (charset, coding, dst, \ |
4237 &produced_chars); \ | |
17052 | 4238 } while (1) |
4239 | |
88365 | 4240 |
4241 /* Produce codes for a DIMENSION2 character whose character set is | |
4242 CHARSET and whose position-codes are C1 and C2. Designation and | |
4243 invocation codes are also produced in advance if necessary. */ | |
4244 | |
4245 #define ENCODE_ISO_CHARACTER_DIMENSION2(charset, c1, c2) \ | |
24506
219c99669e4b
(ENCODE_ISO_CHARACTER): Check validity of CHARSET. If
Kenichi Handa <handa@m17n.org>
parents:
24460
diff
changeset
|
4246 do { \ |
88365 | 4247 int id = CHARSET_ID (charset); \ |
88681
2cdfbffa8a0d
(CODING_ISO_FLAG_USE_ROMAN): New macro
Kenichi Handa <handa@m17n.org>
parents:
88669
diff
changeset
|
4248 \ |
2cdfbffa8a0d
(CODING_ISO_FLAG_USE_ROMAN): New macro
Kenichi Handa <handa@m17n.org>
parents:
88669
diff
changeset
|
4249 if ((CODING_ISO_FLAGS (coding) & CODING_ISO_FLAG_USE_OLDJIS) \ |
2cdfbffa8a0d
(CODING_ISO_FLAG_USE_ROMAN): New macro
Kenichi Handa <handa@m17n.org>
parents:
88669
diff
changeset
|
4250 && id == charset_jisx0208) \ |
2cdfbffa8a0d
(CODING_ISO_FLAG_USE_ROMAN): New macro
Kenichi Handa <handa@m17n.org>
parents:
88669
diff
changeset
|
4251 { \ |
2cdfbffa8a0d
(CODING_ISO_FLAG_USE_ROMAN): New macro
Kenichi Handa <handa@m17n.org>
parents:
88669
diff
changeset
|
4252 id = charset_jisx0208_1978; \ |
2cdfbffa8a0d
(CODING_ISO_FLAG_USE_ROMAN): New macro
Kenichi Handa <handa@m17n.org>
parents:
88669
diff
changeset
|
4253 charset = CHARSET_FROM_ID (id); \ |
2cdfbffa8a0d
(CODING_ISO_FLAG_USE_ROMAN): New macro
Kenichi Handa <handa@m17n.org>
parents:
88669
diff
changeset
|
4254 } \ |
2cdfbffa8a0d
(CODING_ISO_FLAG_USE_ROMAN): New macro
Kenichi Handa <handa@m17n.org>
parents:
88669
diff
changeset
|
4255 \ |
88365 | 4256 if (CODING_ISO_SINGLE_SHIFTING (coding)) \ |
4257 { \ | |
4258 if (CODING_ISO_FLAGS (coding) & CODING_ISO_FLAG_SEVEN_BITS) \ | |
4259 EMIT_TWO_ASCII_BYTES ((c1) & 0x7F, (c2) & 0x7F); \ | |
4260 else \ | |
4261 EMIT_TWO_BYTES ((c1) | 0x80, (c2) | 0x80); \ | |
4262 CODING_ISO_SINGLE_SHIFTING (coding) = 0; \ | |
4263 break; \ | |
4264 } \ | |
4265 else if (id == CODING_ISO_INVOKED_CHARSET (coding, 0)) \ | |
4266 { \ | |
4267 EMIT_TWO_ASCII_BYTES ((c1) & 0x7F, (c2) & 0x7F); \ | |
4268 break; \ | |
4269 } \ | |
4270 else if (id == CODING_ISO_INVOKED_CHARSET (coding, 1)) \ | |
4271 { \ | |
4272 EMIT_TWO_BYTES ((c1) | 0x80, (c2) | 0x80); \ | |
4273 break; \ | |
4274 } \ | |
4275 else \ | |
4276 /* Since CHARSET is not yet invoked to any graphic planes, we \ | |
4277 must invoke it, or, at first, designate it to some graphic \ | |
4278 register. Then repeat the loop to actually produce the \ | |
4279 character. */ \ | |
4280 dst = encode_invocation_designation (charset, coding, dst, \ | |
4281 &produced_chars); \ | |
4282 } while (1) | |
4283 | |
4284 | |
4285 #define ENCODE_ISO_CHARACTER(charset, c) \ | |
4286 do { \ | |
109158
6175ebc3b6ce
* coding.c: Use SPECPDL_INDEX, DOS_NT.
Juanma Barranquero <lekktu@gmail.com>
parents:
109126
diff
changeset
|
4287 int code = ENCODE_CHAR ((charset), (c)); \ |
88365 | 4288 \ |
4289 if (CHARSET_DIMENSION (charset) == 1) \ | |
4290 ENCODE_ISO_CHARACTER_DIMENSION1 ((charset), code); \ | |
4291 else \ | |
4292 ENCODE_ISO_CHARACTER_DIMENSION2 ((charset), code >> 8, code & 0xFF); \ | |
22119
592bb8b9bcfd
Change terms unify/unification to
Kenichi Handa <handa@m17n.org>
parents:
22020
diff
changeset
|
4293 } while (0) |
17725
92f042f73be2
(Valternate_charset_table): The valiable deleted.
Kenichi Handa <handa@m17n.org>
parents:
17717
diff
changeset
|
4294 |
30487
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
4295 |
17052 | 4296 /* Produce designation and invocation codes at a place pointed by DST |
88365 | 4297 to use CHARSET. The element `spec.iso_2022' of *CODING is updated. |
17052 | 4298 Return new DST. */ |
4299 | |
4300 unsigned char * | |
109159
3e9fdeb960d1
* coding.c, sysdep.c: Convert some more functions to standard C.
Juanma Barranquero <lekktu@gmail.com>
parents:
109158
diff
changeset
|
4301 encode_invocation_designation (struct charset *charset, |
3e9fdeb960d1
* coding.c, sysdep.c: Convert some more functions to standard C.
Juanma Barranquero <lekktu@gmail.com>
parents:
109158
diff
changeset
|
4302 struct coding_system *coding, |
3e9fdeb960d1
* coding.c, sysdep.c: Convert some more functions to standard C.
Juanma Barranquero <lekktu@gmail.com>
parents:
109158
diff
changeset
|
4303 unsigned char *dst, int *p_nchars) |
17052 | 4304 { |
88365 | 4305 int multibytep = coding->dst_multibyte; |
4306 int produced_chars = *p_nchars; | |
17052 | 4307 int reg; /* graphic register number */ |
88365 | 4308 int id = CHARSET_ID (charset); |
17052 | 4309 |
4310 /* At first, check designations. */ | |
4311 for (reg = 0; reg < 4; reg++) | |
88365 | 4312 if (id == CODING_ISO_DESIGNATION (coding, reg)) |
17052 | 4313 break; |
4314 | |
4315 if (reg >= 4) | |
4316 { | |
4317 /* CHARSET is not yet designated to any graphic registers. */ | |
4318 /* At first check the requested designation. */ | |
88365 | 4319 reg = CODING_ISO_REQUEST (coding, id); |
4320 if (reg < 0) | |
18002
a14261786239
(encode_invocation_designation): Use macro
Kenichi Handa <handa@m17n.org>
parents:
17835
diff
changeset
|
4321 /* Since CHARSET requests no special designation, designate it |
a14261786239
(encode_invocation_designation): Use macro
Kenichi Handa <handa@m17n.org>
parents:
17835
diff
changeset
|
4322 to graphic register 0. */ |
17052 | 4323 reg = 0; |
4324 | |
4325 ENCODE_DESIGNATION (charset, reg, coding); | |
4326 } | |
4327 | |
88365 | 4328 if (CODING_ISO_INVOCATION (coding, 0) != reg |
4329 && CODING_ISO_INVOCATION (coding, 1) != reg) | |
17052 | 4330 { |
4331 /* Since the graphic register REG is not invoked to any graphic | |
4332 planes, invoke it to graphic plane 0. */ | |
4333 switch (reg) | |
4334 { | |
4335 case 0: /* graphic register 0 */ | |
4336 ENCODE_SHIFT_IN; | |
4337 break; | |
4338 | |
4339 case 1: /* graphic register 1 */ | |
4340 ENCODE_SHIFT_OUT; | |
4341 break; | |
4342 | |
4343 case 2: /* graphic register 2 */ | |
88365 | 4344 if (CODING_ISO_FLAGS (coding) & CODING_ISO_FLAG_SINGLE_SHIFT) |
17052 | 4345 ENCODE_SINGLE_SHIFT_2; |
4346 else | |
4347 ENCODE_LOCKING_SHIFT_2; | |
4348 break; | |
4349 | |
4350 case 3: /* graphic register 3 */ | |
88365 | 4351 if (CODING_ISO_FLAGS (coding) & CODING_ISO_FLAG_SINGLE_SHIFT) |
17052 | 4352 ENCODE_SINGLE_SHIFT_3; |
4353 else | |
4354 ENCODE_LOCKING_SHIFT_3; | |
4355 break; | |
4356 } | |
4357 } | |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4358 |
88365 | 4359 *p_nchars = produced_chars; |
17052 | 4360 return dst; |
4361 } | |
4362 | |
4363 /* The following three macros produce codes for indicating direction | |
4364 of text. */ | |
88365 | 4365 #define ENCODE_CONTROL_SEQUENCE_INTRODUCER \ |
4366 do { \ | |
4367 if (CODING_ISO_FLAGS (coding) == CODING_ISO_FLAG_SEVEN_BITS) \ | |
4368 EMIT_TWO_ASCII_BYTES (ISO_CODE_ESC, '['); \ | |
4369 else \ | |
4370 EMIT_ONE_BYTE (ISO_CODE_CSI); \ | |
17052 | 4371 } while (0) |
4372 | |
88365 | 4373 |
4374 #define ENCODE_DIRECTION_R2L() \ | |
4375 do { \ | |
4376 ENCODE_CONTROL_SEQUENCE_INTRODUCER (dst); \ | |
4377 EMIT_TWO_ASCII_BYTES ('2', ']'); \ | |
4378 } while (0) | |
4379 | |
4380 | |
4381 #define ENCODE_DIRECTION_L2R() \ | |
4382 do { \ | |
4383 ENCODE_CONTROL_SEQUENCE_INTRODUCER (dst); \ | |
4384 EMIT_TWO_ASCII_BYTES ('0', ']'); \ | |
4385 } while (0) | |
4386 | |
17052 | 4387 |
4388 /* Produce codes for designation and invocation to reset the graphic | |
4389 planes and registers to initial state. */ | |
88365 | 4390 #define ENCODE_RESET_PLANE_AND_REGISTER() \ |
4391 do { \ | |
4392 int reg; \ | |
4393 struct charset *charset; \ | |
4394 \ | |
4395 if (CODING_ISO_INVOCATION (coding, 0) != 0) \ | |
4396 ENCODE_SHIFT_IN; \ | |
4397 for (reg = 0; reg < 4; reg++) \ | |
4398 if (CODING_ISO_INITIAL (coding, reg) >= 0 \ | |
4399 && (CODING_ISO_DESIGNATION (coding, reg) \ | |
4400 != CODING_ISO_INITIAL (coding, reg))) \ | |
4401 { \ | |
4402 charset = CHARSET_FROM_ID (CODING_ISO_INITIAL (coding, reg)); \ | |
4403 ENCODE_DESIGNATION (charset, reg, coding); \ | |
4404 } \ | |
17052 | 4405 } while (0) |
4406 | |
88365 | 4407 |
17725
92f042f73be2
(Valternate_charset_table): The valiable deleted.
Kenichi Handa <handa@m17n.org>
parents:
17717
diff
changeset
|
4408 /* 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
|
4409 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
|
4410 |
92f042f73be2
(Valternate_charset_table): The valiable deleted.
Kenichi Handa <handa@m17n.org>
parents:
17717
diff
changeset
|
4411 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
|
4412 find all the necessary designations. */ |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4413 |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4414 static unsigned char * |
109159
3e9fdeb960d1
* coding.c, sysdep.c: Convert some more functions to standard C.
Juanma Barranquero <lekktu@gmail.com>
parents:
109158
diff
changeset
|
4415 encode_designation_at_bol (struct coding_system *coding, int *charbuf, |
3e9fdeb960d1
* coding.c, sysdep.c: Convert some more functions to standard C.
Juanma Barranquero <lekktu@gmail.com>
parents:
109158
diff
changeset
|
4416 int *charbuf_end, unsigned char *dst) |
17119
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
4417 { |
88365 | 4418 struct charset *charset; |
17725
92f042f73be2
(Valternate_charset_table): The valiable deleted.
Kenichi Handa <handa@m17n.org>
parents:
17717
diff
changeset
|
4419 /* 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
|
4420 int r[4]; |
88365 | 4421 int c, found = 0, reg; |
4422 int produced_chars = 0; | |
4423 int multibytep = coding->dst_multibyte; | |
4424 Lisp_Object attrs; | |
4425 Lisp_Object charset_list; | |
4426 | |
4427 attrs = CODING_ID_ATTRS (coding->id); | |
4428 charset_list = CODING_ATTR_CHARSET_LIST (attrs); | |
4429 if (EQ (charset_list, Qiso_2022)) | |
4430 charset_list = Viso_2022_charset_list; | |
17725
92f042f73be2
(Valternate_charset_table): The valiable deleted.
Kenichi Handa <handa@m17n.org>
parents:
17717
diff
changeset
|
4431 |
92f042f73be2
(Valternate_charset_table): The valiable deleted.
Kenichi Handa <handa@m17n.org>
parents:
17717
diff
changeset
|
4432 for (reg = 0; reg < 4; reg++) |
92f042f73be2
(Valternate_charset_table): The valiable deleted.
Kenichi Handa <handa@m17n.org>
parents:
17717
diff
changeset
|
4433 r[reg] = -1; |
92f042f73be2
(Valternate_charset_table): The valiable deleted.
Kenichi Handa <handa@m17n.org>
parents:
17717
diff
changeset
|
4434 |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4435 while (found < 4) |
17119
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
4436 { |
88365 | 4437 int id; |
4438 | |
4439 c = *charbuf++; | |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4440 if (c == '\n') |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4441 break; |
88365 | 4442 charset = char_charset (c, charset_list, NULL); |
4443 id = CHARSET_ID (charset); | |
4444 reg = CODING_ISO_REQUEST (coding, id); | |
4445 if (reg >= 0 && r[reg] < 0) | |
17725
92f042f73be2
(Valternate_charset_table): The valiable deleted.
Kenichi Handa <handa@m17n.org>
parents:
17717
diff
changeset
|
4446 { |
92f042f73be2
(Valternate_charset_table): The valiable deleted.
Kenichi Handa <handa@m17n.org>
parents:
17717
diff
changeset
|
4447 found++; |
88365 | 4448 r[reg] = id; |
17119
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
4449 } |
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
4450 } |
17725
92f042f73be2
(Valternate_charset_table): The valiable deleted.
Kenichi Handa <handa@m17n.org>
parents:
17717
diff
changeset
|
4451 |
92f042f73be2
(Valternate_charset_table): The valiable deleted.
Kenichi Handa <handa@m17n.org>
parents:
17717
diff
changeset
|
4452 if (found) |
92f042f73be2
(Valternate_charset_table): The valiable deleted.
Kenichi Handa <handa@m17n.org>
parents:
17717
diff
changeset
|
4453 { |
92f042f73be2
(Valternate_charset_table): The valiable deleted.
Kenichi Handa <handa@m17n.org>
parents:
17717
diff
changeset
|
4454 for (reg = 0; reg < 4; reg++) |
92f042f73be2
(Valternate_charset_table): The valiable deleted.
Kenichi Handa <handa@m17n.org>
parents:
17717
diff
changeset
|
4455 if (r[reg] >= 0 |
88365 | 4456 && CODING_ISO_DESIGNATION (coding, reg) != r[reg]) |
4457 ENCODE_DESIGNATION (CHARSET_FROM_ID (r[reg]), reg, coding); | |
17725
92f042f73be2
(Valternate_charset_table): The valiable deleted.
Kenichi Handa <handa@m17n.org>
parents:
17717
diff
changeset
|
4458 } |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4459 |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4460 return dst; |
17119
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
4461 } |
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
4462 |
17052 | 4463 /* See the above "GENERAL NOTES on `encode_coding_XXX ()' functions". */ |
4464 | |
88365 | 4465 static int |
109126
aec1143e8d85
Convert (most) functions in src to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109100
diff
changeset
|
4466 encode_coding_iso_2022 (struct coding_system *coding) |
17052 | 4467 { |
88365 | 4468 int multibytep = coding->dst_multibyte; |
4469 int *charbuf = coding->charbuf; | |
4470 int *charbuf_end = charbuf + coding->charbuf_used; | |
4471 unsigned char *dst = coding->destination + coding->produced; | |
4472 unsigned char *dst_end = coding->destination + coding->dst_bytes; | |
4473 int safe_room = 16; | |
4474 int bol_designation | |
4475 = (CODING_ISO_FLAGS (coding) & CODING_ISO_FLAG_DESIGNATE_AT_BOL | |
4476 && CODING_ISO_BOL (coding)); | |
4477 int produced_chars = 0; | |
4478 Lisp_Object attrs, eol_type, charset_list; | |
4479 int ascii_compatible; | |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4480 int c; |
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
4481 int preferred_charset_id = -1; |
88365 | 4482 |
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4483 CODING_GET_INFO (coding, attrs, charset_list); |
102334
7baaea85626e
(decode_coding_utf_8, decode_coding_utf_16, decode_coding_emacs_mule,
Eli Zaretskii <eliz@gnu.org>
parents:
102327
diff
changeset
|
4484 eol_type = inhibit_eol_conversion ? Qunix : CODING_ID_EOL_TYPE (coding->id); |
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4485 if (VECTORP (eol_type)) |
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4486 eol_type = Qunix; |
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4487 |
88497
d2b9e0d4c2f6
(Fdecode_sjis_char): Fix typo (0x7F->0xFF). Fix the
Kenichi Handa <handa@m17n.org>
parents:
88485
diff
changeset
|
4488 setup_iso_safe_charsets (attrs); |
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
4489 /* Charset list may have been changed. */ |
90772
b15334b4a9c3
(coding_alloc_by_making_gap): New arg offset.
Kenichi Handa <handa@m17n.org>
parents:
90737
diff
changeset
|
4490 charset_list = CODING_ATTR_CHARSET_LIST (attrs); |
102186
a12d39ca6870
* coding.h (struct coding_system): Make safe_charsets a pointer to
Andreas Schwab <schwab@suse.de>
parents:
102115
diff
changeset
|
4491 coding->safe_charsets = SDATA (CODING_ATTR_SAFE_CHARSETS (attrs)); |
88365 | 4492 |
110336
3ffb3b102dae
coding.c (encode_coding_iso_2022): Do not optimize for ASCII if we may use designation or locking-shift.
Kenichi Handa <handa@m17n.org>
parents:
110334
diff
changeset
|
4493 ascii_compatible |
3ffb3b102dae
coding.c (encode_coding_iso_2022): Do not optimize for ASCII if we may use designation or locking-shift.
Kenichi Handa <handa@m17n.org>
parents:
110334
diff
changeset
|
4494 = (! NILP (CODING_ATTR_ASCII_COMPAT (attrs)) |
3ffb3b102dae
coding.c (encode_coding_iso_2022): Do not optimize for ASCII if we may use designation or locking-shift.
Kenichi Handa <handa@m17n.org>
parents:
110334
diff
changeset
|
4495 && ! (CODING_ISO_FLAGS (coding) & (CODING_ISO_FLAG_DESIGNATION |
3ffb3b102dae
coding.c (encode_coding_iso_2022): Do not optimize for ASCII if we may use designation or locking-shift.
Kenichi Handa <handa@m17n.org>
parents:
110334
diff
changeset
|
4496 | CODING_ISO_FLAG_LOCKING_SHIFT))); |
88365 | 4497 |
4498 while (charbuf < charbuf_end) | |
4499 { | |
4500 ASSURE_DESTINATION (safe_room); | |
4501 | |
4502 if (bol_designation) | |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4503 { |
88365 | 4504 unsigned char *dst_prev = dst; |
4505 | |
17725
92f042f73be2
(Valternate_charset_table): The valiable deleted.
Kenichi Handa <handa@m17n.org>
parents:
17717
diff
changeset
|
4506 /* We have to produce designation sequences if any now. */ |
88365 | 4507 dst = encode_designation_at_bol (coding, charbuf, charbuf_end, dst); |
4508 bol_designation = 0; | |
4509 /* We are sure that designation sequences are all ASCII bytes. */ | |
4510 produced_chars += dst - dst_prev; | |
17119
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
4511 } |
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
4512 |
88365 | 4513 c = *charbuf++; |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4514 |
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
4515 if (c < 0) |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
4516 { |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
4517 /* Handle an annotation. */ |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
4518 switch (*charbuf) |
17052 | 4519 { |
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
4520 case CODING_ANNOTATE_COMPOSITION_MASK: |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
4521 /* Not yet implemented. */ |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
4522 break; |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
4523 case CODING_ANNOTATE_CHARSET_MASK: |
90014
ade0c9a12f99
(encode_coding_iso_2022): Fix handling of charset
Kenichi Handa <handa@m17n.org>
parents:
90011
diff
changeset
|
4524 preferred_charset_id = charbuf[2]; |
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
4525 if (preferred_charset_id >= 0 |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
4526 && NILP (Fmemq (make_number (preferred_charset_id), |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
4527 charset_list))) |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
4528 preferred_charset_id = -1; |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
4529 break; |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
4530 default: |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
4531 abort (); |
26847 | 4532 } |
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
4533 charbuf += -c - 1; |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
4534 continue; |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
4535 } |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4536 |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4537 /* 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
|
4538 if (c < 0x20 || c == 0x7F) |
17052 | 4539 { |
88365 | 4540 if (c == '\n' |
4541 || (c == '\r' && EQ (eol_type, Qmac))) | |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4542 { |
88365 | 4543 if (CODING_ISO_FLAGS (coding) & CODING_ISO_FLAG_RESET_AT_EOL) |
4544 ENCODE_RESET_PLANE_AND_REGISTER (); | |
4545 if (CODING_ISO_FLAGS (coding) & CODING_ISO_FLAG_INIT_AT_BOL) | |
4546 { | |
4547 int i; | |
4548 | |
4549 for (i = 0; i < 4; i++) | |
4550 CODING_ISO_DESIGNATION (coding, i) | |
4551 = CODING_ISO_INITIAL (coding, i); | |
4552 } | |
4553 bol_designation | |
4554 = CODING_ISO_FLAGS (coding) & CODING_ISO_FLAG_DESIGNATE_AT_BOL; | |
19052
302a7b2a6948
(encode_coding_iso2022): Write out invalid multibyte
Kenichi Handa <handa@m17n.org>
parents:
18910
diff
changeset
|
4555 } |
88365 | 4556 else if (CODING_ISO_FLAGS (coding) & CODING_ISO_FLAG_RESET_AT_CNTL) |
4557 ENCODE_RESET_PLANE_AND_REGISTER (); | |
4558 EMIT_ONE_ASCII_BYTE (c); | |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4559 } |
88365 | 4560 else if (ASCII_CHAR_P (c)) |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4561 { |
88365 | 4562 if (ascii_compatible) |
4563 EMIT_ONE_ASCII_BYTE (c); | |
4564 else | |
88681
2cdfbffa8a0d
(CODING_ISO_FLAG_USE_ROMAN): New macro
Kenichi Handa <handa@m17n.org>
parents:
88669
diff
changeset
|
4565 { |
2cdfbffa8a0d
(CODING_ISO_FLAG_USE_ROMAN): New macro
Kenichi Handa <handa@m17n.org>
parents:
88669
diff
changeset
|
4566 struct charset *charset = CHARSET_FROM_ID (charset_ascii); |
2cdfbffa8a0d
(CODING_ISO_FLAG_USE_ROMAN): New macro
Kenichi Handa <handa@m17n.org>
parents:
88669
diff
changeset
|
4567 ENCODE_ISO_CHARACTER (charset, c); |
2cdfbffa8a0d
(CODING_ISO_FLAG_USE_ROMAN): New macro
Kenichi Handa <handa@m17n.org>
parents:
88669
diff
changeset
|
4568 } |
17052 | 4569 } |
88690
7f284ac55b07
(encode_coding_emacs_mule): Pay attention to raw-8-bit chars.
Kenichi Handa <handa@m17n.org>
parents:
88681
diff
changeset
|
4570 else if (CHAR_BYTE8_P (c)) |
7f284ac55b07
(encode_coding_emacs_mule): Pay attention to raw-8-bit chars.
Kenichi Handa <handa@m17n.org>
parents:
88681
diff
changeset
|
4571 { |
7f284ac55b07
(encode_coding_emacs_mule): Pay attention to raw-8-bit chars.
Kenichi Handa <handa@m17n.org>
parents:
88681
diff
changeset
|
4572 c = CHAR_TO_BYTE8 (c); |
7f284ac55b07
(encode_coding_emacs_mule): Pay attention to raw-8-bit chars.
Kenichi Handa <handa@m17n.org>
parents:
88681
diff
changeset
|
4573 EMIT_ONE_BYTE (c); |
7f284ac55b07
(encode_coding_emacs_mule): Pay attention to raw-8-bit chars.
Kenichi Handa <handa@m17n.org>
parents:
88681
diff
changeset
|
4574 } |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4575 else |
88365 | 4576 { |
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
4577 struct charset *charset; |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
4578 |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
4579 if (preferred_charset_id >= 0) |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
4580 { |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
4581 charset = CHARSET_FROM_ID (preferred_charset_id); |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
4582 if (! CHAR_CHARSET_P (c, charset)) |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
4583 charset = char_charset (c, charset_list, NULL); |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4584 } |
42104
d69c2368e549
(DECODE_COMPOSITION_END): Fixed a typo in the last
Sam Steingold <sds@gnu.org>
parents:
42103
diff
changeset
|
4585 else |
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
4586 charset = char_charset (c, charset_list, NULL); |
88365 | 4587 if (!charset) |
17052 | 4588 { |
88573
133bf7ab1bad
(encode_coding_iso_2022): If coding requires safe
Kenichi Handa <handa@m17n.org>
parents:
88544
diff
changeset
|
4589 if (coding->mode & CODING_MODE_SAFE_ENCODING) |
133bf7ab1bad
(encode_coding_iso_2022): If coding requires safe
Kenichi Handa <handa@m17n.org>
parents:
88544
diff
changeset
|
4590 { |
133bf7ab1bad
(encode_coding_iso_2022): If coding requires safe
Kenichi Handa <handa@m17n.org>
parents:
88544
diff
changeset
|
4591 c = CODING_INHIBIT_CHARACTER_SUBSTITUTION; |
133bf7ab1bad
(encode_coding_iso_2022): If coding requires safe
Kenichi Handa <handa@m17n.org>
parents:
88544
diff
changeset
|
4592 charset = CHARSET_FROM_ID (charset_ascii); |
133bf7ab1bad
(encode_coding_iso_2022): If coding requires safe
Kenichi Handa <handa@m17n.org>
parents:
88544
diff
changeset
|
4593 } |
133bf7ab1bad
(encode_coding_iso_2022): If coding requires safe
Kenichi Handa <handa@m17n.org>
parents:
88544
diff
changeset
|
4594 else |
133bf7ab1bad
(encode_coding_iso_2022): If coding requires safe
Kenichi Handa <handa@m17n.org>
parents:
88544
diff
changeset
|
4595 { |
133bf7ab1bad
(encode_coding_iso_2022): If coding requires safe
Kenichi Handa <handa@m17n.org>
parents:
88544
diff
changeset
|
4596 c = coding->default_char; |
133bf7ab1bad
(encode_coding_iso_2022): If coding requires safe
Kenichi Handa <handa@m17n.org>
parents:
88544
diff
changeset
|
4597 charset = char_charset (c, charset_list, NULL); |
133bf7ab1bad
(encode_coding_iso_2022): If coding requires safe
Kenichi Handa <handa@m17n.org>
parents:
88544
diff
changeset
|
4598 } |
19052
302a7b2a6948
(encode_coding_iso2022): Write out invalid multibyte
Kenichi Handa <handa@m17n.org>
parents:
18910
diff
changeset
|
4599 } |
88365 | 4600 ENCODE_ISO_CHARACTER (charset, c); |
4601 } | |
4602 } | |
4603 | |
4604 if (coding->mode & CODING_MODE_LAST_BLOCK | |
4605 && CODING_ISO_FLAGS (coding) & CODING_ISO_FLAG_RESET_AT_EOL) | |
4606 { | |
4607 ASSURE_DESTINATION (safe_room); | |
4608 ENCODE_RESET_PLANE_AND_REGISTER (); | |
4609 } | |
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
4610 record_conversion_result (coding, CODING_RESULT_SUCCESS); |
88365 | 4611 CODING_ISO_BOL (coding) = bol_designation; |
4612 coding->produced_char += produced_chars; | |
4613 coding->produced = dst - coding->destination; | |
4614 return 0; | |
17052 | 4615 } |
4616 | |
4617 | |
88365 | 4618 /*** 8,9. SJIS and BIG5 handlers ***/ |
4619 | |
4620 /* Although SJIS and BIG5 are not ISO's coding system, they are used | |
17052 | 4621 quite widely. So, for the moment, Emacs supports them in the bare |
4622 C code. But, in the future, they may be supported only by CCL. */ | |
4623 | |
4624 /* SJIS is a coding system encoding three character sets: ASCII, right | |
4625 half of JISX0201-Kana, and JISX0208. An ASCII character is encoded | |
4626 as is. A character of charset katakana-jisx0201 is encoded by | |
4627 "position-code + 0x80". A character of charset japanese-jisx0208 | |
4628 is encoded in 2-byte but two position-codes are divided and shifted | |
88365 | 4629 so that it fit in the range below. |
17052 | 4630 |
4631 --- CODE RANGE of SJIS --- | |
4632 (character set) (range) | |
4633 ASCII 0x00 .. 0x7F | |
88365 | 4634 KATAKANA-JISX0201 0xA0 .. 0xDF |
24324
2eec590faf26
(Fdecode_sjis_char, Fencode_sjis_char): Hanlde
Kenichi Handa <handa@m17n.org>
parents:
24316
diff
changeset
|
4635 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
|
4636 (2nd byte) 0x40 .. 0x7E and 0x80 .. 0xFC |
17052 | 4637 ------------------------------- |
4638 | |
4639 */ | |
4640 | |
4641 /* BIG5 is a coding system encoding two character sets: ASCII and | |
4642 Big5. An ASCII character is encoded as is. Big5 is a two-byte | |
88365 | 4643 character set and is encoded in two-byte. |
17052 | 4644 |
4645 --- CODE RANGE of BIG5 --- | |
4646 (character set) (range) | |
4647 ASCII 0x00 .. 0x7F | |
4648 Big5 (1st byte) 0xA1 .. 0xFE | |
4649 (2nd byte) 0x40 .. 0x7E and 0xA1 .. 0xFE | |
4650 -------------------------- | |
4651 | |
88365 | 4652 */ |
17052 | 4653 |
4654 /* See the above "GENERAL NOTES on `detect_coding_XXX ()' functions". | |
4655 Check if a text is encoded in SJIS. If it is, return | |
88365 | 4656 CATEGORY_MASK_SJIS, else return 0. */ |
17052 | 4657 |
34531
37f85e931855
(ONE_MORE_BYTE_CHECK_MULTIBYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34197
diff
changeset
|
4658 static int |
109159
3e9fdeb960d1
* coding.c, sysdep.c: Convert some more functions to standard C.
Juanma Barranquero <lekktu@gmail.com>
parents:
109158
diff
changeset
|
4659 detect_coding_sjis (struct coding_system *coding, |
3e9fdeb960d1
* coding.c, sysdep.c: Convert some more functions to standard C.
Juanma Barranquero <lekktu@gmail.com>
parents:
109158
diff
changeset
|
4660 struct coding_detection_info *detect_info) |
17052 | 4661 { |
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
4662 const unsigned char *src = coding->source, *src_base; |
89483 | 4663 const unsigned char *src_end = coding->source + coding->src_bytes; |
88365 | 4664 int multibytep = coding->src_multibyte; |
4665 int consumed_chars = 0; | |
4666 int found = 0; | |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4667 int c; |
103762
e72df94a89ca
(detect_coding_sjis): Handle shift_jis-2004 correctly.
Kenichi Handa <handa@m17n.org>
parents:
103655
diff
changeset
|
4668 Lisp_Object attrs, charset_list; |
e72df94a89ca
(detect_coding_sjis): Handle shift_jis-2004 correctly.
Kenichi Handa <handa@m17n.org>
parents:
103655
diff
changeset
|
4669 int max_first_byte_of_2_byte_code; |
e72df94a89ca
(detect_coding_sjis): Handle shift_jis-2004 correctly.
Kenichi Handa <handa@m17n.org>
parents:
103655
diff
changeset
|
4670 |
e72df94a89ca
(detect_coding_sjis): Handle shift_jis-2004 correctly.
Kenichi Handa <handa@m17n.org>
parents:
103655
diff
changeset
|
4671 CODING_GET_INFO (coding, attrs, charset_list); |
e72df94a89ca
(detect_coding_sjis): Handle shift_jis-2004 correctly.
Kenichi Handa <handa@m17n.org>
parents:
103655
diff
changeset
|
4672 max_first_byte_of_2_byte_code |
e72df94a89ca
(detect_coding_sjis): Handle shift_jis-2004 correctly.
Kenichi Handa <handa@m17n.org>
parents:
103655
diff
changeset
|
4673 = (XINT (Flength (charset_list)) > 3 ? 0xFC : 0xEF); |
88365 | 4674 |
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
4675 detect_info->checked |= CATEGORY_MASK_SJIS; |
88365 | 4676 /* A coding system of this category is always ASCII compatible. */ |
4677 src += coding->head_ascii; | |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4678 |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4679 while (1) |
17052 | 4680 { |
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
4681 src_base = src; |
88365 | 4682 ONE_MORE_BYTE (c); |
36647
0a75ccbe42b2
(detect_coding_sjis): Do more rigid check.
Kenichi Handa <handa@m17n.org>
parents:
36520
diff
changeset
|
4683 if (c < 0x80) |
0a75ccbe42b2
(detect_coding_sjis): Do more rigid check.
Kenichi Handa <handa@m17n.org>
parents:
36520
diff
changeset
|
4684 continue; |
103762
e72df94a89ca
(detect_coding_sjis): Handle shift_jis-2004 correctly.
Kenichi Handa <handa@m17n.org>
parents:
103655
diff
changeset
|
4685 if ((c >= 0x81 && c <= 0x9F) |
e72df94a89ca
(detect_coding_sjis): Handle shift_jis-2004 correctly.
Kenichi Handa <handa@m17n.org>
parents:
103655
diff
changeset
|
4686 || (c >= 0xE0 && c <= max_first_byte_of_2_byte_code)) |
17052 | 4687 { |
88365 | 4688 ONE_MORE_BYTE (c); |
36647
0a75ccbe42b2
(detect_coding_sjis): Do more rigid check.
Kenichi Handa <handa@m17n.org>
parents:
36520
diff
changeset
|
4689 if (c < 0x40 || c == 0x7F || c > 0xFC) |
88365 | 4690 break; |
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
4691 found = CATEGORY_MASK_SJIS; |
17052 | 4692 } |
88365 | 4693 else if (c >= 0xA0 && c < 0xE0) |
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
4694 found = CATEGORY_MASK_SJIS; |
88365 | 4695 else |
4696 break; | |
4697 } | |
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
4698 detect_info->rejected |= CATEGORY_MASK_SJIS; |
88365 | 4699 return 0; |
4700 | |
4701 no_more_source: | |
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
4702 if (src_base < src && coding->mode & CODING_MODE_LAST_BLOCK) |
89193
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
4703 { |
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
4704 detect_info->rejected |= CATEGORY_MASK_SJIS; |
89193
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
4705 return 0; |
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
4706 } |
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
4707 detect_info->found |= found; |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
4708 return 1; |
17052 | 4709 } |
4710 | |
4711 /* See the above "GENERAL NOTES on `detect_coding_XXX ()' functions". | |
4712 Check if a text is encoded in BIG5. If it is, return | |
88365 | 4713 CATEGORY_MASK_BIG5, else return 0. */ |
17052 | 4714 |
34531
37f85e931855
(ONE_MORE_BYTE_CHECK_MULTIBYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34197
diff
changeset
|
4715 static int |
109159
3e9fdeb960d1
* coding.c, sysdep.c: Convert some more functions to standard C.
Juanma Barranquero <lekktu@gmail.com>
parents:
109158
diff
changeset
|
4716 detect_coding_big5 (struct coding_system *coding, |
3e9fdeb960d1
* coding.c, sysdep.c: Convert some more functions to standard C.
Juanma Barranquero <lekktu@gmail.com>
parents:
109158
diff
changeset
|
4717 struct coding_detection_info *detect_info) |
17052 | 4718 { |
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
4719 const unsigned char *src = coding->source, *src_base; |
89483 | 4720 const unsigned char *src_end = coding->source + coding->src_bytes; |
88365 | 4721 int multibytep = coding->src_multibyte; |
4722 int consumed_chars = 0; | |
4723 int found = 0; | |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4724 int c; |
88365 | 4725 |
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
4726 detect_info->checked |= CATEGORY_MASK_BIG5; |
88365 | 4727 /* A coding system of this category is always ASCII compatible. */ |
4728 src += coding->head_ascii; | |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4729 |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4730 while (1) |
28022
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
4731 { |
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
4732 src_base = src; |
88365 | 4733 ONE_MORE_BYTE (c); |
4734 if (c < 0x80) | |
28022
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
4735 continue; |
88365 | 4736 if (c >= 0xA1) |
28022
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
4737 { |
88365 | 4738 ONE_MORE_BYTE (c); |
4739 if (c < 0x40 || (c >= 0x7F && c <= 0xA0)) | |
28022
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
4740 return 0; |
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
4741 found = CATEGORY_MASK_BIG5; |
28022
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
4742 } |
88365 | 4743 else |
4744 break; | |
4745 } | |
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
4746 detect_info->rejected |= CATEGORY_MASK_BIG5; |
28022
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
4747 return 0; |
88365 | 4748 |
4749 no_more_source: | |
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
4750 if (src_base < src && coding->mode & CODING_MODE_LAST_BLOCK) |
89193
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
4751 { |
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
4752 detect_info->rejected |= CATEGORY_MASK_BIG5; |
89193
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
4753 return 0; |
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
4754 } |
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
4755 detect_info->found |= found; |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
4756 return 1; |
28022
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
4757 } |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
4758 |
17052 | 4759 /* See the above "GENERAL NOTES on `decode_coding_XXX ()' functions". |
4760 If SJIS_P is 1, decode SJIS text, else decode BIG5 test. */ | |
4761 | |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4762 static void |
109126
aec1143e8d85
Convert (most) functions in src to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109100
diff
changeset
|
4763 decode_coding_sjis (struct coding_system *coding) |
17052 | 4764 { |
89483 | 4765 const unsigned char *src = coding->source + coding->consumed; |
4766 const unsigned char *src_end = coding->source + coding->src_bytes; | |
59168
0345f2b10f1d
(decode_coding_XXX, decode_composition_emacs_mule)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
59095
diff
changeset
|
4767 const unsigned char *src_base; |
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
4768 int *charbuf = coding->charbuf + coding->charbuf_used; |
103035
6e443d717c7b
(decode_coding_utf_16): Reduce charbuf_end for the
Kenichi Handa <handa@m17n.org>
parents:
102738
diff
changeset
|
4769 /* We may produce one charset annocation in one loop and one more at |
6e443d717c7b
(decode_coding_utf_16): Reduce charbuf_end for the
Kenichi Handa <handa@m17n.org>
parents:
102738
diff
changeset
|
4770 the end. */ |
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
4771 int *charbuf_end |
103035
6e443d717c7b
(decode_coding_utf_16): Reduce charbuf_end for the
Kenichi Handa <handa@m17n.org>
parents:
102738
diff
changeset
|
4772 = coding->charbuf + coding->charbuf_size - (MAX_ANNOTATION_LENGTH * 2); |
88365 | 4773 int consumed_chars = 0, consumed_chars_base; |
4774 int multibytep = coding->src_multibyte; | |
4775 struct charset *charset_roman, *charset_kanji, *charset_kana; | |
89764
e3d26232ab78
(decode_coding_sjis): Handle 4th charset (typically JISX0212).
Kenichi Handa <handa@m17n.org>
parents:
89759
diff
changeset
|
4776 struct charset *charset_kanji2; |
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4777 Lisp_Object attrs, charset_list, val; |
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
4778 int char_offset = coding->produced_char; |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
4779 int last_offset = char_offset; |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
4780 int last_id = charset_ascii; |
102334
7baaea85626e
(decode_coding_utf_8, decode_coding_utf_16, decode_coding_emacs_mule,
Eli Zaretskii <eliz@gnu.org>
parents:
102327
diff
changeset
|
4781 int eol_crlf = |
7baaea85626e
(decode_coding_utf_8, decode_coding_utf_16, decode_coding_emacs_mule,
Eli Zaretskii <eliz@gnu.org>
parents:
102327
diff
changeset
|
4782 !inhibit_eol_conversion && EQ (CODING_ID_EOL_TYPE (coding->id), Qdos); |
92399
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
4783 int byte_after_cr = -1; |
88365 | 4784 |
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4785 CODING_GET_INFO (coding, attrs, charset_list); |
88365 | 4786 |
4787 val = charset_list; | |
4788 charset_roman = CHARSET_FROM_ID (XINT (XCAR (val))), val = XCDR (val); | |
89193
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
4789 charset_kana = CHARSET_FROM_ID (XINT (XCAR (val))), val = XCDR (val); |
89764
e3d26232ab78
(decode_coding_sjis): Handle 4th charset (typically JISX0212).
Kenichi Handa <handa@m17n.org>
parents:
89759
diff
changeset
|
4790 charset_kanji = CHARSET_FROM_ID (XINT (XCAR (val))), val = XCDR (val); |
e3d26232ab78
(decode_coding_sjis): Handle 4th charset (typically JISX0212).
Kenichi Handa <handa@m17n.org>
parents:
89759
diff
changeset
|
4791 charset_kanji2 = NILP (val) ? NULL : CHARSET_FROM_ID (XINT (XCAR (val))); |
88365 | 4792 |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4793 while (1) |
17052 | 4794 { |
88365 | 4795 int c, c1; |
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4796 struct charset *charset; |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4797 |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4798 src_base = src; |
88365 | 4799 consumed_chars_base = consumed_chars; |
4800 | |
4801 if (charbuf >= charbuf_end) | |
100936
5c5e6d041634
(decode_coding_utf_8): Check byte_after_cr before breaking the loop.
Kenichi Handa <handa@m17n.org>
parents:
100587
diff
changeset
|
4802 { |
5c5e6d041634
(decode_coding_utf_8): Check byte_after_cr before breaking the loop.
Kenichi Handa <handa@m17n.org>
parents:
100587
diff
changeset
|
4803 if (byte_after_cr >= 0) |
5c5e6d041634
(decode_coding_utf_8): Check byte_after_cr before breaking the loop.
Kenichi Handa <handa@m17n.org>
parents:
100587
diff
changeset
|
4804 src_base--; |
5c5e6d041634
(decode_coding_utf_8): Check byte_after_cr before breaking the loop.
Kenichi Handa <handa@m17n.org>
parents:
100587
diff
changeset
|
4805 break; |
5c5e6d041634
(decode_coding_utf_8): Check byte_after_cr before breaking the loop.
Kenichi Handa <handa@m17n.org>
parents:
100587
diff
changeset
|
4806 } |
88365 | 4807 |
92399
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
4808 if (byte_after_cr >= 0) |
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
4809 c = byte_after_cr, byte_after_cr = -1; |
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
4810 else |
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
4811 ONE_MORE_BYTE (c); |
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
4812 if (c < 0) |
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
4813 goto invalid_code; |
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4814 if (c < 0x80) |
92399
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
4815 { |
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
4816 if (eol_crlf && c == '\r') |
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
4817 ONE_MORE_BYTE (byte_after_cr); |
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
4818 charset = charset_roman; |
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
4819 } |
89764
e3d26232ab78
(decode_coding_sjis): Handle 4th charset (typically JISX0212).
Kenichi Handa <handa@m17n.org>
parents:
89759
diff
changeset
|
4820 else if (c == 0x80 || c == 0xA0) |
89730
d8fcefca5cf6
(decode_coding_sjis): Check the first byte rigidly.
Kenichi Handa <handa@m17n.org>
parents:
89686
diff
changeset
|
4821 goto invalid_code; |
89764
e3d26232ab78
(decode_coding_sjis): Handle 4th charset (typically JISX0212).
Kenichi Handa <handa@m17n.org>
parents:
89759
diff
changeset
|
4822 else if (c >= 0xA1 && c <= 0xDF) |
e3d26232ab78
(decode_coding_sjis): Handle 4th charset (typically JISX0212).
Kenichi Handa <handa@m17n.org>
parents:
89759
diff
changeset
|
4823 { |
e3d26232ab78
(decode_coding_sjis): Handle 4th charset (typically JISX0212).
Kenichi Handa <handa@m17n.org>
parents:
89759
diff
changeset
|
4824 /* SJIS -> JISX0201-Kana */ |
e3d26232ab78
(decode_coding_sjis): Handle 4th charset (typically JISX0212).
Kenichi Handa <handa@m17n.org>
parents:
89759
diff
changeset
|
4825 c &= 0x7F; |
e3d26232ab78
(decode_coding_sjis): Handle 4th charset (typically JISX0212).
Kenichi Handa <handa@m17n.org>
parents:
89759
diff
changeset
|
4826 charset = charset_kana; |
e3d26232ab78
(decode_coding_sjis): Handle 4th charset (typically JISX0212).
Kenichi Handa <handa@m17n.org>
parents:
89759
diff
changeset
|
4827 } |
e3d26232ab78
(decode_coding_sjis): Handle 4th charset (typically JISX0212).
Kenichi Handa <handa@m17n.org>
parents:
89759
diff
changeset
|
4828 else if (c <= 0xEF) |
e3d26232ab78
(decode_coding_sjis): Handle 4th charset (typically JISX0212).
Kenichi Handa <handa@m17n.org>
parents:
89759
diff
changeset
|
4829 { |
e3d26232ab78
(decode_coding_sjis): Handle 4th charset (typically JISX0212).
Kenichi Handa <handa@m17n.org>
parents:
89759
diff
changeset
|
4830 /* SJIS -> JISX0208 */ |
e3d26232ab78
(decode_coding_sjis): Handle 4th charset (typically JISX0212).
Kenichi Handa <handa@m17n.org>
parents:
89759
diff
changeset
|
4831 ONE_MORE_BYTE (c1); |
e3d26232ab78
(decode_coding_sjis): Handle 4th charset (typically JISX0212).
Kenichi Handa <handa@m17n.org>
parents:
89759
diff
changeset
|
4832 if (c1 < 0x40 || c1 == 0x7F || c1 > 0xFC) |
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4833 goto invalid_code; |
89764
e3d26232ab78
(decode_coding_sjis): Handle 4th charset (typically JISX0212).
Kenichi Handa <handa@m17n.org>
parents:
89759
diff
changeset
|
4834 c = (c << 8) | c1; |
e3d26232ab78
(decode_coding_sjis): Handle 4th charset (typically JISX0212).
Kenichi Handa <handa@m17n.org>
parents:
89759
diff
changeset
|
4835 SJIS_TO_JIS (c); |
e3d26232ab78
(decode_coding_sjis): Handle 4th charset (typically JISX0212).
Kenichi Handa <handa@m17n.org>
parents:
89759
diff
changeset
|
4836 charset = charset_kanji; |
e3d26232ab78
(decode_coding_sjis): Handle 4th charset (typically JISX0212).
Kenichi Handa <handa@m17n.org>
parents:
89759
diff
changeset
|
4837 } |
e3d26232ab78
(decode_coding_sjis): Handle 4th charset (typically JISX0212).
Kenichi Handa <handa@m17n.org>
parents:
89759
diff
changeset
|
4838 else if (c <= 0xFC && charset_kanji2) |
e3d26232ab78
(decode_coding_sjis): Handle 4th charset (typically JISX0212).
Kenichi Handa <handa@m17n.org>
parents:
89759
diff
changeset
|
4839 { |
89779
74c503490829
(decode_coding_sjis): Fix comment.
Kenichi Handa <handa@m17n.org>
parents:
89764
diff
changeset
|
4840 /* SJIS -> JISX0213-2 */ |
89764
e3d26232ab78
(decode_coding_sjis): Handle 4th charset (typically JISX0212).
Kenichi Handa <handa@m17n.org>
parents:
89759
diff
changeset
|
4841 ONE_MORE_BYTE (c1); |
e3d26232ab78
(decode_coding_sjis): Handle 4th charset (typically JISX0212).
Kenichi Handa <handa@m17n.org>
parents:
89759
diff
changeset
|
4842 if (c1 < 0x40 || c1 == 0x7F || c1 > 0xFC) |
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4843 goto invalid_code; |
89764
e3d26232ab78
(decode_coding_sjis): Handle 4th charset (typically JISX0212).
Kenichi Handa <handa@m17n.org>
parents:
89759
diff
changeset
|
4844 c = (c << 8) | c1; |
e3d26232ab78
(decode_coding_sjis): Handle 4th charset (typically JISX0212).
Kenichi Handa <handa@m17n.org>
parents:
89759
diff
changeset
|
4845 SJIS_TO_JIS2 (c); |
e3d26232ab78
(decode_coding_sjis): Handle 4th charset (typically JISX0212).
Kenichi Handa <handa@m17n.org>
parents:
89759
diff
changeset
|
4846 charset = charset_kanji2; |
17052 | 4847 } |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4848 else |
89764
e3d26232ab78
(decode_coding_sjis): Handle 4th charset (typically JISX0212).
Kenichi Handa <handa@m17n.org>
parents:
89759
diff
changeset
|
4849 goto invalid_code; |
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4850 if (charset->id != charset_ascii |
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4851 && last_id != charset->id) |
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4852 { |
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4853 if (last_id != charset_ascii) |
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
4854 ADD_CHARSET_DATA (charbuf, char_offset - last_offset, last_id); |
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4855 last_id = charset->id; |
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4856 last_offset = char_offset; |
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4857 } |
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4858 CODING_DECODE_CHAR (coding, src, src_base, src_end, charset, c, c); |
88365 | 4859 *charbuf++ = c; |
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
4860 char_offset++; |
20931
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
4861 continue; |
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
4862 |
88365 | 4863 invalid_code: |
17052 | 4864 src = src_base; |
88365 | 4865 consumed_chars = consumed_chars_base; |
4866 ONE_MORE_BYTE (c); | |
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
4867 *charbuf++ = c < 0 ? -c : BYTE8_TO_CHAR (c); |
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
4868 char_offset++; |
88365 | 4869 coding->errors++; |
4870 } | |
4871 | |
4872 no_more_source: | |
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
4873 if (last_id != charset_ascii) |
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
4874 ADD_CHARSET_DATA (charbuf, char_offset - last_offset, last_id); |
88365 | 4875 coding->consumed_char += consumed_chars_base; |
4876 coding->consumed = src_base - coding->source; | |
4877 coding->charbuf_used = charbuf - coding->charbuf; | |
4878 } | |
4879 | |
4880 static void | |
109126
aec1143e8d85
Convert (most) functions in src to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109100
diff
changeset
|
4881 decode_coding_big5 (struct coding_system *coding) |
88365 | 4882 { |
89483 | 4883 const unsigned char *src = coding->source + coding->consumed; |
4884 const unsigned char *src_end = coding->source + coding->src_bytes; | |
4885 const unsigned char *src_base; | |
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
4886 int *charbuf = coding->charbuf + coding->charbuf_used; |
103035
6e443d717c7b
(decode_coding_utf_16): Reduce charbuf_end for the
Kenichi Handa <handa@m17n.org>
parents:
102738
diff
changeset
|
4887 /* We may produce one charset annocation in one loop and one more at |
6e443d717c7b
(decode_coding_utf_16): Reduce charbuf_end for the
Kenichi Handa <handa@m17n.org>
parents:
102738
diff
changeset
|
4888 the end. */ |
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
4889 int *charbuf_end |
103035
6e443d717c7b
(decode_coding_utf_16): Reduce charbuf_end for the
Kenichi Handa <handa@m17n.org>
parents:
102738
diff
changeset
|
4890 = coding->charbuf + coding->charbuf_size - (MAX_ANNOTATION_LENGTH * 2); |
88365 | 4891 int consumed_chars = 0, consumed_chars_base; |
4892 int multibytep = coding->src_multibyte; | |
4893 struct charset *charset_roman, *charset_big5; | |
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4894 Lisp_Object attrs, charset_list, val; |
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
4895 int char_offset = coding->produced_char; |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
4896 int last_offset = char_offset; |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
4897 int last_id = charset_ascii; |
102334
7baaea85626e
(decode_coding_utf_8, decode_coding_utf_16, decode_coding_emacs_mule,
Eli Zaretskii <eliz@gnu.org>
parents:
102327
diff
changeset
|
4898 int eol_crlf = |
7baaea85626e
(decode_coding_utf_8, decode_coding_utf_16, decode_coding_emacs_mule,
Eli Zaretskii <eliz@gnu.org>
parents:
102327
diff
changeset
|
4899 !inhibit_eol_conversion && EQ (CODING_ID_EOL_TYPE (coding->id), Qdos); |
92399
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
4900 int byte_after_cr = -1; |
88365 | 4901 |
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4902 CODING_GET_INFO (coding, attrs, charset_list); |
88365 | 4903 val = charset_list; |
4904 charset_roman = CHARSET_FROM_ID (XINT (XCAR (val))), val = XCDR (val); | |
4905 charset_big5 = CHARSET_FROM_ID (XINT (XCAR (val))); | |
4906 | |
4907 while (1) | |
4908 { | |
4909 int c, c1; | |
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4910 struct charset *charset; |
88365 | 4911 |
4912 src_base = src; | |
4913 consumed_chars_base = consumed_chars; | |
4914 | |
4915 if (charbuf >= charbuf_end) | |
100936
5c5e6d041634
(decode_coding_utf_8): Check byte_after_cr before breaking the loop.
Kenichi Handa <handa@m17n.org>
parents:
100587
diff
changeset
|
4916 { |
5c5e6d041634
(decode_coding_utf_8): Check byte_after_cr before breaking the loop.
Kenichi Handa <handa@m17n.org>
parents:
100587
diff
changeset
|
4917 if (byte_after_cr >= 0) |
5c5e6d041634
(decode_coding_utf_8): Check byte_after_cr before breaking the loop.
Kenichi Handa <handa@m17n.org>
parents:
100587
diff
changeset
|
4918 src_base--; |
5c5e6d041634
(decode_coding_utf_8): Check byte_after_cr before breaking the loop.
Kenichi Handa <handa@m17n.org>
parents:
100587
diff
changeset
|
4919 break; |
5c5e6d041634
(decode_coding_utf_8): Check byte_after_cr before breaking the loop.
Kenichi Handa <handa@m17n.org>
parents:
100587
diff
changeset
|
4920 } |
88365 | 4921 |
92399
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
4922 if (byte_after_cr >= 0) |
92406
c36bda0a03cc
(decode_coding_big5, produce_chars): Fix typos in last
Andreas Schwab <schwab@suse.de>
parents:
92399
diff
changeset
|
4923 c = byte_after_cr, byte_after_cr = -1; |
92399
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
4924 else |
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
4925 ONE_MORE_BYTE (c); |
88365 | 4926 |
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
4927 if (c < 0) |
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
4928 goto invalid_code; |
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4929 if (c < 0x80) |
92399
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
4930 { |
92406
c36bda0a03cc
(decode_coding_big5, produce_chars): Fix typos in last
Andreas Schwab <schwab@suse.de>
parents:
92399
diff
changeset
|
4931 if (eol_crlf && c == '\r') |
92399
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
4932 ONE_MORE_BYTE (byte_after_cr); |
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
4933 charset = charset_roman; |
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
4934 } |
88365 | 4935 else |
4936 { | |
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4937 /* BIG5 -> Big5 */ |
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4938 if (c < 0xA1 || c > 0xFE) |
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4939 goto invalid_code; |
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4940 ONE_MORE_BYTE (c1); |
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4941 if (c1 < 0x40 || (c1 > 0x7E && c1 < 0xA1) || c1 > 0xFE) |
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4942 goto invalid_code; |
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4943 c = c << 8 | c1; |
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4944 charset = charset_big5; |
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4945 } |
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4946 if (charset->id != charset_ascii |
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4947 && last_id != charset->id) |
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4948 { |
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4949 if (last_id != charset_ascii) |
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
4950 ADD_CHARSET_DATA (charbuf, char_offset - last_offset, last_id); |
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4951 last_id = charset->id; |
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4952 last_offset = char_offset; |
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4953 } |
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4954 CODING_DECODE_CHAR (coding, src, src_base, src_end, charset, c, c); |
88365 | 4955 *charbuf++ = c; |
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
4956 char_offset++; |
20931
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
4957 continue; |
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
4958 |
88365 | 4959 invalid_code: |
17052 | 4960 src = src_base; |
88365 | 4961 consumed_chars = consumed_chars_base; |
4962 ONE_MORE_BYTE (c); | |
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
4963 *charbuf++ = c < 0 ? -c : BYTE8_TO_CHAR (c); |
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
4964 char_offset++; |
88365 | 4965 coding->errors++; |
4966 } | |
4967 | |
4968 no_more_source: | |
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
4969 if (last_id != charset_ascii) |
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
4970 ADD_CHARSET_DATA (charbuf, char_offset - last_offset, last_id); |
88365 | 4971 coding->consumed_char += consumed_chars_base; |
4972 coding->consumed = src_base - coding->source; | |
4973 coding->charbuf_used = charbuf - coding->charbuf; | |
17052 | 4974 } |
4975 | |
4976 /* 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
|
4977 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
|
4978 `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
|
4979 are sure that all these charsets are registered as official charset |
17052 | 4980 (i.e. do not have extended leading-codes). Characters of other |
4981 charsets are produced without any encoding. If SJIS_P is 1, encode | |
4982 SJIS text, else encode BIG5 text. */ | |
4983 | |
88365 | 4984 static int |
109126
aec1143e8d85
Convert (most) functions in src to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109100
diff
changeset
|
4985 encode_coding_sjis (struct coding_system *coding) |
17052 | 4986 { |
88365 | 4987 int multibytep = coding->dst_multibyte; |
4988 int *charbuf = coding->charbuf; | |
4989 int *charbuf_end = charbuf + coding->charbuf_used; | |
4990 unsigned char *dst = coding->destination + coding->produced; | |
4991 unsigned char *dst_end = coding->destination + coding->dst_bytes; | |
4992 int safe_room = 4; | |
4993 int produced_chars = 0; | |
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4994 Lisp_Object attrs, charset_list, val; |
88365 | 4995 int ascii_compatible; |
4996 struct charset *charset_roman, *charset_kanji, *charset_kana; | |
89764
e3d26232ab78
(decode_coding_sjis): Handle 4th charset (typically JISX0212).
Kenichi Handa <handa@m17n.org>
parents:
89759
diff
changeset
|
4997 struct charset *charset_kanji2; |
88365 | 4998 int c; |
4999 | |
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5000 CODING_GET_INFO (coding, attrs, charset_list); |
88365 | 5001 val = charset_list; |
5002 charset_roman = CHARSET_FROM_ID (XINT (XCAR (val))), val = XCDR (val); | |
5003 charset_kana = CHARSET_FROM_ID (XINT (XCAR (val))), val = XCDR (val); | |
89764
e3d26232ab78
(decode_coding_sjis): Handle 4th charset (typically JISX0212).
Kenichi Handa <handa@m17n.org>
parents:
89759
diff
changeset
|
5004 charset_kanji = CHARSET_FROM_ID (XINT (XCAR (val))), val = XCDR (val); |
e3d26232ab78
(decode_coding_sjis): Handle 4th charset (typically JISX0212).
Kenichi Handa <handa@m17n.org>
parents:
89759
diff
changeset
|
5005 charset_kanji2 = NILP (val) ? NULL : CHARSET_FROM_ID (XINT (XCAR (val))); |
88365 | 5006 |
5007 ascii_compatible = ! NILP (CODING_ATTR_ASCII_COMPAT (attrs)); | |
5008 | |
5009 while (charbuf < charbuf_end) | |
5010 { | |
5011 ASSURE_DESTINATION (safe_room); | |
5012 c = *charbuf++; | |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5013 /* Now encode the character C. */ |
88365 | 5014 if (ASCII_CHAR_P (c) && ascii_compatible) |
5015 EMIT_ONE_ASCII_BYTE (c); | |
88690
7f284ac55b07
(encode_coding_emacs_mule): Pay attention to raw-8-bit chars.
Kenichi Handa <handa@m17n.org>
parents:
88681
diff
changeset
|
5016 else if (CHAR_BYTE8_P (c)) |
7f284ac55b07
(encode_coding_emacs_mule): Pay attention to raw-8-bit chars.
Kenichi Handa <handa@m17n.org>
parents:
88681
diff
changeset
|
5017 { |
7f284ac55b07
(encode_coding_emacs_mule): Pay attention to raw-8-bit chars.
Kenichi Handa <handa@m17n.org>
parents:
88681
diff
changeset
|
5018 c = CHAR_TO_BYTE8 (c); |
7f284ac55b07
(encode_coding_emacs_mule): Pay attention to raw-8-bit chars.
Kenichi Handa <handa@m17n.org>
parents:
88681
diff
changeset
|
5019 EMIT_ONE_BYTE (c); |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5020 } |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5021 else |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5022 { |
88365 | 5023 unsigned code; |
5024 struct charset *charset = char_charset (c, charset_list, &code); | |
5025 | |
5026 if (!charset) | |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5027 { |
88573
133bf7ab1bad
(encode_coding_iso_2022): If coding requires safe
Kenichi Handa <handa@m17n.org>
parents:
88544
diff
changeset
|
5028 if (coding->mode & CODING_MODE_SAFE_ENCODING) |
133bf7ab1bad
(encode_coding_iso_2022): If coding requires safe
Kenichi Handa <handa@m17n.org>
parents:
88544
diff
changeset
|
5029 { |
133bf7ab1bad
(encode_coding_iso_2022): If coding requires safe
Kenichi Handa <handa@m17n.org>
parents:
88544
diff
changeset
|
5030 code = CODING_INHIBIT_CHARACTER_SUBSTITUTION; |
133bf7ab1bad
(encode_coding_iso_2022): If coding requires safe
Kenichi Handa <handa@m17n.org>
parents:
88544
diff
changeset
|
5031 charset = CHARSET_FROM_ID (charset_ascii); |
133bf7ab1bad
(encode_coding_iso_2022): If coding requires safe
Kenichi Handa <handa@m17n.org>
parents:
88544
diff
changeset
|
5032 } |
133bf7ab1bad
(encode_coding_iso_2022): If coding requires safe
Kenichi Handa <handa@m17n.org>
parents:
88544
diff
changeset
|
5033 else |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5034 { |
88573
133bf7ab1bad
(encode_coding_iso_2022): If coding requires safe
Kenichi Handa <handa@m17n.org>
parents:
88544
diff
changeset
|
5035 c = coding->default_char; |
133bf7ab1bad
(encode_coding_iso_2022): If coding requires safe
Kenichi Handa <handa@m17n.org>
parents:
88544
diff
changeset
|
5036 charset = char_charset (c, charset_list, &code); |
133bf7ab1bad
(encode_coding_iso_2022): If coding requires safe
Kenichi Handa <handa@m17n.org>
parents:
88544
diff
changeset
|
5037 } |
88365 | 5038 } |
5039 if (code == CHARSET_INVALID_CODE (charset)) | |
5040 abort (); | |
5041 if (charset == charset_kanji) | |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5042 { |
88365 | 5043 int c1, c2; |
5044 JIS_TO_SJIS (code); | |
5045 c1 = code >> 8, c2 = code & 0xFF; | |
5046 EMIT_TWO_BYTES (c1, c2); | |
5047 } | |
5048 else if (charset == charset_kana) | |
5049 EMIT_ONE_BYTE (code | 0x80); | |
89764
e3d26232ab78
(decode_coding_sjis): Handle 4th charset (typically JISX0212).
Kenichi Handa <handa@m17n.org>
parents:
89759
diff
changeset
|
5050 else if (charset_kanji2 && charset == charset_kanji2) |
e3d26232ab78
(decode_coding_sjis): Handle 4th charset (typically JISX0212).
Kenichi Handa <handa@m17n.org>
parents:
89759
diff
changeset
|
5051 { |
e3d26232ab78
(decode_coding_sjis): Handle 4th charset (typically JISX0212).
Kenichi Handa <handa@m17n.org>
parents:
89759
diff
changeset
|
5052 int c1, c2; |
e3d26232ab78
(decode_coding_sjis): Handle 4th charset (typically JISX0212).
Kenichi Handa <handa@m17n.org>
parents:
89759
diff
changeset
|
5053 |
e3d26232ab78
(decode_coding_sjis): Handle 4th charset (typically JISX0212).
Kenichi Handa <handa@m17n.org>
parents:
89759
diff
changeset
|
5054 c1 = code >> 8; |
103762
e72df94a89ca
(detect_coding_sjis): Handle shift_jis-2004 correctly.
Kenichi Handa <handa@m17n.org>
parents:
103655
diff
changeset
|
5055 if (c1 == 0x21 || (c1 >= 0x23 && c1 <= 0x25) |
e72df94a89ca
(detect_coding_sjis): Handle shift_jis-2004 correctly.
Kenichi Handa <handa@m17n.org>
parents:
103655
diff
changeset
|
5056 || c1 == 0x28 |
89764
e3d26232ab78
(decode_coding_sjis): Handle 4th charset (typically JISX0212).
Kenichi Handa <handa@m17n.org>
parents:
89759
diff
changeset
|
5057 || (c1 >= 0x2C && c1 <= 0x2F) || c1 >= 0x6E) |
e3d26232ab78
(decode_coding_sjis): Handle 4th charset (typically JISX0212).
Kenichi Handa <handa@m17n.org>
parents:
89759
diff
changeset
|
5058 { |
e3d26232ab78
(decode_coding_sjis): Handle 4th charset (typically JISX0212).
Kenichi Handa <handa@m17n.org>
parents:
89759
diff
changeset
|
5059 JIS_TO_SJIS2 (code); |
e3d26232ab78
(decode_coding_sjis): Handle 4th charset (typically JISX0212).
Kenichi Handa <handa@m17n.org>
parents:
89759
diff
changeset
|
5060 c1 = code >> 8, c2 = code & 0xFF; |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5061 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
|
5062 } |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5063 else |
89764
e3d26232ab78
(decode_coding_sjis): Handle 4th charset (typically JISX0212).
Kenichi Handa <handa@m17n.org>
parents:
89759
diff
changeset
|
5064 EMIT_ONE_ASCII_BYTE (code & 0x7F); |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5065 } |
17052 | 5066 else |
88365 | 5067 EMIT_ONE_ASCII_BYTE (code & 0x7F); |
5068 } | |
5069 } | |
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
5070 record_conversion_result (coding, CODING_RESULT_SUCCESS); |
88365 | 5071 coding->produced_char += produced_chars; |
5072 coding->produced = dst - coding->destination; | |
5073 return 0; | |
5074 } | |
5075 | |
5076 static int | |
109126
aec1143e8d85
Convert (most) functions in src to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109100
diff
changeset
|
5077 encode_coding_big5 (struct coding_system *coding) |
88365 | 5078 { |
5079 int multibytep = coding->dst_multibyte; | |
5080 int *charbuf = coding->charbuf; | |
5081 int *charbuf_end = charbuf + coding->charbuf_used; | |
5082 unsigned char *dst = coding->destination + coding->produced; | |
5083 unsigned char *dst_end = coding->destination + coding->dst_bytes; | |
5084 int safe_room = 4; | |
5085 int produced_chars = 0; | |
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5086 Lisp_Object attrs, charset_list, val; |
88365 | 5087 int ascii_compatible; |
5088 struct charset *charset_roman, *charset_big5; | |
5089 int c; | |
5090 | |
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5091 CODING_GET_INFO (coding, attrs, charset_list); |
88365 | 5092 val = charset_list; |
5093 charset_roman = CHARSET_FROM_ID (XINT (XCAR (val))), val = XCDR (val); | |
5094 charset_big5 = CHARSET_FROM_ID (XINT (XCAR (val))); | |
5095 ascii_compatible = ! NILP (CODING_ATTR_ASCII_COMPAT (attrs)); | |
5096 | |
5097 while (charbuf < charbuf_end) | |
5098 { | |
5099 ASSURE_DESTINATION (safe_room); | |
5100 c = *charbuf++; | |
5101 /* Now encode the character C. */ | |
5102 if (ASCII_CHAR_P (c) && ascii_compatible) | |
5103 EMIT_ONE_ASCII_BYTE (c); | |
88690
7f284ac55b07
(encode_coding_emacs_mule): Pay attention to raw-8-bit chars.
Kenichi Handa <handa@m17n.org>
parents:
88681
diff
changeset
|
5104 else if (CHAR_BYTE8_P (c)) |
7f284ac55b07
(encode_coding_emacs_mule): Pay attention to raw-8-bit chars.
Kenichi Handa <handa@m17n.org>
parents:
88681
diff
changeset
|
5105 { |
7f284ac55b07
(encode_coding_emacs_mule): Pay attention to raw-8-bit chars.
Kenichi Handa <handa@m17n.org>
parents:
88681
diff
changeset
|
5106 c = CHAR_TO_BYTE8 (c); |
7f284ac55b07
(encode_coding_emacs_mule): Pay attention to raw-8-bit chars.
Kenichi Handa <handa@m17n.org>
parents:
88681
diff
changeset
|
5107 EMIT_ONE_BYTE (c); |
7f284ac55b07
(encode_coding_emacs_mule): Pay attention to raw-8-bit chars.
Kenichi Handa <handa@m17n.org>
parents:
88681
diff
changeset
|
5108 } |
88365 | 5109 else |
5110 { | |
5111 unsigned code; | |
5112 struct charset *charset = char_charset (c, charset_list, &code); | |
5113 | |
5114 if (! charset) | |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5115 { |
88573
133bf7ab1bad
(encode_coding_iso_2022): If coding requires safe
Kenichi Handa <handa@m17n.org>
parents:
88544
diff
changeset
|
5116 if (coding->mode & CODING_MODE_SAFE_ENCODING) |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5117 { |
88573
133bf7ab1bad
(encode_coding_iso_2022): If coding requires safe
Kenichi Handa <handa@m17n.org>
parents:
88544
diff
changeset
|
5118 code = CODING_INHIBIT_CHARACTER_SUBSTITUTION; |
133bf7ab1bad
(encode_coding_iso_2022): If coding requires safe
Kenichi Handa <handa@m17n.org>
parents:
88544
diff
changeset
|
5119 charset = CHARSET_FROM_ID (charset_ascii); |
51140
94d903190cee
(ENCODE_UNSAFE_CHARACTER): Adjusted for the name change
Kenichi Handa <handa@m17n.org>
parents:
51090
diff
changeset
|
5120 } |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5121 else |
88573
133bf7ab1bad
(encode_coding_iso_2022): If coding requires safe
Kenichi Handa <handa@m17n.org>
parents:
88544
diff
changeset
|
5122 { |
133bf7ab1bad
(encode_coding_iso_2022): If coding requires safe
Kenichi Handa <handa@m17n.org>
parents:
88544
diff
changeset
|
5123 c = coding->default_char; |
133bf7ab1bad
(encode_coding_iso_2022): If coding requires safe
Kenichi Handa <handa@m17n.org>
parents:
88544
diff
changeset
|
5124 charset = char_charset (c, charset_list, &code); |
133bf7ab1bad
(encode_coding_iso_2022): If coding requires safe
Kenichi Handa <handa@m17n.org>
parents:
88544
diff
changeset
|
5125 } |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5126 } |
88365 | 5127 if (code == CHARSET_INVALID_CODE (charset)) |
5128 abort (); | |
5129 if (charset == charset_big5) | |
5130 { | |
5131 int c1, c2; | |
5132 | |
5133 c1 = code >> 8, c2 = code & 0xFF; | |
5134 EMIT_TWO_BYTES (c1, c2); | |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5135 } |
17052 | 5136 else |
88365 | 5137 EMIT_ONE_ASCII_BYTE (code & 0x7F); |
17052 | 5138 } |
88365 | 5139 } |
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
5140 record_conversion_result (coding, CODING_RESULT_SUCCESS); |
88365 | 5141 coding->produced_char += produced_chars; |
5142 coding->produced = dst - coding->destination; | |
5143 return 0; | |
17052 | 5144 } |
5145 | |
5146 | |
88365 | 5147 /*** 10. CCL handlers ***/ |
22874
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
5148 |
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
5149 /* See the above "GENERAL NOTES on `detect_coding_XXX ()' functions". |
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
5150 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
|
5151 encoder/decoder are written in CCL program. If it is, return |
88365 | 5152 CATEGORY_MASK_CCL, else return 0. */ |
22874
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
5153 |
34531
37f85e931855
(ONE_MORE_BYTE_CHECK_MULTIBYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34197
diff
changeset
|
5154 static int |
109159
3e9fdeb960d1
* coding.c, sysdep.c: Convert some more functions to standard C.
Juanma Barranquero <lekktu@gmail.com>
parents:
109158
diff
changeset
|
5155 detect_coding_ccl (struct coding_system *coding, |
3e9fdeb960d1
* coding.c, sysdep.c: Convert some more functions to standard C.
Juanma Barranquero <lekktu@gmail.com>
parents:
109158
diff
changeset
|
5156 struct coding_detection_info *detect_info) |
88365 | 5157 { |
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
5158 const unsigned char *src = coding->source, *src_base; |
89483 | 5159 const unsigned char *src_end = coding->source + coding->src_bytes; |
88365 | 5160 int multibytep = coding->src_multibyte; |
5161 int consumed_chars = 0; | |
5162 int found = 0; | |
89848
3edfa038a435
(detect_coding_emacs_mule): Fix counting of encoded
Kenichi Handa <handa@m17n.org>
parents:
89842
diff
changeset
|
5163 unsigned char *valids; |
88365 | 5164 int head_ascii = coding->head_ascii; |
5165 Lisp_Object attrs; | |
5166 | |
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
5167 detect_info->checked |= CATEGORY_MASK_CCL; |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
5168 |
88365 | 5169 coding = &coding_categories[coding_category_ccl]; |
89848
3edfa038a435
(detect_coding_emacs_mule): Fix counting of encoded
Kenichi Handa <handa@m17n.org>
parents:
89842
diff
changeset
|
5170 valids = CODING_CCL_VALIDS (coding); |
88365 | 5171 attrs = CODING_ID_ATTRS (coding->id); |
5172 if (! NILP (CODING_ATTR_ASCII_COMPAT (attrs))) | |
5173 src += head_ascii; | |
5174 | |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5175 while (1) |
22874
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
5176 { |
88365 | 5177 int c; |
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
5178 |
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
5179 src_base = src; |
88365 | 5180 ONE_MORE_BYTE (c); |
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
5181 if (c < 0 || ! valids[c]) |
88365 | 5182 break; |
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
5183 if ((valids[c] > 1)) |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
5184 found = CATEGORY_MASK_CCL; |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
5185 } |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
5186 detect_info->rejected |= CATEGORY_MASK_CCL; |
88365 | 5187 return 0; |
5188 | |
5189 no_more_source: | |
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
5190 detect_info->found |= found; |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
5191 return 1; |
88365 | 5192 } |
5193 | |
5194 static void | |
109126
aec1143e8d85
Convert (most) functions in src to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109100
diff
changeset
|
5195 decode_coding_ccl (struct coding_system *coding) |
22874
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
5196 { |
88876
af9012fdad56
(LEADING_CODE_PRIVATE_11, LEADING_CODE_PRIVATE_12,
Kenichi Handa <handa@m17n.org>
parents:
88862
diff
changeset
|
5197 const unsigned char *src = coding->source + coding->consumed; |
89483 | 5198 const unsigned char *src_end = coding->source + coding->src_bytes; |
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
5199 int *charbuf = coding->charbuf + coding->charbuf_used; |
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
5200 int *charbuf_end = coding->charbuf + coding->charbuf_size; |
88365 | 5201 int consumed_chars = 0; |
5202 int multibytep = coding->src_multibyte; | |
107171
dfc03b454687
Fix the ccl decoder for the case that the output buffer is fullfilled.
Kenichi Handa <handa@m17n.org>
parents:
106918
diff
changeset
|
5203 struct ccl_program *ccl = &coding->spec.ccl->ccl; |
88365 | 5204 int source_charbuf[1024]; |
107506
cd151730b160
coding.c (decode_coding_ccl): Fix previous change for the multibyte case.
Kenichi Handa <handa@m17n.org>
parents:
107323
diff
changeset
|
5205 int source_byteidx[1025]; |
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5206 Lisp_Object attrs, charset_list; |
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5207 |
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5208 CODING_GET_INFO (coding, attrs, charset_list); |
107171
dfc03b454687
Fix the ccl decoder for the case that the output buffer is fullfilled.
Kenichi Handa <handa@m17n.org>
parents:
106918
diff
changeset
|
5209 |
dfc03b454687
Fix the ccl decoder for the case that the output buffer is fullfilled.
Kenichi Handa <handa@m17n.org>
parents:
106918
diff
changeset
|
5210 while (1) |
88365 | 5211 { |
88876
af9012fdad56
(LEADING_CODE_PRIVATE_11, LEADING_CODE_PRIVATE_12,
Kenichi Handa <handa@m17n.org>
parents:
88862
diff
changeset
|
5212 const unsigned char *p = src; |
88365 | 5213 int i = 0; |
5214 | |
5215 if (multibytep) | |
107506
cd151730b160
coding.c (decode_coding_ccl): Fix previous change for the multibyte case.
Kenichi Handa <handa@m17n.org>
parents:
107323
diff
changeset
|
5216 { |
cd151730b160
coding.c (decode_coding_ccl): Fix previous change for the multibyte case.
Kenichi Handa <handa@m17n.org>
parents:
107323
diff
changeset
|
5217 while (i < 1024 && p < src_end) |
cd151730b160
coding.c (decode_coding_ccl): Fix previous change for the multibyte case.
Kenichi Handa <handa@m17n.org>
parents:
107323
diff
changeset
|
5218 { |
cd151730b160
coding.c (decode_coding_ccl): Fix previous change for the multibyte case.
Kenichi Handa <handa@m17n.org>
parents:
107323
diff
changeset
|
5219 source_byteidx[i] = p - src; |
cd151730b160
coding.c (decode_coding_ccl): Fix previous change for the multibyte case.
Kenichi Handa <handa@m17n.org>
parents:
107323
diff
changeset
|
5220 source_charbuf[i++] = STRING_CHAR_ADVANCE (p); |
cd151730b160
coding.c (decode_coding_ccl): Fix previous change for the multibyte case.
Kenichi Handa <handa@m17n.org>
parents:
107323
diff
changeset
|
5221 } |
cd151730b160
coding.c (decode_coding_ccl): Fix previous change for the multibyte case.
Kenichi Handa <handa@m17n.org>
parents:
107323
diff
changeset
|
5222 source_byteidx[i] = p - src; |
cd151730b160
coding.c (decode_coding_ccl): Fix previous change for the multibyte case.
Kenichi Handa <handa@m17n.org>
parents:
107323
diff
changeset
|
5223 } |
88365 | 5224 else |
5225 while (i < 1024 && p < src_end) | |
5226 source_charbuf[i++] = *p++; | |
89483 | 5227 |
88365 | 5228 if (p == src_end && coding->mode & CODING_MODE_LAST_BLOCK) |
107171
dfc03b454687
Fix the ccl decoder for the case that the output buffer is fullfilled.
Kenichi Handa <handa@m17n.org>
parents:
106918
diff
changeset
|
5229 ccl->last_block = 1; |
dfc03b454687
Fix the ccl decoder for the case that the output buffer is fullfilled.
Kenichi Handa <handa@m17n.org>
parents:
106918
diff
changeset
|
5230 ccl_driver (ccl, source_charbuf, charbuf, i, charbuf_end - charbuf, |
dfc03b454687
Fix the ccl decoder for the case that the output buffer is fullfilled.
Kenichi Handa <handa@m17n.org>
parents:
106918
diff
changeset
|
5231 charset_list); |
dfc03b454687
Fix the ccl decoder for the case that the output buffer is fullfilled.
Kenichi Handa <handa@m17n.org>
parents:
106918
diff
changeset
|
5232 charbuf += ccl->produced; |
107506
cd151730b160
coding.c (decode_coding_ccl): Fix previous change for the multibyte case.
Kenichi Handa <handa@m17n.org>
parents:
107323
diff
changeset
|
5233 if (multibytep) |
107171
dfc03b454687
Fix the ccl decoder for the case that the output buffer is fullfilled.
Kenichi Handa <handa@m17n.org>
parents:
106918
diff
changeset
|
5234 src += source_byteidx[ccl->consumed]; |
88365 | 5235 else |
107171
dfc03b454687
Fix the ccl decoder for the case that the output buffer is fullfilled.
Kenichi Handa <handa@m17n.org>
parents:
106918
diff
changeset
|
5236 src += ccl->consumed; |
dfc03b454687
Fix the ccl decoder for the case that the output buffer is fullfilled.
Kenichi Handa <handa@m17n.org>
parents:
106918
diff
changeset
|
5237 consumed_chars += ccl->consumed; |
dfc03b454687
Fix the ccl decoder for the case that the output buffer is fullfilled.
Kenichi Handa <handa@m17n.org>
parents:
106918
diff
changeset
|
5238 if (p == src_end || ccl->status != CCL_STAT_SUSPEND_BY_SRC) |
88365 | 5239 break; |
5240 } | |
5241 | |
107171
dfc03b454687
Fix the ccl decoder for the case that the output buffer is fullfilled.
Kenichi Handa <handa@m17n.org>
parents:
106918
diff
changeset
|
5242 switch (ccl->status) |
88365 | 5243 { |
5244 case CCL_STAT_SUSPEND_BY_SRC: | |
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
5245 record_conversion_result (coding, CODING_RESULT_INSUFFICIENT_SRC); |
88365 | 5246 break; |
5247 case CCL_STAT_SUSPEND_BY_DST: | |
107171
dfc03b454687
Fix the ccl decoder for the case that the output buffer is fullfilled.
Kenichi Handa <handa@m17n.org>
parents:
106918
diff
changeset
|
5248 record_conversion_result (coding, CODING_RESULT_INSUFFICIENT_DST); |
88365 | 5249 break; |
5250 case CCL_STAT_QUIT: | |
5251 case CCL_STAT_INVALID_CMD: | |
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
5252 record_conversion_result (coding, CODING_RESULT_INTERRUPT); |
88365 | 5253 break; |
5254 default: | |
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
5255 record_conversion_result (coding, CODING_RESULT_SUCCESS); |
88365 | 5256 break; |
5257 } | |
5258 coding->consumed_char += consumed_chars; | |
5259 coding->consumed = src - coding->source; | |
5260 coding->charbuf_used = charbuf - coding->charbuf; | |
22874
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
5261 } |
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
5262 |
88365 | 5263 static int |
109126
aec1143e8d85
Convert (most) functions in src to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109100
diff
changeset
|
5264 encode_coding_ccl (struct coding_system *coding) |
88365 | 5265 { |
107507
8960853cf85d
Fix the ccl encoder for the case that the output buffer is fullfilled.
Kenichi Handa <handa@m17n.org>
parents:
107506
diff
changeset
|
5266 struct ccl_program *ccl = &coding->spec.ccl->ccl; |
88365 | 5267 int multibytep = coding->dst_multibyte; |
5268 int *charbuf = coding->charbuf; | |
5269 int *charbuf_end = charbuf + coding->charbuf_used; | |
5270 unsigned char *dst = coding->destination + coding->produced; | |
5271 unsigned char *dst_end = coding->destination + coding->dst_bytes; | |
5272 int destination_charbuf[1024]; | |
5273 int i, produced_chars = 0; | |
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5274 Lisp_Object attrs, charset_list; |
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5275 |
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5276 CODING_GET_INFO (coding, attrs, charset_list); |
107507
8960853cf85d
Fix the ccl encoder for the case that the output buffer is fullfilled.
Kenichi Handa <handa@m17n.org>
parents:
107506
diff
changeset
|
5277 if (coding->consumed_char == coding->src_chars |
8960853cf85d
Fix the ccl encoder for the case that the output buffer is fullfilled.
Kenichi Handa <handa@m17n.org>
parents:
107506
diff
changeset
|
5278 && coding->mode & CODING_MODE_LAST_BLOCK) |
8960853cf85d
Fix the ccl encoder for the case that the output buffer is fullfilled.
Kenichi Handa <handa@m17n.org>
parents:
107506
diff
changeset
|
5279 ccl->last_block = 1; |
88365 | 5280 |
90346
bba59a8cdae0
(encode_coding_ccl): Allocate destination dynamically
Kenichi Handa <handa@m17n.org>
parents:
90336
diff
changeset
|
5281 while (charbuf < charbuf_end) |
bba59a8cdae0
(encode_coding_ccl): Allocate destination dynamically
Kenichi Handa <handa@m17n.org>
parents:
90336
diff
changeset
|
5282 { |
107507
8960853cf85d
Fix the ccl encoder for the case that the output buffer is fullfilled.
Kenichi Handa <handa@m17n.org>
parents:
107506
diff
changeset
|
5283 ccl_driver (ccl, charbuf, destination_charbuf, |
90346
bba59a8cdae0
(encode_coding_ccl): Allocate destination dynamically
Kenichi Handa <handa@m17n.org>
parents:
90336
diff
changeset
|
5284 charbuf_end - charbuf, 1024, charset_list); |
88365 | 5285 if (multibytep) |
90346
bba59a8cdae0
(encode_coding_ccl): Allocate destination dynamically
Kenichi Handa <handa@m17n.org>
parents:
90336
diff
changeset
|
5286 { |
107507
8960853cf85d
Fix the ccl encoder for the case that the output buffer is fullfilled.
Kenichi Handa <handa@m17n.org>
parents:
107506
diff
changeset
|
5287 ASSURE_DESTINATION (ccl->produced * 2); |
8960853cf85d
Fix the ccl encoder for the case that the output buffer is fullfilled.
Kenichi Handa <handa@m17n.org>
parents:
107506
diff
changeset
|
5288 for (i = 0; i < ccl->produced; i++) |
90346
bba59a8cdae0
(encode_coding_ccl): Allocate destination dynamically
Kenichi Handa <handa@m17n.org>
parents:
90336
diff
changeset
|
5289 EMIT_ONE_BYTE (destination_charbuf[i] & 0xFF); |
bba59a8cdae0
(encode_coding_ccl): Allocate destination dynamically
Kenichi Handa <handa@m17n.org>
parents:
90336
diff
changeset
|
5290 } |
88365 | 5291 else |
5292 { | |
107507
8960853cf85d
Fix the ccl encoder for the case that the output buffer is fullfilled.
Kenichi Handa <handa@m17n.org>
parents:
107506
diff
changeset
|
5293 ASSURE_DESTINATION (ccl->produced); |
8960853cf85d
Fix the ccl encoder for the case that the output buffer is fullfilled.
Kenichi Handa <handa@m17n.org>
parents:
107506
diff
changeset
|
5294 for (i = 0; i < ccl->produced; i++) |
88365 | 5295 *dst++ = destination_charbuf[i] & 0xFF; |
107507
8960853cf85d
Fix the ccl encoder for the case that the output buffer is fullfilled.
Kenichi Handa <handa@m17n.org>
parents:
107506
diff
changeset
|
5296 produced_chars += ccl->produced; |
8960853cf85d
Fix the ccl encoder for the case that the output buffer is fullfilled.
Kenichi Handa <handa@m17n.org>
parents:
107506
diff
changeset
|
5297 } |
8960853cf85d
Fix the ccl encoder for the case that the output buffer is fullfilled.
Kenichi Handa <handa@m17n.org>
parents:
107506
diff
changeset
|
5298 charbuf += ccl->consumed; |
8960853cf85d
Fix the ccl encoder for the case that the output buffer is fullfilled.
Kenichi Handa <handa@m17n.org>
parents:
107506
diff
changeset
|
5299 if (ccl->status == CCL_STAT_QUIT |
8960853cf85d
Fix the ccl encoder for the case that the output buffer is fullfilled.
Kenichi Handa <handa@m17n.org>
parents:
107506
diff
changeset
|
5300 || ccl->status == CCL_STAT_INVALID_CMD) |
90346
bba59a8cdae0
(encode_coding_ccl): Allocate destination dynamically
Kenichi Handa <handa@m17n.org>
parents:
90336
diff
changeset
|
5301 break; |
88365 | 5302 } |
5303 | |
107507
8960853cf85d
Fix the ccl encoder for the case that the output buffer is fullfilled.
Kenichi Handa <handa@m17n.org>
parents:
107506
diff
changeset
|
5304 switch (ccl->status) |
88365 | 5305 { |
5306 case CCL_STAT_SUSPEND_BY_SRC: | |
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
5307 record_conversion_result (coding, CODING_RESULT_INSUFFICIENT_SRC); |
88365 | 5308 break; |
5309 case CCL_STAT_SUSPEND_BY_DST: | |
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
5310 record_conversion_result (coding, CODING_RESULT_INSUFFICIENT_DST); |
88365 | 5311 break; |
5312 case CCL_STAT_QUIT: | |
5313 case CCL_STAT_INVALID_CMD: | |
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
5314 record_conversion_result (coding, CODING_RESULT_INTERRUPT); |
88365 | 5315 break; |
5316 default: | |
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
5317 record_conversion_result (coding, CODING_RESULT_SUCCESS); |
88365 | 5318 break; |
5319 } | |
5320 | |
5321 coding->produced_char += produced_chars; | |
5322 coding->produced = dst - coding->destination; | |
5323 return 0; | |
5324 } | |
5325 | |
22874
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
5326 |
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
5327 |
88365 | 5328 /*** 10, 11. no-conversion handlers ***/ |
17052 | 5329 |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5330 /* 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
|
5331 |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5332 static void |
109126
aec1143e8d85
Convert (most) functions in src to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109100
diff
changeset
|
5333 decode_coding_raw_text (struct coding_system *coding) |
17052 | 5334 { |
102334
7baaea85626e
(decode_coding_utf_8, decode_coding_utf_16, decode_coding_emacs_mule,
Eli Zaretskii <eliz@gnu.org>
parents:
102327
diff
changeset
|
5335 int eol_crlf = |
7baaea85626e
(decode_coding_utf_8, decode_coding_utf_16, decode_coding_emacs_mule,
Eli Zaretskii <eliz@gnu.org>
parents:
102327
diff
changeset
|
5336 !inhibit_eol_conversion && EQ (CODING_ID_EOL_TYPE (coding->id), Qdos); |
92399
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
5337 |
88365 | 5338 coding->chars_at_source = 1; |
92399
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
5339 coding->consumed_char = coding->src_chars; |
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
5340 coding->consumed = coding->src_bytes; |
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
5341 if (eol_crlf && coding->source[coding->src_bytes - 1] == '\r') |
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
5342 { |
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
5343 coding->consumed_char--; |
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
5344 coding->consumed--; |
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
5345 record_conversion_result (coding, CODING_RESULT_INSUFFICIENT_SRC); |
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
5346 } |
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
5347 else |
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
5348 record_conversion_result (coding, CODING_RESULT_SUCCESS); |
88365 | 5349 } |
5350 | |
5351 static int | |
109126
aec1143e8d85
Convert (most) functions in src to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109100
diff
changeset
|
5352 encode_coding_raw_text (struct coding_system *coding) |
88365 | 5353 { |
5354 int multibytep = coding->dst_multibyte; | |
5355 int *charbuf = coding->charbuf; | |
5356 int *charbuf_end = coding->charbuf + coding->charbuf_used; | |
5357 unsigned char *dst = coding->destination + coding->produced; | |
5358 unsigned char *dst_end = coding->destination + coding->dst_bytes; | |
95345
0350e5efb8f7
(encode_coding_raw_text): Fix last change.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
95344
diff
changeset
|
5359 int produced_chars = 0; |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5360 int c; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5361 |
88365 | 5362 if (multibytep) |
5363 { | |
5364 int safe_room = MAX_MULTIBYTE_LENGTH * 2; | |
5365 | |
5366 if (coding->src_multibyte) | |
5367 while (charbuf < charbuf_end) | |
5368 { | |
5369 ASSURE_DESTINATION (safe_room); | |
5370 c = *charbuf++; | |
5371 if (ASCII_CHAR_P (c)) | |
5372 EMIT_ONE_ASCII_BYTE (c); | |
5373 else if (CHAR_BYTE8_P (c)) | |
5374 { | |
5375 c = CHAR_TO_BYTE8 (c); | |
5376 EMIT_ONE_BYTE (c); | |
5377 } | |
5378 else | |
5379 { | |
5380 unsigned char str[MAX_MULTIBYTE_LENGTH], *p0 = str, *p1 = str; | |
5381 | |
5382 CHAR_STRING_ADVANCE (c, p1); | |
5383 while (p0 < p1) | |
88950
ad258ee59fbb
* coding.c (make_conversion_work_buffer): Adjusted for the change
Kenichi Handa <handa@m17n.org>
parents:
88936
diff
changeset
|
5384 { |
ad258ee59fbb
* coding.c (make_conversion_work_buffer): Adjusted for the change
Kenichi Handa <handa@m17n.org>
parents:
88936
diff
changeset
|
5385 EMIT_ONE_BYTE (*p0); |
ad258ee59fbb
* coding.c (make_conversion_work_buffer): Adjusted for the change
Kenichi Handa <handa@m17n.org>
parents:
88936
diff
changeset
|
5386 p0++; |
ad258ee59fbb
* coding.c (make_conversion_work_buffer): Adjusted for the change
Kenichi Handa <handa@m17n.org>
parents:
88936
diff
changeset
|
5387 } |
88365 | 5388 } |
5389 } | |
5390 else | |
5391 while (charbuf < charbuf_end) | |
5392 { | |
5393 ASSURE_DESTINATION (safe_room); | |
5394 c = *charbuf++; | |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5395 EMIT_ONE_BYTE (c); |
88365 | 5396 } |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5397 } |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5398 else |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5399 { |
88365 | 5400 if (coding->src_multibyte) |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5401 { |
88365 | 5402 int safe_room = MAX_MULTIBYTE_LENGTH; |
5403 | |
5404 while (charbuf < charbuf_end) | |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5405 { |
88365 | 5406 ASSURE_DESTINATION (safe_room); |
5407 c = *charbuf++; | |
5408 if (ASCII_CHAR_P (c)) | |
5409 *dst++ = c; | |
5410 else if (CHAR_BYTE8_P (c)) | |
5411 *dst++ = CHAR_TO_BYTE8 (c); | |
5412 else | |
5413 CHAR_STRING_ADVANCE (c, dst); | |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5414 } |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5415 } |
20931
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
5416 else |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5417 { |
88365 | 5418 ASSURE_DESTINATION (charbuf_end - charbuf); |
5419 while (charbuf < charbuf_end && dst < dst_end) | |
5420 *dst++ = *charbuf++; | |
89483 | 5421 } |
95353
96d35f50fe34
(encode_coding_raw_text): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
95345
diff
changeset
|
5422 produced_chars = dst - (coding->destination + coding->produced); |
88365 | 5423 } |
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
5424 record_conversion_result (coding, CODING_RESULT_SUCCESS); |
95345
0350e5efb8f7
(encode_coding_raw_text): Fix last change.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
95344
diff
changeset
|
5425 coding->produced_char += produced_chars; |
88365 | 5426 coding->produced = dst - coding->destination; |
5427 return 0; | |
5428 } | |
5429 | |
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
5430 /* See the above "GENERAL NOTES on `detect_coding_XXX ()' functions". |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
5431 Check if a text is encoded in a charset-based coding system. If it |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
5432 is, return 1, else return 0. */ |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
5433 |
88365 | 5434 static int |
109159
3e9fdeb960d1
* coding.c, sysdep.c: Convert some more functions to standard C.
Juanma Barranquero <lekktu@gmail.com>
parents:
109158
diff
changeset
|
5435 detect_coding_charset (struct coding_system *coding, |
3e9fdeb960d1
* coding.c, sysdep.c: Convert some more functions to standard C.
Juanma Barranquero <lekktu@gmail.com>
parents:
109158
diff
changeset
|
5436 struct coding_detection_info *detect_info) |
88365 | 5437 { |
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
5438 const unsigned char *src = coding->source, *src_base; |
89483 | 5439 const unsigned char *src_end = coding->source + coding->src_bytes; |
88365 | 5440 int multibytep = coding->src_multibyte; |
5441 int consumed_chars = 0; | |
98951
71becd1e9707
(detect_coding_charset): For iso-8859-* coding systems,
Kenichi Handa <handa@m17n.org>
parents:
98186
diff
changeset
|
5442 Lisp_Object attrs, valids, name; |
89225
32058afc72e2
(detect_coding_charset): If only ASCII bytes are found, return 0.
Kenichi Handa <handa@m17n.org>
parents:
89221
diff
changeset
|
5443 int found = 0; |
90651
23c1467f8640
(detect_coding_charset): Fix detection of multi-byte
Kenichi Handa <handa@m17n.org>
parents:
90599
diff
changeset
|
5444 int head_ascii = coding->head_ascii; |
98951
71becd1e9707
(detect_coding_charset): For iso-8859-* coding systems,
Kenichi Handa <handa@m17n.org>
parents:
98186
diff
changeset
|
5445 int check_latin_extra = 0; |
88365 | 5446 |
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
5447 detect_info->checked |= CATEGORY_MASK_CHARSET; |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
5448 |
88365 | 5449 coding = &coding_categories[coding_category_charset]; |
5450 attrs = CODING_ID_ATTRS (coding->id); | |
5451 valids = AREF (attrs, coding_attr_charset_valids); | |
98951
71becd1e9707
(detect_coding_charset): For iso-8859-* coding systems,
Kenichi Handa <handa@m17n.org>
parents:
98186
diff
changeset
|
5452 name = CODING_ID_NAME (coding->id); |
102327
a1f0d8fadbb1
(detect_coding_charset): Fix last change for non-latin charsets.
Jason Rumney <jasonr@gnu.org>
parents:
102325
diff
changeset
|
5453 if (strncmp ((char *) SDATA (SYMBOL_NAME (name)), |
a1f0d8fadbb1
(detect_coding_charset): Fix last change for non-latin charsets.
Jason Rumney <jasonr@gnu.org>
parents:
102325
diff
changeset
|
5454 "iso-8859-", sizeof ("iso-8859-") - 1) == 0 |
a1f0d8fadbb1
(detect_coding_charset): Fix last change for non-latin charsets.
Jason Rumney <jasonr@gnu.org>
parents:
102325
diff
changeset
|
5455 || strncmp ((char *) SDATA (SYMBOL_NAME (name)), |
a1f0d8fadbb1
(detect_coding_charset): Fix last change for non-latin charsets.
Jason Rumney <jasonr@gnu.org>
parents:
102325
diff
changeset
|
5456 "iso-latin-", sizeof ("iso-latin-") - 1) == 0) |
98951
71becd1e9707
(detect_coding_charset): For iso-8859-* coding systems,
Kenichi Handa <handa@m17n.org>
parents:
98186
diff
changeset
|
5457 check_latin_extra = 1; |
102327
a1f0d8fadbb1
(detect_coding_charset): Fix last change for non-latin charsets.
Jason Rumney <jasonr@gnu.org>
parents:
102325
diff
changeset
|
5458 |
88365 | 5459 if (! NILP (CODING_ATTR_ASCII_COMPAT (attrs))) |
90651
23c1467f8640
(detect_coding_charset): Fix detection of multi-byte
Kenichi Handa <handa@m17n.org>
parents:
90599
diff
changeset
|
5460 src += head_ascii; |
88365 | 5461 |
5462 while (1) | |
5463 { | |
5464 int c; | |
90651
23c1467f8640
(detect_coding_charset): Fix detection of multi-byte
Kenichi Handa <handa@m17n.org>
parents:
90599
diff
changeset
|
5465 Lisp_Object val; |
23c1467f8640
(detect_coding_charset): Fix detection of multi-byte
Kenichi Handa <handa@m17n.org>
parents:
90599
diff
changeset
|
5466 struct charset *charset; |
23c1467f8640
(detect_coding_charset): Fix detection of multi-byte
Kenichi Handa <handa@m17n.org>
parents:
90599
diff
changeset
|
5467 int dim, idx; |
88365 | 5468 |
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
5469 src_base = src; |
88365 | 5470 ONE_MORE_BYTE (c); |
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
5471 if (c < 0) |
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
5472 continue; |
90651
23c1467f8640
(detect_coding_charset): Fix detection of multi-byte
Kenichi Handa <handa@m17n.org>
parents:
90599
diff
changeset
|
5473 val = AREF (valids, c); |
23c1467f8640
(detect_coding_charset): Fix detection of multi-byte
Kenichi Handa <handa@m17n.org>
parents:
90599
diff
changeset
|
5474 if (NILP (val)) |
88365 | 5475 break; |
89225
32058afc72e2
(detect_coding_charset): If only ASCII bytes are found, return 0.
Kenichi Handa <handa@m17n.org>
parents:
89221
diff
changeset
|
5476 if (c >= 0x80) |
98951
71becd1e9707
(detect_coding_charset): For iso-8859-* coding systems,
Kenichi Handa <handa@m17n.org>
parents:
98186
diff
changeset
|
5477 { |
71becd1e9707
(detect_coding_charset): For iso-8859-* coding systems,
Kenichi Handa <handa@m17n.org>
parents:
98186
diff
changeset
|
5478 if (c < 0xA0 |
102327
a1f0d8fadbb1
(detect_coding_charset): Fix last change for non-latin charsets.
Jason Rumney <jasonr@gnu.org>
parents:
102325
diff
changeset
|
5479 && check_latin_extra |
a1f0d8fadbb1
(detect_coding_charset): Fix last change for non-latin charsets.
Jason Rumney <jasonr@gnu.org>
parents:
102325
diff
changeset
|
5480 && (!VECTORP (Vlatin_extra_code_table) |
102325
2c693a021d83
(detect_coding_charset): If not checking latin extra,
Jason Rumney <jasonr@gnu.org>
parents:
102320
diff
changeset
|
5481 || NILP (XVECTOR (Vlatin_extra_code_table)->contents[c]))) |
98951
71becd1e9707
(detect_coding_charset): For iso-8859-* coding systems,
Kenichi Handa <handa@m17n.org>
parents:
98186
diff
changeset
|
5482 break; |
71becd1e9707
(detect_coding_charset): For iso-8859-* coding systems,
Kenichi Handa <handa@m17n.org>
parents:
98186
diff
changeset
|
5483 found = CATEGORY_MASK_CHARSET; |
71becd1e9707
(detect_coding_charset): For iso-8859-* coding systems,
Kenichi Handa <handa@m17n.org>
parents:
98186
diff
changeset
|
5484 } |
90651
23c1467f8640
(detect_coding_charset): Fix detection of multi-byte
Kenichi Handa <handa@m17n.org>
parents:
90599
diff
changeset
|
5485 if (INTEGERP (val)) |
23c1467f8640
(detect_coding_charset): Fix detection of multi-byte
Kenichi Handa <handa@m17n.org>
parents:
90599
diff
changeset
|
5486 { |
23c1467f8640
(detect_coding_charset): Fix detection of multi-byte
Kenichi Handa <handa@m17n.org>
parents:
90599
diff
changeset
|
5487 charset = CHARSET_FROM_ID (XFASTINT (val)); |
23c1467f8640
(detect_coding_charset): Fix detection of multi-byte
Kenichi Handa <handa@m17n.org>
parents:
90599
diff
changeset
|
5488 dim = CHARSET_DIMENSION (charset); |
23c1467f8640
(detect_coding_charset): Fix detection of multi-byte
Kenichi Handa <handa@m17n.org>
parents:
90599
diff
changeset
|
5489 for (idx = 1; idx < dim; idx++) |
20931
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
5490 { |
90651
23c1467f8640
(detect_coding_charset): Fix detection of multi-byte
Kenichi Handa <handa@m17n.org>
parents:
90599
diff
changeset
|
5491 if (src == src_end) |
23c1467f8640
(detect_coding_charset): Fix detection of multi-byte
Kenichi Handa <handa@m17n.org>
parents:
90599
diff
changeset
|
5492 goto too_short; |
23c1467f8640
(detect_coding_charset): Fix detection of multi-byte
Kenichi Handa <handa@m17n.org>
parents:
90599
diff
changeset
|
5493 ONE_MORE_BYTE (c); |
93877
62d97ebb13a9
* coding.c (detect_coding_emacs_mule)
Michael Albinus <michael.albinus@gmx.de>
parents:
93595
diff
changeset
|
5494 if (c < charset->code_space[(dim - 1 - idx) * 2] |
90651
23c1467f8640
(detect_coding_charset): Fix detection of multi-byte
Kenichi Handa <handa@m17n.org>
parents:
90599
diff
changeset
|
5495 || c > charset->code_space[(dim - 1 - idx) * 2 + 1]) |
23c1467f8640
(detect_coding_charset): Fix detection of multi-byte
Kenichi Handa <handa@m17n.org>
parents:
90599
diff
changeset
|
5496 break; |
23c1467f8640
(detect_coding_charset): Fix detection of multi-byte
Kenichi Handa <handa@m17n.org>
parents:
90599
diff
changeset
|
5497 } |
23c1467f8640
(detect_coding_charset): Fix detection of multi-byte
Kenichi Handa <handa@m17n.org>
parents:
90599
diff
changeset
|
5498 if (idx < dim) |
23c1467f8640
(detect_coding_charset): Fix detection of multi-byte
Kenichi Handa <handa@m17n.org>
parents:
90599
diff
changeset
|
5499 break; |
23c1467f8640
(detect_coding_charset): Fix detection of multi-byte
Kenichi Handa <handa@m17n.org>
parents:
90599
diff
changeset
|
5500 } |
23c1467f8640
(detect_coding_charset): Fix detection of multi-byte
Kenichi Handa <handa@m17n.org>
parents:
90599
diff
changeset
|
5501 else |
23c1467f8640
(detect_coding_charset): Fix detection of multi-byte
Kenichi Handa <handa@m17n.org>
parents:
90599
diff
changeset
|
5502 { |
23c1467f8640
(detect_coding_charset): Fix detection of multi-byte
Kenichi Handa <handa@m17n.org>
parents:
90599
diff
changeset
|
5503 idx = 1; |
23c1467f8640
(detect_coding_charset): Fix detection of multi-byte
Kenichi Handa <handa@m17n.org>
parents:
90599
diff
changeset
|
5504 for (; CONSP (val); val = XCDR (val)) |
23c1467f8640
(detect_coding_charset): Fix detection of multi-byte
Kenichi Handa <handa@m17n.org>
parents:
90599
diff
changeset
|
5505 { |
23c1467f8640
(detect_coding_charset): Fix detection of multi-byte
Kenichi Handa <handa@m17n.org>
parents:
90599
diff
changeset
|
5506 charset = CHARSET_FROM_ID (XFASTINT (XCAR (val))); |
23c1467f8640
(detect_coding_charset): Fix detection of multi-byte
Kenichi Handa <handa@m17n.org>
parents:
90599
diff
changeset
|
5507 dim = CHARSET_DIMENSION (charset); |
23c1467f8640
(detect_coding_charset): Fix detection of multi-byte
Kenichi Handa <handa@m17n.org>
parents:
90599
diff
changeset
|
5508 while (idx < dim) |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5509 { |
90651
23c1467f8640
(detect_coding_charset): Fix detection of multi-byte
Kenichi Handa <handa@m17n.org>
parents:
90599
diff
changeset
|
5510 if (src == src_end) |
23c1467f8640
(detect_coding_charset): Fix detection of multi-byte
Kenichi Handa <handa@m17n.org>
parents:
90599
diff
changeset
|
5511 goto too_short; |
23c1467f8640
(detect_coding_charset): Fix detection of multi-byte
Kenichi Handa <handa@m17n.org>
parents:
90599
diff
changeset
|
5512 ONE_MORE_BYTE (c); |
23c1467f8640
(detect_coding_charset): Fix detection of multi-byte
Kenichi Handa <handa@m17n.org>
parents:
90599
diff
changeset
|
5513 if (c < charset->code_space[(dim - 1 - idx) * 4] |
23c1467f8640
(detect_coding_charset): Fix detection of multi-byte
Kenichi Handa <handa@m17n.org>
parents:
90599
diff
changeset
|
5514 || c > charset->code_space[(dim - 1 - idx) * 4 + 1]) |
23c1467f8640
(detect_coding_charset): Fix detection of multi-byte
Kenichi Handa <handa@m17n.org>
parents:
90599
diff
changeset
|
5515 break; |
23c1467f8640
(detect_coding_charset): Fix detection of multi-byte
Kenichi Handa <handa@m17n.org>
parents:
90599
diff
changeset
|
5516 idx++; |
23c1467f8640
(detect_coding_charset): Fix detection of multi-byte
Kenichi Handa <handa@m17n.org>
parents:
90599
diff
changeset
|
5517 } |
23c1467f8640
(detect_coding_charset): Fix detection of multi-byte
Kenichi Handa <handa@m17n.org>
parents:
90599
diff
changeset
|
5518 if (idx == dim) |
23c1467f8640
(detect_coding_charset): Fix detection of multi-byte
Kenichi Handa <handa@m17n.org>
parents:
90599
diff
changeset
|
5519 { |
23c1467f8640
(detect_coding_charset): Fix detection of multi-byte
Kenichi Handa <handa@m17n.org>
parents:
90599
diff
changeset
|
5520 val = Qnil; |
23c1467f8640
(detect_coding_charset): Fix detection of multi-byte
Kenichi Handa <handa@m17n.org>
parents:
90599
diff
changeset
|
5521 break; |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5522 } |
20931
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
5523 } |
90651
23c1467f8640
(detect_coding_charset): Fix detection of multi-byte
Kenichi Handa <handa@m17n.org>
parents:
90599
diff
changeset
|
5524 if (CONSP (val)) |
23c1467f8640
(detect_coding_charset): Fix detection of multi-byte
Kenichi Handa <handa@m17n.org>
parents:
90599
diff
changeset
|
5525 break; |
23c1467f8640
(detect_coding_charset): Fix detection of multi-byte
Kenichi Handa <handa@m17n.org>
parents:
90599
diff
changeset
|
5526 } |
23c1467f8640
(detect_coding_charset): Fix detection of multi-byte
Kenichi Handa <handa@m17n.org>
parents:
90599
diff
changeset
|
5527 } |
23c1467f8640
(detect_coding_charset): Fix detection of multi-byte
Kenichi Handa <handa@m17n.org>
parents:
90599
diff
changeset
|
5528 too_short: |
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
5529 detect_info->rejected |= CATEGORY_MASK_CHARSET; |
88365 | 5530 return 0; |
5531 | |
5532 no_more_source: | |
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
5533 detect_info->found |= found; |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
5534 return 1; |
88365 | 5535 } |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5536 |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5537 static void |
109126
aec1143e8d85
Convert (most) functions in src to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109100
diff
changeset
|
5538 decode_coding_charset (struct coding_system *coding) |
88365 | 5539 { |
89483 | 5540 const unsigned char *src = coding->source + coding->consumed; |
5541 const unsigned char *src_end = coding->source + coding->src_bytes; | |
46548
cb1914307488
(encode_eol, detect_coding, detect_eol):
Ken Raeburn <raeburn@raeburn.org>
parents:
46462
diff
changeset
|
5542 const unsigned char *src_base; |
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
5543 int *charbuf = coding->charbuf + coding->charbuf_used; |
103035
6e443d717c7b
(decode_coding_utf_16): Reduce charbuf_end for the
Kenichi Handa <handa@m17n.org>
parents:
102738
diff
changeset
|
5544 /* We may produce one charset annocation in one loop and one more at |
6e443d717c7b
(decode_coding_utf_16): Reduce charbuf_end for the
Kenichi Handa <handa@m17n.org>
parents:
102738
diff
changeset
|
5545 the end. */ |
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
5546 int *charbuf_end |
103035
6e443d717c7b
(decode_coding_utf_16): Reduce charbuf_end for the
Kenichi Handa <handa@m17n.org>
parents:
102738
diff
changeset
|
5547 = coding->charbuf + coding->charbuf_size - (MAX_ANNOTATION_LENGTH * 2); |
88365 | 5548 int consumed_chars = 0, consumed_chars_base; |
5549 int multibytep = coding->src_multibyte; | |
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5550 Lisp_Object attrs, charset_list, valids; |
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
5551 int char_offset = coding->produced_char; |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
5552 int last_offset = char_offset; |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
5553 int last_id = charset_ascii; |
102334
7baaea85626e
(decode_coding_utf_8, decode_coding_utf_16, decode_coding_emacs_mule,
Eli Zaretskii <eliz@gnu.org>
parents:
102327
diff
changeset
|
5554 int eol_crlf = |
7baaea85626e
(decode_coding_utf_8, decode_coding_utf_16, decode_coding_emacs_mule,
Eli Zaretskii <eliz@gnu.org>
parents:
102327
diff
changeset
|
5555 !inhibit_eol_conversion && EQ (CODING_ID_EOL_TYPE (coding->id), Qdos); |
92399
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
5556 int byte_after_cr = -1; |
88365 | 5557 |
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5558 CODING_GET_INFO (coding, attrs, charset_list); |
88465
ae455bb40718
(decode_coding_charset, encode_coding_charset): Handle
Kenichi Handa <handa@m17n.org>
parents:
88456
diff
changeset
|
5559 valids = AREF (attrs, coding_attr_charset_valids); |
88365 | 5560 |
5561 while (1) | |
5562 { | |
88465
ae455bb40718
(decode_coding_charset, encode_coding_charset): Handle
Kenichi Handa <handa@m17n.org>
parents:
88456
diff
changeset
|
5563 int c; |
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5564 Lisp_Object val; |
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5565 struct charset *charset; |
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5566 int dim; |
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5567 int len = 1; |
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5568 unsigned code; |
88365 | 5569 |
29093
176708661b08
(encode_eol): Fix a bug of DOS style EOL encoding.
Kenichi Handa <handa@m17n.org>
parents:
29005
diff
changeset
|
5570 src_base = src; |
88365 | 5571 consumed_chars_base = consumed_chars; |
5572 | |
5573 if (charbuf >= charbuf_end) | |
100936
5c5e6d041634
(decode_coding_utf_8): Check byte_after_cr before breaking the loop.
Kenichi Handa <handa@m17n.org>
parents:
100587
diff
changeset
|
5574 { |
5c5e6d041634
(decode_coding_utf_8): Check byte_after_cr before breaking the loop.
Kenichi Handa <handa@m17n.org>
parents:
100587
diff
changeset
|
5575 if (byte_after_cr >= 0) |
5c5e6d041634
(decode_coding_utf_8): Check byte_after_cr before breaking the loop.
Kenichi Handa <handa@m17n.org>
parents:
100587
diff
changeset
|
5576 src_base--; |
5c5e6d041634
(decode_coding_utf_8): Check byte_after_cr before breaking the loop.
Kenichi Handa <handa@m17n.org>
parents:
100587
diff
changeset
|
5577 break; |
5c5e6d041634
(decode_coding_utf_8): Check byte_after_cr before breaking the loop.
Kenichi Handa <handa@m17n.org>
parents:
100587
diff
changeset
|
5578 } |
88365 | 5579 |
92399
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
5580 if (byte_after_cr >= 0) |
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
5581 { |
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
5582 c = byte_after_cr; |
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
5583 byte_after_cr = -1; |
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
5584 } |
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
5585 else |
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
5586 { |
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
5587 ONE_MORE_BYTE (c); |
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
5588 if (eol_crlf && c == '\r') |
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
5589 ONE_MORE_BYTE (byte_after_cr); |
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
5590 } |
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
5591 if (c < 0) |
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
5592 goto invalid_code; |
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5593 code = c; |
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5594 |
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5595 val = AREF (valids, c); |
100170
86455974b971
(decode_coding_charset): Check type of an element of
Kenichi Handa <handa@m17n.org>
parents:
100135
diff
changeset
|
5596 if (! INTEGERP (val) && ! CONSP (val)) |
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5597 goto invalid_code; |
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5598 if (INTEGERP (val)) |
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5599 { |
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5600 charset = CHARSET_FROM_ID (XFASTINT (val)); |
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5601 dim = CHARSET_DIMENSION (charset); |
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5602 while (len < dim) |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5603 { |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5604 ONE_MORE_BYTE (c); |
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5605 code = (code << 8) | c; |
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5606 len++; |
20931
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
5607 } |
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5608 CODING_DECODE_CHAR (coding, src, src_base, src_end, |
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5609 charset, code, c); |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5610 } |
20931
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
5611 else |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5612 { |
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5613 /* VAL is a list of charset IDs. It is assured that the |
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5614 list is sorted by charset dimensions (smaller one |
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5615 comes first). */ |
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5616 while (CONSP (val)) |
88465
ae455bb40718
(decode_coding_charset, encode_coding_charset): Handle
Kenichi Handa <handa@m17n.org>
parents:
88456
diff
changeset
|
5617 { |
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5618 charset = CHARSET_FROM_ID (XFASTINT (XCAR (val))); |
88597
74b74f59bc09
(decode_coding_charset): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
88587
diff
changeset
|
5619 dim = CHARSET_DIMENSION (charset); |
88607
18436bf3d6dd
(Fdefine_coding_system_internal): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
88598
diff
changeset
|
5620 while (len < dim) |
88465
ae455bb40718
(decode_coding_charset, encode_coding_charset): Handle
Kenichi Handa <handa@m17n.org>
parents:
88456
diff
changeset
|
5621 { |
88598
b88195f69856
(decode_coding_charset): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
88597
diff
changeset
|
5622 ONE_MORE_BYTE (c); |
b88195f69856
(decode_coding_charset): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
88597
diff
changeset
|
5623 code = (code << 8) | c; |
88607
18436bf3d6dd
(Fdefine_coding_system_internal): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
88598
diff
changeset
|
5624 len++; |
88465
ae455bb40718
(decode_coding_charset, encode_coding_charset): Handle
Kenichi Handa <handa@m17n.org>
parents:
88456
diff
changeset
|
5625 } |
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5626 CODING_DECODE_CHAR (coding, src, src_base, |
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5627 src_end, charset, code, c); |
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5628 if (c >= 0) |
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5629 break; |
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5630 val = XCDR (val); |
88465
ae455bb40718
(decode_coding_charset, encode_coding_charset): Handle
Kenichi Handa <handa@m17n.org>
parents:
88456
diff
changeset
|
5631 } |
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5632 } |
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5633 if (c < 0) |
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5634 goto invalid_code; |
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5635 if (charset->id != charset_ascii |
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5636 && last_id != charset->id) |
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5637 { |
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5638 if (last_id != charset_ascii) |
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
5639 ADD_CHARSET_DATA (charbuf, char_offset - last_offset, last_id); |
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5640 last_id = charset->id; |
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5641 last_offset = char_offset; |
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5642 } |
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5643 |
88365 | 5644 *charbuf++ = c; |
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
5645 char_offset++; |
88365 | 5646 continue; |
5647 | |
5648 invalid_code: | |
5649 src = src_base; | |
5650 consumed_chars = consumed_chars_base; | |
5651 ONE_MORE_BYTE (c); | |
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
5652 *charbuf++ = c < 0 ? -c : ASCII_BYTE_P (c) ? c : BYTE8_TO_CHAR (c); |
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
5653 char_offset++; |
88365 | 5654 coding->errors++; |
5655 } | |
5656 | |
5657 no_more_source: | |
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
5658 if (last_id != charset_ascii) |
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
5659 ADD_CHARSET_DATA (charbuf, char_offset - last_offset, last_id); |
88365 | 5660 coding->consumed_char += consumed_chars_base; |
5661 coding->consumed = src_base - coding->source; | |
5662 coding->charbuf_used = charbuf - coding->charbuf; | |
5663 } | |
5664 | |
5665 static int | |
109126
aec1143e8d85
Convert (most) functions in src to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109100
diff
changeset
|
5666 encode_coding_charset (struct coding_system *coding) |
88365 | 5667 { |
5668 int multibytep = coding->dst_multibyte; | |
5669 int *charbuf = coding->charbuf; | |
5670 int *charbuf_end = charbuf + coding->charbuf_used; | |
5671 unsigned char *dst = coding->destination + coding->produced; | |
5672 unsigned char *dst_end = coding->destination + coding->dst_bytes; | |
5673 int safe_room = MAX_MULTIBYTE_LENGTH; | |
5674 int produced_chars = 0; | |
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5675 Lisp_Object attrs, charset_list; |
88365 | 5676 int ascii_compatible; |
5677 int c; | |
5678 | |
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5679 CODING_GET_INFO (coding, attrs, charset_list); |
88365 | 5680 ascii_compatible = ! NILP (CODING_ATTR_ASCII_COMPAT (attrs)); |
5681 | |
5682 while (charbuf < charbuf_end) | |
5683 { | |
88465
ae455bb40718
(decode_coding_charset, encode_coding_charset): Handle
Kenichi Handa <handa@m17n.org>
parents:
88456
diff
changeset
|
5684 struct charset *charset; |
88365 | 5685 unsigned code; |
89483 | 5686 |
88365 | 5687 ASSURE_DESTINATION (safe_room); |
5688 c = *charbuf++; | |
5689 if (ascii_compatible && ASCII_CHAR_P (c)) | |
5690 EMIT_ONE_ASCII_BYTE (c); | |
88690
7f284ac55b07
(encode_coding_emacs_mule): Pay attention to raw-8-bit chars.
Kenichi Handa <handa@m17n.org>
parents:
88681
diff
changeset
|
5691 else if (CHAR_BYTE8_P (c)) |
7f284ac55b07
(encode_coding_emacs_mule): Pay attention to raw-8-bit chars.
Kenichi Handa <handa@m17n.org>
parents:
88681
diff
changeset
|
5692 { |
7f284ac55b07
(encode_coding_emacs_mule): Pay attention to raw-8-bit chars.
Kenichi Handa <handa@m17n.org>
parents:
88681
diff
changeset
|
5693 c = CHAR_TO_BYTE8 (c); |
7f284ac55b07
(encode_coding_emacs_mule): Pay attention to raw-8-bit chars.
Kenichi Handa <handa@m17n.org>
parents:
88681
diff
changeset
|
5694 EMIT_ONE_BYTE (c); |
7f284ac55b07
(encode_coding_emacs_mule): Pay attention to raw-8-bit chars.
Kenichi Handa <handa@m17n.org>
parents:
88681
diff
changeset
|
5695 } |
88365 | 5696 else |
88465
ae455bb40718
(decode_coding_charset, encode_coding_charset): Handle
Kenichi Handa <handa@m17n.org>
parents:
88456
diff
changeset
|
5697 { |
ae455bb40718
(decode_coding_charset, encode_coding_charset): Handle
Kenichi Handa <handa@m17n.org>
parents:
88456
diff
changeset
|
5698 charset = char_charset (c, charset_list, &code); |
ae455bb40718
(decode_coding_charset, encode_coding_charset): Handle
Kenichi Handa <handa@m17n.org>
parents:
88456
diff
changeset
|
5699 if (charset) |
ae455bb40718
(decode_coding_charset, encode_coding_charset): Handle
Kenichi Handa <handa@m17n.org>
parents:
88456
diff
changeset
|
5700 { |
ae455bb40718
(decode_coding_charset, encode_coding_charset): Handle
Kenichi Handa <handa@m17n.org>
parents:
88456
diff
changeset
|
5701 if (CHARSET_DIMENSION (charset) == 1) |
ae455bb40718
(decode_coding_charset, encode_coding_charset): Handle
Kenichi Handa <handa@m17n.org>
parents:
88456
diff
changeset
|
5702 EMIT_ONE_BYTE (code); |
ae455bb40718
(decode_coding_charset, encode_coding_charset): Handle
Kenichi Handa <handa@m17n.org>
parents:
88456
diff
changeset
|
5703 else if (CHARSET_DIMENSION (charset) == 2) |
ae455bb40718
(decode_coding_charset, encode_coding_charset): Handle
Kenichi Handa <handa@m17n.org>
parents:
88456
diff
changeset
|
5704 EMIT_TWO_BYTES (code >> 8, code & 0xFF); |
ae455bb40718
(decode_coding_charset, encode_coding_charset): Handle
Kenichi Handa <handa@m17n.org>
parents:
88456
diff
changeset
|
5705 else if (CHARSET_DIMENSION (charset) == 3) |
ae455bb40718
(decode_coding_charset, encode_coding_charset): Handle
Kenichi Handa <handa@m17n.org>
parents:
88456
diff
changeset
|
5706 EMIT_THREE_BYTES (code >> 16, (code >> 8) & 0xFF, code & 0xFF); |
ae455bb40718
(decode_coding_charset, encode_coding_charset): Handle
Kenichi Handa <handa@m17n.org>
parents:
88456
diff
changeset
|
5707 else |
ae455bb40718
(decode_coding_charset, encode_coding_charset): Handle
Kenichi Handa <handa@m17n.org>
parents:
88456
diff
changeset
|
5708 EMIT_FOUR_BYTES (code >> 24, (code >> 16) & 0xFF, |
ae455bb40718
(decode_coding_charset, encode_coding_charset): Handle
Kenichi Handa <handa@m17n.org>
parents:
88456
diff
changeset
|
5709 (code >> 8) & 0xFF, code & 0xFF); |
ae455bb40718
(decode_coding_charset, encode_coding_charset): Handle
Kenichi Handa <handa@m17n.org>
parents:
88456
diff
changeset
|
5710 } |
ae455bb40718
(decode_coding_charset, encode_coding_charset): Handle
Kenichi Handa <handa@m17n.org>
parents:
88456
diff
changeset
|
5711 else |
88573
133bf7ab1bad
(encode_coding_iso_2022): If coding requires safe
Kenichi Handa <handa@m17n.org>
parents:
88544
diff
changeset
|
5712 { |
133bf7ab1bad
(encode_coding_iso_2022): If coding requires safe
Kenichi Handa <handa@m17n.org>
parents:
88544
diff
changeset
|
5713 if (coding->mode & CODING_MODE_SAFE_ENCODING) |
133bf7ab1bad
(encode_coding_iso_2022): If coding requires safe
Kenichi Handa <handa@m17n.org>
parents:
88544
diff
changeset
|
5714 c = CODING_INHIBIT_CHARACTER_SUBSTITUTION; |
133bf7ab1bad
(encode_coding_iso_2022): If coding requires safe
Kenichi Handa <handa@m17n.org>
parents:
88544
diff
changeset
|
5715 else |
133bf7ab1bad
(encode_coding_iso_2022): If coding requires safe
Kenichi Handa <handa@m17n.org>
parents:
88544
diff
changeset
|
5716 c = coding->default_char; |
133bf7ab1bad
(encode_coding_iso_2022): If coding requires safe
Kenichi Handa <handa@m17n.org>
parents:
88544
diff
changeset
|
5717 EMIT_ONE_BYTE (c); |
133bf7ab1bad
(encode_coding_iso_2022): If coding requires safe
Kenichi Handa <handa@m17n.org>
parents:
88544
diff
changeset
|
5718 } |
88465
ae455bb40718
(decode_coding_charset, encode_coding_charset): Handle
Kenichi Handa <handa@m17n.org>
parents:
88456
diff
changeset
|
5719 } |
88365 | 5720 } |
5721 | |
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
5722 record_conversion_result (coding, CODING_RESULT_SUCCESS); |
88365 | 5723 coding->produced_char += produced_chars; |
5724 coding->produced = dst - coding->destination; | |
5725 return 0; | |
17052 | 5726 } |
5727 | |
5728 | |
22874
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
5729 /*** 7. C library functions ***/ |
17052 | 5730 |
88365 | 5731 /* Setup coding context CODING from information about CODING_SYSTEM. |
5732 If CODING_SYSTEM is nil, `no-conversion' is assumed. If | |
5733 CODING_SYSTEM is invalid, signal an error. */ | |
5734 | |
5735 void | |
109126
aec1143e8d85
Convert (most) functions in src to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109100
diff
changeset
|
5736 setup_coding_system (Lisp_Object coding_system, struct coding_system *coding) |
17052 | 5737 { |
88365 | 5738 Lisp_Object attrs; |
5739 Lisp_Object eol_type; | |
5740 Lisp_Object coding_type; | |
20105
c017642863c2
(Qcoding_system_spec): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
19824
diff
changeset
|
5741 Lisp_Object val; |
17052 | 5742 |
24460
be35d27a4bfb
(setup_coding_system): Check for CODING_SYSTEM = nil.
Kenichi Handa <handa@m17n.org>
parents:
24425
diff
changeset
|
5743 if (NILP (coding_system)) |
90011
26cef35a1562
(setup_coding_system): If coding_system is nil, use
Kenichi Handa <handa@m17n.org>
parents:
89976
diff
changeset
|
5744 coding_system = Qundecided; |
88365 | 5745 |
5746 CHECK_CODING_SYSTEM_GET_ID (coding_system, coding->id); | |
5747 | |
5748 attrs = CODING_ID_ATTRS (coding->id); | |
102334
7baaea85626e
(decode_coding_utf_8, decode_coding_utf_16, decode_coding_emacs_mule,
Eli Zaretskii <eliz@gnu.org>
parents:
102327
diff
changeset
|
5749 eol_type = inhibit_eol_conversion ? Qunix : CODING_ID_EOL_TYPE (coding->id); |
88365 | 5750 |
5751 coding->mode = 0; | |
5752 coding->head_ascii = -1; | |
17052 | 5753 if (VECTORP (eol_type)) |
90587
fe721cfad011
(setup_coding_system): Fix setting of
Kenichi Handa <handa@m17n.org>
parents:
90573
diff
changeset
|
5754 coding->common_flags = (CODING_REQUIRE_DECODING_MASK |
fe721cfad011
(setup_coding_system): Fix setting of
Kenichi Handa <handa@m17n.org>
parents:
90573
diff
changeset
|
5755 | CODING_REQUIRE_DETECTION_MASK); |
fe721cfad011
(setup_coding_system): Fix setting of
Kenichi Handa <handa@m17n.org>
parents:
90573
diff
changeset
|
5756 else if (! EQ (eol_type, Qunix)) |
fe721cfad011
(setup_coding_system): Fix setting of
Kenichi Handa <handa@m17n.org>
parents:
90573
diff
changeset
|
5757 coding->common_flags = (CODING_REQUIRE_DECODING_MASK |
fe721cfad011
(setup_coding_system): Fix setting of
Kenichi Handa <handa@m17n.org>
parents:
90573
diff
changeset
|
5758 | CODING_REQUIRE_ENCODING_MASK); |
fe721cfad011
(setup_coding_system): Fix setting of
Kenichi Handa <handa@m17n.org>
parents:
90573
diff
changeset
|
5759 else |
fe721cfad011
(setup_coding_system): Fix setting of
Kenichi Handa <handa@m17n.org>
parents:
90573
diff
changeset
|
5760 coding->common_flags = 0; |
89448
de8b460070cc
(setup_coding_system): If coding has
Kenichi Handa <handa@m17n.org>
parents:
89446
diff
changeset
|
5761 if (! NILP (CODING_ATTR_POST_READ (attrs))) |
de8b460070cc
(setup_coding_system): If coding has
Kenichi Handa <handa@m17n.org>
parents:
89446
diff
changeset
|
5762 coding->common_flags |= CODING_REQUIRE_DECODING_MASK; |
de8b460070cc
(setup_coding_system): If coding has
Kenichi Handa <handa@m17n.org>
parents:
89446
diff
changeset
|
5763 if (! NILP (CODING_ATTR_PRE_WRITE (attrs))) |
de8b460070cc
(setup_coding_system): If coding has
Kenichi Handa <handa@m17n.org>
parents:
89446
diff
changeset
|
5764 coding->common_flags |= CODING_REQUIRE_ENCODING_MASK; |
89483 | 5765 if (! NILP (CODING_ATTR_FOR_UNIBYTE (attrs))) |
5766 coding->common_flags |= CODING_FOR_UNIBYTE_MASK; | |
88365 | 5767 |
5768 val = CODING_ATTR_SAFE_CHARSETS (attrs); | |
89483 | 5769 coding->max_charset_id = SCHARS (val) - 1; |
102186
a12d39ca6870
* coding.h (struct coding_system): Make safe_charsets a pointer to
Andreas Schwab <schwab@suse.de>
parents:
102115
diff
changeset
|
5770 coding->safe_charsets = SDATA (val); |
88365 | 5771 coding->default_char = XINT (CODING_ATTR_DEFAULT_CHAR (attrs)); |
103655
e2d67c929da2
(setup_coding_system): Initialize
Kenichi Handa <handa@m17n.org>
parents:
103486
diff
changeset
|
5772 coding->carryover_bytes = 0; |
88365 | 5773 |
5774 coding_type = CODING_ATTR_TYPE (attrs); | |
5775 if (EQ (coding_type, Qundecided)) | |
5776 { | |
5777 coding->detector = NULL; | |
5778 coding->decoder = decode_coding_raw_text; | |
5779 coding->encoder = encode_coding_raw_text; | |
5780 coding->common_flags |= CODING_REQUIRE_DETECTION_MASK; | |
5781 } | |
5782 else if (EQ (coding_type, Qiso_2022)) | |
5783 { | |
5784 int i; | |
5785 int flags = XINT (AREF (attrs, coding_attr_iso_flags)); | |
5786 | |
5787 /* Invoke graphic register 0 to plane 0. */ | |
5788 CODING_ISO_INVOCATION (coding, 0) = 0; | |
5789 /* Invoke graphic register 1 to plane 1 if we can use 8-bit. */ | |
5790 CODING_ISO_INVOCATION (coding, 1) | |
5791 = (flags & CODING_ISO_FLAG_SEVEN_BITS ? -1 : 1); | |
5792 /* Setup the initial status of designation. */ | |
5793 for (i = 0; i < 4; i++) | |
5794 CODING_ISO_DESIGNATION (coding, i) = CODING_ISO_INITIAL (coding, i); | |
5795 /* Not single shifting initially. */ | |
5796 CODING_ISO_SINGLE_SHIFTING (coding) = 0; | |
5797 /* Beginning of buffer should also be regarded as bol. */ | |
5798 CODING_ISO_BOL (coding) = 1; | |
5799 coding->detector = detect_coding_iso_2022; | |
5800 coding->decoder = decode_coding_iso_2022; | |
5801 coding->encoder = encode_coding_iso_2022; | |
5802 if (flags & CODING_ISO_FLAG_SAFE) | |
5803 coding->mode |= CODING_MODE_SAFE_ENCODING; | |
20227
71008f909642
(setup_coding_system): Initialize common_flags member
Kenichi Handa <handa@m17n.org>
parents:
20150
diff
changeset
|
5804 coding->common_flags |
88365 | 5805 |= (CODING_REQUIRE_DECODING_MASK | CODING_REQUIRE_ENCODING_MASK |
5806 | CODING_REQUIRE_FLUSHING_MASK); | |
5807 if (flags & CODING_ISO_FLAG_COMPOSITION) | |
5808 coding->common_flags |= CODING_ANNOTATE_COMPOSITION_MASK; | |
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
5809 if (flags & CODING_ISO_FLAG_DESIGNATION) |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
5810 coding->common_flags |= CODING_ANNOTATE_CHARSET_MASK; |
88365 | 5811 if (flags & CODING_ISO_FLAG_FULL_SUPPORT) |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5812 { |
88365 | 5813 setup_iso_safe_charsets (attrs); |
5814 val = CODING_ATTR_SAFE_CHARSETS (attrs); | |
89483 | 5815 coding->max_charset_id = SCHARS (val) - 1; |
102186
a12d39ca6870
* coding.h (struct coding_system): Make safe_charsets a pointer to
Andreas Schwab <schwab@suse.de>
parents:
102115
diff
changeset
|
5816 coding->safe_charsets = SDATA (val); |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5817 } |
88365 | 5818 CODING_ISO_FLAGS (coding) = flags; |
102422
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
5819 CODING_ISO_CMP_STATUS (coding)->state = COMPOSING_NO; |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
5820 CODING_ISO_CMP_STATUS (coding)->method = COMPOSITION_NO; |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
5821 CODING_ISO_EXTSEGMENT_LEN (coding) = 0; |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
5822 CODING_ISO_EMBEDDED_UTF_8 (coding) = 0; |
88365 | 5823 } |
5824 else if (EQ (coding_type, Qcharset)) | |
5825 { | |
5826 coding->detector = detect_coding_charset; | |
5827 coding->decoder = decode_coding_charset; | |
5828 coding->encoder = encode_coding_charset; | |
34888
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
5829 coding->common_flags |
88365 | 5830 |= (CODING_REQUIRE_DECODING_MASK | CODING_REQUIRE_ENCODING_MASK); |
5831 } | |
5832 else if (EQ (coding_type, Qutf_8)) | |
5833 { | |
95397
c99f0a16c077
(CODING_UTF_8_BOM): New macro.
Kenichi Handa <handa@m17n.org>
parents:
95356
diff
changeset
|
5834 val = AREF (attrs, coding_attr_utf_bom); |
c99f0a16c077
(CODING_UTF_8_BOM): New macro.
Kenichi Handa <handa@m17n.org>
parents:
95356
diff
changeset
|
5835 CODING_UTF_8_BOM (coding) = (CONSP (val) ? utf_detect_bom |
c99f0a16c077
(CODING_UTF_8_BOM): New macro.
Kenichi Handa <handa@m17n.org>
parents:
95356
diff
changeset
|
5836 : EQ (val, Qt) ? utf_with_bom |
c99f0a16c077
(CODING_UTF_8_BOM): New macro.
Kenichi Handa <handa@m17n.org>
parents:
95356
diff
changeset
|
5837 : utf_without_bom); |
88365 | 5838 coding->detector = detect_coding_utf_8; |
5839 coding->decoder = decode_coding_utf_8; | |
5840 coding->encoder = encode_coding_utf_8; | |
34888
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
5841 coding->common_flags |
88365 | 5842 |= (CODING_REQUIRE_DECODING_MASK | CODING_REQUIRE_ENCODING_MASK); |
95397
c99f0a16c077
(CODING_UTF_8_BOM): New macro.
Kenichi Handa <handa@m17n.org>
parents:
95356
diff
changeset
|
5843 if (CODING_UTF_8_BOM (coding) == utf_detect_bom) |
c99f0a16c077
(CODING_UTF_8_BOM): New macro.
Kenichi Handa <handa@m17n.org>
parents:
95356
diff
changeset
|
5844 coding->common_flags |= CODING_REQUIRE_DETECTION_MASK; |
88365 | 5845 } |
5846 else if (EQ (coding_type, Qutf_16)) | |
5847 { | |
95397
c99f0a16c077
(CODING_UTF_8_BOM): New macro.
Kenichi Handa <handa@m17n.org>
parents:
95356
diff
changeset
|
5848 val = AREF (attrs, coding_attr_utf_bom); |
c99f0a16c077
(CODING_UTF_8_BOM): New macro.
Kenichi Handa <handa@m17n.org>
parents:
95356
diff
changeset
|
5849 CODING_UTF_16_BOM (coding) = (CONSP (val) ? utf_detect_bom |
c99f0a16c077
(CODING_UTF_8_BOM): New macro.
Kenichi Handa <handa@m17n.org>
parents:
95356
diff
changeset
|
5850 : EQ (val, Qt) ? utf_with_bom |
c99f0a16c077
(CODING_UTF_8_BOM): New macro.
Kenichi Handa <handa@m17n.org>
parents:
95356
diff
changeset
|
5851 : utf_without_bom); |
88365 | 5852 val = AREF (attrs, coding_attr_utf_16_endian); |
89420
c3e67ce6ee0f
(Qsignature, Qendian): Delete these variables.
Kenichi Handa <handa@m17n.org>
parents:
89418
diff
changeset
|
5853 CODING_UTF_16_ENDIAN (coding) = (EQ (val, Qbig) ? utf_16_big_endian |
88365 | 5854 : utf_16_little_endian); |
88438
3a34b722dd71
(encode_coding_utf_8): Initialize produced_chars to 0.
Kenichi Handa <handa@m17n.org>
parents:
88430
diff
changeset
|
5855 CODING_UTF_16_SURROGATE (coding) = 0; |
88365 | 5856 coding->detector = detect_coding_utf_16; |
5857 coding->decoder = decode_coding_utf_16; | |
5858 coding->encoder = encode_coding_utf_16; | |
20227
71008f909642
(setup_coding_system): Initialize common_flags member
Kenichi Handa <handa@m17n.org>
parents:
20150
diff
changeset
|
5859 coding->common_flags |
88365 | 5860 |= (CODING_REQUIRE_DECODING_MASK | CODING_REQUIRE_ENCODING_MASK); |
95397
c99f0a16c077
(CODING_UTF_8_BOM): New macro.
Kenichi Handa <handa@m17n.org>
parents:
95356
diff
changeset
|
5861 if (CODING_UTF_16_BOM (coding) == utf_detect_bom) |
89420
c3e67ce6ee0f
(Qsignature, Qendian): Delete these variables.
Kenichi Handa <handa@m17n.org>
parents:
89418
diff
changeset
|
5862 coding->common_flags |= CODING_REQUIRE_DETECTION_MASK; |
88365 | 5863 } |
5864 else if (EQ (coding_type, Qccl)) | |
5865 { | |
5866 coding->detector = detect_coding_ccl; | |
5867 coding->decoder = decode_coding_ccl; | |
5868 coding->encoder = encode_coding_ccl; | |
20227
71008f909642
(setup_coding_system): Initialize common_flags member
Kenichi Handa <handa@m17n.org>
parents:
20150
diff
changeset
|
5869 coding->common_flags |
88365 | 5870 |= (CODING_REQUIRE_DECODING_MASK | CODING_REQUIRE_ENCODING_MASK |
5871 | CODING_REQUIRE_FLUSHING_MASK); | |
5872 } | |
5873 else if (EQ (coding_type, Qemacs_mule)) | |
5874 { | |
5875 coding->detector = detect_coding_emacs_mule; | |
5876 coding->decoder = decode_coding_emacs_mule; | |
5877 coding->encoder = encode_coding_emacs_mule; | |
20227
71008f909642
(setup_coding_system): Initialize common_flags member
Kenichi Handa <handa@m17n.org>
parents:
20150
diff
changeset
|
5878 coding->common_flags |
88365 | 5879 |= (CODING_REQUIRE_DECODING_MASK | CODING_REQUIRE_ENCODING_MASK); |
102422
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
5880 coding->spec.emacs_mule.full_support = 1; |
88365 | 5881 if (! NILP (AREF (attrs, coding_attr_emacs_mule_full)) |
5882 && ! EQ (CODING_ATTR_CHARSET_LIST (attrs), Vemacs_mule_charset_list)) | |
5883 { | |
5884 Lisp_Object tail, safe_charsets; | |
5885 int max_charset_id = 0; | |
5886 | |
5887 for (tail = Vemacs_mule_charset_list; CONSP (tail); | |
5888 tail = XCDR (tail)) | |
5889 if (max_charset_id < XFASTINT (XCAR (tail))) | |
5890 max_charset_id = XFASTINT (XCAR (tail)); | |
102186
a12d39ca6870
* coding.h (struct coding_system): Make safe_charsets a pointer to
Andreas Schwab <schwab@suse.de>
parents:
102115
diff
changeset
|
5891 safe_charsets = make_uninit_string (max_charset_id + 1); |
a12d39ca6870
* coding.h (struct coding_system): Make safe_charsets a pointer to
Andreas Schwab <schwab@suse.de>
parents:
102115
diff
changeset
|
5892 memset (SDATA (safe_charsets), 255, max_charset_id + 1); |
88365 | 5893 for (tail = Vemacs_mule_charset_list; CONSP (tail); |
5894 tail = XCDR (tail)) | |
89483 | 5895 SSET (safe_charsets, XFASTINT (XCAR (tail)), 0); |
88365 | 5896 coding->max_charset_id = max_charset_id; |
102186
a12d39ca6870
* coding.h (struct coding_system): Make safe_charsets a pointer to
Andreas Schwab <schwab@suse.de>
parents:
102115
diff
changeset
|
5897 coding->safe_charsets = SDATA (safe_charsets); |
102422
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
5898 coding->spec.emacs_mule.full_support = 1; |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
5899 } |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
5900 coding->spec.emacs_mule.cmp_status.state = COMPOSING_NO; |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
5901 coding->spec.emacs_mule.cmp_status.method = COMPOSITION_NO; |
88365 | 5902 } |
5903 else if (EQ (coding_type, Qshift_jis)) | |
5904 { | |
5905 coding->detector = detect_coding_sjis; | |
5906 coding->decoder = decode_coding_sjis; | |
5907 coding->encoder = encode_coding_sjis; | |
5908 coding->common_flags | |
5909 |= (CODING_REQUIRE_DECODING_MASK | CODING_REQUIRE_ENCODING_MASK); | |
5910 } | |
5911 else if (EQ (coding_type, Qbig5)) | |
5912 { | |
5913 coding->detector = detect_coding_big5; | |
5914 coding->decoder = decode_coding_big5; | |
5915 coding->encoder = encode_coding_big5; | |
20227
71008f909642
(setup_coding_system): Initialize common_flags member
Kenichi Handa <handa@m17n.org>
parents:
20150
diff
changeset
|
5916 coding->common_flags |
88365 | 5917 |= (CODING_REQUIRE_DECODING_MASK | CODING_REQUIRE_ENCODING_MASK); |
5918 } | |
5919 else /* EQ (coding_type, Qraw_text) */ | |
5920 { | |
5921 coding->detector = NULL; | |
5922 coding->decoder = decode_coding_raw_text; | |
5923 coding->encoder = encode_coding_raw_text; | |
89933
48af0ea7d387
(setup_coding_system): Set coding->common_flags
Kenichi Handa <handa@m17n.org>
parents:
89924
diff
changeset
|
5924 if (! EQ (eol_type, Qunix)) |
48af0ea7d387
(setup_coding_system): Set coding->common_flags
Kenichi Handa <handa@m17n.org>
parents:
89924
diff
changeset
|
5925 { |
48af0ea7d387
(setup_coding_system): Set coding->common_flags
Kenichi Handa <handa@m17n.org>
parents:
89924
diff
changeset
|
5926 coding->common_flags |= CODING_REQUIRE_DECODING_MASK; |
48af0ea7d387
(setup_coding_system): Set coding->common_flags
Kenichi Handa <handa@m17n.org>
parents:
89924
diff
changeset
|
5927 if (! VECTORP (eol_type)) |
48af0ea7d387
(setup_coding_system): Set coding->common_flags
Kenichi Handa <handa@m17n.org>
parents:
89924
diff
changeset
|
5928 coding->common_flags |= CODING_REQUIRE_ENCODING_MASK; |
48af0ea7d387
(setup_coding_system): Set coding->common_flags
Kenichi Handa <handa@m17n.org>
parents:
89924
diff
changeset
|
5929 } |
48af0ea7d387
(setup_coding_system): Set coding->common_flags
Kenichi Handa <handa@m17n.org>
parents:
89924
diff
changeset
|
5930 |
88365 | 5931 } |
5932 | |
22616
c493ce6a31e4
(setup_raw_text_coding_system): New function.
Kenichi Handa <handa@m17n.org>
parents:
22529
diff
changeset
|
5933 return; |
c493ce6a31e4
(setup_raw_text_coding_system): New function.
Kenichi Handa <handa@m17n.org>
parents:
22529
diff
changeset
|
5934 } |
c493ce6a31e4
(setup_raw_text_coding_system): New function.
Kenichi Handa <handa@m17n.org>
parents:
22529
diff
changeset
|
5935 |
90061
48210be97b12
Cancel the change done in HEAD on 2004-11-30.
Kenichi Handa <handa@m17n.org>
parents:
90054
diff
changeset
|
5936 /* Return a list of charsets supported by CODING. */ |
48210be97b12
Cancel the change done in HEAD on 2004-11-30.
Kenichi Handa <handa@m17n.org>
parents:
90054
diff
changeset
|
5937 |
48210be97b12
Cancel the change done in HEAD on 2004-11-30.
Kenichi Handa <handa@m17n.org>
parents:
90054
diff
changeset
|
5938 Lisp_Object |
109126
aec1143e8d85
Convert (most) functions in src to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109100
diff
changeset
|
5939 coding_charset_list (struct coding_system *coding) |
26847 | 5940 { |
90214
460ee00505d5
(QCascii_compatible_p): New variable.
Kenichi Handa <handa@m17n.org>
parents:
90201
diff
changeset
|
5941 Lisp_Object attrs, charset_list; |
90061
48210be97b12
Cancel the change done in HEAD on 2004-11-30.
Kenichi Handa <handa@m17n.org>
parents:
90054
diff
changeset
|
5942 |
48210be97b12
Cancel the change done in HEAD on 2004-11-30.
Kenichi Handa <handa@m17n.org>
parents:
90054
diff
changeset
|
5943 CODING_GET_INFO (coding, attrs, charset_list); |
48210be97b12
Cancel the change done in HEAD on 2004-11-30.
Kenichi Handa <handa@m17n.org>
parents:
90054
diff
changeset
|
5944 if (EQ (CODING_ATTR_TYPE (attrs), Qiso_2022)) |
48210be97b12
Cancel the change done in HEAD on 2004-11-30.
Kenichi Handa <handa@m17n.org>
parents:
90054
diff
changeset
|
5945 { |
48210be97b12
Cancel the change done in HEAD on 2004-11-30.
Kenichi Handa <handa@m17n.org>
parents:
90054
diff
changeset
|
5946 int flags = XINT (AREF (attrs, coding_attr_iso_flags)); |
48210be97b12
Cancel the change done in HEAD on 2004-11-30.
Kenichi Handa <handa@m17n.org>
parents:
90054
diff
changeset
|
5947 |
48210be97b12
Cancel the change done in HEAD on 2004-11-30.
Kenichi Handa <handa@m17n.org>
parents:
90054
diff
changeset
|
5948 if (flags & CODING_ISO_FLAG_FULL_SUPPORT) |
48210be97b12
Cancel the change done in HEAD on 2004-11-30.
Kenichi Handa <handa@m17n.org>
parents:
90054
diff
changeset
|
5949 charset_list = Viso_2022_charset_list; |
48210be97b12
Cancel the change done in HEAD on 2004-11-30.
Kenichi Handa <handa@m17n.org>
parents:
90054
diff
changeset
|
5950 } |
48210be97b12
Cancel the change done in HEAD on 2004-11-30.
Kenichi Handa <handa@m17n.org>
parents:
90054
diff
changeset
|
5951 else if (EQ (CODING_ATTR_TYPE (attrs), Qemacs_mule)) |
48210be97b12
Cancel the change done in HEAD on 2004-11-30.
Kenichi Handa <handa@m17n.org>
parents:
90054
diff
changeset
|
5952 { |
48210be97b12
Cancel the change done in HEAD on 2004-11-30.
Kenichi Handa <handa@m17n.org>
parents:
90054
diff
changeset
|
5953 charset_list = Vemacs_mule_charset_list; |
48210be97b12
Cancel the change done in HEAD on 2004-11-30.
Kenichi Handa <handa@m17n.org>
parents:
90054
diff
changeset
|
5954 } |
48210be97b12
Cancel the change done in HEAD on 2004-11-30.
Kenichi Handa <handa@m17n.org>
parents:
90054
diff
changeset
|
5955 return charset_list; |
48210be97b12
Cancel the change done in HEAD on 2004-11-30.
Kenichi Handa <handa@m17n.org>
parents:
90054
diff
changeset
|
5956 } |
48210be97b12
Cancel the change done in HEAD on 2004-11-30.
Kenichi Handa <handa@m17n.org>
parents:
90054
diff
changeset
|
5957 |
48210be97b12
Cancel the change done in HEAD on 2004-11-30.
Kenichi Handa <handa@m17n.org>
parents:
90054
diff
changeset
|
5958 |
101776
11ba351ce12b
(coding_system_charset_list): New function.
Kenichi Handa <handa@m17n.org>
parents:
101678
diff
changeset
|
5959 /* Return a list of charsets supported by CODING-SYSTEM. */ |
11ba351ce12b
(coding_system_charset_list): New function.
Kenichi Handa <handa@m17n.org>
parents:
101678
diff
changeset
|
5960 |
11ba351ce12b
(coding_system_charset_list): New function.
Kenichi Handa <handa@m17n.org>
parents:
101678
diff
changeset
|
5961 Lisp_Object |
109126
aec1143e8d85
Convert (most) functions in src to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109100
diff
changeset
|
5962 coding_system_charset_list (Lisp_Object coding_system) |
101776
11ba351ce12b
(coding_system_charset_list): New function.
Kenichi Handa <handa@m17n.org>
parents:
101678
diff
changeset
|
5963 { |
11ba351ce12b
(coding_system_charset_list): New function.
Kenichi Handa <handa@m17n.org>
parents:
101678
diff
changeset
|
5964 int id; |
11ba351ce12b
(coding_system_charset_list): New function.
Kenichi Handa <handa@m17n.org>
parents:
101678
diff
changeset
|
5965 Lisp_Object attrs, charset_list; |
11ba351ce12b
(coding_system_charset_list): New function.
Kenichi Handa <handa@m17n.org>
parents:
101678
diff
changeset
|
5966 |
11ba351ce12b
(coding_system_charset_list): New function.
Kenichi Handa <handa@m17n.org>
parents:
101678
diff
changeset
|
5967 CHECK_CODING_SYSTEM_GET_ID (coding_system, id); |
11ba351ce12b
(coding_system_charset_list): New function.
Kenichi Handa <handa@m17n.org>
parents:
101678
diff
changeset
|
5968 attrs = CODING_ID_ATTRS (id); |
11ba351ce12b
(coding_system_charset_list): New function.
Kenichi Handa <handa@m17n.org>
parents:
101678
diff
changeset
|
5969 |
11ba351ce12b
(coding_system_charset_list): New function.
Kenichi Handa <handa@m17n.org>
parents:
101678
diff
changeset
|
5970 if (EQ (CODING_ATTR_TYPE (attrs), Qiso_2022)) |
11ba351ce12b
(coding_system_charset_list): New function.
Kenichi Handa <handa@m17n.org>
parents:
101678
diff
changeset
|
5971 { |
11ba351ce12b
(coding_system_charset_list): New function.
Kenichi Handa <handa@m17n.org>
parents:
101678
diff
changeset
|
5972 int flags = XINT (AREF (attrs, coding_attr_iso_flags)); |
11ba351ce12b
(coding_system_charset_list): New function.
Kenichi Handa <handa@m17n.org>
parents:
101678
diff
changeset
|
5973 |
11ba351ce12b
(coding_system_charset_list): New function.
Kenichi Handa <handa@m17n.org>
parents:
101678
diff
changeset
|
5974 if (flags & CODING_ISO_FLAG_FULL_SUPPORT) |
11ba351ce12b
(coding_system_charset_list): New function.
Kenichi Handa <handa@m17n.org>
parents:
101678
diff
changeset
|
5975 charset_list = Viso_2022_charset_list; |
11ba351ce12b
(coding_system_charset_list): New function.
Kenichi Handa <handa@m17n.org>
parents:
101678
diff
changeset
|
5976 else |
11ba351ce12b
(coding_system_charset_list): New function.
Kenichi Handa <handa@m17n.org>
parents:
101678
diff
changeset
|
5977 charset_list = CODING_ATTR_CHARSET_LIST (attrs); |
11ba351ce12b
(coding_system_charset_list): New function.
Kenichi Handa <handa@m17n.org>
parents:
101678
diff
changeset
|
5978 } |
11ba351ce12b
(coding_system_charset_list): New function.
Kenichi Handa <handa@m17n.org>
parents:
101678
diff
changeset
|
5979 else if (EQ (CODING_ATTR_TYPE (attrs), Qemacs_mule)) |
11ba351ce12b
(coding_system_charset_list): New function.
Kenichi Handa <handa@m17n.org>
parents:
101678
diff
changeset
|
5980 { |
11ba351ce12b
(coding_system_charset_list): New function.
Kenichi Handa <handa@m17n.org>
parents:
101678
diff
changeset
|
5981 charset_list = Vemacs_mule_charset_list; |
11ba351ce12b
(coding_system_charset_list): New function.
Kenichi Handa <handa@m17n.org>
parents:
101678
diff
changeset
|
5982 } |
11ba351ce12b
(coding_system_charset_list): New function.
Kenichi Handa <handa@m17n.org>
parents:
101678
diff
changeset
|
5983 else |
11ba351ce12b
(coding_system_charset_list): New function.
Kenichi Handa <handa@m17n.org>
parents:
101678
diff
changeset
|
5984 { |
11ba351ce12b
(coding_system_charset_list): New function.
Kenichi Handa <handa@m17n.org>
parents:
101678
diff
changeset
|
5985 charset_list = CODING_ATTR_CHARSET_LIST (attrs); |
11ba351ce12b
(coding_system_charset_list): New function.
Kenichi Handa <handa@m17n.org>
parents:
101678
diff
changeset
|
5986 } |
11ba351ce12b
(coding_system_charset_list): New function.
Kenichi Handa <handa@m17n.org>
parents:
101678
diff
changeset
|
5987 return charset_list; |
11ba351ce12b
(coding_system_charset_list): New function.
Kenichi Handa <handa@m17n.org>
parents:
101678
diff
changeset
|
5988 } |
11ba351ce12b
(coding_system_charset_list): New function.
Kenichi Handa <handa@m17n.org>
parents:
101678
diff
changeset
|
5989 |
11ba351ce12b
(coding_system_charset_list): New function.
Kenichi Handa <handa@m17n.org>
parents:
101678
diff
changeset
|
5990 |
88365 | 5991 /* Return raw-text or one of its subsidiaries that has the same |
5992 eol_type as CODING-SYSTEM. */ | |
5993 | |
5994 Lisp_Object | |
109126
aec1143e8d85
Convert (most) functions in src to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109100
diff
changeset
|
5995 raw_text_coding_system (Lisp_Object coding_system) |
26847 | 5996 { |
88430
6418a272b97e
* coding.c: Delete unused variables.
Kenichi Handa <handa@m17n.org>
parents:
88365
diff
changeset
|
5997 Lisp_Object spec, attrs; |
88365 | 5998 Lisp_Object eol_type, raw_text_eol_type; |
5999 | |
89462
4e359ebf3984
(decode_coding_iso_2022): Fix handling of invalid
Kenichi Handa <handa@m17n.org>
parents:
89448
diff
changeset
|
6000 if (NILP (coding_system)) |
4e359ebf3984
(decode_coding_iso_2022): Fix handling of invalid
Kenichi Handa <handa@m17n.org>
parents:
89448
diff
changeset
|
6001 return Qraw_text; |
88365 | 6002 spec = CODING_SYSTEM_SPEC (coding_system); |
6003 attrs = AREF (spec, 0); | |
89483 | 6004 |
88365 | 6005 if (EQ (CODING_ATTR_TYPE (attrs), Qraw_text)) |
6006 return coding_system; | |
6007 | |
6008 eol_type = AREF (spec, 2); | |
6009 if (VECTORP (eol_type)) | |
6010 return Qraw_text; | |
6011 spec = CODING_SYSTEM_SPEC (Qraw_text); | |
6012 raw_text_eol_type = AREF (spec, 2); | |
6013 return (EQ (eol_type, Qunix) ? AREF (raw_text_eol_type, 0) | |
6014 : EQ (eol_type, Qdos) ? AREF (raw_text_eol_type, 1) | |
6015 : AREF (raw_text_eol_type, 2)); | |
26847 | 6016 } |
6017 | |
88365 | 6018 |
6019 /* If CODING_SYSTEM doesn't specify end-of-line format but PARENT | |
6020 does, return one of the subsidiary that has the same eol-spec as | |
90394
263867fe7b55
(system_eol_type): Sync with HEAD.
Kenichi Handa <handa@m17n.org>
parents:
90380
diff
changeset
|
6021 PARENT. Otherwise, return CODING_SYSTEM. If PARENT is nil, |
263867fe7b55
(system_eol_type): Sync with HEAD.
Kenichi Handa <handa@m17n.org>
parents:
90380
diff
changeset
|
6022 inherit end-of-line format from the system's setting |
263867fe7b55
(system_eol_type): Sync with HEAD.
Kenichi Handa <handa@m17n.org>
parents:
90380
diff
changeset
|
6023 (system_eol_type). */ |
88365 | 6024 |
6025 Lisp_Object | |
109126
aec1143e8d85
Convert (most) functions in src to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109100
diff
changeset
|
6026 coding_inherit_eol_type (Lisp_Object coding_system, Lisp_Object parent) |
22616
c493ce6a31e4
(setup_raw_text_coding_system): New function.
Kenichi Handa <handa@m17n.org>
parents:
22529
diff
changeset
|
6027 { |
89545
4f394eed6ff2
(inhibit_pre_post_conversion): Removed (unused).
Dave Love <fx@gnu.org>
parents:
89519
diff
changeset
|
6028 Lisp_Object spec, eol_type; |
88365 | 6029 |
89462
4e359ebf3984
(decode_coding_iso_2022): Fix handling of invalid
Kenichi Handa <handa@m17n.org>
parents:
89448
diff
changeset
|
6030 if (NILP (coding_system)) |
4e359ebf3984
(decode_coding_iso_2022): Fix handling of invalid
Kenichi Handa <handa@m17n.org>
parents:
89448
diff
changeset
|
6031 coding_system = Qraw_text; |
88365 | 6032 spec = CODING_SYSTEM_SPEC (coding_system); |
6033 eol_type = AREF (spec, 2); | |
90394
263867fe7b55
(system_eol_type): Sync with HEAD.
Kenichi Handa <handa@m17n.org>
parents:
90380
diff
changeset
|
6034 if (VECTORP (eol_type)) |
263867fe7b55
(system_eol_type): Sync with HEAD.
Kenichi Handa <handa@m17n.org>
parents:
90380
diff
changeset
|
6035 { |
88365 | 6036 Lisp_Object parent_eol_type; |
6037 | |
90394
263867fe7b55
(system_eol_type): Sync with HEAD.
Kenichi Handa <handa@m17n.org>
parents:
90380
diff
changeset
|
6038 if (! NILP (parent)) |
263867fe7b55
(system_eol_type): Sync with HEAD.
Kenichi Handa <handa@m17n.org>
parents:
90380
diff
changeset
|
6039 { |
263867fe7b55
(system_eol_type): Sync with HEAD.
Kenichi Handa <handa@m17n.org>
parents:
90380
diff
changeset
|
6040 Lisp_Object parent_spec; |
263867fe7b55
(system_eol_type): Sync with HEAD.
Kenichi Handa <handa@m17n.org>
parents:
90380
diff
changeset
|
6041 |
90587
fe721cfad011
(setup_coding_system): Fix setting of
Kenichi Handa <handa@m17n.org>
parents:
90573
diff
changeset
|
6042 parent_spec = CODING_SYSTEM_SPEC (parent); |
90394
263867fe7b55
(system_eol_type): Sync with HEAD.
Kenichi Handa <handa@m17n.org>
parents:
90380
diff
changeset
|
6043 parent_eol_type = AREF (parent_spec, 2); |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
6044 } |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
6045 else |
90394
263867fe7b55
(system_eol_type): Sync with HEAD.
Kenichi Handa <handa@m17n.org>
parents:
90380
diff
changeset
|
6046 parent_eol_type = system_eol_type; |
88365 | 6047 if (EQ (parent_eol_type, Qunix)) |
6048 coding_system = AREF (eol_type, 0); | |
6049 else if (EQ (parent_eol_type, Qdos)) | |
6050 coding_system = AREF (eol_type, 1); | |
6051 else if (EQ (parent_eol_type, Qmac)) | |
6052 coding_system = AREF (eol_type, 2); | |
6053 } | |
6054 return coding_system; | |
22616
c493ce6a31e4
(setup_raw_text_coding_system): New function.
Kenichi Handa <handa@m17n.org>
parents:
22529
diff
changeset
|
6055 } |
c493ce6a31e4
(setup_raw_text_coding_system): New function.
Kenichi Handa <handa@m17n.org>
parents:
22529
diff
changeset
|
6056 |
17052 | 6057 /* Emacs has a mechanism to automatically detect a coding system if it |
6058 is one of Emacs' internal format, ISO2022, SJIS, and BIG5. But, | |
6059 it's impossible to distinguish some coding systems accurately | |
6060 because they use the same range of codes. So, at first, coding | |
6061 systems are categorized into 7, those are: | |
6062 | |
17835
f36ffb6f1208
Name change through the code:
Kenichi Handa <handa@m17n.org>
parents:
17725
diff
changeset
|
6063 o coding-category-emacs-mule |
17052 | 6064 |
6065 The category for a coding system which has the same code range | |
6066 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
|
6067 symbol) `emacs-mule' by default. |
17052 | 6068 |
6069 o coding-category-sjis | |
6070 | |
6071 The category for a coding system which has the same code range | |
6072 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
|
6073 symbol) `japanese-shift-jis' by default. |
17052 | 6074 |
6075 o coding-category-iso-7 | |
6076 | |
6077 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
|
6078 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
|
6079 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
|
6080 charsets. Assigned the coding-system (Lisp symbol) |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
6081 `iso-2022-7bit' by default. |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
6082 |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
6083 o coding-category-iso-7-tight |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
6084 |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
6085 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
|
6086 encode/decode only the specified charsets. |
17052 | 6087 |
6088 o coding-category-iso-8-1 | |
6089 | |
6090 The category for a coding system which has the same code range | |
6091 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
|
6092 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
|
6093 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
|
6094 symbol) `iso-latin-1' by default. |
17052 | 6095 |
6096 o coding-category-iso-8-2 | |
6097 | |
6098 The category for a coding system which has the same code range | |
6099 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
|
6100 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
|
6101 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
|
6102 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
|
6103 |
954e6be0a757
(detect_coding_iso2022): Distinguish coding-category-iso-7-else and
Kenichi Handa <handa@m17n.org>
parents:
18766
diff
changeset
|
6104 o coding-category-iso-7-else |
17052 | 6105 |
6106 The category for a coding system which has the same code range | |
88365 | 6107 as ISO2022 of 7-bit environemnt 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
|
6108 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
|
6109 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
|
6110 |
954e6be0a757
(detect_coding_iso2022): Distinguish coding-category-iso-7-else and
Kenichi Handa <handa@m17n.org>
parents:
18766
diff
changeset
|
6111 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
|
6112 |
954e6be0a757
(detect_coding_iso2022): Distinguish coding-category-iso-7-else and
Kenichi Handa <handa@m17n.org>
parents:
18766
diff
changeset
|
6113 The category for a coding system which has the same code range |
88365 | 6114 as ISO2022 of 8-bit environemnt 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
|
6115 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
|
6116 symbol) `iso-2022-8bit-ss2' by default. |
17052 | 6117 |
6118 o coding-category-big5 | |
6119 | |
6120 The category for a coding system which has the same code range | |
6121 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
|
6122 `cn-big5' by default. |
17052 | 6123 |
28022
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
6124 o coding-category-utf-8 |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
6125 |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
6126 The category for a coding system which has the same code range |
54303 | 6127 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
|
6128 symbol) `utf-8' by default. |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
6129 |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
6130 o coding-category-utf-16-be |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
6131 |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
6132 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
|
6133 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
|
6134 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
|
6135 `utf-16-be' by default. |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
6136 |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
6137 o coding-category-utf-16-le |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
6138 |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
6139 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
|
6140 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
|
6141 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
|
6142 symbol) `utf-16-le' by default. |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
6143 |
22874
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
6144 o coding-category-ccl |
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
6145 |
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
6146 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
|
6147 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
|
6148 coding system is assigned. |
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
6149 |
17052 | 6150 o coding-category-binary |
6151 | |
6152 The category for a coding system not categorized in any of the | |
6153 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
|
6154 `no-conversion' by default. |
17052 | 6155 |
6156 Each of them is a Lisp symbol and the value is an actual | |
88365 | 6157 `coding-system's (this is also a Lisp symbol) assigned by a user. |
17052 | 6158 What Emacs does actually is to detect a category of coding system. |
6159 Then, it uses a `coding-system' assigned to it. If Emacs can't | |
88365 | 6160 decide only one possible category, it selects a category of the |
17052 | 6161 highest priority. Priorities of categories are also specified by a |
6162 user in a Lisp variable `coding-category-list'. | |
6163 | |
6164 */ | |
6165 | |
88365 | 6166 #define EOL_SEEN_NONE 0 |
6167 #define EOL_SEEN_LF 1 | |
6168 #define EOL_SEEN_CR 2 | |
6169 #define EOL_SEEN_CRLF 4 | |
17052 | 6170 |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
6171 /* Detect how end-of-line of a text of length SRC_BYTES pointed by |
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6172 SOURCE is encoded. If CATEGORY is one of |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6173 coding_category_utf_16_XXXX, assume that CR and LF are encoded by |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6174 two-byte, else they are encoded by one-byte. |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6175 |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6176 Return one of EOL_SEEN_XXX. */ |
17052 | 6177 |
19173
04ed7c3f5cee
(detect_eol_type): If EOL representation does not
Richard M. Stallman <rms@gnu.org>
parents:
19134
diff
changeset
|
6178 #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
|
6179 |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
6180 static int |
109159
3e9fdeb960d1
* coding.c, sysdep.c: Convert some more functions to standard C.
Juanma Barranquero <lekktu@gmail.com>
parents:
109158
diff
changeset
|
6181 detect_eol (const unsigned char *source, EMACS_INT src_bytes, |
3e9fdeb960d1
* coding.c, sysdep.c: Convert some more functions to standard C.
Juanma Barranquero <lekktu@gmail.com>
parents:
109158
diff
changeset
|
6182 enum coding_category category) |
17052 | 6183 { |
84646
922a7e3b7383
(detect_eol_type, detect_eol_type_in_2_octet_form):
Michaël Cadilhac <michael.cadilhac@lrde.org>
parents:
83648
diff
changeset
|
6184 const unsigned char *src = source, *src_end = src + src_bytes; |
17052 | 6185 unsigned char c; |
88365 | 6186 int total = 0; |
6187 int eol_seen = EOL_SEEN_NONE; | |
6188 | |
89193
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
6189 if ((1 << category) & CATEGORY_MASK_UTF_16) |
88365 | 6190 { |
6191 int msb, lsb; | |
6192 | |
89193
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
6193 msb = category == (coding_category_utf_16_le |
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
6194 | coding_category_utf_16_le_nosig); |
88365 | 6195 lsb = 1 - msb; |
6196 | |
6197 while (src + 1 < src_end) | |
17052 | 6198 { |
88365 | 6199 c = src[lsb]; |
6200 if (src[msb] == 0 && (c == '\n' || c == '\r')) | |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
6201 { |
88365 | 6202 int this_eol; |
6203 | |
6204 if (c == '\n') | |
6205 this_eol = EOL_SEEN_LF; | |
6206 else if (src + 3 >= src_end | |
6207 || src[msb + 2] != 0 | |
6208 || src[lsb + 2] != '\n') | |
6209 this_eol = EOL_SEEN_CR; | |
6210 else | |
101678
589af07b7af1
(detect_eol, decode_eol): Handle text with DOS-style EOLs that also has
Eli Zaretskii <eliz@gnu.org>
parents:
101197
diff
changeset
|
6211 { |
589af07b7af1
(detect_eol, decode_eol): Handle text with DOS-style EOLs that also has
Eli Zaretskii <eliz@gnu.org>
parents:
101197
diff
changeset
|
6212 this_eol = EOL_SEEN_CRLF; |
589af07b7af1
(detect_eol, decode_eol): Handle text with DOS-style EOLs that also has
Eli Zaretskii <eliz@gnu.org>
parents:
101197
diff
changeset
|
6213 src += 2; |
589af07b7af1
(detect_eol, decode_eol): Handle text with DOS-style EOLs that also has
Eli Zaretskii <eliz@gnu.org>
parents:
101197
diff
changeset
|
6214 } |
88365 | 6215 |
6216 if (eol_seen == EOL_SEEN_NONE) | |
6217 /* This is the first end-of-line. */ | |
6218 eol_seen = this_eol; | |
6219 else if (eol_seen != this_eol) | |
6220 { | |
101678
589af07b7af1
(detect_eol, decode_eol): Handle text with DOS-style EOLs that also has
Eli Zaretskii <eliz@gnu.org>
parents:
101197
diff
changeset
|
6221 /* The found type is different from what found before. |
589af07b7af1
(detect_eol, decode_eol): Handle text with DOS-style EOLs that also has
Eli Zaretskii <eliz@gnu.org>
parents:
101197
diff
changeset
|
6222 Allow for stray ^M characters in DOS EOL files. */ |
589af07b7af1
(detect_eol, decode_eol): Handle text with DOS-style EOLs that also has
Eli Zaretskii <eliz@gnu.org>
parents:
101197
diff
changeset
|
6223 if (eol_seen == EOL_SEEN_CR && this_eol == EOL_SEEN_CRLF |
589af07b7af1
(detect_eol, decode_eol): Handle text with DOS-style EOLs that also has
Eli Zaretskii <eliz@gnu.org>
parents:
101197
diff
changeset
|
6224 || eol_seen == EOL_SEEN_CRLF && this_eol == EOL_SEEN_CR) |
589af07b7af1
(detect_eol, decode_eol): Handle text with DOS-style EOLs that also has
Eli Zaretskii <eliz@gnu.org>
parents:
101197
diff
changeset
|
6225 eol_seen = EOL_SEEN_CRLF; |
589af07b7af1
(detect_eol, decode_eol): Handle text with DOS-style EOLs that also has
Eli Zaretskii <eliz@gnu.org>
parents:
101197
diff
changeset
|
6226 else |
589af07b7af1
(detect_eol, decode_eol): Handle text with DOS-style EOLs that also has
Eli Zaretskii <eliz@gnu.org>
parents:
101197
diff
changeset
|
6227 { |
589af07b7af1
(detect_eol, decode_eol): Handle text with DOS-style EOLs that also has
Eli Zaretskii <eliz@gnu.org>
parents:
101197
diff
changeset
|
6228 eol_seen = EOL_SEEN_LF; |
589af07b7af1
(detect_eol, decode_eol): Handle text with DOS-style EOLs that also has
Eli Zaretskii <eliz@gnu.org>
parents:
101197
diff
changeset
|
6229 break; |
589af07b7af1
(detect_eol, decode_eol): Handle text with DOS-style EOLs that also has
Eli Zaretskii <eliz@gnu.org>
parents:
101197
diff
changeset
|
6230 } |
88365 | 6231 } |
6232 if (++total == MAX_EOL_CHECK_COUNT) | |
6233 break; | |
6234 } | |
6235 src += 2; | |
6236 } | |
30833
2db6e42a6ba3
(MINIMUM_CONVERSION_BUFFER_SIZE): Macro deleted.
Kenichi Handa <handa@m17n.org>
parents:
30756
diff
changeset
|
6237 } |
88365 | 6238 else |
6239 { | |
6240 while (src < src_end) | |
6241 { | |
6242 c = *src++; | |
6243 if (c == '\n' || c == '\r') | |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
6244 { |
88365 | 6245 int this_eol; |
6246 | |
6247 if (c == '\n') | |
6248 this_eol = EOL_SEEN_LF; | |
6249 else if (src >= src_end || *src != '\n') | |
6250 this_eol = EOL_SEEN_CR; | |
6251 else | |
6252 this_eol = EOL_SEEN_CRLF, src++; | |
6253 | |
6254 if (eol_seen == EOL_SEEN_NONE) | |
6255 /* This is the first end-of-line. */ | |
6256 eol_seen = this_eol; | |
6257 else if (eol_seen != this_eol) | |
6258 { | |
101678
589af07b7af1
(detect_eol, decode_eol): Handle text with DOS-style EOLs that also has
Eli Zaretskii <eliz@gnu.org>
parents:
101197
diff
changeset
|
6259 /* The found type is different from what found before. |
589af07b7af1
(detect_eol, decode_eol): Handle text with DOS-style EOLs that also has
Eli Zaretskii <eliz@gnu.org>
parents:
101197
diff
changeset
|
6260 Allow for stray ^M characters in DOS EOL files. */ |
589af07b7af1
(detect_eol, decode_eol): Handle text with DOS-style EOLs that also has
Eli Zaretskii <eliz@gnu.org>
parents:
101197
diff
changeset
|
6261 if (eol_seen == EOL_SEEN_CR && this_eol == EOL_SEEN_CRLF |
589af07b7af1
(detect_eol, decode_eol): Handle text with DOS-style EOLs that also has
Eli Zaretskii <eliz@gnu.org>
parents:
101197
diff
changeset
|
6262 || eol_seen == EOL_SEEN_CRLF && this_eol == EOL_SEEN_CR) |
589af07b7af1
(detect_eol, decode_eol): Handle text with DOS-style EOLs that also has
Eli Zaretskii <eliz@gnu.org>
parents:
101197
diff
changeset
|
6263 eol_seen = EOL_SEEN_CRLF; |
589af07b7af1
(detect_eol, decode_eol): Handle text with DOS-style EOLs that also has
Eli Zaretskii <eliz@gnu.org>
parents:
101197
diff
changeset
|
6264 else |
589af07b7af1
(detect_eol, decode_eol): Handle text with DOS-style EOLs that also has
Eli Zaretskii <eliz@gnu.org>
parents:
101197
diff
changeset
|
6265 { |
589af07b7af1
(detect_eol, decode_eol): Handle text with DOS-style EOLs that also has
Eli Zaretskii <eliz@gnu.org>
parents:
101197
diff
changeset
|
6266 eol_seen = EOL_SEEN_LF; |
589af07b7af1
(detect_eol, decode_eol): Handle text with DOS-style EOLs that also has
Eli Zaretskii <eliz@gnu.org>
parents:
101197
diff
changeset
|
6267 break; |
589af07b7af1
(detect_eol, decode_eol): Handle text with DOS-style EOLs that also has
Eli Zaretskii <eliz@gnu.org>
parents:
101197
diff
changeset
|
6268 } |
88365 | 6269 } |
6270 if (++total == MAX_EOL_CHECK_COUNT) | |
6271 break; | |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
6272 } |
17052 | 6273 } |
6274 } | |
88365 | 6275 return eol_seen; |
17052 | 6276 } |
6277 | |
88365 | 6278 |
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6279 static Lisp_Object |
109126
aec1143e8d85
Convert (most) functions in src to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109100
diff
changeset
|
6280 adjust_coding_eol_type (struct coding_system *coding, int eol_seen) |
88365 | 6281 { |
88430
6418a272b97e
* coding.c: Delete unused variables.
Kenichi Handa <handa@m17n.org>
parents:
88365
diff
changeset
|
6282 Lisp_Object eol_type; |
89483 | 6283 |
88365 | 6284 eol_type = CODING_ID_EOL_TYPE (coding->id); |
6285 if (eol_seen & EOL_SEEN_LF) | |
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6286 { |
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6287 coding->id = CODING_SYSTEM_ID (AREF (eol_type, 0)); |
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6288 eol_type = Qunix; |
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6289 } |
88862
108e2535280d
(adjust_coding_eol_type): Fix eol_type/eol_seen mixup.
Dave Love <fx@gnu.org>
parents:
88856
diff
changeset
|
6290 else if (eol_seen & EOL_SEEN_CRLF) |
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6291 { |
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6292 coding->id = CODING_SYSTEM_ID (AREF (eol_type, 1)); |
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6293 eol_type = Qdos; |
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6294 } |
88862
108e2535280d
(adjust_coding_eol_type): Fix eol_type/eol_seen mixup.
Dave Love <fx@gnu.org>
parents:
88856
diff
changeset
|
6295 else if (eol_seen & EOL_SEEN_CR) |
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6296 { |
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6297 coding->id = CODING_SYSTEM_ID (AREF (eol_type, 2)); |
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6298 eol_type = Qmac; |
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6299 } |
19181
917138730635
(detect_eol_type): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
19173
diff
changeset
|
6300 return eol_type; |
17052 | 6301 } |
6302 | |
88365 | 6303 /* Detect how a text specified in CODING is encoded. If a coding |
6304 system is detected, update fields of CODING by the detected coding | |
6305 system. */ | |
17052 | 6306 |
6307 void | |
109126
aec1143e8d85
Convert (most) functions in src to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109100
diff
changeset
|
6308 detect_coding (struct coding_system *coding) |
28022
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
6309 { |
89483 | 6310 const unsigned char *src, *src_end; |
102105
a5023e8bbb1e
(detect_coding): Preserve coding->mode.
Kenichi Handa <handa@m17n.org>
parents:
102058
diff
changeset
|
6311 int saved_mode = coding->mode; |
88365 | 6312 |
6313 coding->consumed = coding->consumed_char = 0; | |
6314 coding->produced = coding->produced_char = 0; | |
6315 coding_set_source (coding); | |
6316 | |
6317 src_end = coding->source + coding->src_bytes; | |
95533
831c8ee4d884
(detect_coding): Fix handling of coding->head_ascii.
Kenichi Handa <handa@m17n.org>
parents:
95397
diff
changeset
|
6318 coding->head_ascii = 0; |
88365 | 6319 |
6320 /* If we have not yet decided the text encoding type, detect it | |
6321 now. */ | |
6322 if (EQ (CODING_ATTR_TYPE (CODING_ID_ATTRS (coding->id)), Qundecided)) | |
6323 { | |
6324 int c, i; | |
89974
2fef8edebd5c
(detect_coding_utf_16): Don't set detect_info->found if
Kenichi Handa <handa@m17n.org>
parents:
89933
diff
changeset
|
6325 struct coding_detection_info detect_info; |
93595
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
6326 int null_byte_found = 0, eight_bit_found = 0; |
89974
2fef8edebd5c
(detect_coding_utf_16): Don't set detect_info->found if
Kenichi Handa <handa@m17n.org>
parents:
89933
diff
changeset
|
6327 |
2fef8edebd5c
(detect_coding_utf_16): Don't set detect_info->found if
Kenichi Handa <handa@m17n.org>
parents:
89933
diff
changeset
|
6328 detect_info.checked = detect_info.found = detect_info.rejected = 0; |
93595
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
6329 for (src = coding->source; src < src_end; src++) |
28022
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
6330 { |
88365 | 6331 c = *src; |
89974
2fef8edebd5c
(detect_coding_utf_16): Don't set detect_info->found if
Kenichi Handa <handa@m17n.org>
parents:
89933
diff
changeset
|
6332 if (c & 0x80) |
93595
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
6333 { |
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
6334 eight_bit_found = 1; |
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
6335 if (null_byte_found) |
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
6336 break; |
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
6337 } |
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
6338 else if (c < 0x20) |
34892
3868f2e7355a
(setup_coding_system): Initialize
Kenichi Handa <handa@m17n.org>
parents:
34888
diff
changeset
|
6339 { |
93595
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
6340 if ((c == ISO_CODE_ESC || c == ISO_CODE_SI || c == ISO_CODE_SO) |
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
6341 && ! inhibit_iso_escape_detection |
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
6342 && ! detect_info.checked) |
34892
3868f2e7355a
(setup_coding_system): Initialize
Kenichi Handa <handa@m17n.org>
parents:
34888
diff
changeset
|
6343 { |
93595
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
6344 if (detect_coding_iso_2022 (coding, &detect_info)) |
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
6345 { |
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
6346 /* We have scanned the whole data. */ |
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
6347 if (! (detect_info.rejected & CATEGORY_MASK_ISO_7_ELSE)) |
95533
831c8ee4d884
(detect_coding): Fix handling of coding->head_ascii.
Kenichi Handa <handa@m17n.org>
parents:
95397
diff
changeset
|
6348 { |
831c8ee4d884
(detect_coding): Fix handling of coding->head_ascii.
Kenichi Handa <handa@m17n.org>
parents:
95397
diff
changeset
|
6349 /* We didn't find an 8-bit code. We may |
831c8ee4d884
(detect_coding): Fix handling of coding->head_ascii.
Kenichi Handa <handa@m17n.org>
parents:
95397
diff
changeset
|
6350 have found a null-byte, but it's very |
107984
bef5d1738c0b
Make variable forwarding explicit rather the using special values.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
107507
diff
changeset
|
6351 rare that a binary file conforms to |
95533
831c8ee4d884
(detect_coding): Fix handling of coding->head_ascii.
Kenichi Handa <handa@m17n.org>
parents:
95397
diff
changeset
|
6352 ISO-2022. */ |
831c8ee4d884
(detect_coding): Fix handling of coding->head_ascii.
Kenichi Handa <handa@m17n.org>
parents:
95397
diff
changeset
|
6353 src = src_end; |
831c8ee4d884
(detect_coding): Fix handling of coding->head_ascii.
Kenichi Handa <handa@m17n.org>
parents:
95397
diff
changeset
|
6354 coding->head_ascii = src - coding->source; |
831c8ee4d884
(detect_coding): Fix handling of coding->head_ascii.
Kenichi Handa <handa@m17n.org>
parents:
95397
diff
changeset
|
6355 } |
831c8ee4d884
(detect_coding): Fix handling of coding->head_ascii.
Kenichi Handa <handa@m17n.org>
parents:
95397
diff
changeset
|
6356 detect_info.rejected |= ~CATEGORY_MASK_ISO_ESCAPE; |
93595
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
6357 break; |
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
6358 } |
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
6359 } |
101040 | 6360 else if (! c && !inhibit_null_byte_detection) |
93595
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
6361 { |
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
6362 null_byte_found = 1; |
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
6363 if (eight_bit_found) |
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
6364 break; |
34892
3868f2e7355a
(setup_coding_system): Initialize
Kenichi Handa <handa@m17n.org>
parents:
34888
diff
changeset
|
6365 } |
95585
862c7386145c
(detect_coding): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
95533
diff
changeset
|
6366 if (! eight_bit_found) |
862c7386145c
(detect_coding): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
95533
diff
changeset
|
6367 coding->head_ascii++; |
34892
3868f2e7355a
(setup_coding_system): Initialize
Kenichi Handa <handa@m17n.org>
parents:
34888
diff
changeset
|
6368 } |
95585
862c7386145c
(detect_coding): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
95533
diff
changeset
|
6369 else if (! eight_bit_found) |
95533
831c8ee4d884
(detect_coding): Fix handling of coding->head_ascii.
Kenichi Handa <handa@m17n.org>
parents:
95397
diff
changeset
|
6370 coding->head_ascii++; |
831c8ee4d884
(detect_coding): Fix handling of coding->head_ascii.
Kenichi Handa <handa@m17n.org>
parents:
95397
diff
changeset
|
6371 } |
93595
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
6372 |
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
6373 if (null_byte_found || eight_bit_found |
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
6374 || coding->head_ascii < coding->src_bytes |
89974
2fef8edebd5c
(detect_coding_utf_16): Don't set detect_info->found if
Kenichi Handa <handa@m17n.org>
parents:
89933
diff
changeset
|
6375 || detect_info.found) |
2fef8edebd5c
(detect_coding_utf_16): Don't set detect_info->found if
Kenichi Handa <handa@m17n.org>
parents:
89933
diff
changeset
|
6376 { |
2fef8edebd5c
(detect_coding_utf_16): Don't set detect_info->found if
Kenichi Handa <handa@m17n.org>
parents:
89933
diff
changeset
|
6377 enum coding_category category; |
2fef8edebd5c
(detect_coding_utf_16): Don't set detect_info->found if
Kenichi Handa <handa@m17n.org>
parents:
89933
diff
changeset
|
6378 struct coding_system *this; |
2fef8edebd5c
(detect_coding_utf_16): Don't set detect_info->found if
Kenichi Handa <handa@m17n.org>
parents:
89933
diff
changeset
|
6379 |
2fef8edebd5c
(detect_coding_utf_16): Don't set detect_info->found if
Kenichi Handa <handa@m17n.org>
parents:
89933
diff
changeset
|
6380 if (coding->head_ascii == coding->src_bytes) |
2fef8edebd5c
(detect_coding_utf_16): Don't set detect_info->found if
Kenichi Handa <handa@m17n.org>
parents:
89933
diff
changeset
|
6381 /* As all bytes are 7-bit, we can ignore non-ISO-2022 codings. */ |
2fef8edebd5c
(detect_coding_utf_16): Don't set detect_info->found if
Kenichi Handa <handa@m17n.org>
parents:
89933
diff
changeset
|
6382 for (i = 0; i < coding_category_raw_text; i++) |
2fef8edebd5c
(detect_coding_utf_16): Don't set detect_info->found if
Kenichi Handa <handa@m17n.org>
parents:
89933
diff
changeset
|
6383 { |
2fef8edebd5c
(detect_coding_utf_16): Don't set detect_info->found if
Kenichi Handa <handa@m17n.org>
parents:
89933
diff
changeset
|
6384 category = coding_priorities[i]; |
2fef8edebd5c
(detect_coding_utf_16): Don't set detect_info->found if
Kenichi Handa <handa@m17n.org>
parents:
89933
diff
changeset
|
6385 this = coding_categories + category; |
2fef8edebd5c
(detect_coding_utf_16): Don't set detect_info->found if
Kenichi Handa <handa@m17n.org>
parents:
89933
diff
changeset
|
6386 if (detect_info.found & (1 << category)) |
2fef8edebd5c
(detect_coding_utf_16): Don't set detect_info->found if
Kenichi Handa <handa@m17n.org>
parents:
89933
diff
changeset
|
6387 break; |
2fef8edebd5c
(detect_coding_utf_16): Don't set detect_info->found if
Kenichi Handa <handa@m17n.org>
parents:
89933
diff
changeset
|
6388 } |
2fef8edebd5c
(detect_coding_utf_16): Don't set detect_info->found if
Kenichi Handa <handa@m17n.org>
parents:
89933
diff
changeset
|
6389 else |
93595
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
6390 { |
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
6391 if (null_byte_found) |
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
6392 { |
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
6393 detect_info.checked |= ~CATEGORY_MASK_UTF_16; |
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
6394 detect_info.rejected |= ~CATEGORY_MASK_UTF_16; |
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
6395 } |
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
6396 for (i = 0; i < coding_category_raw_text; i++) |
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
6397 { |
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
6398 category = coding_priorities[i]; |
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
6399 this = coding_categories + category; |
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
6400 if (this->id < 0) |
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
6401 { |
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
6402 /* No coding system of this category is defined. */ |
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
6403 detect_info.rejected |= (1 << category); |
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
6404 } |
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
6405 else if (category >= coding_category_raw_text) |
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
6406 continue; |
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
6407 else if (detect_info.checked & (1 << category)) |
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
6408 { |
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
6409 if (detect_info.found & (1 << category)) |
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
6410 break; |
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
6411 } |
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
6412 else if ((*(this->detector)) (coding, &detect_info) |
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
6413 && detect_info.found & (1 << category)) |
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
6414 { |
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
6415 if (category == coding_category_utf_16_auto) |
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
6416 { |
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
6417 if (detect_info.found & CATEGORY_MASK_UTF_16_LE) |
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
6418 category = coding_category_utf_16_le; |
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
6419 else |
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
6420 category = coding_category_utf_16_be; |
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
6421 } |
89974
2fef8edebd5c
(detect_coding_utf_16): Don't set detect_info->found if
Kenichi Handa <handa@m17n.org>
parents:
89933
diff
changeset
|
6422 break; |
93595
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
6423 } |
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
6424 } |
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
6425 } |
95533
831c8ee4d884
(detect_coding): Fix handling of coding->head_ascii.
Kenichi Handa <handa@m17n.org>
parents:
95397
diff
changeset
|
6426 |
831c8ee4d884
(detect_coding): Fix handling of coding->head_ascii.
Kenichi Handa <handa@m17n.org>
parents:
95397
diff
changeset
|
6427 if (i < coding_category_raw_text) |
831c8ee4d884
(detect_coding): Fix handling of coding->head_ascii.
Kenichi Handa <handa@m17n.org>
parents:
95397
diff
changeset
|
6428 setup_coding_system (CODING_ID_NAME (this->id), coding); |
831c8ee4d884
(detect_coding): Fix handling of coding->head_ascii.
Kenichi Handa <handa@m17n.org>
parents:
95397
diff
changeset
|
6429 else if (null_byte_found) |
831c8ee4d884
(detect_coding): Fix handling of coding->head_ascii.
Kenichi Handa <handa@m17n.org>
parents:
95397
diff
changeset
|
6430 setup_coding_system (Qno_conversion, coding); |
831c8ee4d884
(detect_coding): Fix handling of coding->head_ascii.
Kenichi Handa <handa@m17n.org>
parents:
95397
diff
changeset
|
6431 else if ((detect_info.rejected & CATEGORY_MASK_ANY) |
831c8ee4d884
(detect_coding): Fix handling of coding->head_ascii.
Kenichi Handa <handa@m17n.org>
parents:
95397
diff
changeset
|
6432 == CATEGORY_MASK_ANY) |
831c8ee4d884
(detect_coding): Fix handling of coding->head_ascii.
Kenichi Handa <handa@m17n.org>
parents:
95397
diff
changeset
|
6433 setup_coding_system (Qraw_text, coding); |
831c8ee4d884
(detect_coding): Fix handling of coding->head_ascii.
Kenichi Handa <handa@m17n.org>
parents:
95397
diff
changeset
|
6434 else if (detect_info.rejected) |
831c8ee4d884
(detect_coding): Fix handling of coding->head_ascii.
Kenichi Handa <handa@m17n.org>
parents:
95397
diff
changeset
|
6435 for (i = 0; i < coding_category_raw_text; i++) |
831c8ee4d884
(detect_coding): Fix handling of coding->head_ascii.
Kenichi Handa <handa@m17n.org>
parents:
95397
diff
changeset
|
6436 if (! (detect_info.rejected & (1 << coding_priorities[i]))) |
831c8ee4d884
(detect_coding): Fix handling of coding->head_ascii.
Kenichi Handa <handa@m17n.org>
parents:
95397
diff
changeset
|
6437 { |
831c8ee4d884
(detect_coding): Fix handling of coding->head_ascii.
Kenichi Handa <handa@m17n.org>
parents:
95397
diff
changeset
|
6438 this = coding_categories + coding_priorities[i]; |
831c8ee4d884
(detect_coding): Fix handling of coding->head_ascii.
Kenichi Handa <handa@m17n.org>
parents:
95397
diff
changeset
|
6439 setup_coding_system (CODING_ID_NAME (this->id), coding); |
831c8ee4d884
(detect_coding): Fix handling of coding->head_ascii.
Kenichi Handa <handa@m17n.org>
parents:
95397
diff
changeset
|
6440 break; |
831c8ee4d884
(detect_coding): Fix handling of coding->head_ascii.
Kenichi Handa <handa@m17n.org>
parents:
95397
diff
changeset
|
6441 } |
88365 | 6442 } |
6443 } | |
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6444 else if (XINT (CODING_ATTR_CATEGORY (CODING_ID_ATTRS (coding->id))) |
95397
c99f0a16c077
(CODING_UTF_8_BOM): New macro.
Kenichi Handa <handa@m17n.org>
parents:
95356
diff
changeset
|
6445 == coding_category_utf_8_auto) |
c99f0a16c077
(CODING_UTF_8_BOM): New macro.
Kenichi Handa <handa@m17n.org>
parents:
95356
diff
changeset
|
6446 { |
c99f0a16c077
(CODING_UTF_8_BOM): New macro.
Kenichi Handa <handa@m17n.org>
parents:
95356
diff
changeset
|
6447 Lisp_Object coding_systems; |
c99f0a16c077
(CODING_UTF_8_BOM): New macro.
Kenichi Handa <handa@m17n.org>
parents:
95356
diff
changeset
|
6448 struct coding_detection_info detect_info; |
c99f0a16c077
(CODING_UTF_8_BOM): New macro.
Kenichi Handa <handa@m17n.org>
parents:
95356
diff
changeset
|
6449 |
c99f0a16c077
(CODING_UTF_8_BOM): New macro.
Kenichi Handa <handa@m17n.org>
parents:
95356
diff
changeset
|
6450 coding_systems |
c99f0a16c077
(CODING_UTF_8_BOM): New macro.
Kenichi Handa <handa@m17n.org>
parents:
95356
diff
changeset
|
6451 = AREF (CODING_ID_ATTRS (coding->id), coding_attr_utf_bom); |
c99f0a16c077
(CODING_UTF_8_BOM): New macro.
Kenichi Handa <handa@m17n.org>
parents:
95356
diff
changeset
|
6452 detect_info.found = detect_info.rejected = 0; |
c99f0a16c077
(CODING_UTF_8_BOM): New macro.
Kenichi Handa <handa@m17n.org>
parents:
95356
diff
changeset
|
6453 coding->head_ascii = 0; |
c99f0a16c077
(CODING_UTF_8_BOM): New macro.
Kenichi Handa <handa@m17n.org>
parents:
95356
diff
changeset
|
6454 if (CONSP (coding_systems) |
c99f0a16c077
(CODING_UTF_8_BOM): New macro.
Kenichi Handa <handa@m17n.org>
parents:
95356
diff
changeset
|
6455 && detect_coding_utf_8 (coding, &detect_info)) |
c99f0a16c077
(CODING_UTF_8_BOM): New macro.
Kenichi Handa <handa@m17n.org>
parents:
95356
diff
changeset
|
6456 { |
c99f0a16c077
(CODING_UTF_8_BOM): New macro.
Kenichi Handa <handa@m17n.org>
parents:
95356
diff
changeset
|
6457 if (detect_info.found & CATEGORY_MASK_UTF_8_SIG) |
c99f0a16c077
(CODING_UTF_8_BOM): New macro.
Kenichi Handa <handa@m17n.org>
parents:
95356
diff
changeset
|
6458 setup_coding_system (XCAR (coding_systems), coding); |
c99f0a16c077
(CODING_UTF_8_BOM): New macro.
Kenichi Handa <handa@m17n.org>
parents:
95356
diff
changeset
|
6459 else |
c99f0a16c077
(CODING_UTF_8_BOM): New macro.
Kenichi Handa <handa@m17n.org>
parents:
95356
diff
changeset
|
6460 setup_coding_system (XCDR (coding_systems), coding); |
c99f0a16c077
(CODING_UTF_8_BOM): New macro.
Kenichi Handa <handa@m17n.org>
parents:
95356
diff
changeset
|
6461 } |
c99f0a16c077
(CODING_UTF_8_BOM): New macro.
Kenichi Handa <handa@m17n.org>
parents:
95356
diff
changeset
|
6462 } |
c99f0a16c077
(CODING_UTF_8_BOM): New macro.
Kenichi Handa <handa@m17n.org>
parents:
95356
diff
changeset
|
6463 else if (XINT (CODING_ATTR_CATEGORY (CODING_ID_ATTRS (coding->id))) |
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6464 == coding_category_utf_16_auto) |
89420
c3e67ce6ee0f
(Qsignature, Qendian): Delete these variables.
Kenichi Handa <handa@m17n.org>
parents:
89418
diff
changeset
|
6465 { |
c3e67ce6ee0f
(Qsignature, Qendian): Delete these variables.
Kenichi Handa <handa@m17n.org>
parents:
89418
diff
changeset
|
6466 Lisp_Object coding_systems; |
c3e67ce6ee0f
(Qsignature, Qendian): Delete these variables.
Kenichi Handa <handa@m17n.org>
parents:
89418
diff
changeset
|
6467 struct coding_detection_info detect_info; |
c3e67ce6ee0f
(Qsignature, Qendian): Delete these variables.
Kenichi Handa <handa@m17n.org>
parents:
89418
diff
changeset
|
6468 |
c3e67ce6ee0f
(Qsignature, Qendian): Delete these variables.
Kenichi Handa <handa@m17n.org>
parents:
89418
diff
changeset
|
6469 coding_systems |
95397
c99f0a16c077
(CODING_UTF_8_BOM): New macro.
Kenichi Handa <handa@m17n.org>
parents:
95356
diff
changeset
|
6470 = AREF (CODING_ID_ATTRS (coding->id), coding_attr_utf_bom); |
89420
c3e67ce6ee0f
(Qsignature, Qendian): Delete these variables.
Kenichi Handa <handa@m17n.org>
parents:
89418
diff
changeset
|
6471 detect_info.found = detect_info.rejected = 0; |
95397
c99f0a16c077
(CODING_UTF_8_BOM): New macro.
Kenichi Handa <handa@m17n.org>
parents:
95356
diff
changeset
|
6472 coding->head_ascii = 0; |
89420
c3e67ce6ee0f
(Qsignature, Qendian): Delete these variables.
Kenichi Handa <handa@m17n.org>
parents:
89418
diff
changeset
|
6473 if (CONSP (coding_systems) |
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6474 && detect_coding_utf_16 (coding, &detect_info)) |
89420
c3e67ce6ee0f
(Qsignature, Qendian): Delete these variables.
Kenichi Handa <handa@m17n.org>
parents:
89418
diff
changeset
|
6475 { |
c3e67ce6ee0f
(Qsignature, Qendian): Delete these variables.
Kenichi Handa <handa@m17n.org>
parents:
89418
diff
changeset
|
6476 if (detect_info.found & CATEGORY_MASK_UTF_16_LE) |
c3e67ce6ee0f
(Qsignature, Qendian): Delete these variables.
Kenichi Handa <handa@m17n.org>
parents:
89418
diff
changeset
|
6477 setup_coding_system (XCAR (coding_systems), coding); |
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6478 else if (detect_info.found & CATEGORY_MASK_UTF_16_BE) |
89420
c3e67ce6ee0f
(Qsignature, Qendian): Delete these variables.
Kenichi Handa <handa@m17n.org>
parents:
89418
diff
changeset
|
6479 setup_coding_system (XCDR (coding_systems), coding); |
c3e67ce6ee0f
(Qsignature, Qendian): Delete these variables.
Kenichi Handa <handa@m17n.org>
parents:
89418
diff
changeset
|
6480 } |
c3e67ce6ee0f
(Qsignature, Qendian): Delete these variables.
Kenichi Handa <handa@m17n.org>
parents:
89418
diff
changeset
|
6481 } |
102105
a5023e8bbb1e
(detect_coding): Preserve coding->mode.
Kenichi Handa <handa@m17n.org>
parents:
102058
diff
changeset
|
6482 coding->mode = saved_mode; |
88365 | 6483 } |
6484 | |
29725
2bc397e9b09a
(setup_coding_system) <4>: Reset member `cr_carryover'.
Kenichi Handa <handa@m17n.org>
parents:
29663
diff
changeset
|
6485 |
2bc397e9b09a
(setup_coding_system) <4>: Reset member `cr_carryover'.
Kenichi Handa <handa@m17n.org>
parents:
29663
diff
changeset
|
6486 static void |
109126
aec1143e8d85
Convert (most) functions in src to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109100
diff
changeset
|
6487 decode_eol (struct coding_system *coding) |
88365 | 6488 { |
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6489 Lisp_Object eol_type; |
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6490 unsigned char *p, *pbeg, *pend; |
93877
62d97ebb13a9
* coding.c (detect_coding_emacs_mule)
Michael Albinus <michael.albinus@gmx.de>
parents:
93595
diff
changeset
|
6491 |
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6492 eol_type = CODING_ID_EOL_TYPE (coding->id); |
102334
7baaea85626e
(decode_coding_utf_8, decode_coding_utf_16, decode_coding_emacs_mule,
Eli Zaretskii <eliz@gnu.org>
parents:
102327
diff
changeset
|
6493 if (EQ (eol_type, Qunix) || inhibit_eol_conversion) |
17052 | 6494 return; |
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6495 |
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6496 if (NILP (coding->dst_object)) |
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6497 pbeg = coding->destination; |
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6498 else |
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6499 pbeg = BYTE_POS_ADDR (coding->dst_pos_byte); |
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6500 pend = pbeg + coding->produced; |
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6501 |
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6502 if (VECTORP (eol_type)) |
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6503 { |
88365 | 6504 int eol_seen = EOL_SEEN_NONE; |
6505 | |
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6506 for (p = pbeg; p < pend; p++) |
88365 | 6507 { |
6508 if (*p == '\n') | |
6509 eol_seen |= EOL_SEEN_LF; | |
6510 else if (*p == '\r') | |
29725
2bc397e9b09a
(setup_coding_system) <4>: Reset member `cr_carryover'.
Kenichi Handa <handa@m17n.org>
parents:
29663
diff
changeset
|
6511 { |
88365 | 6512 if (p + 1 < pend && *(p + 1) == '\n') |
29725
2bc397e9b09a
(setup_coding_system) <4>: Reset member `cr_carryover'.
Kenichi Handa <handa@m17n.org>
parents:
29663
diff
changeset
|
6513 { |
88365 | 6514 eol_seen |= EOL_SEEN_CRLF; |
6515 p++; | |
29725
2bc397e9b09a
(setup_coding_system) <4>: Reset member `cr_carryover'.
Kenichi Handa <handa@m17n.org>
parents:
29663
diff
changeset
|
6516 } |
2bc397e9b09a
(setup_coding_system) <4>: Reset member `cr_carryover'.
Kenichi Handa <handa@m17n.org>
parents:
29663
diff
changeset
|
6517 else |
88365 | 6518 eol_seen |= EOL_SEEN_CR; |
29725
2bc397e9b09a
(setup_coding_system) <4>: Reset member `cr_carryover'.
Kenichi Handa <handa@m17n.org>
parents:
29663
diff
changeset
|
6519 } |
28022
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
6520 } |
101678
589af07b7af1
(detect_eol, decode_eol): Handle text with DOS-style EOLs that also has
Eli Zaretskii <eliz@gnu.org>
parents:
101197
diff
changeset
|
6521 /* Handle DOS-style EOLs in a file with stray ^M characters. */ |
589af07b7af1
(detect_eol, decode_eol): Handle text with DOS-style EOLs that also has
Eli Zaretskii <eliz@gnu.org>
parents:
101197
diff
changeset
|
6522 if ((eol_seen & EOL_SEEN_CRLF) != 0 |
589af07b7af1
(detect_eol, decode_eol): Handle text with DOS-style EOLs that also has
Eli Zaretskii <eliz@gnu.org>
parents:
101197
diff
changeset
|
6523 && (eol_seen & EOL_SEEN_CR) != 0 |
589af07b7af1
(detect_eol, decode_eol): Handle text with DOS-style EOLs that also has
Eli Zaretskii <eliz@gnu.org>
parents:
101197
diff
changeset
|
6524 && (eol_seen & EOL_SEEN_LF) == 0) |
589af07b7af1
(detect_eol, decode_eol): Handle text with DOS-style EOLs that also has
Eli Zaretskii <eliz@gnu.org>
parents:
101197
diff
changeset
|
6525 eol_seen = EOL_SEEN_CRLF; |
589af07b7af1
(detect_eol, decode_eol): Handle text with DOS-style EOLs that also has
Eli Zaretskii <eliz@gnu.org>
parents:
101197
diff
changeset
|
6526 else if (eol_seen != EOL_SEEN_NONE |
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6527 && eol_seen != EOL_SEEN_LF |
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6528 && eol_seen != EOL_SEEN_CRLF |
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6529 && eol_seen != EOL_SEEN_CR) |
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6530 eol_seen = EOL_SEEN_LF; |
88365 | 6531 if (eol_seen != EOL_SEEN_NONE) |
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6532 eol_type = adjust_coding_eol_type (coding, eol_seen); |
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6533 } |
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6534 |
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6535 if (EQ (eol_type, Qmac)) |
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6536 { |
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6537 for (p = pbeg; p < pend; p++) |
88365 | 6538 if (*p == '\r') |
6539 *p = '\n'; | |
6540 } | |
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6541 else if (EQ (eol_type, Qdos)) |
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6542 { |
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6543 int n = 0; |
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6544 |
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6545 if (NILP (coding->dst_object)) |
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6546 { |
90378
0aec08f4c729
(decode_eol): Pay attention to buffer relocation in
Kenichi Handa <handa@m17n.org>
parents:
90363
diff
changeset
|
6547 /* Start deleting '\r' from the tail to minimize the memory |
0aec08f4c729
(decode_eol): Pay attention to buffer relocation in
Kenichi Handa <handa@m17n.org>
parents:
90363
diff
changeset
|
6548 movement. */ |
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6549 for (p = pend - 2; p >= pbeg; p--) |
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6550 if (*p == '\r') |
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6551 { |
109165
750db9f3e6d8
Replace bcopy, bzero, bcmp by memcpy, memmove, memset, memcmp
Andreas Schwab <schwab@linux-m68k.org>
parents:
109159
diff
changeset
|
6552 memmove (p, p + 1, pend-- - p - 1); |
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6553 n++; |
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6554 } |
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6555 } |
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6556 else |
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6557 { |
90378
0aec08f4c729
(decode_eol): Pay attention to buffer relocation in
Kenichi Handa <handa@m17n.org>
parents:
90363
diff
changeset
|
6558 int pos_byte = coding->dst_pos_byte; |
0aec08f4c729
(decode_eol): Pay attention to buffer relocation in
Kenichi Handa <handa@m17n.org>
parents:
90363
diff
changeset
|
6559 int pos = coding->dst_pos; |
0aec08f4c729
(decode_eol): Pay attention to buffer relocation in
Kenichi Handa <handa@m17n.org>
parents:
90363
diff
changeset
|
6560 int pos_end = pos + coding->produced_char - 1; |
0aec08f4c729
(decode_eol): Pay attention to buffer relocation in
Kenichi Handa <handa@m17n.org>
parents:
90363
diff
changeset
|
6561 |
0aec08f4c729
(decode_eol): Pay attention to buffer relocation in
Kenichi Handa <handa@m17n.org>
parents:
90363
diff
changeset
|
6562 while (pos < pos_end) |
0aec08f4c729
(decode_eol): Pay attention to buffer relocation in
Kenichi Handa <handa@m17n.org>
parents:
90363
diff
changeset
|
6563 { |
0aec08f4c729
(decode_eol): Pay attention to buffer relocation in
Kenichi Handa <handa@m17n.org>
parents:
90363
diff
changeset
|
6564 p = BYTE_POS_ADDR (pos_byte); |
0aec08f4c729
(decode_eol): Pay attention to buffer relocation in
Kenichi Handa <handa@m17n.org>
parents:
90363
diff
changeset
|
6565 if (*p == '\r' && p[1] == '\n') |
0aec08f4c729
(decode_eol): Pay attention to buffer relocation in
Kenichi Handa <handa@m17n.org>
parents:
90363
diff
changeset
|
6566 { |
0aec08f4c729
(decode_eol): Pay attention to buffer relocation in
Kenichi Handa <handa@m17n.org>
parents:
90363
diff
changeset
|
6567 del_range_2 (pos, pos_byte, pos + 1, pos_byte + 1, 0); |
0aec08f4c729
(decode_eol): Pay attention to buffer relocation in
Kenichi Handa <handa@m17n.org>
parents:
90363
diff
changeset
|
6568 n++; |
0aec08f4c729
(decode_eol): Pay attention to buffer relocation in
Kenichi Handa <handa@m17n.org>
parents:
90363
diff
changeset
|
6569 pos_end--; |
0aec08f4c729
(decode_eol): Pay attention to buffer relocation in
Kenichi Handa <handa@m17n.org>
parents:
90363
diff
changeset
|
6570 } |
0aec08f4c729
(decode_eol): Pay attention to buffer relocation in
Kenichi Handa <handa@m17n.org>
parents:
90363
diff
changeset
|
6571 pos++; |
91535
419a669bc4f2
(decode_eol): Pay attention to coding->dst_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
91367
diff
changeset
|
6572 if (coding->dst_multibyte) |
419a669bc4f2
(decode_eol): Pay attention to coding->dst_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
91367
diff
changeset
|
6573 pos_byte += BYTES_BY_CHAR_HEAD (*p); |
419a669bc4f2
(decode_eol): Pay attention to coding->dst_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
91367
diff
changeset
|
6574 else |
419a669bc4f2
(decode_eol): Pay attention to coding->dst_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
91367
diff
changeset
|
6575 pos_byte++; |
90378
0aec08f4c729
(decode_eol): Pay attention to buffer relocation in
Kenichi Handa <handa@m17n.org>
parents:
90363
diff
changeset
|
6576 } |
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6577 } |
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6578 coding->produced -= n; |
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6579 coding->produced_char -= n; |
17052 | 6580 } |
6581 } | |
6582 | |
89732
8acde12aba89
(get_translation_table): New function.
Kenichi Handa <handa@m17n.org>
parents:
89730
diff
changeset
|
6583 |
89759
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
6584 /* Return a translation table (or list of them) from coding system |
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
6585 attribute vector ATTRS for encoding (ENCODEP is nonzero) or |
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
6586 decoding (ENCODEP is zero). */ |
89732
8acde12aba89
(get_translation_table): New function.
Kenichi Handa <handa@m17n.org>
parents:
89730
diff
changeset
|
6587 |
89858
23cb9ed79225
(get_translation_table): Declare it as Lisp_Object.
Kenichi Handa <handa@m17n.org>
parents:
89856
diff
changeset
|
6588 static Lisp_Object |
109126
aec1143e8d85
Convert (most) functions in src to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109100
diff
changeset
|
6589 get_translation_table (Lisp_Object attrs, int encodep, int *max_lookup) |
89732
8acde12aba89
(get_translation_table): New function.
Kenichi Handa <handa@m17n.org>
parents:
89730
diff
changeset
|
6590 { |
8acde12aba89
(get_translation_table): New function.
Kenichi Handa <handa@m17n.org>
parents:
89730
diff
changeset
|
6591 Lisp_Object standard, translation_table; |
89859
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
6592 Lisp_Object val; |
89732
8acde12aba89
(get_translation_table): New function.
Kenichi Handa <handa@m17n.org>
parents:
89730
diff
changeset
|
6593 |
103306
3680b4fe0f79
* coding.c (get_translation_table): Check Venable_character_translation.
Chong Yidong <cyd@stupidchicken.com>
parents:
103133
diff
changeset
|
6594 if (NILP (Venable_character_translation)) |
3680b4fe0f79
* coding.c (get_translation_table): Check Venable_character_translation.
Chong Yidong <cyd@stupidchicken.com>
parents:
103133
diff
changeset
|
6595 { |
3680b4fe0f79
* coding.c (get_translation_table): Check Venable_character_translation.
Chong Yidong <cyd@stupidchicken.com>
parents:
103133
diff
changeset
|
6596 if (max_lookup) |
3680b4fe0f79
* coding.c (get_translation_table): Check Venable_character_translation.
Chong Yidong <cyd@stupidchicken.com>
parents:
103133
diff
changeset
|
6597 *max_lookup = 0; |
3680b4fe0f79
* coding.c (get_translation_table): Check Venable_character_translation.
Chong Yidong <cyd@stupidchicken.com>
parents:
103133
diff
changeset
|
6598 return Qnil; |
3680b4fe0f79
* coding.c (get_translation_table): Check Venable_character_translation.
Chong Yidong <cyd@stupidchicken.com>
parents:
103133
diff
changeset
|
6599 } |
89732
8acde12aba89
(get_translation_table): New function.
Kenichi Handa <handa@m17n.org>
parents:
89730
diff
changeset
|
6600 if (encodep) |
8acde12aba89
(get_translation_table): New function.
Kenichi Handa <handa@m17n.org>
parents:
89730
diff
changeset
|
6601 translation_table = CODING_ATTR_ENCODE_TBL (attrs), |
8acde12aba89
(get_translation_table): New function.
Kenichi Handa <handa@m17n.org>
parents:
89730
diff
changeset
|
6602 standard = Vstandard_translation_table_for_encode; |
8acde12aba89
(get_translation_table): New function.
Kenichi Handa <handa@m17n.org>
parents:
89730
diff
changeset
|
6603 else |
8acde12aba89
(get_translation_table): New function.
Kenichi Handa <handa@m17n.org>
parents:
89730
diff
changeset
|
6604 translation_table = CODING_ATTR_DECODE_TBL (attrs), |
8acde12aba89
(get_translation_table): New function.
Kenichi Handa <handa@m17n.org>
parents:
89730
diff
changeset
|
6605 standard = Vstandard_translation_table_for_decode; |
89759
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
6606 if (NILP (translation_table)) |
89859
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
6607 translation_table = standard; |
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
6608 else |
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
6609 { |
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
6610 if (SYMBOLP (translation_table)) |
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
6611 translation_table = Fget (translation_table, Qtranslation_table); |
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
6612 else if (CONSP (translation_table)) |
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
6613 { |
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
6614 translation_table = Fcopy_sequence (translation_table); |
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
6615 for (val = translation_table; CONSP (val); val = XCDR (val)) |
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
6616 if (SYMBOLP (XCAR (val))) |
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
6617 XSETCAR (val, Fget (XCAR (val), Qtranslation_table)); |
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
6618 } |
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
6619 if (CHAR_TABLE_P (standard)) |
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
6620 { |
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
6621 if (CONSP (translation_table)) |
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
6622 translation_table = nconc2 (translation_table, |
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
6623 Fcons (standard, Qnil)); |
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
6624 else |
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
6625 translation_table = Fcons (translation_table, |
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
6626 Fcons (standard, Qnil)); |
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
6627 } |
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
6628 } |
89861
7160ded23e55
(get_translation_table): Allow max_lookup to be NULL.
Kenichi Handa <handa@m17n.org>
parents:
89859
diff
changeset
|
6629 |
7160ded23e55
(get_translation_table): Allow max_lookup to be NULL.
Kenichi Handa <handa@m17n.org>
parents:
89859
diff
changeset
|
6630 if (max_lookup) |
7160ded23e55
(get_translation_table): Allow max_lookup to be NULL.
Kenichi Handa <handa@m17n.org>
parents:
89859
diff
changeset
|
6631 { |
7160ded23e55
(get_translation_table): Allow max_lookup to be NULL.
Kenichi Handa <handa@m17n.org>
parents:
89859
diff
changeset
|
6632 *max_lookup = 1; |
7160ded23e55
(get_translation_table): Allow max_lookup to be NULL.
Kenichi Handa <handa@m17n.org>
parents:
89859
diff
changeset
|
6633 if (CHAR_TABLE_P (translation_table) |
7160ded23e55
(get_translation_table): Allow max_lookup to be NULL.
Kenichi Handa <handa@m17n.org>
parents:
89859
diff
changeset
|
6634 && CHAR_TABLE_EXTRA_SLOTS (XCHAR_TABLE (translation_table)) > 1) |
7160ded23e55
(get_translation_table): Allow max_lookup to be NULL.
Kenichi Handa <handa@m17n.org>
parents:
89859
diff
changeset
|
6635 { |
7160ded23e55
(get_translation_table): Allow max_lookup to be NULL.
Kenichi Handa <handa@m17n.org>
parents:
89859
diff
changeset
|
6636 val = XCHAR_TABLE (translation_table)->extras[1]; |
7160ded23e55
(get_translation_table): Allow max_lookup to be NULL.
Kenichi Handa <handa@m17n.org>
parents:
89859
diff
changeset
|
6637 if (NATNUMP (val) && *max_lookup < XFASTINT (val)) |
7160ded23e55
(get_translation_table): Allow max_lookup to be NULL.
Kenichi Handa <handa@m17n.org>
parents:
89859
diff
changeset
|
6638 *max_lookup = XFASTINT (val); |
7160ded23e55
(get_translation_table): Allow max_lookup to be NULL.
Kenichi Handa <handa@m17n.org>
parents:
89859
diff
changeset
|
6639 } |
7160ded23e55
(get_translation_table): Allow max_lookup to be NULL.
Kenichi Handa <handa@m17n.org>
parents:
89859
diff
changeset
|
6640 else if (CONSP (translation_table)) |
7160ded23e55
(get_translation_table): Allow max_lookup to be NULL.
Kenichi Handa <handa@m17n.org>
parents:
89859
diff
changeset
|
6641 { |
7160ded23e55
(get_translation_table): Allow max_lookup to be NULL.
Kenichi Handa <handa@m17n.org>
parents:
89859
diff
changeset
|
6642 Lisp_Object tail, val; |
7160ded23e55
(get_translation_table): Allow max_lookup to be NULL.
Kenichi Handa <handa@m17n.org>
parents:
89859
diff
changeset
|
6643 |
7160ded23e55
(get_translation_table): Allow max_lookup to be NULL.
Kenichi Handa <handa@m17n.org>
parents:
89859
diff
changeset
|
6644 for (tail = translation_table; CONSP (tail); tail = XCDR (tail)) |
7160ded23e55
(get_translation_table): Allow max_lookup to be NULL.
Kenichi Handa <handa@m17n.org>
parents:
89859
diff
changeset
|
6645 if (CHAR_TABLE_P (XCAR (tail)) |
7160ded23e55
(get_translation_table): Allow max_lookup to be NULL.
Kenichi Handa <handa@m17n.org>
parents:
89859
diff
changeset
|
6646 && CHAR_TABLE_EXTRA_SLOTS (XCHAR_TABLE (XCAR (tail))) > 1) |
7160ded23e55
(get_translation_table): Allow max_lookup to be NULL.
Kenichi Handa <handa@m17n.org>
parents:
89859
diff
changeset
|
6647 { |
7160ded23e55
(get_translation_table): Allow max_lookup to be NULL.
Kenichi Handa <handa@m17n.org>
parents:
89859
diff
changeset
|
6648 val = XCHAR_TABLE (XCAR (tail))->extras[1]; |
7160ded23e55
(get_translation_table): Allow max_lookup to be NULL.
Kenichi Handa <handa@m17n.org>
parents:
89859
diff
changeset
|
6649 if (NATNUMP (val) && *max_lookup < XFASTINT (val)) |
7160ded23e55
(get_translation_table): Allow max_lookup to be NULL.
Kenichi Handa <handa@m17n.org>
parents:
89859
diff
changeset
|
6650 *max_lookup = XFASTINT (val); |
7160ded23e55
(get_translation_table): Allow max_lookup to be NULL.
Kenichi Handa <handa@m17n.org>
parents:
89859
diff
changeset
|
6651 } |
7160ded23e55
(get_translation_table): Allow max_lookup to be NULL.
Kenichi Handa <handa@m17n.org>
parents:
89859
diff
changeset
|
6652 } |
89759
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
6653 } |
89732
8acde12aba89
(get_translation_table): New function.
Kenichi Handa <handa@m17n.org>
parents:
89730
diff
changeset
|
6654 return translation_table; |
8acde12aba89
(get_translation_table): New function.
Kenichi Handa <handa@m17n.org>
parents:
89730
diff
changeset
|
6655 } |
8acde12aba89
(get_translation_table): New function.
Kenichi Handa <handa@m17n.org>
parents:
89730
diff
changeset
|
6656 |
89859
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
6657 #define LOOKUP_TRANSLATION_TABLE(table, c, trans) \ |
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
6658 do { \ |
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
6659 trans = Qnil; \ |
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
6660 if (CHAR_TABLE_P (table)) \ |
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
6661 { \ |
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
6662 trans = CHAR_TABLE_REF (table, c); \ |
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
6663 if (CHARACTERP (trans)) \ |
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
6664 c = XFASTINT (trans), trans = Qnil; \ |
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
6665 } \ |
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
6666 else if (CONSP (table)) \ |
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
6667 { \ |
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
6668 Lisp_Object tail; \ |
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
6669 \ |
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
6670 for (tail = table; CONSP (tail); tail = XCDR (tail)) \ |
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
6671 if (CHAR_TABLE_P (XCAR (tail))) \ |
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
6672 { \ |
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
6673 trans = CHAR_TABLE_REF (XCAR (tail), c); \ |
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
6674 if (CHARACTERP (trans)) \ |
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
6675 c = XFASTINT (trans), trans = Qnil; \ |
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
6676 else if (! NILP (trans)) \ |
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
6677 break; \ |
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
6678 } \ |
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
6679 } \ |
89858
23cb9ed79225
(get_translation_table): Declare it as Lisp_Object.
Kenichi Handa <handa@m17n.org>
parents:
89856
diff
changeset
|
6680 } while (0) |
23cb9ed79225
(get_translation_table): Declare it as Lisp_Object.
Kenichi Handa <handa@m17n.org>
parents:
89856
diff
changeset
|
6681 |
89732
8acde12aba89
(get_translation_table): New function.
Kenichi Handa <handa@m17n.org>
parents:
89730
diff
changeset
|
6682 |
102422
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
6683 /* Return a translation of character(s) at BUF according to TRANS. |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
6684 TRANS is TO-CHAR or ((FROM . TO) ...) where |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
6685 FROM = [FROM-CHAR ...], TO is TO-CHAR or [TO-CHAR ...]. |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
6686 The return value is TO-CHAR or ([FROM-CHAR ...] . TO) if a |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
6687 translation is found, and Qnil if not found.. |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
6688 If BUF is too short to lookup characters in FROM, return Qt. */ |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
6689 |
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
6690 static Lisp_Object |
109126
aec1143e8d85
Convert (most) functions in src to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109100
diff
changeset
|
6691 get_translation (Lisp_Object trans, int *buf, int *buf_end) |
102422
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
6692 { |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
6693 |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
6694 if (INTEGERP (trans)) |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
6695 return trans; |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
6696 for (; CONSP (trans); trans = XCDR (trans)) |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
6697 { |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
6698 Lisp_Object val = XCAR (trans); |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
6699 Lisp_Object from = XCAR (val); |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
6700 int len = ASIZE (from); |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
6701 int i; |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
6702 |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
6703 for (i = 0; i < len; i++) |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
6704 { |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
6705 if (buf + i == buf_end) |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
6706 return Qt; |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
6707 if (XINT (AREF (from, i)) != buf[i]) |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
6708 break; |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
6709 } |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
6710 if (i == len) |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
6711 return val; |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
6712 } |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
6713 return Qnil; |
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
6714 } |
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
6715 |
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
6716 |
88365 | 6717 static int |
109159
3e9fdeb960d1
* coding.c, sysdep.c: Convert some more functions to standard C.
Juanma Barranquero <lekktu@gmail.com>
parents:
109158
diff
changeset
|
6718 produce_chars (struct coding_system *coding, Lisp_Object translation_table, |
3e9fdeb960d1
* coding.c, sysdep.c: Convert some more functions to standard C.
Juanma Barranquero <lekktu@gmail.com>
parents:
109158
diff
changeset
|
6719 int last_block) |
17052 | 6720 { |
88365 | 6721 unsigned char *dst = coding->destination + coding->produced; |
6722 unsigned char *dst_end = coding->destination + coding->dst_bytes; | |
92399
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
6723 EMACS_INT produced; |
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
6724 EMACS_INT produced_chars = 0; |
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
6725 int carryover = 0; |
88365 | 6726 |
6727 if (! coding->chars_at_source) | |
6728 { | |
92399
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
6729 /* Source characters are in coding->charbuf. */ |
89575
59d10ebd2a0b
(produce_chars): Revert last change.
Andreas Schwab <schwab@suse.de>
parents:
89571
diff
changeset
|
6730 int *buf = coding->charbuf; |
59d10ebd2a0b
(produce_chars): Revert last change.
Andreas Schwab <schwab@suse.de>
parents:
89571
diff
changeset
|
6731 int *buf_end = buf + coding->charbuf_used; |
88365 | 6732 |
92992
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
6733 if (EQ (coding->src_object, coding->dst_object)) |
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
6734 { |
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
6735 coding_set_source (coding); |
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
6736 dst_end = ((unsigned char *) coding->source) + coding->consumed; |
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
6737 } |
88365 | 6738 |
6739 while (buf < buf_end) | |
6740 { | |
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
6741 int c = *buf, i; |
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
6742 |
88365 | 6743 if (c >= 0) |
6744 { | |
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
6745 int from_nchars = 1, to_nchars = 1; |
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
6746 Lisp_Object trans = Qnil; |
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
6747 |
89859
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
6748 LOOKUP_TRANSLATION_TABLE (translation_table, c, trans); |
89858
23cb9ed79225
(get_translation_table): Declare it as Lisp_Object.
Kenichi Handa <handa@m17n.org>
parents:
89856
diff
changeset
|
6749 if (! NILP (trans)) |
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
6750 { |
102422
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
6751 trans = get_translation (trans, buf, buf_end); |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
6752 if (INTEGERP (trans)) |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
6753 c = XINT (trans); |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
6754 else if (CONSP (trans)) |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
6755 { |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
6756 from_nchars = ASIZE (XCAR (trans)); |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
6757 trans = XCDR (trans); |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
6758 if (INTEGERP (trans)) |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
6759 c = XINT (trans); |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
6760 else |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
6761 { |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
6762 to_nchars = ASIZE (trans); |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
6763 c = XINT (AREF (trans, 0)); |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
6764 } |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
6765 } |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
6766 else if (EQ (trans, Qt) && ! last_block) |
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
6767 break; |
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
6768 } |
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
6769 |
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
6770 if (dst + MAX_MULTIBYTE_LENGTH * to_nchars > dst_end) |
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
6771 { |
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
6772 dst = alloc_destination (coding, |
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
6773 buf_end - buf |
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
6774 + MAX_MULTIBYTE_LENGTH * to_nchars, |
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
6775 dst); |
92992
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
6776 if (EQ (coding->src_object, coding->dst_object)) |
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
6777 { |
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
6778 coding_set_source (coding); |
102422
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
6779 dst_end = (((unsigned char *) coding->source) |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
6780 + coding->consumed); |
92992
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
6781 } |
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
6782 else |
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
6783 dst_end = coding->destination + coding->dst_bytes; |
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
6784 } |
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
6785 |
89856
18b52da60a76
(get_translation): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89852
diff
changeset
|
6786 for (i = 0; i < to_nchars; i++) |
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
6787 { |
89856
18b52da60a76
(get_translation): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89852
diff
changeset
|
6788 if (i > 0) |
18b52da60a76
(get_translation): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89852
diff
changeset
|
6789 c = XINT (AREF (trans, i)); |
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
6790 if (coding->dst_multibyte |
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
6791 || ! CHAR_BYTE8_P (c)) |
92992
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
6792 CHAR_STRING_ADVANCE_NO_UNIFY (c, dst); |
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
6793 else |
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
6794 *dst++ = CHAR_TO_BYTE8 (c); |
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
6795 } |
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
6796 produced_chars += to_nchars; |
102422
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
6797 buf += from_nchars; |
88365 | 6798 } |
6799 else | |
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
6800 /* This is an annotation datum. (-C) is the length. */ |
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
6801 buf += -c; |
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
6802 } |
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
6803 carryover = buf_end - buf; |
30833
2db6e42a6ba3
(MINIMUM_CONVERSION_BUFFER_SIZE): Macro deleted.
Kenichi Handa <handa@m17n.org>
parents:
30756
diff
changeset
|
6804 } |
2db6e42a6ba3
(MINIMUM_CONVERSION_BUFFER_SIZE): Macro deleted.
Kenichi Handa <handa@m17n.org>
parents:
30756
diff
changeset
|
6805 else |
2db6e42a6ba3
(MINIMUM_CONVERSION_BUFFER_SIZE): Macro deleted.
Kenichi Handa <handa@m17n.org>
parents:
30756
diff
changeset
|
6806 { |
92399
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
6807 /* Source characters are at coding->source. */ |
89483 | 6808 const unsigned char *src = coding->source; |
92399
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
6809 const unsigned char *src_end = src + coding->consumed; |
88365 | 6810 |
92992
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
6811 if (EQ (coding->dst_object, coding->src_object)) |
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
6812 dst_end = (unsigned char *) src; |
88365 | 6813 if (coding->src_multibyte != coding->dst_multibyte) |
34892
3868f2e7355a
(setup_coding_system): Initialize
Kenichi Handa <handa@m17n.org>
parents:
34888
diff
changeset
|
6814 { |
88365 | 6815 if (coding->src_multibyte) |
34892
3868f2e7355a
(setup_coding_system): Initialize
Kenichi Handa <handa@m17n.org>
parents:
34888
diff
changeset
|
6816 { |
88443
6b86cf30a0b9
(produce_chars): Set the variable `multibytep' correctly.
Kenichi Handa <handa@m17n.org>
parents:
88438
diff
changeset
|
6817 int multibytep = 1; |
100135
0e17542db552
(detect_coding_system): Initialize utf_16_le_eol to -1, val to
Kenichi Handa <handa@m17n.org>
parents:
100133
diff
changeset
|
6818 EMACS_INT consumed_chars = 0; |
88365 | 6819 |
6820 while (1) | |
34892
3868f2e7355a
(setup_coding_system): Initialize
Kenichi Handa <handa@m17n.org>
parents:
34888
diff
changeset
|
6821 { |
89483 | 6822 const unsigned char *src_base = src; |
88365 | 6823 int c; |
6824 | |
6825 ONE_MORE_BYTE (c); | |
6826 if (dst == dst_end) | |
6827 { | |
92399
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
6828 if (EQ (coding->src_object, coding->dst_object)) |
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
6829 dst_end = (unsigned char *) src; |
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
6830 if (dst == dst_end) |
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
6831 { |
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
6832 EMACS_INT offset = src - coding->source; |
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
6833 |
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
6834 dst = alloc_destination (coding, src_end - src + 1, |
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
6835 dst); |
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
6836 dst_end = coding->destination + coding->dst_bytes; |
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
6837 coding_set_source (coding); |
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
6838 src = coding->source + offset; |
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
6839 src_end = coding->source + coding->src_bytes; |
92992
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
6840 if (EQ (coding->src_object, coding->dst_object)) |
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
6841 dst_end = (unsigned char *) src; |
92399
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
6842 } |
88365 | 6843 } |
6844 *dst++ = c; | |
6845 produced_chars++; | |
6846 } | |
6847 no_more_source: | |
6848 ; | |
6849 } | |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
6850 else |
88365 | 6851 while (src < src_end) |
6852 { | |
88443
6b86cf30a0b9
(produce_chars): Set the variable `multibytep' correctly.
Kenichi Handa <handa@m17n.org>
parents:
88438
diff
changeset
|
6853 int multibytep = 1; |
88365 | 6854 int c = *src++; |
6855 | |
6856 if (dst >= dst_end - 1) | |
6857 { | |
88456
a7b309f72920
(coding_alloc_by_making_gap): Check the case that the
Kenichi Handa <handa@m17n.org>
parents:
88443
diff
changeset
|
6858 if (EQ (coding->src_object, coding->dst_object)) |
89483 | 6859 dst_end = (unsigned char *) src; |
88456
a7b309f72920
(coding_alloc_by_making_gap): Check the case that the
Kenichi Handa <handa@m17n.org>
parents:
88443
diff
changeset
|
6860 if (dst >= dst_end - 1) |
a7b309f72920
(coding_alloc_by_making_gap): Check the case that the
Kenichi Handa <handa@m17n.org>
parents:
88443
diff
changeset
|
6861 { |
92399
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
6862 EMACS_INT offset = src - coding->source; |
92992
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
6863 EMACS_INT more_bytes; |
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
6864 |
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
6865 if (EQ (coding->src_object, coding->dst_object)) |
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
6866 more_bytes = ((src_end - src) / 2) + 2; |
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
6867 else |
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
6868 more_bytes = src_end - src + 2; |
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
6869 dst = alloc_destination (coding, more_bytes, dst); |
88456
a7b309f72920
(coding_alloc_by_making_gap): Check the case that the
Kenichi Handa <handa@m17n.org>
parents:
88443
diff
changeset
|
6870 dst_end = coding->destination + coding->dst_bytes; |
a7b309f72920
(coding_alloc_by_making_gap): Check the case that the
Kenichi Handa <handa@m17n.org>
parents:
88443
diff
changeset
|
6871 coding_set_source (coding); |
92399
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
6872 src = coding->source + offset; |
88456
a7b309f72920
(coding_alloc_by_making_gap): Check the case that the
Kenichi Handa <handa@m17n.org>
parents:
88443
diff
changeset
|
6873 src_end = coding->source + coding->src_bytes; |
92992
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
6874 if (EQ (coding->src_object, coding->dst_object)) |
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
6875 dst_end = (unsigned char *) src; |
88456
a7b309f72920
(coding_alloc_by_making_gap): Check the case that the
Kenichi Handa <handa@m17n.org>
parents:
88443
diff
changeset
|
6876 } |
88365 | 6877 } |
6878 EMIT_ONE_BYTE (c); | |
6879 } | |
6880 } | |
6881 else | |
6882 { | |
6883 if (!EQ (coding->src_object, coding->dst_object)) | |
6884 { | |
92399
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
6885 EMACS_INT require = coding->src_bytes - coding->dst_bytes; |
88365 | 6886 |
6887 if (require > 0) | |
23325
bbd06336cd0c
(check_composing_code): If the current composing
Kenichi Handa <handa@m17n.org>
parents:
23315
diff
changeset
|
6888 { |
88365 | 6889 EMACS_INT offset = src - coding->source; |
6890 | |
6891 dst = alloc_destination (coding, require, dst); | |
6892 coding_set_source (coding); | |
6893 src = coding->source + offset; | |
6894 src_end = coding->source + coding->src_bytes; | |
23325
bbd06336cd0c
(check_composing_code): If the current composing
Kenichi Handa <handa@m17n.org>
parents:
23315
diff
changeset
|
6895 } |
34892
3868f2e7355a
(setup_coding_system): Initialize
Kenichi Handa <handa@m17n.org>
parents:
34888
diff
changeset
|
6896 } |
92399
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
6897 produced_chars = coding->consumed_char; |
88365 | 6898 while (src < src_end) |
92406
c36bda0a03cc
(decode_coding_big5, produce_chars): Fix typos in last
Andreas Schwab <schwab@suse.de>
parents:
92399
diff
changeset
|
6899 *dst++ = *src++; |
92399
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
6900 } |
88365 | 6901 } |
6902 | |
6903 produced = dst - (coding->destination + coding->produced); | |
90809
3c52757d5f6e
(produce_chars): Don't call insert_from_gap if no
Kenichi Handa <handa@m17n.org>
parents:
90772
diff
changeset
|
6904 if (BUFFERP (coding->dst_object) && produced_chars > 0) |
88365 | 6905 insert_from_gap (produced_chars, produced); |
6906 coding->produced += produced; | |
6907 coding->produced_char += produced_chars; | |
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
6908 return carryover; |
88365 | 6909 } |
6910 | |
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6911 /* Compose text in CODING->object according to the annotation data at |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6912 CHARBUF. CHARBUF is an array: |
102422
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
6913 [ -LENGTH ANNOTATION_MASK NCHARS NBYTES METHOD [ COMPONENTS... ] ] |
88365 | 6914 */ |
6915 | |
6916 static INLINE void | |
109126
aec1143e8d85
Convert (most) functions in src to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109100
diff
changeset
|
6917 produce_composition (struct coding_system *coding, int *charbuf, EMACS_INT pos) |
88365 | 6918 { |
6919 int len; | |
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
6920 EMACS_INT to; |
88365 | 6921 enum composition_method method; |
6922 Lisp_Object components; | |
6923 | |
102422
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
6924 len = -charbuf[0] - MAX_ANNOTATION_LENGTH; |
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
6925 to = pos + charbuf[2]; |
102422
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
6926 method = (enum composition_method) (charbuf[4]); |
88365 | 6927 |
6928 if (method == COMPOSITION_RELATIVE) | |
6929 components = Qnil; | |
102422
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
6930 else |
88365 | 6931 { |
6932 Lisp_Object args[MAX_COMPOSITION_COMPONENTS * 2 - 1]; | |
102422
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
6933 int i, j; |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
6934 |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
6935 if (method == COMPOSITION_WITH_RULE) |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
6936 len = charbuf[2] * 3 - 2; |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
6937 charbuf += MAX_ANNOTATION_LENGTH; |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
6938 /* charbuf = [ CHRA ... CHAR] or [ CHAR -2 RULE ... CHAR ] */ |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
6939 for (i = j = 0; i < len && charbuf[i] != -1; i++, j++) |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
6940 { |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
6941 if (charbuf[i] >= 0) |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
6942 args[j] = make_number (charbuf[i]); |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
6943 else |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
6944 { |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
6945 i++; |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
6946 args[j] = make_number (charbuf[i] % 0x100); |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
6947 } |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
6948 } |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
6949 components = (i == j ? Fstring (j, args) : Fvector (j, args)); |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
6950 } |
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
6951 compose_text (pos, to, components, Qnil, coding->dst_object); |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
6952 } |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
6953 |
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6954 |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6955 /* Put `charset' property on text in CODING->object according to |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6956 the annotation data at CHARBUF. CHARBUF is an array: |
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
6957 [ -LENGTH ANNOTATION_MASK NCHARS CHARSET-ID ] |
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6958 */ |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6959 |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6960 static INLINE void |
109126
aec1143e8d85
Convert (most) functions in src to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109100
diff
changeset
|
6961 produce_charset (struct coding_system *coding, int *charbuf, EMACS_INT pos) |
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
6962 { |
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
6963 EMACS_INT from = pos - charbuf[2]; |
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
6964 struct charset *charset = CHARSET_FROM_ID (charbuf[3]); |
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
6965 |
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
6966 Fput_text_property (make_number (from), make_number (pos), |
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6967 Qcharset, CHARSET_NAME (charset), |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6968 coding->dst_object); |
88365 | 6969 } |
6970 | |
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6971 |
88365 | 6972 #define CHARBUF_SIZE 0x4000 |
6973 | |
6974 #define ALLOC_CONVERSION_WORK_AREA(coding) \ | |
6975 do { \ | |
101943
97c9e9322753
Remove spurious semicolons.
Juanma Barranquero <lekktu@gmail.com>
parents:
101904
diff
changeset
|
6976 int size = CHARBUF_SIZE; \ |
88365 | 6977 \ |
6978 coding->charbuf = NULL; \ | |
6979 while (size > 1024) \ | |
6980 { \ | |
6981 coding->charbuf = (int *) alloca (sizeof (int) * size); \ | |
6982 if (coding->charbuf) \ | |
6983 break; \ | |
6984 size >>= 1; \ | |
6985 } \ | |
6986 if (! coding->charbuf) \ | |
6987 { \ | |
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
6988 record_conversion_result (coding, CODING_RESULT_INSUFFICIENT_MEM); \ |
88365 | 6989 return coding->result; \ |
6990 } \ | |
6991 coding->charbuf_size = size; \ | |
6992 } while (0) | |
6993 | |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
6994 |
30833
2db6e42a6ba3
(MINIMUM_CONVERSION_BUFFER_SIZE): Macro deleted.
Kenichi Handa <handa@m17n.org>
parents:
30756
diff
changeset
|
6995 static void |
109126
aec1143e8d85
Convert (most) functions in src to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109100
diff
changeset
|
6996 produce_annotation (struct coding_system *coding, EMACS_INT pos) |
29725
2bc397e9b09a
(setup_coding_system) <4>: Reset member `cr_carryover'.
Kenichi Handa <handa@m17n.org>
parents:
29663
diff
changeset
|
6997 { |
88365 | 6998 int *charbuf = coding->charbuf; |
6999 int *charbuf_end = charbuf + coding->charbuf_used; | |
7000 | |
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7001 if (NILP (coding->dst_object)) |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7002 return; |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7003 |
88365 | 7004 while (charbuf < charbuf_end) |
7005 { | |
7006 if (*charbuf >= 0) | |
102422
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
7007 pos++, charbuf++; |
88365 | 7008 else |
29877
7b43e1fb478a
(decode_eol_post_ccl): Special handling for undecided
Eli Zaretskii <eliz@gnu.org>
parents:
29725
diff
changeset
|
7009 { |
88365 | 7010 int len = -*charbuf; |
102422
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
7011 |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
7012 if (len > 2) |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
7013 switch (charbuf[1]) |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
7014 { |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
7015 case CODING_ANNOTATE_COMPOSITION_MASK: |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
7016 produce_composition (coding, charbuf, pos); |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
7017 break; |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
7018 case CODING_ANNOTATE_CHARSET_MASK: |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
7019 produce_charset (coding, charbuf, pos); |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
7020 break; |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
7021 } |
88365 | 7022 charbuf += len; |
29725
2bc397e9b09a
(setup_coding_system) <4>: Reset member `cr_carryover'.
Kenichi Handa <handa@m17n.org>
parents:
29663
diff
changeset
|
7023 } |
2bc397e9b09a
(setup_coding_system) <4>: Reset member `cr_carryover'.
Kenichi Handa <handa@m17n.org>
parents:
29663
diff
changeset
|
7024 } |
2bc397e9b09a
(setup_coding_system) <4>: Reset member `cr_carryover'.
Kenichi Handa <handa@m17n.org>
parents:
29663
diff
changeset
|
7025 } |
2bc397e9b09a
(setup_coding_system) <4>: Reset member `cr_carryover'.
Kenichi Handa <handa@m17n.org>
parents:
29663
diff
changeset
|
7026 |
88365 | 7027 /* Decode the data at CODING->src_object into CODING->dst_object. |
7028 CODING->src_object is a buffer, a string, or nil. | |
7029 CODING->dst_object is a buffer. | |
7030 | |
7031 If CODING->src_object is a buffer, it must be the current buffer. | |
7032 In this case, if CODING->src_pos is positive, it is a position of | |
7033 the source text in the buffer, otherwise, the source text is in the | |
7034 gap area of the buffer, and CODING->src_pos specifies the offset of | |
7035 the text from GPT (which must be the same as PT). If this is the | |
7036 same buffer as CODING->dst_object, CODING->src_pos must be | |
7037 negative. | |
7038 | |
90380
4bf7966e0788
(decode_coding): Typo in comment fixed.
Kenichi Handa <handa@m17n.org>
parents:
90378
diff
changeset
|
7039 If CODING->src_object is a string, CODING->src_pos is an index to |
88365 | 7040 that string. |
7041 | |
7042 If CODING->src_object is nil, CODING->source must already point to | |
7043 the non-relocatable memory area. In this case, CODING->src_pos is | |
7044 an offset from CODING->source. | |
7045 | |
7046 The decoded data is inserted at the current point of the buffer | |
7047 CODING->dst_object. | |
7048 */ | |
7049 | |
7050 static int | |
109126
aec1143e8d85
Convert (most) functions in src to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109100
diff
changeset
|
7051 decode_coding (struct coding_system *coding) |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
7052 { |
88365 | 7053 Lisp_Object attrs; |
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
7054 Lisp_Object undo_list; |
89732
8acde12aba89
(get_translation_table): New function.
Kenichi Handa <handa@m17n.org>
parents:
89730
diff
changeset
|
7055 Lisp_Object translation_table; |
107171
dfc03b454687
Fix the ccl decoder for the case that the output buffer is fullfilled.
Kenichi Handa <handa@m17n.org>
parents:
106918
diff
changeset
|
7056 struct ccl_spec cclspec; |
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
7057 int carryover; |
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
7058 int i; |
88365 | 7059 |
7060 if (BUFFERP (coding->src_object) | |
7061 && coding->src_pos > 0 | |
7062 && coding->src_pos < GPT | |
7063 && coding->src_pos + coding->src_chars > GPT) | |
7064 move_gap_both (coding->src_pos, coding->src_pos_byte); | |
7065 | |
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
7066 undo_list = Qt; |
88365 | 7067 if (BUFFERP (coding->dst_object)) |
7068 { | |
7069 if (current_buffer != XBUFFER (coding->dst_object)) | |
7070 set_buffer_internal (XBUFFER (coding->dst_object)); | |
7071 if (GPT != PT) | |
7072 move_gap_both (PT, PT_BYTE); | |
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
7073 undo_list = current_buffer->undo_list; |
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
7074 current_buffer->undo_list = Qt; |
88365 | 7075 } |
7076 | |
7077 coding->consumed = 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
|
7078 coding->produced = coding->produced_char = 0; |
88365 | 7079 coding->chars_at_source = 0; |
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
7080 record_conversion_result (coding, CODING_RESULT_SUCCESS); |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
7081 coding->errors = 0; |
88365 | 7082 |
7083 ALLOC_CONVERSION_WORK_AREA (coding); | |
7084 | |
7085 attrs = CODING_ID_ATTRS (coding->id); | |
89861
7160ded23e55
(get_translation_table): Allow max_lookup to be NULL.
Kenichi Handa <handa@m17n.org>
parents:
89859
diff
changeset
|
7086 translation_table = get_translation_table (attrs, 0, NULL); |
88365 | 7087 |
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
7088 carryover = 0; |
107171
dfc03b454687
Fix the ccl decoder for the case that the output buffer is fullfilled.
Kenichi Handa <handa@m17n.org>
parents:
106918
diff
changeset
|
7089 if (coding->decoder == decode_coding_ccl) |
dfc03b454687
Fix the ccl decoder for the case that the output buffer is fullfilled.
Kenichi Handa <handa@m17n.org>
parents:
106918
diff
changeset
|
7090 { |
dfc03b454687
Fix the ccl decoder for the case that the output buffer is fullfilled.
Kenichi Handa <handa@m17n.org>
parents:
106918
diff
changeset
|
7091 coding->spec.ccl = &cclspec; |
dfc03b454687
Fix the ccl decoder for the case that the output buffer is fullfilled.
Kenichi Handa <handa@m17n.org>
parents:
106918
diff
changeset
|
7092 setup_ccl_program (&cclspec.ccl, CODING_CCL_DECODER (coding)); |
dfc03b454687
Fix the ccl decoder for the case that the output buffer is fullfilled.
Kenichi Handa <handa@m17n.org>
parents:
106918
diff
changeset
|
7093 } |
88365 | 7094 do |
7095 { | |
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
7096 EMACS_INT pos = coding->dst_pos + coding->produced_char; |
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
7097 |
88365 | 7098 coding_set_source (coding); |
7099 coding->annotated = 0; | |
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
7100 coding->charbuf_used = carryover; |
88365 | 7101 (*(coding->decoder)) (coding); |
7102 coding_set_destination (coding); | |
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
7103 carryover = produce_chars (coding, translation_table, 0); |
88365 | 7104 if (coding->annotated) |
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
7105 produce_annotation (coding, pos); |
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
7106 for (i = 0; i < carryover; i++) |
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
7107 coding->charbuf[i] |
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
7108 = coding->charbuf[coding->charbuf_used - carryover + i]; |
88365 | 7109 } |
107171
dfc03b454687
Fix the ccl decoder for the case that the output buffer is fullfilled.
Kenichi Handa <handa@m17n.org>
parents:
106918
diff
changeset
|
7110 while (coding->result == CODING_RESULT_INSUFFICIENT_DST |
dfc03b454687
Fix the ccl decoder for the case that the output buffer is fullfilled.
Kenichi Handa <handa@m17n.org>
parents:
106918
diff
changeset
|
7111 || (coding->consumed < coding->src_bytes |
dfc03b454687
Fix the ccl decoder for the case that the output buffer is fullfilled.
Kenichi Handa <handa@m17n.org>
parents:
106918
diff
changeset
|
7112 && (coding->result == CODING_RESULT_SUCCESS |
dfc03b454687
Fix the ccl decoder for the case that the output buffer is fullfilled.
Kenichi Handa <handa@m17n.org>
parents:
106918
diff
changeset
|
7113 || coding->result == CODING_RESULT_INVALID_SRC))); |
88365 | 7114 |
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
7115 if (carryover > 0) |
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
7116 { |
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
7117 coding_set_destination (coding); |
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
7118 coding->charbuf_used = carryover; |
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
7119 produce_chars (coding, translation_table, 1); |
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
7120 } |
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
7121 |
88365 | 7122 coding->carryover_bytes = 0; |
7123 if (coding->consumed < coding->src_bytes) | |
7124 { | |
7125 int nbytes = coding->src_bytes - coding->consumed; | |
89483 | 7126 const unsigned char *src; |
88365 | 7127 |
7128 coding_set_source (coding); | |
7129 coding_set_destination (coding); | |
7130 src = coding->source + coding->consumed; | |
7131 | |
7132 if (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
|
7133 { |
88365 | 7134 /* Flush out unprocessed data as binary chars. We are sure |
7135 that the number of data is less than the size of | |
7136 coding->charbuf. */ | |
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
7137 coding->charbuf_used = 0; |
100587
d91e3320dd81
(decode_coding): Clear chars_at_source flag when using charbuf.
Jason Rumney <jasonr@gnu.org>
parents:
100303
diff
changeset
|
7138 coding->chars_at_source = 0; |
d91e3320dd81
(decode_coding): Clear chars_at_source flag when using charbuf.
Jason Rumney <jasonr@gnu.org>
parents:
100303
diff
changeset
|
7139 |
88365 | 7140 while (nbytes-- > 0) |
7141 { | |
7142 int c = *src++; | |
89279
1fd77c471ee6
(decode_coding_utf_8): When eol_type is Qdos, handle
Kenichi Handa <handa@m17n.org>
parents:
89227
diff
changeset
|
7143 |
90243
c59afb15f5c6
(decode_coding): Fix handling of invalid bytes.
Kenichi Handa <handa@m17n.org>
parents:
90231
diff
changeset
|
7144 if (c & 0x80) |
c59afb15f5c6
(decode_coding): Fix handling of invalid bytes.
Kenichi Handa <handa@m17n.org>
parents:
90231
diff
changeset
|
7145 c = BYTE8_TO_CHAR (c); |
c59afb15f5c6
(decode_coding): Fix handling of invalid bytes.
Kenichi Handa <handa@m17n.org>
parents:
90231
diff
changeset
|
7146 coding->charbuf[coding->charbuf_used++] = c; |
88365 | 7147 } |
89863
428fc37b2ae6
Add many prototypes for static functions.
Kenichi Handa <handa@m17n.org>
parents:
89861
diff
changeset
|
7148 produce_chars (coding, Qnil, 1); |
29725
2bc397e9b09a
(setup_coding_system) <4>: Reset member `cr_carryover'.
Kenichi Handa <handa@m17n.org>
parents:
29663
diff
changeset
|
7149 } |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
7150 else |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
7151 { |
88365 | 7152 /* Record unprocessed bytes in coding->carryover. We are |
7153 sure that the number of data is less than the size of | |
7154 coding->carryover. */ | |
7155 unsigned char *p = coding->carryover; | |
7156 | |
102115
db1f94e25359
(detect_coding): Don't overflow coding->carryover.
Kenichi Handa <handa@m17n.org>
parents:
102105
diff
changeset
|
7157 if (nbytes > sizeof coding->carryover) |
db1f94e25359
(detect_coding): Don't overflow coding->carryover.
Kenichi Handa <handa@m17n.org>
parents:
102105
diff
changeset
|
7158 nbytes = sizeof coding->carryover; |
88365 | 7159 coding->carryover_bytes = nbytes; |
7160 while (nbytes-- > 0) | |
7161 *p++ = *src++; | |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
7162 } |
88365 | 7163 coding->consumed = coding->src_bytes; |
7164 } | |
7165 | |
102334
7baaea85626e
(decode_coding_utf_8, decode_coding_utf_16, decode_coding_emacs_mule,
Eli Zaretskii <eliz@gnu.org>
parents:
102327
diff
changeset
|
7166 if (! EQ (CODING_ID_EOL_TYPE (coding->id), Qunix) |
7baaea85626e
(decode_coding_utf_8, decode_coding_utf_16, decode_coding_emacs_mule,
Eli Zaretskii <eliz@gnu.org>
parents:
102327
diff
changeset
|
7167 && !inhibit_eol_conversion) |
90378
0aec08f4c729
(decode_eol): Pay attention to buffer relocation in
Kenichi Handa <handa@m17n.org>
parents:
90363
diff
changeset
|
7168 decode_eol (coding); |
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
7169 if (BUFFERP (coding->dst_object)) |
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
7170 { |
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
7171 current_buffer->undo_list = undo_list; |
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
7172 record_insert (coding->dst_pos, coding->produced_char); |
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
7173 } |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
7174 return coding->result; |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
7175 } |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
7176 |
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7177 |
89394
6ffca50f25b9
(Fcheck_coding_systems_region): Fix type errors.
Dave Love <fx@gnu.org>
parents:
89373
diff
changeset
|
7178 /* Extract an annotation datum from a composition starting at POS and |
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7179 ending before LIMIT of CODING->src_object (buffer or string), store |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7180 the data in BUF, set *STOP to a starting position of the next |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7181 composition (if any) or to LIMIT, and return the address of the |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7182 next element of BUF. |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7183 |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7184 If such an annotation is not found, set *STOP to a starting |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7185 position of a composition after POS (if any) or to LIMIT, and |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7186 return BUF. */ |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7187 |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7188 static INLINE int * |
109159
3e9fdeb960d1
* coding.c, sysdep.c: Convert some more functions to standard C.
Juanma Barranquero <lekktu@gmail.com>
parents:
109158
diff
changeset
|
7189 handle_composition_annotation (EMACS_INT pos, EMACS_INT limit, |
3e9fdeb960d1
* coding.c, sysdep.c: Convert some more functions to standard C.
Juanma Barranquero <lekktu@gmail.com>
parents:
109158
diff
changeset
|
7190 struct coding_system *coding, int *buf, |
3e9fdeb960d1
* coding.c, sysdep.c: Convert some more functions to standard C.
Juanma Barranquero <lekktu@gmail.com>
parents:
109158
diff
changeset
|
7191 EMACS_INT *stop) |
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7192 { |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7193 EMACS_INT start, end; |
26847 | 7194 Lisp_Object prop; |
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7195 |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7196 if (! find_composition (pos, limit, &start, &end, &prop, coding->src_object) |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7197 || end > limit) |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7198 *stop = limit; |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7199 else if (start > pos) |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7200 *stop = start; |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7201 else |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7202 { |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7203 if (start == pos) |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7204 { |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7205 /* We found a composition. Store the corresponding |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7206 annotation data in BUF. */ |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7207 int *head = buf; |
26847 | 7208 enum composition_method method = COMPOSITION_METHOD (prop); |
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7209 int nchars = COMPOSITION_LENGTH (prop); |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7210 |
102422
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
7211 ADD_COMPOSITION_DATA (buf, nchars, 0, method); |
26847 | 7212 if (method != COMPOSITION_RELATIVE) |
7213 { | |
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7214 Lisp_Object components; |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7215 int len, i, i_byte; |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7216 |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7217 components = COMPOSITION_COMPONENTS (prop); |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7218 if (VECTORP (components)) |
26847 | 7219 { |
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7220 len = XVECTOR (components)->size; |
26847 | 7221 for (i = 0; i < len; i++) |
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7222 *buf++ = XINT (AREF (components, i)); |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7223 } |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7224 else if (STRINGP (components)) |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7225 { |
89483 | 7226 len = SCHARS (components); |
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7227 i = i_byte = 0; |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7228 while (i < len) |
26847 | 7229 { |
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7230 FETCH_STRING_CHAR_ADVANCE (*buf, components, i, i_byte); |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7231 buf++; |
26847 | 7232 } |
7233 } | |
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7234 else if (INTEGERP (components)) |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7235 { |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7236 len = 1; |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7237 *buf++ = XINT (components); |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7238 } |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7239 else if (CONSP (components)) |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7240 { |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7241 for (len = 0; CONSP (components); |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7242 len++, components = XCDR (components)) |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7243 *buf++ = XINT (XCAR (components)); |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7244 } |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7245 else |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7246 abort (); |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7247 *head -= len; |
26847 | 7248 } |
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7249 } |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7250 |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7251 if (find_composition (end, limit, &start, &end, &prop, |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7252 coding->src_object) |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7253 && end <= limit) |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7254 *stop = start; |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7255 else |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7256 *stop = limit; |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7257 } |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7258 return buf; |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7259 } |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7260 |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7261 |
89394
6ffca50f25b9
(Fcheck_coding_systems_region): Fix type errors.
Dave Love <fx@gnu.org>
parents:
89373
diff
changeset
|
7262 /* Extract an annotation datum from a text property `charset' at POS of |
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7263 CODING->src_object (buffer of string), store the data in BUF, set |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7264 *STOP to the position where the value of `charset' property changes |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7265 (limiting by LIMIT), and return the address of the next element of |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7266 BUF. |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7267 |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7268 If the property value is nil, set *STOP to the position where the |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7269 property value is non-nil (limiting by LIMIT), and return BUF. */ |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7270 |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7271 static INLINE int * |
109159
3e9fdeb960d1
* coding.c, sysdep.c: Convert some more functions to standard C.
Juanma Barranquero <lekktu@gmail.com>
parents:
109158
diff
changeset
|
7272 handle_charset_annotation (EMACS_INT pos, EMACS_INT limit, |
3e9fdeb960d1
* coding.c, sysdep.c: Convert some more functions to standard C.
Juanma Barranquero <lekktu@gmail.com>
parents:
109158
diff
changeset
|
7273 struct coding_system *coding, int *buf, |
3e9fdeb960d1
* coding.c, sysdep.c: Convert some more functions to standard C.
Juanma Barranquero <lekktu@gmail.com>
parents:
109158
diff
changeset
|
7274 EMACS_INT *stop) |
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7275 { |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7276 Lisp_Object val, next; |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7277 int id; |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7278 |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7279 val = Fget_text_property (make_number (pos), Qcharset, coding->src_object); |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7280 if (! NILP (val) && CHARSETP (val)) |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7281 id = XINT (CHARSET_SYMBOL_ID (val)); |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7282 else |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7283 id = -1; |
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
7284 ADD_CHARSET_DATA (buf, 0, id); |
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7285 next = Fnext_single_property_change (make_number (pos), Qcharset, |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7286 coding->src_object, |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7287 make_number (limit)); |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7288 *stop = XINT (next); |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7289 return buf; |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7290 } |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7291 |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7292 |
88365 | 7293 static void |
109159
3e9fdeb960d1
* coding.c, sysdep.c: Convert some more functions to standard C.
Juanma Barranquero <lekktu@gmail.com>
parents:
109158
diff
changeset
|
7294 consume_chars (struct coding_system *coding, Lisp_Object translation_table, |
3e9fdeb960d1
* coding.c, sysdep.c: Convert some more functions to standard C.
Juanma Barranquero <lekktu@gmail.com>
parents:
109158
diff
changeset
|
7295 int max_lookup) |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
7296 { |
88365 | 7297 int *buf = coding->charbuf; |
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7298 int *buf_end = coding->charbuf + coding->charbuf_size; |
88876
af9012fdad56
(LEADING_CODE_PRIVATE_11, LEADING_CODE_PRIVATE_12,
Kenichi Handa <handa@m17n.org>
parents:
88862
diff
changeset
|
7299 const unsigned char *src = coding->source + coding->consumed; |
89442
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
7300 const unsigned char *src_end = coding->source + coding->src_bytes; |
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7301 EMACS_INT pos = coding->src_pos + coding->consumed_char; |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7302 EMACS_INT end_pos = coding->src_pos + coding->src_chars; |
88365 | 7303 int multibytep = coding->src_multibyte; |
7304 Lisp_Object eol_type; | |
7305 int c; | |
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7306 EMACS_INT stop, stop_composition, stop_charset; |
89859
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
7307 int *lookup_buf = NULL; |
89856
18b52da60a76
(get_translation): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89852
diff
changeset
|
7308 |
18b52da60a76
(get_translation): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89852
diff
changeset
|
7309 if (! NILP (translation_table)) |
89859
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
7310 lookup_buf = alloca (sizeof (int) * max_lookup); |
88365 | 7311 |
102334
7baaea85626e
(decode_coding_utf_8, decode_coding_utf_16, decode_coding_emacs_mule,
Eli Zaretskii <eliz@gnu.org>
parents:
102327
diff
changeset
|
7312 eol_type = inhibit_eol_conversion ? Qunix : CODING_ID_EOL_TYPE (coding->id); |
88365 | 7313 if (VECTORP (eol_type)) |
7314 eol_type = Qunix; | |
7315 | |
7316 /* Note: composition handling is not yet implemented. */ | |
7317 coding->common_flags &= ~CODING_ANNOTATE_COMPOSITION_MASK; | |
7318 | |
89562
12fbcfebb9ad
(consume_chars): If coding->src_object is nil, don't check annotation.
Kenichi Handa <handa@m17n.org>
parents:
89545
diff
changeset
|
7319 if (NILP (coding->src_object)) |
12fbcfebb9ad
(consume_chars): If coding->src_object is nil, don't check annotation.
Kenichi Handa <handa@m17n.org>
parents:
89545
diff
changeset
|
7320 stop = stop_composition = stop_charset = end_pos; |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
7321 else |
89562
12fbcfebb9ad
(consume_chars): If coding->src_object is nil, don't check annotation.
Kenichi Handa <handa@m17n.org>
parents:
89545
diff
changeset
|
7322 { |
12fbcfebb9ad
(consume_chars): If coding->src_object is nil, don't check annotation.
Kenichi Handa <handa@m17n.org>
parents:
89545
diff
changeset
|
7323 if (coding->common_flags & CODING_ANNOTATE_COMPOSITION_MASK) |
12fbcfebb9ad
(consume_chars): If coding->src_object is nil, don't check annotation.
Kenichi Handa <handa@m17n.org>
parents:
89545
diff
changeset
|
7324 stop = stop_composition = pos; |
12fbcfebb9ad
(consume_chars): If coding->src_object is nil, don't check annotation.
Kenichi Handa <handa@m17n.org>
parents:
89545
diff
changeset
|
7325 else |
12fbcfebb9ad
(consume_chars): If coding->src_object is nil, don't check annotation.
Kenichi Handa <handa@m17n.org>
parents:
89545
diff
changeset
|
7326 stop = stop_composition = end_pos; |
12fbcfebb9ad
(consume_chars): If coding->src_object is nil, don't check annotation.
Kenichi Handa <handa@m17n.org>
parents:
89545
diff
changeset
|
7327 if (coding->common_flags & CODING_ANNOTATE_CHARSET_MASK) |
12fbcfebb9ad
(consume_chars): If coding->src_object is nil, don't check annotation.
Kenichi Handa <handa@m17n.org>
parents:
89545
diff
changeset
|
7328 stop = stop_charset = pos; |
12fbcfebb9ad
(consume_chars): If coding->src_object is nil, don't check annotation.
Kenichi Handa <handa@m17n.org>
parents:
89545
diff
changeset
|
7329 else |
12fbcfebb9ad
(consume_chars): If coding->src_object is nil, don't check annotation.
Kenichi Handa <handa@m17n.org>
parents:
89545
diff
changeset
|
7330 stop_charset = end_pos; |
12fbcfebb9ad
(consume_chars): If coding->src_object is nil, don't check annotation.
Kenichi Handa <handa@m17n.org>
parents:
89545
diff
changeset
|
7331 } |
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7332 |
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
7333 /* Compensate for CRLF and conversion. */ |
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7334 buf_end -= 1 + MAX_ANNOTATION_LENGTH; |
88365 | 7335 while (buf < buf_end) |
7336 { | |
89856
18b52da60a76
(get_translation): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89852
diff
changeset
|
7337 Lisp_Object trans; |
18b52da60a76
(get_translation): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89852
diff
changeset
|
7338 |
88365 | 7339 if (pos == stop) |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
7340 { |
88365 | 7341 if (pos == end_pos) |
7342 break; | |
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7343 if (pos == stop_composition) |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7344 buf = handle_composition_annotation (pos, end_pos, coding, |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7345 buf, &stop_composition); |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7346 if (pos == stop_charset) |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7347 buf = handle_charset_annotation (pos, end_pos, coding, |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7348 buf, &stop_charset); |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7349 stop = (stop_composition < stop_charset |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7350 ? stop_composition : stop_charset); |
88365 | 7351 } |
7352 | |
7353 if (! multibytep) | |
89442
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
7354 { |
89462
4e359ebf3984
(decode_coding_iso_2022): Fix handling of invalid
Kenichi Handa <handa@m17n.org>
parents:
89448
diff
changeset
|
7355 EMACS_INT bytes; |
4e359ebf3984
(decode_coding_iso_2022): Fix handling of invalid
Kenichi Handa <handa@m17n.org>
parents:
89448
diff
changeset
|
7356 |
106918
d6e8fa5622b7
Fix ccl encoding of unibyte source.
Kenichi Handa <handa@m17n.org>
parents:
106826
diff
changeset
|
7357 if (coding->encoder == encode_coding_raw_text |
d6e8fa5622b7
Fix ccl encoding of unibyte source.
Kenichi Handa <handa@m17n.org>
parents:
106826
diff
changeset
|
7358 || coding->encoder == encode_coding_ccl) |
89933
48af0ea7d387
(setup_coding_system): Set coding->common_flags
Kenichi Handa <handa@m17n.org>
parents:
89924
diff
changeset
|
7359 c = *src++, pos++; |
48af0ea7d387
(setup_coding_system): Set coding->common_flags
Kenichi Handa <handa@m17n.org>
parents:
89924
diff
changeset
|
7360 else if ((bytes = MULTIBYTE_LENGTH (src, src_end)) > 0) |
92992
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
7361 c = STRING_CHAR_ADVANCE_NO_UNIFY (src), pos += bytes; |
89442
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
7362 else |
89917
1763eef5ad02
(encode_coding_utf_8): Fix handling of raw-byte char.
Kenichi Handa <handa@m17n.org>
parents:
89905
diff
changeset
|
7363 c = BYTE8_TO_CHAR (*src), src++, pos++; |
89442
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
7364 } |
88365 | 7365 else |
92992
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
7366 c = STRING_CHAR_ADVANCE_NO_UNIFY (src), pos++; |
88365 | 7367 if ((c == '\r') && (coding->mode & CODING_MODE_SELECTIVE_DISPLAY)) |
7368 c = '\n'; | |
7369 if (! EQ (eol_type, Qunix)) | |
7370 { | |
7371 if (c == '\n') | |
32443
57fa108c491f
(code_convert_region): Be sure to initialize coding->category_idx.
Kenichi Handa <handa@m17n.org>
parents:
31458
diff
changeset
|
7372 { |
88365 | 7373 if (EQ (eol_type, Qdos)) |
7374 *buf++ = '\r'; | |
7375 else | |
7376 c = '\r'; | |
32443
57fa108c491f
(code_convert_region): Be sure to initialize coding->category_idx.
Kenichi Handa <handa@m17n.org>
parents:
31458
diff
changeset
|
7377 } |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
7378 } |
89856
18b52da60a76
(get_translation): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89852
diff
changeset
|
7379 |
89858
23cb9ed79225
(get_translation_table): Declare it as Lisp_Object.
Kenichi Handa <handa@m17n.org>
parents:
89856
diff
changeset
|
7380 trans = Qnil; |
89859
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
7381 LOOKUP_TRANSLATION_TABLE (translation_table, c, trans); |
89858
23cb9ed79225
(get_translation_table): Declare it as Lisp_Object.
Kenichi Handa <handa@m17n.org>
parents:
89856
diff
changeset
|
7382 if (NILP (trans)) |
89856
18b52da60a76
(get_translation): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89852
diff
changeset
|
7383 *buf++ = c; |
26847 | 7384 else |
89856
18b52da60a76
(get_translation): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89852
diff
changeset
|
7385 { |
18b52da60a76
(get_translation): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89852
diff
changeset
|
7386 int from_nchars = 1, to_nchars = 1; |
18b52da60a76
(get_translation): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89852
diff
changeset
|
7387 int *lookup_buf_end; |
18b52da60a76
(get_translation): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89852
diff
changeset
|
7388 const unsigned char *p = src; |
18b52da60a76
(get_translation): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89852
diff
changeset
|
7389 int i; |
18b52da60a76
(get_translation): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89852
diff
changeset
|
7390 |
18b52da60a76
(get_translation): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89852
diff
changeset
|
7391 lookup_buf[0] = c; |
18b52da60a76
(get_translation): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89852
diff
changeset
|
7392 for (i = 1; i < max_lookup && p < src_end; i++) |
18b52da60a76
(get_translation): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89852
diff
changeset
|
7393 lookup_buf[i] = STRING_CHAR_ADVANCE (p); |
18b52da60a76
(get_translation): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89852
diff
changeset
|
7394 lookup_buf_end = lookup_buf + i; |
102422
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
7395 trans = get_translation (trans, lookup_buf, lookup_buf_end); |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
7396 if (INTEGERP (trans)) |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
7397 c = XINT (trans); |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
7398 else if (CONSP (trans)) |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
7399 { |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
7400 from_nchars = ASIZE (XCAR (trans)); |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
7401 trans = XCDR (trans); |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
7402 if (INTEGERP (trans)) |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
7403 c = XINT (trans); |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
7404 else |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
7405 { |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
7406 to_nchars = ASIZE (trans); |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
7407 if (buf + to_nchars > buf_end) |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
7408 break; |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
7409 c = XINT (AREF (trans, 0)); |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
7410 } |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
7411 } |
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
7412 else |
23881
20d595402dea
(DECODE_DESIGNATION): Jump to label_invalid_code if
Kenichi Handa <handa@m17n.org>
parents:
23564
diff
changeset
|
7413 break; |
102422
82f82b92314e
(CODING_ISO_CMP_STATUS): New macro.
Kenichi Handa <handa@m17n.org>
parents:
102334
diff
changeset
|
7414 *buf++ = c; |
89856
18b52da60a76
(get_translation): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89852
diff
changeset
|
7415 for (i = 1; i < to_nchars; i++) |
18b52da60a76
(get_translation): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89852
diff
changeset
|
7416 *buf++ = XINT (AREF (trans, i)); |
18b52da60a76
(get_translation): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89852
diff
changeset
|
7417 for (i = 1; i < from_nchars; i++, pos++) |
18b52da60a76
(get_translation): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89852
diff
changeset
|
7418 src += MULTIBYTE_LENGTH_NO_CHECK (src); |
18b52da60a76
(get_translation): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89852
diff
changeset
|
7419 } |
88365 | 7420 } |
7421 | |
7422 coding->consumed = src - coding->source; | |
7423 coding->consumed_char = pos - coding->src_pos; | |
7424 coding->charbuf_used = buf - coding->charbuf; | |
7425 coding->chars_at_source = 0; | |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
7426 } |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
7427 |
88365 | 7428 |
7429 /* Encode the text at CODING->src_object into CODING->dst_object. | |
7430 CODING->src_object is a buffer or a string. | |
7431 CODING->dst_object is a buffer or nil. | |
7432 | |
7433 If CODING->src_object is a buffer, it must be the current buffer. | |
7434 In this case, if CODING->src_pos is positive, it is a position of | |
7435 the source text in the buffer, otherwise. the source text is in the | |
7436 gap area of the buffer, and coding->src_pos specifies the offset of | |
7437 the text from GPT (which must be the same as PT). If this is the | |
7438 same buffer as CODING->dst_object, CODING->src_pos must be | |
7439 negative and CODING should not have `pre-write-conversion'. | |
7440 | |
7441 If CODING->src_object is a string, CODING should not have | |
7442 `pre-write-conversion'. | |
7443 | |
7444 If CODING->dst_object is a buffer, the encoded data is inserted at | |
7445 the current point of that buffer. | |
7446 | |
7447 If CODING->dst_object is nil, the encoded data is placed at the | |
7448 memory area specified by CODING->destination. */ | |
7449 | |
7450 static int | |
109126
aec1143e8d85
Convert (most) functions in src to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109100
diff
changeset
|
7451 encode_coding (struct coding_system *coding) |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
7452 { |
88365 | 7453 Lisp_Object attrs; |
89732
8acde12aba89
(get_translation_table): New function.
Kenichi Handa <handa@m17n.org>
parents:
89730
diff
changeset
|
7454 Lisp_Object translation_table; |
89859
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
7455 int max_lookup; |
107507
8960853cf85d
Fix the ccl encoder for the case that the output buffer is fullfilled.
Kenichi Handa <handa@m17n.org>
parents:
107506
diff
changeset
|
7456 struct ccl_spec cclspec; |
88365 | 7457 |
7458 attrs = CODING_ID_ATTRS (coding->id); | |
89933
48af0ea7d387
(setup_coding_system): Set coding->common_flags
Kenichi Handa <handa@m17n.org>
parents:
89924
diff
changeset
|
7459 if (coding->encoder == encode_coding_raw_text) |
48af0ea7d387
(setup_coding_system): Set coding->common_flags
Kenichi Handa <handa@m17n.org>
parents:
89924
diff
changeset
|
7460 translation_table = Qnil, max_lookup = 0; |
42661
e85e4d9494b1
(code_convert_region): Don't copy old text if undo disabled.
Richard M. Stallman <rms@gnu.org>
parents:
42105
diff
changeset
|
7461 else |
89933
48af0ea7d387
(setup_coding_system): Set coding->common_flags
Kenichi Handa <handa@m17n.org>
parents:
89924
diff
changeset
|
7462 translation_table = get_translation_table (attrs, 1, &max_lookup); |
88365 | 7463 |
7464 if (BUFFERP (coding->dst_object)) | |
7465 { | |
7466 set_buffer_internal (XBUFFER (coding->dst_object)); | |
7467 coding->dst_multibyte | |
7468 = ! NILP (current_buffer->enable_multibyte_characters); | |
7469 } | |
7470 | |
7471 coding->consumed = coding->consumed_char = 0; | |
7472 coding->produced = coding->produced_char = 0; | |
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
7473 record_conversion_result (coding, CODING_RESULT_SUCCESS); |
88365 | 7474 coding->errors = 0; |
7475 | |
7476 ALLOC_CONVERSION_WORK_AREA (coding); | |
7477 | |
107507
8960853cf85d
Fix the ccl encoder for the case that the output buffer is fullfilled.
Kenichi Handa <handa@m17n.org>
parents:
107506
diff
changeset
|
7478 if (coding->encoder == encode_coding_ccl) |
8960853cf85d
Fix the ccl encoder for the case that the output buffer is fullfilled.
Kenichi Handa <handa@m17n.org>
parents:
107506
diff
changeset
|
7479 { |
8960853cf85d
Fix the ccl encoder for the case that the output buffer is fullfilled.
Kenichi Handa <handa@m17n.org>
parents:
107506
diff
changeset
|
7480 coding->spec.ccl = &cclspec; |
8960853cf85d
Fix the ccl encoder for the case that the output buffer is fullfilled.
Kenichi Handa <handa@m17n.org>
parents:
107506
diff
changeset
|
7481 setup_ccl_program (&cclspec.ccl, CODING_CCL_ENCODER (coding)); |
8960853cf85d
Fix the ccl encoder for the case that the output buffer is fullfilled.
Kenichi Handa <handa@m17n.org>
parents:
107506
diff
changeset
|
7482 } |
88365 | 7483 do { |
7484 coding_set_source (coding); | |
89859
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
7485 consume_chars (coding, translation_table, max_lookup); |
88365 | 7486 coding_set_destination (coding); |
7487 (*(coding->encoder)) (coding); | |
7488 } while (coding->consumed_char < coding->src_chars); | |
7489 | |
90809
3c52757d5f6e
(produce_chars): Don't call insert_from_gap if no
Kenichi Handa <handa@m17n.org>
parents:
90772
diff
changeset
|
7490 if (BUFFERP (coding->dst_object) && coding->produced_char > 0) |
88365 | 7491 insert_from_gap (coding->produced_char, coding->produced); |
7492 | |
7493 return (coding->result); | |
7494 } | |
7495 | |
89442
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
7496 |
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
7497 /* Name (or base name) of work buffer for code conversion. */ |
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
7498 static Lisp_Object Vcode_conversion_workbuf_name; |
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
7499 |
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
7500 /* A working buffer used by the top level conversion. Once it is |
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
7501 created, it is never destroyed. It has the name |
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
7502 Vcode_conversion_workbuf_name. The other working buffers are |
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
7503 destroyed after the use is finished, and their names are modified |
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
7504 versions of Vcode_conversion_workbuf_name. */ |
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
7505 static Lisp_Object Vcode_conversion_reused_workbuf; |
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
7506 |
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
7507 /* 1 iff Vcode_conversion_reused_workbuf is already in use. */ |
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
7508 static int reused_workbuf_in_use; |
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
7509 |
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
7510 |
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
7511 /* Return a working buffer of code convesion. MULTIBYTE specifies the |
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
7512 multibyteness of returning buffer. */ |
88365 | 7513 |
89863
428fc37b2ae6
Add many prototypes for static functions.
Kenichi Handa <handa@m17n.org>
parents:
89861
diff
changeset
|
7514 static Lisp_Object |
109126
aec1143e8d85
Convert (most) functions in src to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109100
diff
changeset
|
7515 make_conversion_work_buffer (int multibyte) |
88365 | 7516 { |
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
7517 Lisp_Object name, workbuf; |
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
7518 struct buffer *current; |
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
7519 |
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
7520 if (reused_workbuf_in_use++) |
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
7521 { |
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
7522 name = Fgenerate_new_buffer_name (Vcode_conversion_workbuf_name, Qnil); |
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
7523 workbuf = Fget_buffer_create (name); |
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
7524 } |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
7525 else |
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
7526 { |
99074
10cd979d05ca
(make_conversion_work_buffer): Check that Vcode_conversion_reused_workbuf
Noah Friedman <friedman@splode.com>
parents:
98992
diff
changeset
|
7527 if (NILP (Fbuffer_live_p (Vcode_conversion_reused_workbuf))) |
98186
1cfa973fde14
(make_conversion_work_buffer): Avoid calling
Kenichi Handa <handa@m17n.org>
parents:
96571
diff
changeset
|
7528 Vcode_conversion_reused_workbuf |
1cfa973fde14
(make_conversion_work_buffer): Avoid calling
Kenichi Handa <handa@m17n.org>
parents:
96571
diff
changeset
|
7529 = Fget_buffer_create (Vcode_conversion_workbuf_name); |
1cfa973fde14
(make_conversion_work_buffer): Avoid calling
Kenichi Handa <handa@m17n.org>
parents:
96571
diff
changeset
|
7530 workbuf = Vcode_conversion_reused_workbuf; |
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
7531 } |
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
7532 current = current_buffer; |
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
7533 set_buffer_internal (XBUFFER (workbuf)); |
100262
46114a72fb0e
(make_conversion_work_buffer): Disable buffer modification hooks in
Chong Yidong <cyd@stupidchicken.com>
parents:
100176
diff
changeset
|
7534 /* We can't allow modification hooks to run in the work buffer. For |
46114a72fb0e
(make_conversion_work_buffer): Disable buffer modification hooks in
Chong Yidong <cyd@stupidchicken.com>
parents:
100176
diff
changeset
|
7535 instance, directory_files_internal assumes that file decoding |
46114a72fb0e
(make_conversion_work_buffer): Disable buffer modification hooks in
Chong Yidong <cyd@stupidchicken.com>
parents:
100176
diff
changeset
|
7536 doesn't compile new regexps. */ |
46114a72fb0e
(make_conversion_work_buffer): Disable buffer modification hooks in
Chong Yidong <cyd@stupidchicken.com>
parents:
100176
diff
changeset
|
7537 Fset (Fmake_local_variable (Qinhibit_modification_hooks), Qt); |
93877
62d97ebb13a9
* coding.c (detect_coding_emacs_mule)
Michael Albinus <michael.albinus@gmx.de>
parents:
93595
diff
changeset
|
7538 Ferase_buffer (); |
88365 | 7539 current_buffer->undo_list = Qt; |
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
7540 current_buffer->enable_multibyte_characters = multibyte ? Qt : Qnil; |
88365 | 7541 set_buffer_internal (current); |
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
7542 return workbuf; |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
7543 } |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
7544 |
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
7545 |
89442
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
7546 static Lisp_Object |
109126
aec1143e8d85
Convert (most) functions in src to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109100
diff
changeset
|
7547 code_conversion_restore (Lisp_Object arg) |
26067
f54ca66e2571
(code_convert_string): Add record_unwind_protect to
Kenichi Handa <handa@m17n.org>
parents:
25860
diff
changeset
|
7548 { |
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
7549 Lisp_Object current, workbuf; |
90263
80fb4c061e99
(code_conversion_restore): GCPRO arg.
Kenichi Handa <handa@m17n.org>
parents:
90261
diff
changeset
|
7550 struct gcpro gcpro1; |
80fb4c061e99
(code_conversion_restore): GCPRO arg.
Kenichi Handa <handa@m17n.org>
parents:
90261
diff
changeset
|
7551 |
80fb4c061e99
(code_conversion_restore): GCPRO arg.
Kenichi Handa <handa@m17n.org>
parents:
90261
diff
changeset
|
7552 GCPRO1 (arg); |
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
7553 current = XCAR (arg); |
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
7554 workbuf = XCDR (arg); |
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
7555 if (! NILP (workbuf)) |
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
7556 { |
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
7557 if (EQ (workbuf, Vcode_conversion_reused_workbuf)) |
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
7558 reused_workbuf_in_use = 0; |
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
7559 else if (! NILP (Fbuffer_live_p (workbuf))) |
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
7560 Fkill_buffer (workbuf); |
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
7561 } |
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
7562 set_buffer_internal (XBUFFER (current)); |
90263
80fb4c061e99
(code_conversion_restore): GCPRO arg.
Kenichi Handa <handa@m17n.org>
parents:
90261
diff
changeset
|
7563 UNGCPRO; |
89442
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
7564 return Qnil; |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
7565 } |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
7566 |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
7567 Lisp_Object |
109126
aec1143e8d85
Convert (most) functions in src to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109100
diff
changeset
|
7568 code_conversion_save (int with_work_buf, int multibyte) |
89442
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
7569 { |
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
7570 Lisp_Object workbuf = Qnil; |
89442
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
7571 |
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
7572 if (with_work_buf) |
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
7573 workbuf = make_conversion_work_buffer (multibyte); |
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
7574 record_unwind_protect (code_conversion_restore, |
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
7575 Fcons (Fcurrent_buffer (), workbuf)); |
89442
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
7576 return workbuf; |
17052 | 7577 } |
7578 | |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
7579 int |
109159
3e9fdeb960d1
* coding.c, sysdep.c: Convert some more functions to standard C.
Juanma Barranquero <lekktu@gmail.com>
parents:
109158
diff
changeset
|
7580 decode_coding_gap (struct coding_system *coding, |
3e9fdeb960d1
* coding.c, sysdep.c: Convert some more functions to standard C.
Juanma Barranquero <lekktu@gmail.com>
parents:
109158
diff
changeset
|
7581 EMACS_INT chars, EMACS_INT bytes) |
88365 | 7582 { |
109158
6175ebc3b6ce
* coding.c: Use SPECPDL_INDEX, DOS_NT.
Juanma Barranquero <lekktu@gmail.com>
parents:
109126
diff
changeset
|
7583 int count = SPECPDL_INDEX (); |
89448
de8b460070cc
(setup_coding_system): If coding has
Kenichi Handa <handa@m17n.org>
parents:
89446
diff
changeset
|
7584 Lisp_Object attrs; |
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
7585 |
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
7586 code_conversion_save (0, 0); |
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
7587 |
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
7588 coding->src_object = Fcurrent_buffer (); |
88365 | 7589 coding->src_chars = chars; |
7590 coding->src_bytes = bytes; | |
7591 coding->src_pos = -chars; | |
7592 coding->src_pos_byte = -bytes; | |
7593 coding->src_multibyte = chars < bytes; | |
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
7594 coding->dst_object = coding->src_object; |
88365 | 7595 coding->dst_pos = PT; |
7596 coding->dst_pos_byte = PT_BYTE; | |
88443
6b86cf30a0b9
(produce_chars): Set the variable `multibytep' correctly.
Kenichi Handa <handa@m17n.org>
parents:
88438
diff
changeset
|
7597 coding->dst_multibyte = ! NILP (current_buffer->enable_multibyte_characters); |
88365 | 7598 |
7599 if (CODING_REQUIRE_DETECTION (coding)) | |
7600 detect_coding (coding); | |
89483 | 7601 |
90350
60eaefb08cf7
(DECODE_COMPOSITION_START): If the source is short, set
Kenichi Handa <handa@m17n.org>
parents:
90346
diff
changeset
|
7602 coding->mode |= CODING_MODE_LAST_BLOCK; |
90772
b15334b4a9c3
(coding_alloc_by_making_gap): New arg offset.
Kenichi Handa <handa@m17n.org>
parents:
90737
diff
changeset
|
7603 current_buffer->text->inhibit_shrinking = 1; |
88365 | 7604 decode_coding (coding); |
90772
b15334b4a9c3
(coding_alloc_by_making_gap): New arg offset.
Kenichi Handa <handa@m17n.org>
parents:
90737
diff
changeset
|
7605 current_buffer->text->inhibit_shrinking = 0; |
88365 | 7606 |
89448
de8b460070cc
(setup_coding_system): If coding has
Kenichi Handa <handa@m17n.org>
parents:
89446
diff
changeset
|
7607 attrs = CODING_ID_ATTRS (coding->id); |
de8b460070cc
(setup_coding_system): If coding has
Kenichi Handa <handa@m17n.org>
parents:
89446
diff
changeset
|
7608 if (! NILP (CODING_ATTR_POST_READ (attrs))) |
de8b460070cc
(setup_coding_system): If coding has
Kenichi Handa <handa@m17n.org>
parents:
89446
diff
changeset
|
7609 { |
de8b460070cc
(setup_coding_system): If coding has
Kenichi Handa <handa@m17n.org>
parents:
89446
diff
changeset
|
7610 EMACS_INT prev_Z = Z, prev_Z_BYTE = Z_BYTE; |
de8b460070cc
(setup_coding_system): If coding has
Kenichi Handa <handa@m17n.org>
parents:
89446
diff
changeset
|
7611 Lisp_Object val; |
de8b460070cc
(setup_coding_system): If coding has
Kenichi Handa <handa@m17n.org>
parents:
89446
diff
changeset
|
7612 |
de8b460070cc
(setup_coding_system): If coding has
Kenichi Handa <handa@m17n.org>
parents:
89446
diff
changeset
|
7613 TEMP_SET_PT_BOTH (coding->dst_pos, coding->dst_pos_byte); |
de8b460070cc
(setup_coding_system): If coding has
Kenichi Handa <handa@m17n.org>
parents:
89446
diff
changeset
|
7614 val = call1 (CODING_ATTR_POST_READ (attrs), |
de8b460070cc
(setup_coding_system): If coding has
Kenichi Handa <handa@m17n.org>
parents:
89446
diff
changeset
|
7615 make_number (coding->produced_char)); |
de8b460070cc
(setup_coding_system): If coding has
Kenichi Handa <handa@m17n.org>
parents:
89446
diff
changeset
|
7616 CHECK_NATNUM (val); |
de8b460070cc
(setup_coding_system): If coding has
Kenichi Handa <handa@m17n.org>
parents:
89446
diff
changeset
|
7617 coding->produced_char += Z - prev_Z; |
de8b460070cc
(setup_coding_system): If coding has
Kenichi Handa <handa@m17n.org>
parents:
89446
diff
changeset
|
7618 coding->produced += Z_BYTE - prev_Z_BYTE; |
de8b460070cc
(setup_coding_system): If coding has
Kenichi Handa <handa@m17n.org>
parents:
89446
diff
changeset
|
7619 } |
de8b460070cc
(setup_coding_system): If coding has
Kenichi Handa <handa@m17n.org>
parents:
89446
diff
changeset
|
7620 |
88365 | 7621 unbind_to (count, Qnil); |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
7622 return coding->result; |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
7623 } |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
7624 |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
7625 int |
109159
3e9fdeb960d1
* coding.c, sysdep.c: Convert some more functions to standard C.
Juanma Barranquero <lekktu@gmail.com>
parents:
109158
diff
changeset
|
7626 encode_coding_gap (struct coding_system *coding, |
3e9fdeb960d1
* coding.c, sysdep.c: Convert some more functions to standard C.
Juanma Barranquero <lekktu@gmail.com>
parents:
109158
diff
changeset
|
7627 EMACS_INT chars, EMACS_INT bytes) |
26847 | 7628 { |
109158
6175ebc3b6ce
* coding.c: Use SPECPDL_INDEX, DOS_NT.
Juanma Barranquero <lekktu@gmail.com>
parents:
109126
diff
changeset
|
7629 int count = SPECPDL_INDEX (); |
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
7630 |
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
7631 code_conversion_save (0, 0); |
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
7632 |
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
7633 coding->src_object = Fcurrent_buffer (); |
88365 | 7634 coding->src_chars = chars; |
7635 coding->src_bytes = bytes; | |
7636 coding->src_pos = -chars; | |
7637 coding->src_pos_byte = -bytes; | |
7638 coding->src_multibyte = chars < bytes; | |
7639 coding->dst_object = coding->src_object; | |
7640 coding->dst_pos = PT; | |
7641 coding->dst_pos_byte = PT_BYTE; | |
7642 | |
7643 encode_coding (coding); | |
7644 | |
7645 unbind_to (count, Qnil); | |
7646 return coding->result; | |
26847 | 7647 } |
7648 | |
88365 | 7649 |
7650 /* Decode the text in the range FROM/FROM_BYTE and TO/TO_BYTE in | |
7651 SRC_OBJECT into DST_OBJECT by coding context CODING. | |
7652 | |
7653 SRC_OBJECT is a buffer, a string, or Qnil. | |
7654 | |
7655 If it is a buffer, the text is at point of the buffer. FROM and TO | |
7656 are positions in the buffer. | |
7657 | |
7658 If it is a string, the text is at the beginning of the string. | |
7659 FROM and TO are indices to the string. | |
7660 | |
7661 If it is nil, the text is at coding->source. FROM and TO are | |
7662 indices to coding->source. | |
7663 | |
7664 DST_OBJECT is a buffer, Qt, or Qnil. | |
7665 | |
7666 If it is a buffer, the decoded text is inserted at point of the | |
7667 buffer. If the buffer is the same as SRC_OBJECT, the source text | |
7668 is deleted. | |
7669 | |
7670 If it is Qt, a string is made from the decoded text, and | |
7671 set in CODING->dst_object. | |
7672 | |
7673 If it is Qnil, the decoded text is stored at CODING->destination. | |
89418
a9c2b3712863
(coding_set_source): Fix for the case that the current
Kenichi Handa <handa@m17n.org>
parents:
89404
diff
changeset
|
7674 The caller must allocate CODING->dst_bytes bytes at |
88365 | 7675 CODING->destination by xmalloc. If the decoded text is longer than |
7676 CODING->dst_bytes, CODING->destination is relocated by xrealloc. | |
7677 */ | |
26847 | 7678 |
7679 void | |
109159
3e9fdeb960d1
* coding.c, sysdep.c: Convert some more functions to standard C.
Juanma Barranquero <lekktu@gmail.com>
parents:
109158
diff
changeset
|
7680 decode_coding_object (struct coding_system *coding, |
3e9fdeb960d1
* coding.c, sysdep.c: Convert some more functions to standard C.
Juanma Barranquero <lekktu@gmail.com>
parents:
109158
diff
changeset
|
7681 Lisp_Object src_object, |
3e9fdeb960d1
* coding.c, sysdep.c: Convert some more functions to standard C.
Juanma Barranquero <lekktu@gmail.com>
parents:
109158
diff
changeset
|
7682 EMACS_INT from, EMACS_INT from_byte, |
3e9fdeb960d1
* coding.c, sysdep.c: Convert some more functions to standard C.
Juanma Barranquero <lekktu@gmail.com>
parents:
109158
diff
changeset
|
7683 EMACS_INT to, EMACS_INT to_byte, |
3e9fdeb960d1
* coding.c, sysdep.c: Convert some more functions to standard C.
Juanma Barranquero <lekktu@gmail.com>
parents:
109158
diff
changeset
|
7684 Lisp_Object dst_object) |
26847 | 7685 { |
109158
6175ebc3b6ce
* coding.c: Use SPECPDL_INDEX, DOS_NT.
Juanma Barranquero <lekktu@gmail.com>
parents:
109126
diff
changeset
|
7686 int count = SPECPDL_INDEX (); |
88365 | 7687 unsigned char *destination; |
7688 EMACS_INT dst_bytes; | |
7689 EMACS_INT chars = to - from; | |
7690 EMACS_INT bytes = to_byte - from_byte; | |
7691 Lisp_Object attrs; | |
89442
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
7692 int saved_pt = -1, saved_pt_byte; |
91344
56f3473b139e
(decode_coding_object): Adjuste marker positions after
Kenichi Handa <handa@m17n.org>
parents:
91327
diff
changeset
|
7693 int need_marker_adjustment = 0; |
91838
7bed61cbed0c
(decode_coding_object, encode_coding_object): Preserve
Kenichi Handa <handa@m17n.org>
parents:
91807
diff
changeset
|
7694 Lisp_Object old_deactivate_mark; |
7bed61cbed0c
(decode_coding_object, encode_coding_object): Preserve
Kenichi Handa <handa@m17n.org>
parents:
91807
diff
changeset
|
7695 |
7bed61cbed0c
(decode_coding_object, encode_coding_object): Preserve
Kenichi Handa <handa@m17n.org>
parents:
91807
diff
changeset
|
7696 old_deactivate_mark = Vdeactivate_mark; |
88365 | 7697 |
7698 if (NILP (dst_object)) | |
7699 { | |
7700 destination = coding->destination; | |
7701 dst_bytes = coding->dst_bytes; | |
7702 } | |
7703 | |
7704 coding->src_object = src_object; | |
7705 coding->src_chars = chars; | |
7706 coding->src_bytes = bytes; | |
7707 coding->src_multibyte = chars < bytes; | |
7708 | |
7709 if (STRINGP (src_object)) | |
7710 { | |
7711 coding->src_pos = from; | |
7712 coding->src_pos_byte = from_byte; | |
7713 } | |
7714 else if (BUFFERP (src_object)) | |
7715 { | |
7716 set_buffer_internal (XBUFFER (src_object)); | |
7717 if (from != GPT) | |
7718 move_gap_both (from, from_byte); | |
7719 if (EQ (src_object, dst_object)) | |
26847 | 7720 { |
91344
56f3473b139e
(decode_coding_object): Adjuste marker positions after
Kenichi Handa <handa@m17n.org>
parents:
91327
diff
changeset
|
7721 struct Lisp_Marker *tail; |
56f3473b139e
(decode_coding_object): Adjuste marker positions after
Kenichi Handa <handa@m17n.org>
parents:
91327
diff
changeset
|
7722 |
56f3473b139e
(decode_coding_object): Adjuste marker positions after
Kenichi Handa <handa@m17n.org>
parents:
91327
diff
changeset
|
7723 for (tail = BUF_MARKERS (current_buffer); tail; tail = tail->next) |
26847 | 7724 { |
91344
56f3473b139e
(decode_coding_object): Adjuste marker positions after
Kenichi Handa <handa@m17n.org>
parents:
91327
diff
changeset
|
7725 tail->need_adjustment |
56f3473b139e
(decode_coding_object): Adjuste marker positions after
Kenichi Handa <handa@m17n.org>
parents:
91327
diff
changeset
|
7726 = tail->charpos == (tail->insertion_type ? from : to); |
56f3473b139e
(decode_coding_object): Adjuste marker positions after
Kenichi Handa <handa@m17n.org>
parents:
91327
diff
changeset
|
7727 need_marker_adjustment |= tail->need_adjustment; |
56f3473b139e
(decode_coding_object): Adjuste marker positions after
Kenichi Handa <handa@m17n.org>
parents:
91327
diff
changeset
|
7728 } |
89442
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
7729 saved_pt = PT, saved_pt_byte = PT_BYTE; |
88365 | 7730 TEMP_SET_PT_BOTH (from, from_byte); |
92458
5f5f07a5c076
(decode_coding_object): Inhibit gap shrinking while
Andreas Schwab <schwab@suse.de>
parents:
92406
diff
changeset
|
7731 current_buffer->text->inhibit_shrinking = 1; |
88365 | 7732 del_range_both (from, from_byte, to, to_byte, 1); |
7733 coding->src_pos = -chars; | |
7734 coding->src_pos_byte = -bytes; | |
20931
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
7735 } |
42661
e85e4d9494b1
(code_convert_region): Don't copy old text if undo disabled.
Richard M. Stallman <rms@gnu.org>
parents:
42105
diff
changeset
|
7736 else |
e85e4d9494b1
(code_convert_region): Don't copy old text if undo disabled.
Richard M. Stallman <rms@gnu.org>
parents:
42105
diff
changeset
|
7737 { |
88365 | 7738 coding->src_pos = from; |
7739 coding->src_pos_byte = from_byte; | |
29985
c17e78d8c720
(code_convert_region): Even if the length of text is
Kenichi Handa <handa@m17n.org>
parents:
29932
diff
changeset
|
7740 } |
88365 | 7741 } |
7742 | |
7743 if (CODING_REQUIRE_DETECTION (coding)) | |
7744 detect_coding (coding); | |
7745 attrs = CODING_ID_ATTRS (coding->id); | |
7746 | |
89418
a9c2b3712863
(coding_set_source): Fix for the case that the current
Kenichi Handa <handa@m17n.org>
parents:
89404
diff
changeset
|
7747 if (EQ (dst_object, Qt) |
a9c2b3712863
(coding_set_source): Fix for the case that the current
Kenichi Handa <handa@m17n.org>
parents:
89404
diff
changeset
|
7748 || (! NILP (CODING_ATTR_POST_READ (attrs)) |
a9c2b3712863
(coding_set_source): Fix for the case that the current
Kenichi Handa <handa@m17n.org>
parents:
89404
diff
changeset
|
7749 && NILP (dst_object))) |
88365 | 7750 { |
93321
c3fe9ef79b56
(decode_coding_object): Fix last change.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
93197
diff
changeset
|
7751 coding->dst_multibyte = !CODING_FOR_UNIBYTE (coding); |
c3fe9ef79b56
(decode_coding_object): Fix last change.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
93197
diff
changeset
|
7752 coding->dst_object = code_conversion_save (1, coding->dst_multibyte); |
88365 | 7753 coding->dst_pos = BEG; |
7754 coding->dst_pos_byte = BEG_BYTE; | |
7755 } | |
7756 else if (BUFFERP (dst_object)) | |
7757 { | |
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
7758 code_conversion_save (0, 0); |
88365 | 7759 coding->dst_object = dst_object; |
7760 coding->dst_pos = BUF_PT (XBUFFER (dst_object)); | |
7761 coding->dst_pos_byte = BUF_PT_BYTE (XBUFFER (dst_object)); | |
7762 coding->dst_multibyte | |
7763 = ! NILP (XBUFFER (dst_object)->enable_multibyte_characters); | |
7764 } | |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
7765 else |
29172
46ad5a027334
(run_pre_post_conversion_on_str): Set point to the
Kenichi Handa <handa@m17n.org>
parents:
29093
diff
changeset
|
7766 { |
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
7767 code_conversion_save (0, 0); |
88365 | 7768 coding->dst_object = Qnil; |
93322
3b82aab9d8fc
(decode_coding_object): Revert part of last change.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
93321
diff
changeset
|
7769 /* Most callers presume this will return a multibyte result, and they |
3b82aab9d8fc
(decode_coding_object): Revert part of last change.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
93321
diff
changeset
|
7770 won't use `binary' or `raw-text' anyway, so let's not worry about |
3b82aab9d8fc
(decode_coding_object): Revert part of last change.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
93321
diff
changeset
|
7771 CODING_FOR_UNIBYTE. */ |
93323
06e93ffa2e9f
(decode_coding_object): Fix last change.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
93322
diff
changeset
|
7772 coding->dst_multibyte = 1; |
88365 | 7773 } |
7774 | |
7775 decode_coding (coding); | |
7776 | |
7777 if (BUFFERP (coding->dst_object)) | |
7778 set_buffer_internal (XBUFFER (coding->dst_object)); | |
7779 | |
7780 if (! NILP (CODING_ATTR_POST_READ (attrs))) | |
7781 { | |
91838
7bed61cbed0c
(decode_coding_object, encode_coding_object): Preserve
Kenichi Handa <handa@m17n.org>
parents:
91807
diff
changeset
|
7782 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5; |
88365 | 7783 EMACS_INT prev_Z = Z, prev_Z_BYTE = Z_BYTE; |
7784 Lisp_Object val; | |
7785 | |
88506
a7f0d13affa5
(decode_coding_object): Move point to coding->dst_pos before
Kenichi Handa <handa@m17n.org>
parents:
88497
diff
changeset
|
7786 TEMP_SET_PT_BOTH (coding->dst_pos, coding->dst_pos_byte); |
91838
7bed61cbed0c
(decode_coding_object, encode_coding_object): Preserve
Kenichi Handa <handa@m17n.org>
parents:
91807
diff
changeset
|
7787 GCPRO5 (coding->src_object, coding->dst_object, src_object, dst_object, |
7bed61cbed0c
(decode_coding_object, encode_coding_object): Preserve
Kenichi Handa <handa@m17n.org>
parents:
91807
diff
changeset
|
7788 old_deactivate_mark); |
90131
503a3c779486
(decode_coding_object): Use safe_call1 instead of call1.
Kenichi Handa <handa@m17n.org>
parents:
90127
diff
changeset
|
7789 val = safe_call1 (CODING_ATTR_POST_READ (attrs), |
503a3c779486
(decode_coding_object): Use safe_call1 instead of call1.
Kenichi Handa <handa@m17n.org>
parents:
90127
diff
changeset
|
7790 make_number (coding->produced_char)); |
88365 | 7791 UNGCPRO; |
7792 CHECK_NATNUM (val); | |
7793 coding->produced_char += Z - prev_Z; | |
7794 coding->produced += Z_BYTE - prev_Z_BYTE; | |
7795 } | |
7796 | |
7797 if (EQ (dst_object, Qt)) | |
7798 { | |
7799 coding->dst_object = Fbuffer_string (); | |
7800 } | |
7801 else if (NILP (dst_object) && BUFFERP (coding->dst_object)) | |
7802 { | |
7803 set_buffer_internal (XBUFFER (coding->dst_object)); | |
7804 if (dst_bytes < coding->produced) | |
42105
09cc243e2d14
(code_convert_region): Update coding->cmp_data->char_offset
Richard M. Stallman <rms@gnu.org>
parents:
42104
diff
changeset
|
7805 { |
91838
7bed61cbed0c
(decode_coding_object, encode_coding_object): Preserve
Kenichi Handa <handa@m17n.org>
parents:
91807
diff
changeset
|
7806 destination = xrealloc (destination, coding->produced); |
88365 | 7807 if (! destination) |
26847 | 7808 { |
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
7809 record_conversion_result (coding, |
107174
e98bd64897e0
Fix handling of CODING_RESULT_INSUFFICIENT_DST.
Kenichi Handa <handa@m17n.org>
parents:
107171
diff
changeset
|
7810 CODING_RESULT_INSUFFICIENT_MEM); |
88365 | 7811 unbind_to (count, Qnil); |
7812 return; | |
26847 | 7813 } |
88365 | 7814 if (BEGV < GPT && GPT < BEGV + coding->produced_char) |
7815 move_gap_both (BEGV, BEGV_BYTE); | |
109165
750db9f3e6d8
Replace bcopy, bzero, bcmp by memcpy, memmove, memset, memcmp
Andreas Schwab <schwab@linux-m68k.org>
parents:
109159
diff
changeset
|
7816 memcpy (destination, BEGV_ADDR, coding->produced); |
88365 | 7817 coding->destination = destination; |
23279
ca159e828a68
(ccl_coding_driver): If ccl_driver is interrupted by a
Kenichi Handa <handa@m17n.org>
parents:
23258
diff
changeset
|
7818 } |
88365 | 7819 } |
7820 | |
89442
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
7821 if (saved_pt >= 0) |
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
7822 { |
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
7823 /* This is the case of: |
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
7824 (BUFFERP (src_object) && EQ (src_object, dst_object)) |
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
7825 As we have moved PT while replacing the original buffer |
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
7826 contents, we must recover it now. */ |
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
7827 set_buffer_internal (XBUFFER (src_object)); |
92458
5f5f07a5c076
(decode_coding_object): Inhibit gap shrinking while
Andreas Schwab <schwab@suse.de>
parents:
92406
diff
changeset
|
7828 current_buffer->text->inhibit_shrinking = 0; |
89442
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
7829 if (saved_pt < from) |
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
7830 TEMP_SET_PT_BOTH (saved_pt, saved_pt_byte); |
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
7831 else if (saved_pt < from + chars) |
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
7832 TEMP_SET_PT_BOTH (from, from_byte); |
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
7833 else if (! NILP (current_buffer->enable_multibyte_characters)) |
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
7834 TEMP_SET_PT_BOTH (saved_pt + (coding->produced_char - chars), |
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
7835 saved_pt_byte + (coding->produced - bytes)); |
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
7836 else |
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
7837 TEMP_SET_PT_BOTH (saved_pt + (coding->produced - bytes), |
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
7838 saved_pt_byte + (coding->produced - bytes)); |
91344
56f3473b139e
(decode_coding_object): Adjuste marker positions after
Kenichi Handa <handa@m17n.org>
parents:
91327
diff
changeset
|
7839 |
56f3473b139e
(decode_coding_object): Adjuste marker positions after
Kenichi Handa <handa@m17n.org>
parents:
91327
diff
changeset
|
7840 if (need_marker_adjustment) |
56f3473b139e
(decode_coding_object): Adjuste marker positions after
Kenichi Handa <handa@m17n.org>
parents:
91327
diff
changeset
|
7841 { |
56f3473b139e
(decode_coding_object): Adjuste marker positions after
Kenichi Handa <handa@m17n.org>
parents:
91327
diff
changeset
|
7842 struct Lisp_Marker *tail; |
56f3473b139e
(decode_coding_object): Adjuste marker positions after
Kenichi Handa <handa@m17n.org>
parents:
91327
diff
changeset
|
7843 |
56f3473b139e
(decode_coding_object): Adjuste marker positions after
Kenichi Handa <handa@m17n.org>
parents:
91327
diff
changeset
|
7844 for (tail = BUF_MARKERS (current_buffer); tail; tail = tail->next) |
56f3473b139e
(decode_coding_object): Adjuste marker positions after
Kenichi Handa <handa@m17n.org>
parents:
91327
diff
changeset
|
7845 if (tail->need_adjustment) |
56f3473b139e
(decode_coding_object): Adjuste marker positions after
Kenichi Handa <handa@m17n.org>
parents:
91327
diff
changeset
|
7846 { |
56f3473b139e
(decode_coding_object): Adjuste marker positions after
Kenichi Handa <handa@m17n.org>
parents:
91327
diff
changeset
|
7847 tail->need_adjustment = 0; |
56f3473b139e
(decode_coding_object): Adjuste marker positions after
Kenichi Handa <handa@m17n.org>
parents:
91327
diff
changeset
|
7848 if (tail->insertion_type) |
26847 | 7849 { |
91344
56f3473b139e
(decode_coding_object): Adjuste marker positions after
Kenichi Handa <handa@m17n.org>
parents:
91327
diff
changeset
|
7850 tail->bytepos = from_byte; |
56f3473b139e
(decode_coding_object): Adjuste marker positions after
Kenichi Handa <handa@m17n.org>
parents:
91327
diff
changeset
|
7851 tail->charpos = from; |
26847 | 7852 } |
91344
56f3473b139e
(decode_coding_object): Adjuste marker positions after
Kenichi Handa <handa@m17n.org>
parents:
91327
diff
changeset
|
7853 else |
56f3473b139e
(decode_coding_object): Adjuste marker positions after
Kenichi Handa <handa@m17n.org>
parents:
91327
diff
changeset
|
7854 { |
56f3473b139e
(decode_coding_object): Adjuste marker positions after
Kenichi Handa <handa@m17n.org>
parents:
91327
diff
changeset
|
7855 tail->bytepos = from_byte + coding->produced; |
56f3473b139e
(decode_coding_object): Adjuste marker positions after
Kenichi Handa <handa@m17n.org>
parents:
91327
diff
changeset
|
7856 tail->charpos |
56f3473b139e
(decode_coding_object): Adjuste marker positions after
Kenichi Handa <handa@m17n.org>
parents:
91327
diff
changeset
|
7857 = (NILP (current_buffer->enable_multibyte_characters) |
56f3473b139e
(decode_coding_object): Adjuste marker positions after
Kenichi Handa <handa@m17n.org>
parents:
91327
diff
changeset
|
7858 ? tail->bytepos : from + coding->produced_char); |
56f3473b139e
(decode_coding_object): Adjuste marker positions after
Kenichi Handa <handa@m17n.org>
parents:
91327
diff
changeset
|
7859 } |
56f3473b139e
(decode_coding_object): Adjuste marker positions after
Kenichi Handa <handa@m17n.org>
parents:
91327
diff
changeset
|
7860 } |
56f3473b139e
(decode_coding_object): Adjuste marker positions after
Kenichi Handa <handa@m17n.org>
parents:
91327
diff
changeset
|
7861 } |
89442
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
7862 } |
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
7863 |
91838
7bed61cbed0c
(decode_coding_object, encode_coding_object): Preserve
Kenichi Handa <handa@m17n.org>
parents:
91807
diff
changeset
|
7864 Vdeactivate_mark = old_deactivate_mark; |
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
7865 unbind_to (count, coding->dst_object); |
88365 | 7866 } |
7867 | |
26847 | 7868 |
29275
b4ea9178e480
(DECODE_COMPOSITION_START): If coding->cmp_data is not
Kenichi Handa <handa@m17n.org>
parents:
29247
diff
changeset
|
7869 void |
109159
3e9fdeb960d1
* coding.c, sysdep.c: Convert some more functions to standard C.
Juanma Barranquero <lekktu@gmail.com>
parents:
109158
diff
changeset
|
7870 encode_coding_object (struct coding_system *coding, |
3e9fdeb960d1
* coding.c, sysdep.c: Convert some more functions to standard C.
Juanma Barranquero <lekktu@gmail.com>
parents:
109158
diff
changeset
|
7871 Lisp_Object src_object, |
3e9fdeb960d1
* coding.c, sysdep.c: Convert some more functions to standard C.
Juanma Barranquero <lekktu@gmail.com>
parents:
109158
diff
changeset
|
7872 EMACS_INT from, EMACS_INT from_byte, |
3e9fdeb960d1
* coding.c, sysdep.c: Convert some more functions to standard C.
Juanma Barranquero <lekktu@gmail.com>
parents:
109158
diff
changeset
|
7873 EMACS_INT to, EMACS_INT to_byte, |
3e9fdeb960d1
* coding.c, sysdep.c: Convert some more functions to standard C.
Juanma Barranquero <lekktu@gmail.com>
parents:
109158
diff
changeset
|
7874 Lisp_Object dst_object) |
88365 | 7875 { |
109158
6175ebc3b6ce
* coding.c: Use SPECPDL_INDEX, DOS_NT.
Juanma Barranquero <lekktu@gmail.com>
parents:
109126
diff
changeset
|
7876 int count = SPECPDL_INDEX (); |
88365 | 7877 EMACS_INT chars = to - from; |
7878 EMACS_INT bytes = to_byte - from_byte; | |
7879 Lisp_Object attrs; | |
89442
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
7880 int saved_pt = -1, saved_pt_byte; |
91344
56f3473b139e
(decode_coding_object): Adjuste marker positions after
Kenichi Handa <handa@m17n.org>
parents:
91327
diff
changeset
|
7881 int need_marker_adjustment = 0; |
90231
8be9e4c6d687
(encode_coding_object): If a pre-write-conversion
Kenichi Handa <handa@m17n.org>
parents:
90224
diff
changeset
|
7882 int kill_src_buffer = 0; |
91838
7bed61cbed0c
(decode_coding_object, encode_coding_object): Preserve
Kenichi Handa <handa@m17n.org>
parents:
91807
diff
changeset
|
7883 Lisp_Object old_deactivate_mark; |
7bed61cbed0c
(decode_coding_object, encode_coding_object): Preserve
Kenichi Handa <handa@m17n.org>
parents:
91807
diff
changeset
|
7884 |
7bed61cbed0c
(decode_coding_object, encode_coding_object): Preserve
Kenichi Handa <handa@m17n.org>
parents:
91807
diff
changeset
|
7885 old_deactivate_mark = Vdeactivate_mark; |
88365 | 7886 |
7887 coding->src_object = src_object; | |
7888 coding->src_chars = chars; | |
7889 coding->src_bytes = bytes; | |
7890 coding->src_multibyte = chars < bytes; | |
7891 | |
7892 attrs = CODING_ID_ATTRS (coding->id); | |
7893 | |
91344
56f3473b139e
(decode_coding_object): Adjuste marker positions after
Kenichi Handa <handa@m17n.org>
parents:
91327
diff
changeset
|
7894 if (EQ (src_object, dst_object)) |
56f3473b139e
(decode_coding_object): Adjuste marker positions after
Kenichi Handa <handa@m17n.org>
parents:
91327
diff
changeset
|
7895 { |
56f3473b139e
(decode_coding_object): Adjuste marker positions after
Kenichi Handa <handa@m17n.org>
parents:
91327
diff
changeset
|
7896 struct Lisp_Marker *tail; |
56f3473b139e
(decode_coding_object): Adjuste marker positions after
Kenichi Handa <handa@m17n.org>
parents:
91327
diff
changeset
|
7897 |
56f3473b139e
(decode_coding_object): Adjuste marker positions after
Kenichi Handa <handa@m17n.org>
parents:
91327
diff
changeset
|
7898 for (tail = BUF_MARKERS (current_buffer); tail; tail = tail->next) |
56f3473b139e
(decode_coding_object): Adjuste marker positions after
Kenichi Handa <handa@m17n.org>
parents:
91327
diff
changeset
|
7899 { |
56f3473b139e
(decode_coding_object): Adjuste marker positions after
Kenichi Handa <handa@m17n.org>
parents:
91327
diff
changeset
|
7900 tail->need_adjustment |
56f3473b139e
(decode_coding_object): Adjuste marker positions after
Kenichi Handa <handa@m17n.org>
parents:
91327
diff
changeset
|
7901 = tail->charpos == (tail->insertion_type ? from : to); |
56f3473b139e
(decode_coding_object): Adjuste marker positions after
Kenichi Handa <handa@m17n.org>
parents:
91327
diff
changeset
|
7902 need_marker_adjustment |= tail->need_adjustment; |
56f3473b139e
(decode_coding_object): Adjuste marker positions after
Kenichi Handa <handa@m17n.org>
parents:
91327
diff
changeset
|
7903 } |
56f3473b139e
(decode_coding_object): Adjuste marker positions after
Kenichi Handa <handa@m17n.org>
parents:
91327
diff
changeset
|
7904 } |
56f3473b139e
(decode_coding_object): Adjuste marker positions after
Kenichi Handa <handa@m17n.org>
parents:
91327
diff
changeset
|
7905 |
88365 | 7906 if (! NILP (CODING_ATTR_PRE_WRITE (attrs))) |
21062
839b22ad1e42
(code_convert_region): Handle the case that codes
Kenichi Handa <handa@m17n.org>
parents:
20999
diff
changeset
|
7907 { |
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
7908 coding->src_object = code_conversion_save (1, coding->src_multibyte); |
88365 | 7909 set_buffer_internal (XBUFFER (coding->src_object)); |
7910 if (STRINGP (src_object)) | |
7911 insert_from_string (src_object, from, from_byte, chars, bytes, 0); | |
7912 else if (BUFFERP (src_object)) | |
7913 insert_from_buffer (XBUFFER (src_object), from, chars, 0); | |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
7914 else |
88365 | 7915 insert_1_both (coding->source + from, chars, bytes, 0, 0, 0); |
7916 | |
7917 if (EQ (src_object, dst_object)) | |
7918 { | |
7919 set_buffer_internal (XBUFFER (src_object)); | |
89442
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
7920 saved_pt = PT, saved_pt_byte = PT_BYTE; |
88365 | 7921 del_range_both (from, from_byte, to, to_byte, 1); |
7922 set_buffer_internal (XBUFFER (coding->src_object)); | |
7923 } | |
7924 | |
90131
503a3c779486
(decode_coding_object): Use safe_call1 instead of call1.
Kenichi Handa <handa@m17n.org>
parents:
90127
diff
changeset
|
7925 { |
503a3c779486
(decode_coding_object): Use safe_call1 instead of call1.
Kenichi Handa <handa@m17n.org>
parents:
90127
diff
changeset
|
7926 Lisp_Object args[3]; |
91838
7bed61cbed0c
(decode_coding_object, encode_coding_object): Preserve
Kenichi Handa <handa@m17n.org>
parents:
91807
diff
changeset
|
7927 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5; |
7bed61cbed0c
(decode_coding_object, encode_coding_object): Preserve
Kenichi Handa <handa@m17n.org>
parents:
91807
diff
changeset
|
7928 |
7bed61cbed0c
(decode_coding_object, encode_coding_object): Preserve
Kenichi Handa <handa@m17n.org>
parents:
91807
diff
changeset
|
7929 GCPRO5 (coding->src_object, coding->dst_object, src_object, dst_object, |
7bed61cbed0c
(decode_coding_object, encode_coding_object): Preserve
Kenichi Handa <handa@m17n.org>
parents:
91807
diff
changeset
|
7930 old_deactivate_mark); |
90131
503a3c779486
(decode_coding_object): Use safe_call1 instead of call1.
Kenichi Handa <handa@m17n.org>
parents:
90127
diff
changeset
|
7931 args[0] = CODING_ATTR_PRE_WRITE (attrs); |
503a3c779486
(decode_coding_object): Use safe_call1 instead of call1.
Kenichi Handa <handa@m17n.org>
parents:
90127
diff
changeset
|
7932 args[1] = make_number (BEG); |
503a3c779486
(decode_coding_object): Use safe_call1 instead of call1.
Kenichi Handa <handa@m17n.org>
parents:
90127
diff
changeset
|
7933 args[2] = make_number (Z); |
503a3c779486
(decode_coding_object): Use safe_call1 instead of call1.
Kenichi Handa <handa@m17n.org>
parents:
90127
diff
changeset
|
7934 safe_call (3, args); |
91838
7bed61cbed0c
(decode_coding_object, encode_coding_object): Preserve
Kenichi Handa <handa@m17n.org>
parents:
91807
diff
changeset
|
7935 UNGCPRO; |
90131
503a3c779486
(decode_coding_object): Use safe_call1 instead of call1.
Kenichi Handa <handa@m17n.org>
parents:
90127
diff
changeset
|
7936 } |
90231
8be9e4c6d687
(encode_coding_object): If a pre-write-conversion
Kenichi Handa <handa@m17n.org>
parents:
90224
diff
changeset
|
7937 if (XBUFFER (coding->src_object) != current_buffer) |
8be9e4c6d687
(encode_coding_object): If a pre-write-conversion
Kenichi Handa <handa@m17n.org>
parents:
90224
diff
changeset
|
7938 kill_src_buffer = 1; |
88510
d266b8fb8761
(encode_coding_object): Give correct arguments ot
Kenichi Handa <handa@m17n.org>
parents:
88506
diff
changeset
|
7939 coding->src_object = Fcurrent_buffer (); |
88365 | 7940 if (BEG != GPT) |
7941 move_gap_both (BEG, BEG_BYTE); | |
7942 coding->src_chars = Z - BEG; | |
7943 coding->src_bytes = Z_BYTE - BEG_BYTE; | |
7944 coding->src_pos = BEG; | |
7945 coding->src_pos_byte = BEG_BYTE; | |
7946 coding->src_multibyte = Z < Z_BYTE; | |
7947 } | |
7948 else if (STRINGP (src_object)) | |
7949 { | |
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
7950 code_conversion_save (0, 0); |
88365 | 7951 coding->src_pos = from; |
7952 coding->src_pos_byte = from_byte; | |
7953 } | |
7954 else if (BUFFERP (src_object)) | |
7955 { | |
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
7956 code_conversion_save (0, 0); |
88365 | 7957 set_buffer_internal (XBUFFER (src_object)); |
7958 if (EQ (src_object, dst_object)) | |
7959 { | |
89442
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
7960 saved_pt = PT, saved_pt_byte = PT_BYTE; |
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7961 coding->src_object = del_range_1 (from, to, 1, 1); |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7962 coding->src_pos = 0; |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7963 coding->src_pos_byte = 0; |
88365 | 7964 } |
23514
7bad909cd6f1
(setup_coding_system): Fix setting up
Kenichi Handa <handa@m17n.org>
parents:
23475
diff
changeset
|
7965 else |
42105
09cc243e2d14
(code_convert_region): Update coding->cmp_data->char_offset
Richard M. Stallman <rms@gnu.org>
parents:
42104
diff
changeset
|
7966 { |
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7967 if (from < GPT && to >= GPT) |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7968 move_gap_both (from, from_byte); |
88365 | 7969 coding->src_pos = from; |
7970 coding->src_pos_byte = from_byte; | |
7971 } | |
64308
93129de4b8a4
(code_convert_region_unwind): ARG is changed to a cons.
Kenichi Handa <handa@m17n.org>
parents:
64251
diff
changeset
|
7972 } |
93129de4b8a4
(code_convert_region_unwind): ARG is changed to a cons.
Kenichi Handa <handa@m17n.org>
parents:
64251
diff
changeset
|
7973 else |
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
7974 code_conversion_save (0, 0); |
88365 | 7975 |
7976 if (BUFFERP (dst_object)) | |
7977 { | |
7978 coding->dst_object = dst_object; | |
89042
2b9f8973f240
(coding_set_destination): Fix coding->destination for
Kenichi Handa <handa@m17n.org>
parents:
88977
diff
changeset
|
7979 if (EQ (src_object, dst_object)) |
2b9f8973f240
(coding_set_destination): Fix coding->destination for
Kenichi Handa <handa@m17n.org>
parents:
88977
diff
changeset
|
7980 { |
2b9f8973f240
(coding_set_destination): Fix coding->destination for
Kenichi Handa <handa@m17n.org>
parents:
88977
diff
changeset
|
7981 coding->dst_pos = from; |
2b9f8973f240
(coding_set_destination): Fix coding->destination for
Kenichi Handa <handa@m17n.org>
parents:
88977
diff
changeset
|
7982 coding->dst_pos_byte = from_byte; |
2b9f8973f240
(coding_set_destination): Fix coding->destination for
Kenichi Handa <handa@m17n.org>
parents:
88977
diff
changeset
|
7983 } |
2b9f8973f240
(coding_set_destination): Fix coding->destination for
Kenichi Handa <handa@m17n.org>
parents:
88977
diff
changeset
|
7984 else |
2b9f8973f240
(coding_set_destination): Fix coding->destination for
Kenichi Handa <handa@m17n.org>
parents:
88977
diff
changeset
|
7985 { |
95353
96d35f50fe34
(encode_coding_raw_text): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
95345
diff
changeset
|
7986 struct buffer *current = current_buffer; |
96d35f50fe34
(encode_coding_raw_text): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
95345
diff
changeset
|
7987 |
96d35f50fe34
(encode_coding_raw_text): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
95345
diff
changeset
|
7988 set_buffer_temp (XBUFFER (dst_object)); |
96d35f50fe34
(encode_coding_raw_text): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
95345
diff
changeset
|
7989 coding->dst_pos = PT; |
96d35f50fe34
(encode_coding_raw_text): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
95345
diff
changeset
|
7990 coding->dst_pos_byte = PT_BYTE; |
96d35f50fe34
(encode_coding_raw_text): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
95345
diff
changeset
|
7991 move_gap_both (coding->dst_pos, coding->dst_pos_byte); |
96d35f50fe34
(encode_coding_raw_text): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
95345
diff
changeset
|
7992 set_buffer_temp (current); |
89042
2b9f8973f240
(coding_set_destination): Fix coding->destination for
Kenichi Handa <handa@m17n.org>
parents:
88977
diff
changeset
|
7993 } |
88365 | 7994 coding->dst_multibyte |
7995 = ! NILP (XBUFFER (dst_object)->enable_multibyte_characters); | |
7996 } | |
7997 else if (EQ (dst_object, Qt)) | |
7998 { | |
7999 coding->dst_object = Qnil; | |
8000 coding->dst_bytes = coding->src_chars; | |
88510
d266b8fb8761
(encode_coding_object): Give correct arguments ot
Kenichi Handa <handa@m17n.org>
parents:
88506
diff
changeset
|
8001 if (coding->dst_bytes == 0) |
d266b8fb8761
(encode_coding_object): Give correct arguments ot
Kenichi Handa <handa@m17n.org>
parents:
88506
diff
changeset
|
8002 coding->dst_bytes = 1; |
d266b8fb8761
(encode_coding_object): Give correct arguments ot
Kenichi Handa <handa@m17n.org>
parents:
88506
diff
changeset
|
8003 coding->destination = (unsigned char *) xmalloc (coding->dst_bytes); |
88365 | 8004 coding->dst_multibyte = 0; |
65506
f376635f5061
(code_convert_region_unwind): Argument format changed.
Kenichi Handa <handa@m17n.org>
parents:
64770
diff
changeset
|
8005 } |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
8006 else |
29172
46ad5a027334
(run_pre_post_conversion_on_str): Set point to the
Kenichi Handa <handa@m17n.org>
parents:
29093
diff
changeset
|
8007 { |
88365 | 8008 coding->dst_object = Qnil; |
8009 coding->dst_multibyte = 0; | |
8010 } | |
8011 | |
8012 encode_coding (coding); | |
8013 | |
8014 if (EQ (dst_object, Qt)) | |
8015 { | |
8016 if (BUFFERP (coding->dst_object)) | |
8017 coding->dst_object = Fbuffer_string (); | |
23514
7bad909cd6f1
(setup_coding_system): Fix setting up
Kenichi Handa <handa@m17n.org>
parents:
23475
diff
changeset
|
8018 else |
88365 | 8019 { |
8020 coding->dst_object | |
8021 = make_unibyte_string ((char *) coding->destination, | |
8022 coding->produced); | |
8023 xfree (coding->destination); | |
8024 } | |
8025 } | |
8026 | |
89442
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
8027 if (saved_pt >= 0) |
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
8028 { |
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
8029 /* This is the case of: |
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
8030 (BUFFERP (src_object) && EQ (src_object, dst_object)) |
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
8031 As we have moved PT while replacing the original buffer |
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
8032 contents, we must recover it now. */ |
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
8033 set_buffer_internal (XBUFFER (src_object)); |
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
8034 if (saved_pt < from) |
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
8035 TEMP_SET_PT_BOTH (saved_pt, saved_pt_byte); |
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
8036 else if (saved_pt < from + chars) |
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
8037 TEMP_SET_PT_BOTH (from, from_byte); |
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
8038 else if (! NILP (current_buffer->enable_multibyte_characters)) |
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
8039 TEMP_SET_PT_BOTH (saved_pt + (coding->produced_char - chars), |
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
8040 saved_pt_byte + (coding->produced - bytes)); |
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
8041 else |
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
8042 TEMP_SET_PT_BOTH (saved_pt + (coding->produced - bytes), |
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
8043 saved_pt_byte + (coding->produced - bytes)); |
91344
56f3473b139e
(decode_coding_object): Adjuste marker positions after
Kenichi Handa <handa@m17n.org>
parents:
91327
diff
changeset
|
8044 |
56f3473b139e
(decode_coding_object): Adjuste marker positions after
Kenichi Handa <handa@m17n.org>
parents:
91327
diff
changeset
|
8045 if (need_marker_adjustment) |
56f3473b139e
(decode_coding_object): Adjuste marker positions after
Kenichi Handa <handa@m17n.org>
parents:
91327
diff
changeset
|
8046 { |
56f3473b139e
(decode_coding_object): Adjuste marker positions after
Kenichi Handa <handa@m17n.org>
parents:
91327
diff
changeset
|
8047 struct Lisp_Marker *tail; |
56f3473b139e
(decode_coding_object): Adjuste marker positions after
Kenichi Handa <handa@m17n.org>
parents:
91327
diff
changeset
|
8048 |
56f3473b139e
(decode_coding_object): Adjuste marker positions after
Kenichi Handa <handa@m17n.org>
parents:
91327
diff
changeset
|
8049 for (tail = BUF_MARKERS (current_buffer); tail; tail = tail->next) |
56f3473b139e
(decode_coding_object): Adjuste marker positions after
Kenichi Handa <handa@m17n.org>
parents:
91327
diff
changeset
|
8050 if (tail->need_adjustment) |
56f3473b139e
(decode_coding_object): Adjuste marker positions after
Kenichi Handa <handa@m17n.org>
parents:
91327
diff
changeset
|
8051 { |
56f3473b139e
(decode_coding_object): Adjuste marker positions after
Kenichi Handa <handa@m17n.org>
parents:
91327
diff
changeset
|
8052 tail->need_adjustment = 0; |
56f3473b139e
(decode_coding_object): Adjuste marker positions after
Kenichi Handa <handa@m17n.org>
parents:
91327
diff
changeset
|
8053 if (tail->insertion_type) |
56f3473b139e
(decode_coding_object): Adjuste marker positions after
Kenichi Handa <handa@m17n.org>
parents:
91327
diff
changeset
|
8054 { |
56f3473b139e
(decode_coding_object): Adjuste marker positions after
Kenichi Handa <handa@m17n.org>
parents:
91327
diff
changeset
|
8055 tail->bytepos = from_byte; |
56f3473b139e
(decode_coding_object): Adjuste marker positions after
Kenichi Handa <handa@m17n.org>
parents:
91327
diff
changeset
|
8056 tail->charpos = from; |
56f3473b139e
(decode_coding_object): Adjuste marker positions after
Kenichi Handa <handa@m17n.org>
parents:
91327
diff
changeset
|
8057 } |
56f3473b139e
(decode_coding_object): Adjuste marker positions after
Kenichi Handa <handa@m17n.org>
parents:
91327
diff
changeset
|
8058 else |
56f3473b139e
(decode_coding_object): Adjuste marker positions after
Kenichi Handa <handa@m17n.org>
parents:
91327
diff
changeset
|
8059 { |
56f3473b139e
(decode_coding_object): Adjuste marker positions after
Kenichi Handa <handa@m17n.org>
parents:
91327
diff
changeset
|
8060 tail->bytepos = from_byte + coding->produced; |
56f3473b139e
(decode_coding_object): Adjuste marker positions after
Kenichi Handa <handa@m17n.org>
parents:
91327
diff
changeset
|
8061 tail->charpos |
56f3473b139e
(decode_coding_object): Adjuste marker positions after
Kenichi Handa <handa@m17n.org>
parents:
91327
diff
changeset
|
8062 = (NILP (current_buffer->enable_multibyte_characters) |
56f3473b139e
(decode_coding_object): Adjuste marker positions after
Kenichi Handa <handa@m17n.org>
parents:
91327
diff
changeset
|
8063 ? tail->bytepos : from + coding->produced_char); |
56f3473b139e
(decode_coding_object): Adjuste marker positions after
Kenichi Handa <handa@m17n.org>
parents:
91327
diff
changeset
|
8064 } |
56f3473b139e
(decode_coding_object): Adjuste marker positions after
Kenichi Handa <handa@m17n.org>
parents:
91327
diff
changeset
|
8065 } |
56f3473b139e
(decode_coding_object): Adjuste marker positions after
Kenichi Handa <handa@m17n.org>
parents:
91327
diff
changeset
|
8066 } |
89442
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
8067 } |
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
8068 |
90231
8be9e4c6d687
(encode_coding_object): If a pre-write-conversion
Kenichi Handa <handa@m17n.org>
parents:
90224
diff
changeset
|
8069 if (kill_src_buffer) |
8be9e4c6d687
(encode_coding_object): If a pre-write-conversion
Kenichi Handa <handa@m17n.org>
parents:
90224
diff
changeset
|
8070 Fkill_buffer (coding->src_object); |
91838
7bed61cbed0c
(decode_coding_object, encode_coding_object): Preserve
Kenichi Handa <handa@m17n.org>
parents:
91807
diff
changeset
|
8071 |
7bed61cbed0c
(decode_coding_object, encode_coding_object): Preserve
Kenichi Handa <handa@m17n.org>
parents:
91807
diff
changeset
|
8072 Vdeactivate_mark = old_deactivate_mark; |
88365 | 8073 unbind_to (count, Qnil); |
58637
ff8a37b5299b
(Vcode_conversion_workbuf_name): New variable.
Kenichi Handa <handa@m17n.org>
parents:
58502
diff
changeset
|
8074 } |
ff8a37b5299b
(Vcode_conversion_workbuf_name): New variable.
Kenichi Handa <handa@m17n.org>
parents:
58502
diff
changeset
|
8075 |
ff8a37b5299b
(Vcode_conversion_workbuf_name): New variable.
Kenichi Handa <handa@m17n.org>
parents:
58502
diff
changeset
|
8076 |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
8077 Lisp_Object |
109126
aec1143e8d85
Convert (most) functions in src to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109100
diff
changeset
|
8078 preferred_coding_system (void) |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
8079 { |
88365 | 8080 int id = coding_categories[coding_priorities[0]].id; |
8081 | |
8082 return CODING_ID_NAME (id); | |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
8083 } |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
8084 |
17052 | 8085 |
8086 #ifdef emacs | |
22874
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
8087 /*** 8. Emacs Lisp library functions ***/ |
17052 | 8088 |
8089 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
|
8090 doc: /* Return t if OBJECT is nil or a coding-system. |
88365 | 8091 See the documentation of `define-coding-system' for information |
40713
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
8092 about coding-system objects. */) |
109179
8cfee7d2955f
Convert DEFUNs to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109165
diff
changeset
|
8093 (Lisp_Object object) |
95088
524350e4961c
(Fcoding_system_p): Rename argument to match docstring.
Juanma Barranquero <lekktu@gmail.com>
parents:
94963
diff
changeset
|
8094 { |
524350e4961c
(Fcoding_system_p): Rename argument to match docstring.
Juanma Barranquero <lekktu@gmail.com>
parents:
94963
diff
changeset
|
8095 if (NILP (object) |
524350e4961c
(Fcoding_system_p): Rename argument to match docstring.
Juanma Barranquero <lekktu@gmail.com>
parents:
94963
diff
changeset
|
8096 || CODING_SYSTEM_ID (object) >= 0) |
20105
c017642863c2
(Qcoding_system_spec): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
19824
diff
changeset
|
8097 return Qt; |
95088
524350e4961c
(Fcoding_system_p): Rename argument to match docstring.
Juanma Barranquero <lekktu@gmail.com>
parents:
94963
diff
changeset
|
8098 if (! SYMBOLP (object) |
524350e4961c
(Fcoding_system_p): Rename argument to match docstring.
Juanma Barranquero <lekktu@gmail.com>
parents:
94963
diff
changeset
|
8099 || NILP (Fget (object, Qcoding_system_define_form))) |
20105
c017642863c2
(Qcoding_system_spec): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
19824
diff
changeset
|
8100 return Qnil; |
90272
f1df126ec7de
Sync to HEAD for handling autoload-coding-system.
Kenichi Handa <handa@m17n.org>
parents:
90263
diff
changeset
|
8101 return Qt; |
17052 | 8102 } |
8103 | |
17717
4891aaecc5cc
(Fread_coding_system, Fread_non_nil_coding_system):
Richard M. Stallman <rms@gnu.org>
parents:
17485
diff
changeset
|
8104 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
|
8105 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
|
8106 doc: /* Read a coding system from the minibuffer, prompting with string PROMPT. */) |
109179
8cfee7d2955f
Convert DEFUNs to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109165
diff
changeset
|
8107 (Lisp_Object prompt) |
17052 | 8108 { |
17119
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
8109 Lisp_Object val; |
17717
4891aaecc5cc
(Fread_coding_system, Fread_non_nil_coding_system):
Richard M. Stallman <rms@gnu.org>
parents:
17485
diff
changeset
|
8110 do |
4891aaecc5cc
(Fread_coding_system, Fread_non_nil_coding_system):
Richard M. Stallman <rms@gnu.org>
parents:
17485
diff
changeset
|
8111 { |
20105
c017642863c2
(Qcoding_system_spec): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
19824
diff
changeset
|
8112 val = Fcompleting_read (prompt, Vcoding_system_alist, Qnil, |
c017642863c2
(Qcoding_system_spec): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
19824
diff
changeset
|
8113 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
|
8114 } |
46370
40db0673e6f0
Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents:
46293
diff
changeset
|
8115 while (SCHARS (val) == 0); |
17119
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
8116 return (Fintern (val, Qnil)); |
17052 | 8117 } |
8118 | |
19758
49a1662b68dd
(Fread_coding_system): New optional arg DEFAULT_CODING_SYSTEM.
Richard M. Stallman <rms@gnu.org>
parents:
19750
diff
changeset
|
8119 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
|
8120 doc: /* Read a coding system from the minibuffer, prompting with string PROMPT. |
79107
cce707ee192e
(Qcompletion_ignore_case): New external Lisp_Object.
Glenn Morris <rgm@gnu.org>
parents:
78313
diff
changeset
|
8121 If the user enters null input, return second argument DEFAULT-CODING-SYSTEM. |
cce707ee192e
(Qcompletion_ignore_case): New external Lisp_Object.
Glenn Morris <rgm@gnu.org>
parents:
78313
diff
changeset
|
8122 Ignores case when completing coding systems (all Emacs coding systems |
cce707ee192e
(Qcompletion_ignore_case): New external Lisp_Object.
Glenn Morris <rgm@gnu.org>
parents:
78313
diff
changeset
|
8123 are lower-case). */) |
109179
8cfee7d2955f
Convert DEFUNs to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109165
diff
changeset
|
8124 (Lisp_Object prompt, Lisp_Object default_coding_system) |
17052 | 8125 { |
19747
bed06df9cbc5
(setup_coding_system, Ffind_operation_coding_system)
Richard M. Stallman <rms@gnu.org>
parents:
19743
diff
changeset
|
8126 Lisp_Object val; |
79107
cce707ee192e
(Qcompletion_ignore_case): New external Lisp_Object.
Glenn Morris <rgm@gnu.org>
parents:
78313
diff
changeset
|
8127 int count = SPECPDL_INDEX (); |
cce707ee192e
(Qcompletion_ignore_case): New external Lisp_Object.
Glenn Morris <rgm@gnu.org>
parents:
78313
diff
changeset
|
8128 |
19758
49a1662b68dd
(Fread_coding_system): New optional arg DEFAULT_CODING_SYSTEM.
Richard M. Stallman <rms@gnu.org>
parents:
19750
diff
changeset
|
8129 if (SYMBOLP (default_coding_system)) |
45396
cab845213388
* coding.c (Fread_coding_system, code_convert_region1)
Ken Raeburn <raeburn@raeburn.org>
parents:
45239
diff
changeset
|
8130 default_coding_system = SYMBOL_NAME (default_coding_system); |
79107
cce707ee192e
(Qcompletion_ignore_case): New external Lisp_Object.
Glenn Morris <rgm@gnu.org>
parents:
78313
diff
changeset
|
8131 specbind (Qcompletion_ignore_case, Qt); |
20105
c017642863c2
(Qcoding_system_spec): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
19824
diff
changeset
|
8132 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
|
8133 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
|
8134 default_coding_system, Qnil); |
79107
cce707ee192e
(Qcompletion_ignore_case): New external Lisp_Object.
Glenn Morris <rgm@gnu.org>
parents:
78313
diff
changeset
|
8135 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
|
8136 return (SCHARS (val) == 0 ? Qnil : Fintern (val, Qnil)); |
17052 | 8137 } |
8138 | |
8139 DEFUN ("check-coding-system", Fcheck_coding_system, Scheck_coding_system, | |
8140 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
|
8141 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
|
8142 If valid, return CODING-SYSTEM, else signal a `coding-system-error' error. |
89892 | 8143 It is valid if it is nil or a symbol defined as a coding system by the |
8144 function `define-coding-system'. */) | |
109179
8cfee7d2955f
Convert DEFUNs to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109165
diff
changeset
|
8145 (Lisp_Object coding_system) |
17052 | 8146 { |
52794
f4d906e31662
(Qcoding_system_define_form): New variable.
Kenichi Handa <handa@m17n.org>
parents:
52401
diff
changeset
|
8147 Lisp_Object define_form; |
f4d906e31662
(Qcoding_system_define_form): New variable.
Kenichi Handa <handa@m17n.org>
parents:
52401
diff
changeset
|
8148 |
f4d906e31662
(Qcoding_system_define_form): New variable.
Kenichi Handa <handa@m17n.org>
parents:
52401
diff
changeset
|
8149 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
|
8150 if (! NILP (define_form)) |
f4d906e31662
(Qcoding_system_define_form): New variable.
Kenichi Handa <handa@m17n.org>
parents:
52401
diff
changeset
|
8151 { |
f4d906e31662
(Qcoding_system_define_form): New variable.
Kenichi Handa <handa@m17n.org>
parents:
52401
diff
changeset
|
8152 Fput (coding_system, Qcoding_system_define_form, Qnil); |
f4d906e31662
(Qcoding_system_define_form): New variable.
Kenichi Handa <handa@m17n.org>
parents:
52401
diff
changeset
|
8153 safe_eval (define_form); |
f4d906e31662
(Qcoding_system_define_form): New variable.
Kenichi Handa <handa@m17n.org>
parents:
52401
diff
changeset
|
8154 } |
17052 | 8155 if (!NILP (Fcoding_system_p (coding_system))) |
8156 return coding_system; | |
71972
eaa3c19b94d2
(Fcheck_coding_system): Use xsignal1. Remove loop.
Kim F. Storm <storm@cua.dk>
parents:
71084
diff
changeset
|
8157 xsignal1 (Qcoding_system_error, coding_system); |
17052 | 8158 } |
88365 | 8159 |
20680
dd46027e8412
(code_convert_region): Always count chars inserted
Richard M. Stallman <rms@gnu.org>
parents:
20668
diff
changeset
|
8160 |
89193
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
8161 /* Detect how the bytes at SRC of length SRC_BYTES are encoded. If |
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
8162 HIGHEST is nonzero, return the coding system of the highest |
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
8163 priority among the detected coding systems. Otherwize return a |
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
8164 list of detected coding systems sorted by their priorities. If |
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
8165 MULTIBYTEP is nonzero, it is assumed that the bytes are in correct |
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
8166 multibyte form but contains only ASCII and eight-bit chars. |
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
8167 Otherwise, the bytes are raw bytes. |
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
8168 |
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
8169 CODING-SYSTEM controls the detection as below: |
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
8170 |
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
8171 If it is nil, detect both text-format and eol-format. If the |
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
8172 text-format part of CODING-SYSTEM is already specified |
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
8173 (e.g. `iso-latin-1'), detect only eol-format. If the eol-format |
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
8174 part of CODING-SYSTEM is already specified (e.g. `undecided-unix'), |
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
8175 detect only text-format. */ |
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
8176 |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
8177 Lisp_Object |
109159
3e9fdeb960d1
* coding.c, sysdep.c: Convert some more functions to standard C.
Juanma Barranquero <lekktu@gmail.com>
parents:
109158
diff
changeset
|
8178 detect_coding_system (const unsigned char *src, |
3e9fdeb960d1
* coding.c, sysdep.c: Convert some more functions to standard C.
Juanma Barranquero <lekktu@gmail.com>
parents:
109158
diff
changeset
|
8179 EMACS_INT src_chars, EMACS_INT src_bytes, |
3e9fdeb960d1
* coding.c, sysdep.c: Convert some more functions to standard C.
Juanma Barranquero <lekktu@gmail.com>
parents:
109158
diff
changeset
|
8180 int highest, int multibytep, |
3e9fdeb960d1
* coding.c, sysdep.c: Convert some more functions to standard C.
Juanma Barranquero <lekktu@gmail.com>
parents:
109158
diff
changeset
|
8181 Lisp_Object coding_system) |
17052 | 8182 { |
89483 | 8183 const unsigned char *src_end = src + src_bytes; |
88365 | 8184 Lisp_Object attrs, eol_type; |
100135
0e17542db552
(detect_coding_system): Initialize utf_16_le_eol to -1, val to
Kenichi Handa <handa@m17n.org>
parents:
100133
diff
changeset
|
8185 Lisp_Object val = Qnil; |
88365 | 8186 struct coding_system coding; |
89193
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
8187 int id; |
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
8188 struct coding_detection_info detect_info; |
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
8189 enum coding_category base_category; |
93595
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
8190 int null_byte_found = 0, eight_bit_found = 0; |
88365 | 8191 |
8192 if (NILP (coding_system)) | |
8193 coding_system = Qundecided; | |
8194 setup_coding_system (coding_system, &coding); | |
8195 attrs = CODING_ID_ATTRS (coding.id); | |
8196 eol_type = CODING_ID_EOL_TYPE (coding.id); | |
89193
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
8197 coding_system = CODING_ATTR_BASE_NAME (attrs); |
88365 | 8198 |
8199 coding.source = src; | |
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
8200 coding.src_chars = src_chars; |
88365 | 8201 coding.src_bytes = src_bytes; |
8202 coding.src_multibyte = multibytep; | |
8203 coding.consumed = 0; | |
89193
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
8204 coding.mode |= CODING_MODE_LAST_BLOCK; |
95533
831c8ee4d884
(detect_coding): Fix handling of coding->head_ascii.
Kenichi Handa <handa@m17n.org>
parents:
95397
diff
changeset
|
8205 coding.head_ascii = 0; |
89193
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
8206 |
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
8207 detect_info.checked = detect_info.found = detect_info.rejected = 0; |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
8208 |
89193
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
8209 /* At first, detect text-format if necessary. */ |
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
8210 base_category = XINT (CODING_ATTR_CATEGORY (attrs)); |
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
8211 if (base_category == coding_category_undecided) |
89193
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
8212 { |
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
8213 enum coding_category category; |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
8214 struct coding_system *this; |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
8215 int c, i; |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
8216 |
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
8217 /* Skip all ASCII bytes except for a few ISO2022 controls. */ |
93595
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
8218 for (; src < src_end; src++) |
17052 | 8219 { |
88365 | 8220 c = *src; |
89974
2fef8edebd5c
(detect_coding_utf_16): Don't set detect_info->found if
Kenichi Handa <handa@m17n.org>
parents:
89933
diff
changeset
|
8221 if (c & 0x80) |
93595
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
8222 { |
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
8223 eight_bit_found = 1; |
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
8224 if (null_byte_found) |
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
8225 break; |
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
8226 } |
95533
831c8ee4d884
(detect_coding): Fix handling of coding->head_ascii.
Kenichi Handa <handa@m17n.org>
parents:
95397
diff
changeset
|
8227 else if (c < 0x20) |
89974
2fef8edebd5c
(detect_coding_utf_16): Don't set detect_info->found if
Kenichi Handa <handa@m17n.org>
parents:
89933
diff
changeset
|
8228 { |
93595
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
8229 if ((c == ISO_CODE_ESC || c == ISO_CODE_SI || c == ISO_CODE_SO) |
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
8230 && ! inhibit_iso_escape_detection |
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
8231 && ! detect_info.checked) |
89974
2fef8edebd5c
(detect_coding_utf_16): Don't set detect_info->found if
Kenichi Handa <handa@m17n.org>
parents:
89933
diff
changeset
|
8232 { |
93595
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
8233 if (detect_coding_iso_2022 (&coding, &detect_info)) |
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
8234 { |
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
8235 /* We have scanned the whole data. */ |
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
8236 if (! (detect_info.rejected & CATEGORY_MASK_ISO_7_ELSE)) |
95533
831c8ee4d884
(detect_coding): Fix handling of coding->head_ascii.
Kenichi Handa <handa@m17n.org>
parents:
95397
diff
changeset
|
8237 { |
831c8ee4d884
(detect_coding): Fix handling of coding->head_ascii.
Kenichi Handa <handa@m17n.org>
parents:
95397
diff
changeset
|
8238 /* We didn't find an 8-bit code. We may |
831c8ee4d884
(detect_coding): Fix handling of coding->head_ascii.
Kenichi Handa <handa@m17n.org>
parents:
95397
diff
changeset
|
8239 have found a null-byte, but it's very |
831c8ee4d884
(detect_coding): Fix handling of coding->head_ascii.
Kenichi Handa <handa@m17n.org>
parents:
95397
diff
changeset
|
8240 rare that a binary file confirm to |
831c8ee4d884
(detect_coding): Fix handling of coding->head_ascii.
Kenichi Handa <handa@m17n.org>
parents:
95397
diff
changeset
|
8241 ISO-2022. */ |
831c8ee4d884
(detect_coding): Fix handling of coding->head_ascii.
Kenichi Handa <handa@m17n.org>
parents:
95397
diff
changeset
|
8242 src = src_end; |
831c8ee4d884
(detect_coding): Fix handling of coding->head_ascii.
Kenichi Handa <handa@m17n.org>
parents:
95397
diff
changeset
|
8243 coding.head_ascii = src - coding.source; |
831c8ee4d884
(detect_coding): Fix handling of coding->head_ascii.
Kenichi Handa <handa@m17n.org>
parents:
95397
diff
changeset
|
8244 } |
831c8ee4d884
(detect_coding): Fix handling of coding->head_ascii.
Kenichi Handa <handa@m17n.org>
parents:
95397
diff
changeset
|
8245 detect_info.rejected |= ~CATEGORY_MASK_ISO_ESCAPE; |
93595
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
8246 break; |
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
8247 } |
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
8248 } |
101040 | 8249 else if (! c && !inhibit_null_byte_detection) |
93595
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
8250 { |
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
8251 null_byte_found = 1; |
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
8252 if (eight_bit_found) |
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
8253 break; |
89974
2fef8edebd5c
(detect_coding_utf_16): Don't set detect_info->found if
Kenichi Handa <handa@m17n.org>
parents:
89933
diff
changeset
|
8254 } |
95585
862c7386145c
(detect_coding): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
95533
diff
changeset
|
8255 if (! eight_bit_found) |
862c7386145c
(detect_coding): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
95533
diff
changeset
|
8256 coding.head_ascii++; |
89974
2fef8edebd5c
(detect_coding_utf_16): Don't set detect_info->found if
Kenichi Handa <handa@m17n.org>
parents:
89933
diff
changeset
|
8257 } |
95585
862c7386145c
(detect_coding): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
95533
diff
changeset
|
8258 else if (! eight_bit_found) |
95533
831c8ee4d884
(detect_coding): Fix handling of coding->head_ascii.
Kenichi Handa <handa@m17n.org>
parents:
95397
diff
changeset
|
8259 coding.head_ascii++; |
831c8ee4d884
(detect_coding): Fix handling of coding->head_ascii.
Kenichi Handa <handa@m17n.org>
parents:
95397
diff
changeset
|
8260 } |
93595
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
8261 |
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
8262 if (null_byte_found || eight_bit_found |
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
8263 || coding.head_ascii < coding.src_bytes |
89974
2fef8edebd5c
(detect_coding_utf_16): Don't set detect_info->found if
Kenichi Handa <handa@m17n.org>
parents:
89933
diff
changeset
|
8264 || detect_info.found) |
2fef8edebd5c
(detect_coding_utf_16): Don't set detect_info->found if
Kenichi Handa <handa@m17n.org>
parents:
89933
diff
changeset
|
8265 { |
93595
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
8266 if (coding.head_ascii == coding.src_bytes) |
89974
2fef8edebd5c
(detect_coding_utf_16): Don't set detect_info->found if
Kenichi Handa <handa@m17n.org>
parents:
89933
diff
changeset
|
8267 /* As all bytes are 7-bit, we can ignore non-ISO-2022 codings. */ |
2fef8edebd5c
(detect_coding_utf_16): Don't set detect_info->found if
Kenichi Handa <handa@m17n.org>
parents:
89933
diff
changeset
|
8268 for (i = 0; i < coding_category_raw_text; i++) |
88365 | 8269 { |
89974
2fef8edebd5c
(detect_coding_utf_16): Don't set detect_info->found if
Kenichi Handa <handa@m17n.org>
parents:
89933
diff
changeset
|
8270 category = coding_priorities[i]; |
90594
a965377e6761
(detect_coding_system): Fix for handling off
Kenichi Handa <handa@m17n.org>
parents:
90587
diff
changeset
|
8271 this = coding_categories + category; |
89974
2fef8edebd5c
(detect_coding_utf_16): Don't set detect_info->found if
Kenichi Handa <handa@m17n.org>
parents:
89933
diff
changeset
|
8272 if (detect_info.found & (1 << category)) |
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
8273 break; |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
8274 } |
89974
2fef8edebd5c
(detect_coding_utf_16): Don't set detect_info->found if
Kenichi Handa <handa@m17n.org>
parents:
89933
diff
changeset
|
8275 else |
93595
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
8276 { |
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
8277 if (null_byte_found) |
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
8278 { |
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
8279 detect_info.checked |= ~CATEGORY_MASK_UTF_16; |
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
8280 detect_info.rejected |= ~CATEGORY_MASK_UTF_16; |
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
8281 } |
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
8282 for (i = 0; i < coding_category_raw_text; i++) |
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
8283 { |
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
8284 category = coding_priorities[i]; |
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
8285 this = coding_categories + category; |
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
8286 |
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
8287 if (this->id < 0) |
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
8288 { |
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
8289 /* No coding system of this category is defined. */ |
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
8290 detect_info.rejected |= (1 << category); |
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
8291 } |
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
8292 else if (category >= coding_category_raw_text) |
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
8293 continue; |
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
8294 else if (detect_info.checked & (1 << category)) |
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
8295 { |
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
8296 if (highest |
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
8297 && (detect_info.found & (1 << category))) |
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
8298 break; |
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
8299 } |
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
8300 else if ((*(this->detector)) (&coding, &detect_info) |
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
8301 && highest |
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
8302 && (detect_info.found & (1 << category))) |
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
8303 { |
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
8304 if (category == coding_category_utf_16_auto) |
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
8305 { |
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
8306 if (detect_info.found & CATEGORY_MASK_UTF_16_LE) |
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
8307 category = coding_category_utf_16_le; |
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
8308 else |
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
8309 category = coding_category_utf_16_be; |
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
8310 } |
89974
2fef8edebd5c
(detect_coding_utf_16): Don't set detect_info->found if
Kenichi Handa <handa@m17n.org>
parents:
89933
diff
changeset
|
8311 break; |
93595
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
8312 } |
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
8313 } |
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
8314 } |
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
8315 } |
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
8316 |
101197
ee5f395f3c19
(detect_coding_system): Fix handling of null_byte_fount.
Kenichi Handa <handa@m17n.org>
parents:
101174
diff
changeset
|
8317 if ((detect_info.rejected & CATEGORY_MASK_ANY) == CATEGORY_MASK_ANY |
ee5f395f3c19
(detect_coding_system): Fix handling of null_byte_fount.
Kenichi Handa <handa@m17n.org>
parents:
101174
diff
changeset
|
8318 || null_byte_found) |
89193
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
8319 { |
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
8320 detect_info.found = CATEGORY_MASK_RAW_TEXT; |
101197
ee5f395f3c19
(detect_coding_system): Fix handling of null_byte_fount.
Kenichi Handa <handa@m17n.org>
parents:
101174
diff
changeset
|
8321 id = CODING_SYSTEM_ID (Qno_conversion); |
89193
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
8322 val = Fcons (make_number (id), Qnil); |
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
8323 } |
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
8324 else if (! detect_info.rejected && ! detect_info.found) |
89193
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
8325 { |
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
8326 detect_info.found = CATEGORY_MASK_ANY; |
89193
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
8327 id = coding_categories[coding_category_undecided].id; |
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
8328 val = Fcons (make_number (id), Qnil); |
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
8329 } |
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
8330 else if (highest) |
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
8331 { |
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
8332 if (detect_info.found) |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
8333 { |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
8334 detect_info.found = 1 << category; |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
8335 val = Fcons (make_number (this->id), Qnil); |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
8336 } |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
8337 else |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
8338 for (i = 0; i < coding_category_raw_text; i++) |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
8339 if (! (detect_info.rejected & (1 << coding_priorities[i]))) |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
8340 { |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
8341 detect_info.found = 1 << coding_priorities[i]; |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
8342 id = coding_categories[coding_priorities[i]].id; |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
8343 val = Fcons (make_number (id), Qnil); |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
8344 break; |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
8345 } |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
8346 } |
89193
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
8347 else |
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
8348 { |
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
8349 int mask = detect_info.rejected | detect_info.found; |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
8350 int found = 0; |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
8351 |
89193
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
8352 for (i = coding_category_raw_text - 1; i >= 0; i--) |
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
8353 { |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
8354 category = coding_priorities[i]; |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
8355 if (! (mask & (1 << category))) |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
8356 { |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
8357 found |= 1 << category; |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
8358 id = coding_categories[category].id; |
90594
a965377e6761
(detect_coding_system): Fix for handling off
Kenichi Handa <handa@m17n.org>
parents:
90587
diff
changeset
|
8359 if (id >= 0) |
a965377e6761
(detect_coding_system): Fix for handling off
Kenichi Handa <handa@m17n.org>
parents:
90587
diff
changeset
|
8360 val = Fcons (make_number (id), val); |
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
8361 } |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
8362 } |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
8363 for (i = coding_category_raw_text - 1; i >= 0; i--) |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
8364 { |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
8365 category = coding_priorities[i]; |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
8366 if (detect_info.found & (1 << category)) |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
8367 { |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
8368 id = coding_categories[category].id; |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
8369 val = Fcons (make_number (id), val); |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
8370 } |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
8371 } |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
8372 detect_info.found |= found; |
89193
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
8373 } |
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
8374 } |
95397
c99f0a16c077
(CODING_UTF_8_BOM): New macro.
Kenichi Handa <handa@m17n.org>
parents:
95356
diff
changeset
|
8375 else if (base_category == coding_category_utf_8_auto) |
c99f0a16c077
(CODING_UTF_8_BOM): New macro.
Kenichi Handa <handa@m17n.org>
parents:
95356
diff
changeset
|
8376 { |
c99f0a16c077
(CODING_UTF_8_BOM): New macro.
Kenichi Handa <handa@m17n.org>
parents:
95356
diff
changeset
|
8377 if (detect_coding_utf_8 (&coding, &detect_info)) |
c99f0a16c077
(CODING_UTF_8_BOM): New macro.
Kenichi Handa <handa@m17n.org>
parents:
95356
diff
changeset
|
8378 { |
c99f0a16c077
(CODING_UTF_8_BOM): New macro.
Kenichi Handa <handa@m17n.org>
parents:
95356
diff
changeset
|
8379 struct coding_system *this; |
c99f0a16c077
(CODING_UTF_8_BOM): New macro.
Kenichi Handa <handa@m17n.org>
parents:
95356
diff
changeset
|
8380 |
c99f0a16c077
(CODING_UTF_8_BOM): New macro.
Kenichi Handa <handa@m17n.org>
parents:
95356
diff
changeset
|
8381 if (detect_info.found & CATEGORY_MASK_UTF_8_SIG) |
c99f0a16c077
(CODING_UTF_8_BOM): New macro.
Kenichi Handa <handa@m17n.org>
parents:
95356
diff
changeset
|
8382 this = coding_categories + coding_category_utf_8_sig; |
c99f0a16c077
(CODING_UTF_8_BOM): New macro.
Kenichi Handa <handa@m17n.org>
parents:
95356
diff
changeset
|
8383 else |
c99f0a16c077
(CODING_UTF_8_BOM): New macro.
Kenichi Handa <handa@m17n.org>
parents:
95356
diff
changeset
|
8384 this = coding_categories + coding_category_utf_8_nosig; |
c99f0a16c077
(CODING_UTF_8_BOM): New macro.
Kenichi Handa <handa@m17n.org>
parents:
95356
diff
changeset
|
8385 val = Fcons (make_number (this->id), Qnil); |
c99f0a16c077
(CODING_UTF_8_BOM): New macro.
Kenichi Handa <handa@m17n.org>
parents:
95356
diff
changeset
|
8386 } |
c99f0a16c077
(CODING_UTF_8_BOM): New macro.
Kenichi Handa <handa@m17n.org>
parents:
95356
diff
changeset
|
8387 } |
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
8388 else if (base_category == coding_category_utf_16_auto) |
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
8389 { |
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
8390 if (detect_coding_utf_16 (&coding, &detect_info)) |
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
8391 { |
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
8392 struct coding_system *this; |
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
8393 |
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
8394 if (detect_info.found & CATEGORY_MASK_UTF_16_LE) |
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
8395 this = coding_categories + coding_category_utf_16_le; |
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
8396 else if (detect_info.found & CATEGORY_MASK_UTF_16_BE) |
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
8397 this = coding_categories + coding_category_utf_16_be; |
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
8398 else if (detect_info.rejected & CATEGORY_MASK_UTF_16_LE_NOSIG) |
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
8399 this = coding_categories + coding_category_utf_16_be_nosig; |
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
8400 else |
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
8401 this = coding_categories + coding_category_utf_16_le_nosig; |
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
8402 val = Fcons (make_number (this->id), Qnil); |
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
8403 } |
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
8404 } |
88365 | 8405 else |
8406 { | |
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
8407 detect_info.found = 1 << XINT (CODING_ATTR_CATEGORY (attrs)); |
89193
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
8408 val = Fcons (make_number (coding.id), Qnil); |
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
8409 } |
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
8410 |
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
8411 /* Then, detect eol-format if necessary. */ |
88365 | 8412 { |
100135
0e17542db552
(detect_coding_system): Initialize utf_16_le_eol to -1, val to
Kenichi Handa <handa@m17n.org>
parents:
100133
diff
changeset
|
8413 int normal_eol = -1, utf_16_be_eol = -1, utf_16_le_eol = -1; |
88365 | 8414 Lisp_Object tail; |
8415 | |
89193
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
8416 if (VECTORP (eol_type)) |
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
8417 { |
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
8418 if (detect_info.found & ~CATEGORY_MASK_UTF_16) |
93595
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
8419 { |
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
8420 if (null_byte_found) |
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
8421 normal_eol = EOL_SEEN_LF; |
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
8422 else |
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
8423 normal_eol = detect_eol (coding.source, src_bytes, |
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
8424 coding_category_raw_text); |
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
8425 } |
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
8426 if (detect_info.found & (CATEGORY_MASK_UTF_16_BE |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
8427 | CATEGORY_MASK_UTF_16_BE_NOSIG)) |
89193
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
8428 utf_16_be_eol = detect_eol (coding.source, src_bytes, |
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
8429 coding_category_utf_16_be); |
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
8430 if (detect_info.found & (CATEGORY_MASK_UTF_16_LE |
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
8431 | CATEGORY_MASK_UTF_16_LE_NOSIG)) |
89193
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
8432 utf_16_le_eol = detect_eol (coding.source, src_bytes, |
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
8433 coding_category_utf_16_le); |
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
8434 } |
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
8435 else |
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
8436 { |
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
8437 if (EQ (eol_type, Qunix)) |
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
8438 normal_eol = utf_16_be_eol = utf_16_le_eol = EOL_SEEN_LF; |
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
8439 else if (EQ (eol_type, Qdos)) |
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
8440 normal_eol = utf_16_be_eol = utf_16_le_eol = EOL_SEEN_CRLF; |
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
8441 else |
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
8442 normal_eol = utf_16_be_eol = utf_16_le_eol = EOL_SEEN_CR; |
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
8443 } |
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
8444 |
88365 | 8445 for (tail = val; CONSP (tail); tail = XCDR (tail)) |
8446 { | |
89193
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
8447 enum coding_category category; |
88365 | 8448 int this_eol; |
89193
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
8449 |
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
8450 id = XINT (XCAR (tail)); |
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
8451 attrs = CODING_ID_ATTRS (id); |
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
8452 category = XINT (CODING_ATTR_CATEGORY (attrs)); |
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
8453 eol_type = CODING_ID_EOL_TYPE (id); |
88365 | 8454 if (VECTORP (eol_type)) |
8455 { | |
89193
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
8456 if (category == coding_category_utf_16_be |
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
8457 || category == coding_category_utf_16_be_nosig) |
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
8458 this_eol = utf_16_be_eol; |
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
8459 else if (category == coding_category_utf_16_le |
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
8460 || category == coding_category_utf_16_le_nosig) |
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
8461 this_eol = utf_16_le_eol; |
88365 | 8462 else |
89193
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
8463 this_eol = normal_eol; |
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
8464 |
88365 | 8465 if (this_eol == EOL_SEEN_LF) |
8466 XSETCAR (tail, AREF (eol_type, 0)); | |
8467 else if (this_eol == EOL_SEEN_CRLF) | |
8468 XSETCAR (tail, AREF (eol_type, 1)); | |
8469 else if (this_eol == EOL_SEEN_CR) | |
8470 XSETCAR (tail, AREF (eol_type, 2)); | |
89193
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
8471 else |
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
8472 XSETCAR (tail, CODING_ID_NAME (id)); |
88365 | 8473 } |
89193
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
8474 else |
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
8475 XSETCAR (tail, CODING_ID_NAME (id)); |
88365 | 8476 } |
8477 } | |
8478 | |
100135
0e17542db552
(detect_coding_system): Initialize utf_16_le_eol to -1, val to
Kenichi Handa <handa@m17n.org>
parents:
100133
diff
changeset
|
8479 return (highest ? (CONSP (val) ? XCAR (val) : Qnil) : val); |
42104
d69c2368e549
(DECODE_COMPOSITION_END): Fixed a typo in the last
Sam Steingold <sds@gnu.org>
parents:
42103
diff
changeset
|
8480 } |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
8481 |
88365 | 8482 |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
8483 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
|
8484 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
|
8485 doc: /* Detect coding system of the text in the region between START and END. |
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
8486 Return a list of possible coding systems ordered by priority. |
102737
f556415c326b
(Fdetect_coding_region, Fcoding_system_priority_list): Improve the
Kenichi Handa <handa@m17n.org>
parents:
102422
diff
changeset
|
8487 The coding systems to try and their priorities follows what |
f556415c326b
(Fdetect_coding_region, Fcoding_system_priority_list): Improve the
Kenichi Handa <handa@m17n.org>
parents:
102422
diff
changeset
|
8488 the function `coding-system-priority-list' (which see) returns. |
40713
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
8489 |
72552
6493d4697ad2
(Fdetect_coding_region, Fdetect_coding_string): Fix
Kenichi Handa <handa@m17n.org>
parents:
72395
diff
changeset
|
8490 If only ASCII characters are found (except for such ISO-2022 control |
95088
524350e4961c
(Fcoding_system_p): Rename argument to match docstring.
Juanma Barranquero <lekktu@gmail.com>
parents:
94963
diff
changeset
|
8491 characters as ESC), it returns a list of single element `undecided' |
524350e4961c
(Fcoding_system_p): Rename argument to match docstring.
Juanma Barranquero <lekktu@gmail.com>
parents:
94963
diff
changeset
|
8492 or its subsidiary coding system according to a detected end-of-line |
524350e4961c
(Fcoding_system_p): Rename argument to match docstring.
Juanma Barranquero <lekktu@gmail.com>
parents:
94963
diff
changeset
|
8493 format. |
40713
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
8494 |
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
8495 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
|
8496 highest priority. */) |
109179
8cfee7d2955f
Convert DEFUNs to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109165
diff
changeset
|
8497 (Lisp_Object start, Lisp_Object end, Lisp_Object highest) |
17052 | 8498 { |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
8499 int from, to; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
8500 int from_byte, to_byte; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
8501 |
40656
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents:
40461
diff
changeset
|
8502 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
|
8503 CHECK_NUMBER_COERCE_MARKER (end); |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
8504 |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
8505 validate_region (&start, &end); |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
8506 from = XINT (start), to = XINT (end); |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
8507 from_byte = CHAR_TO_BYTE (from); |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
8508 to_byte = CHAR_TO_BYTE (to); |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
8509 |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
8510 if (from < GPT && to >= GPT) |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
8511 move_gap_both (to, to_byte); |
88365 | 8512 |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
8513 return detect_coding_system (BYTE_POS_ADDR (from_byte), |
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
8514 to - from, to_byte - from_byte, |
34531
37f85e931855
(ONE_MORE_BYTE_CHECK_MULTIBYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34197
diff
changeset
|
8515 !NILP (highest), |
37f85e931855
(ONE_MORE_BYTE_CHECK_MULTIBYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34197
diff
changeset
|
8516 !NILP (current_buffer |
88365 | 8517 ->enable_multibyte_characters), |
8518 Qnil); | |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
8519 } |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
8520 |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
8521 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
|
8522 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
|
8523 doc: /* Detect coding system of the text in STRING. |
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
8524 Return a list of possible coding systems ordered by priority. |
102738
41e7ab490f69
(Fdetect_coding_string): Improve the docstrings.
Kenichi Handa <handa@m17n.org>
parents:
102737
diff
changeset
|
8525 The coding systems to try and their priorities follows what |
41e7ab490f69
(Fdetect_coding_string): Improve the docstrings.
Kenichi Handa <handa@m17n.org>
parents:
102737
diff
changeset
|
8526 the function `coding-system-priority-list' (which see) returns. |
40713
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
8527 |
72552
6493d4697ad2
(Fdetect_coding_region, Fdetect_coding_string): Fix
Kenichi Handa <handa@m17n.org>
parents:
72395
diff
changeset
|
8528 If only ASCII characters are found (except for such ISO-2022 control |
95088
524350e4961c
(Fcoding_system_p): Rename argument to match docstring.
Juanma Barranquero <lekktu@gmail.com>
parents:
94963
diff
changeset
|
8529 characters as ESC), it returns a list of single element `undecided' |
524350e4961c
(Fcoding_system_p): Rename argument to match docstring.
Juanma Barranquero <lekktu@gmail.com>
parents:
94963
diff
changeset
|
8530 or its subsidiary coding system according to a detected end-of-line |
524350e4961c
(Fcoding_system_p): Rename argument to match docstring.
Juanma Barranquero <lekktu@gmail.com>
parents:
94963
diff
changeset
|
8531 format. |
40713
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
8532 |
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
8533 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
|
8534 highest priority. */) |
109179
8cfee7d2955f
Convert DEFUNs to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109165
diff
changeset
|
8535 (Lisp_Object string, Lisp_Object highest) |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
8536 { |
40656
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents:
40461
diff
changeset
|
8537 CHECK_STRING (string); |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
8538 |
46370
40db0673e6f0
Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents:
46293
diff
changeset
|
8539 return detect_coding_system (SDATA (string), |
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
8540 SCHARS (string), SBYTES (string), |
89483 | 8541 !NILP (highest), STRING_MULTIBYTE (string), |
88365 | 8542 Qnil); |
30487
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
8543 } |
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
8544 |
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
8545 |
88365 | 8546 static INLINE int |
109126
aec1143e8d85
Convert (most) functions in src to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109100
diff
changeset
|
8547 char_encodable_p (int c, Lisp_Object attrs) |
30487
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
8548 { |
88365 | 8549 Lisp_Object tail; |
8550 struct charset *charset; | |
89732
8acde12aba89
(get_translation_table): New function.
Kenichi Handa <handa@m17n.org>
parents:
89730
diff
changeset
|
8551 Lisp_Object translation_table; |
8acde12aba89
(get_translation_table): New function.
Kenichi Handa <handa@m17n.org>
parents:
89730
diff
changeset
|
8552 |
8acde12aba89
(get_translation_table): New function.
Kenichi Handa <handa@m17n.org>
parents:
89730
diff
changeset
|
8553 translation_table = CODING_ATTR_TRANS_TBL (attrs); |
89759
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
8554 if (! NILP (translation_table)) |
89732
8acde12aba89
(get_translation_table): New function.
Kenichi Handa <handa@m17n.org>
parents:
89730
diff
changeset
|
8555 c = translate_char (translation_table, c); |
88365 | 8556 for (tail = CODING_ATTR_CHARSET_LIST (attrs); |
8557 CONSP (tail); tail = XCDR (tail)) | |
8558 { | |
8559 charset = CHARSET_FROM_ID (XINT (XCAR (tail))); | |
8560 if (CHAR_CHARSET_P (c, charset)) | |
8561 break; | |
8562 } | |
8563 return (! NILP (tail)); | |
30487
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
8564 } |
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
8565 |
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
8566 |
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
8567 /* Return a list of coding systems that safely encode the text between |
88365 | 8568 START and END. If EXCLUDE is non-nil, it is a list of coding |
8569 systems not to check. The returned list doesn't contain any such | |
88889
4548f224c603
(Ffind_coding_systems_region_internal): Detect an
Kenichi Handa <handa@m17n.org>
parents:
88876
diff
changeset
|
8570 coding systems. In any case, if the text contains only ASCII or is |
88365 | 8571 unibyte, return t. */ |
30487
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
8572 |
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
8573 DEFUN ("find-coding-systems-region-internal", |
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
8574 Ffind_coding_systems_region_internal, |
88365 | 8575 Sfind_coding_systems_region_internal, 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
|
8576 doc: /* Internal use only. */) |
109179
8cfee7d2955f
Convert DEFUNs to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109165
diff
changeset
|
8577 (Lisp_Object start, Lisp_Object end, Lisp_Object exclude) |
30487
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
8578 { |
88365 | 8579 Lisp_Object coding_attrs_list, safe_codings; |
8580 EMACS_INT start_byte, end_byte; | |
88876
af9012fdad56
(LEADING_CODE_PRIVATE_11, LEADING_CODE_PRIVATE_12,
Kenichi Handa <handa@m17n.org>
parents:
88862
diff
changeset
|
8581 const unsigned char *p, *pbeg, *pend; |
88365 | 8582 int c; |
103486
091a55d2d6f7
(Ffind_coding_systems_region_internal): Cache checked characters.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
103474
diff
changeset
|
8583 Lisp_Object tail, elt, work_table; |
30487
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
8584 |
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
8585 if (STRINGP (start)) |
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
8586 { |
88365 | 8587 if (!STRING_MULTIBYTE (start) |
89483 | 8588 || SCHARS (start) == SBYTES (start)) |
30487
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
8589 return Qt; |
88365 | 8590 start_byte = 0; |
89483 | 8591 end_byte = SBYTES (start); |
30487
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
8592 } |
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
8593 else |
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
8594 { |
40656
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents:
40461
diff
changeset
|
8595 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
|
8596 CHECK_NUMBER_COERCE_MARKER (end); |
30487
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
8597 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
|
8598 args_out_of_range (start, end); |
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
8599 if (NILP (current_buffer->enable_multibyte_characters)) |
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
8600 return Qt; |
88365 | 8601 start_byte = CHAR_TO_BYTE (XINT (start)); |
8602 end_byte = CHAR_TO_BYTE (XINT (end)); | |
8603 if (XINT (end) - XINT (start) == end_byte - start_byte) | |
8604 return Qt; | |
8605 | |
89394
6ffca50f25b9
(Fcheck_coding_systems_region): Fix type errors.
Dave Love <fx@gnu.org>
parents:
89373
diff
changeset
|
8606 if (XINT (start) < GPT && XINT (end) > GPT) |
88365 | 8607 { |
89394
6ffca50f25b9
(Fcheck_coding_systems_region): Fix type errors.
Dave Love <fx@gnu.org>
parents:
89373
diff
changeset
|
8608 if ((GPT - XINT (start)) < (XINT (end) - GPT)) |
6ffca50f25b9
(Fcheck_coding_systems_region): Fix type errors.
Dave Love <fx@gnu.org>
parents:
89373
diff
changeset
|
8609 move_gap_both (XINT (start), start_byte); |
88365 | 8610 else |
89394
6ffca50f25b9
(Fcheck_coding_systems_region): Fix type errors.
Dave Love <fx@gnu.org>
parents:
89373
diff
changeset
|
8611 move_gap_both (XINT (end), end_byte); |
88365 | 8612 } |
8613 } | |
8614 | |
8615 coding_attrs_list = Qnil; | |
8616 for (tail = Vcoding_system_list; CONSP (tail); tail = XCDR (tail)) | |
8617 if (NILP (exclude) | |
8618 || NILP (Fmemq (XCAR (tail), exclude))) | |
8619 { | |
8620 Lisp_Object attrs; | |
8621 | |
8622 attrs = AREF (CODING_SYSTEM_SPEC (XCAR (tail)), 0); | |
8623 if (EQ (XCAR (tail), CODING_ATTR_BASE_NAME (attrs)) | |
8624 && ! EQ (CODING_ATTR_TYPE (attrs), Qundecided)) | |
89732
8acde12aba89
(get_translation_table): New function.
Kenichi Handa <handa@m17n.org>
parents:
89730
diff
changeset
|
8625 { |
8acde12aba89
(get_translation_table): New function.
Kenichi Handa <handa@m17n.org>
parents:
89730
diff
changeset
|
8626 ASET (attrs, coding_attr_trans_tbl, |
89861
7160ded23e55
(get_translation_table): Allow max_lookup to be NULL.
Kenichi Handa <handa@m17n.org>
parents:
89859
diff
changeset
|
8627 get_translation_table (attrs, 1, NULL)); |
89732
8acde12aba89
(get_translation_table): New function.
Kenichi Handa <handa@m17n.org>
parents:
89730
diff
changeset
|
8628 coding_attrs_list = Fcons (attrs, coding_attrs_list); |
8acde12aba89
(get_translation_table): New function.
Kenichi Handa <handa@m17n.org>
parents:
89730
diff
changeset
|
8629 } |
88365 | 8630 } |
8631 | |
8632 if (STRINGP (start)) | |
89483 | 8633 p = pbeg = SDATA (start); |
88365 | 8634 else |
8635 p = pbeg = BYTE_POS_ADDR (start_byte); | |
8636 pend = p + (end_byte - start_byte); | |
8637 | |
8638 while (p < pend && ASCII_BYTE_P (*p)) p++; | |
8639 while (p < pend && ASCII_BYTE_P (*(pend - 1))) pend--; | |
8640 | |
103486
091a55d2d6f7
(Ffind_coding_systems_region_internal): Cache checked characters.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
103474
diff
changeset
|
8641 work_table = Fmake_char_table (Qnil, Qnil); |
88365 | 8642 while (p < pend) |
8643 { | |
8644 if (ASCII_BYTE_P (*p)) | |
8645 p++; | |
30487
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
8646 else |
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
8647 { |
88365 | 8648 c = STRING_CHAR_ADVANCE (p); |
103486
091a55d2d6f7
(Ffind_coding_systems_region_internal): Cache checked characters.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
103474
diff
changeset
|
8649 if (!NILP (char_table_ref (work_table, c))) |
091a55d2d6f7
(Ffind_coding_systems_region_internal): Cache checked characters.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
103474
diff
changeset
|
8650 /* This character was already checked. Ignore it. */ |
091a55d2d6f7
(Ffind_coding_systems_region_internal): Cache checked characters.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
103474
diff
changeset
|
8651 continue; |
88365 | 8652 |
8653 charset_map_loaded = 0; | |
8654 for (tail = coding_attrs_list; CONSP (tail);) | |
8655 { | |
8656 elt = XCAR (tail); | |
8657 if (NILP (elt)) | |
8658 tail = XCDR (tail); | |
8659 else if (char_encodable_p (c, elt)) | |
8660 tail = XCDR (tail); | |
8661 else if (CONSP (XCDR (tail))) | |
8662 { | |
8663 XSETCAR (tail, XCAR (XCDR (tail))); | |
8664 XSETCDR (tail, XCDR (XCDR (tail))); | |
8665 } | |
8666 else | |
8667 { | |
8668 XSETCAR (tail, Qnil); | |
8669 tail = XCDR (tail); | |
8670 } | |
8671 } | |
8672 if (charset_map_loaded) | |
8673 { | |
8674 EMACS_INT p_offset = p - pbeg, pend_offset = pend - pbeg; | |
8675 | |
8676 if (STRINGP (start)) | |
89483 | 8677 pbeg = SDATA (start); |
88365 | 8678 else |
8679 pbeg = BYTE_POS_ADDR (start_byte); | |
8680 p = pbeg + p_offset; | |
8681 pend = pbeg + pend_offset; | |
8682 } | |
103486
091a55d2d6f7
(Ffind_coding_systems_region_internal): Cache checked characters.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
103474
diff
changeset
|
8683 char_table_set (work_table, c, Qt); |
30487
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
8684 } |
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
8685 } |
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
8686 |
89905
37e044cc35f6
(Ffind_coding_systems_region_internal): Include raw-text and
Kenichi Handa <handa@m17n.org>
parents:
89892
diff
changeset
|
8687 safe_codings = list2 (Qraw_text, Qno_conversion); |
88365 | 8688 for (tail = coding_attrs_list; CONSP (tail); tail = XCDR (tail)) |
8689 if (! NILP (XCAR (tail))) | |
8690 safe_codings = Fcons (CODING_ATTR_BASE_NAME (XCAR (tail)), safe_codings); | |
49539
1ad5bfbb831a
(syms_of_coding): Add `...' for symbols in the docstring of
Kenichi Handa <handa@m17n.org>
parents:
48874
diff
changeset
|
8691 |
1ad5bfbb831a
(syms_of_coding): Add `...' for symbols in the docstring of
Kenichi Handa <handa@m17n.org>
parents:
48874
diff
changeset
|
8692 return safe_codings; |
1ad5bfbb831a
(syms_of_coding): Add `...' for symbols in the docstring of
Kenichi Handa <handa@m17n.org>
parents:
48874
diff
changeset
|
8693 } |
1ad5bfbb831a
(syms_of_coding): Add `...' for symbols in the docstring of
Kenichi Handa <handa@m17n.org>
parents:
48874
diff
changeset
|
8694 |
1ad5bfbb831a
(syms_of_coding): Add `...' for symbols in the docstring of
Kenichi Handa <handa@m17n.org>
parents:
48874
diff
changeset
|
8695 |
46859
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
8696 DEFUN ("unencodable-char-position", Funencodable_char_position, |
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
8697 Sunencodable_char_position, 3, 5, 0, |
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
8698 doc: /* |
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
8699 Return position of first un-encodable character in a region. |
95088
524350e4961c
(Fcoding_system_p): Rename argument to match docstring.
Juanma Barranquero <lekktu@gmail.com>
parents:
94963
diff
changeset
|
8700 START and END specify the region and CODING-SYSTEM specifies the |
46859
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
8701 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
|
8702 |
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
8703 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
|
8704 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
|
8705 list of positions. |
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
8706 |
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
8707 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
|
8708 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
|
8709 to the string. */) |
109179
8cfee7d2955f
Convert DEFUNs to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109165
diff
changeset
|
8710 (Lisp_Object start, Lisp_Object end, Lisp_Object coding_system, Lisp_Object count, Lisp_Object string) |
46859
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
8711 { |
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
8712 int n; |
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
8713 struct coding_system coding; |
89732
8acde12aba89
(get_translation_table): New function.
Kenichi Handa <handa@m17n.org>
parents:
89730
diff
changeset
|
8714 Lisp_Object attrs, charset_list, translation_table; |
46859
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
8715 Lisp_Object positions; |
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
8716 int from, to; |
89483 | 8717 const unsigned char *p, *stop, *pend; |
8718 int ascii_compatible; | |
8719 | |
8720 setup_coding_system (Fcheck_coding_system (coding_system), &coding); | |
8721 attrs = CODING_ID_ATTRS (coding.id); | |
8722 if (EQ (CODING_ATTR_TYPE (attrs), Qraw_text)) | |
8723 return Qnil; | |
8724 ascii_compatible = ! NILP (CODING_ATTR_ASCII_COMPAT (attrs)); | |
8725 charset_list = CODING_ATTR_CHARSET_LIST (attrs); | |
89861
7160ded23e55
(get_translation_table): Allow max_lookup to be NULL.
Kenichi Handa <handa@m17n.org>
parents:
89859
diff
changeset
|
8726 translation_table = get_translation_table (attrs, 1, NULL); |
46859
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
8727 |
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
8728 if (NILP (string)) |
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
8729 { |
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
8730 validate_region (&start, &end); |
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
8731 from = XINT (start); |
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
8732 to = XINT (end); |
89483 | 8733 if (NILP (current_buffer->enable_multibyte_characters) |
8734 || (ascii_compatible | |
8735 && (to - from) == (CHAR_TO_BYTE (to) - (CHAR_TO_BYTE (from))))) | |
46859
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
8736 return Qnil; |
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
8737 p = CHAR_POS_ADDR (from); |
89483 | 8738 pend = CHAR_POS_ADDR (to); |
8739 if (from < GPT && to >= GPT) | |
8740 stop = GPT_ADDR; | |
48829
f6c59ca557c7
(Funencodable_char_position): Set pend correctly.
Kenichi Handa <handa@m17n.org>
parents:
48230
diff
changeset
|
8741 else |
89483 | 8742 stop = pend; |
46859
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
8743 } |
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
8744 else |
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
8745 { |
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
8746 CHECK_STRING (string); |
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
8747 CHECK_NATNUM (start); |
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
8748 CHECK_NATNUM (end); |
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
8749 from = XINT (start); |
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
8750 to = XINT (end); |
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
8751 if (from > to |
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
8752 || to > SCHARS (string)) |
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
8753 args_out_of_range_3 (string, start, end); |
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
8754 if (! STRING_MULTIBYTE (string)) |
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
8755 return Qnil; |
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
8756 p = SDATA (string) + string_char_to_byte (string, from); |
89483 | 8757 stop = pend = SDATA (string) + string_char_to_byte (string, to); |
8758 if (ascii_compatible && (to - from) == (pend - p)) | |
8759 return Qnil; | |
8760 } | |
46859
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
8761 |
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
8762 if (NILP (count)) |
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
8763 n = 1; |
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
8764 else |
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
8765 { |
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
8766 CHECK_NATNUM (count); |
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
8767 n = XINT (count); |
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
8768 } |
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
8769 |
89483 | 8770 positions = Qnil; |
8771 while (1) | |
8772 { | |
8773 int c; | |
8774 | |
8775 if (ascii_compatible) | |
8776 while (p < stop && ASCII_BYTE_P (*p)) | |
8777 p++, from++; | |
8778 if (p >= stop) | |
8779 { | |
8780 if (p >= pend) | |
8781 break; | |
8782 stop = pend; | |
8783 p = GAP_END_ADDR; | |
8784 } | |
8785 | |
8786 c = STRING_CHAR_ADVANCE (p); | |
8787 if (! (ASCII_CHAR_P (c) && ascii_compatible) | |
89732
8acde12aba89
(get_translation_table): New function.
Kenichi Handa <handa@m17n.org>
parents:
89730
diff
changeset
|
8788 && ! char_charset (translate_char (translation_table, c), |
8acde12aba89
(get_translation_table): New function.
Kenichi Handa <handa@m17n.org>
parents:
89730
diff
changeset
|
8789 charset_list, NULL)) |
89483 | 8790 { |
8791 positions = Fcons (make_number (from), positions); | |
8792 n--; | |
8793 if (n == 0) | |
8794 break; | |
8795 } | |
8796 | |
8797 from++; | |
8798 } | |
8799 | |
8800 return (NILP (count) ? Fcar (positions) : Fnreverse (positions)); | |
8801 } | |
8802 | |
8803 | |
88365 | 8804 DEFUN ("check-coding-systems-region", Fcheck_coding_systems_region, |
8805 Scheck_coding_systems_region, 3, 3, 0, | |
8806 doc: /* Check if the region is encodable by coding systems. | |
8807 | |
8808 START and END are buffer positions specifying the region. | |
8809 CODING-SYSTEM-LIST is a list of coding systems to check. | |
8810 | |
8811 The value is an alist ((CODING-SYSTEM POS0 POS1 ...) ...), where | |
95088
524350e4961c
(Fcoding_system_p): Rename argument to match docstring.
Juanma Barranquero <lekktu@gmail.com>
parents:
94963
diff
changeset
|
8812 CODING-SYSTEM is a member of CODING-SYSTEM-LIST and can't encode the |
88365 | 8813 whole region, POS0, POS1, ... are buffer positions where non-encodable |
8814 characters are found. | |
8815 | |
8816 If all coding systems in CODING-SYSTEM-LIST can encode the region, the | |
8817 value is nil. | |
8818 | |
8819 START may be a string. In that case, check if the string is | |
8820 encodable, and the value contains indices to the string instead of | |
102055
4d3a5c88cb2b
(Fcheck_coding_systems_region): Fix typo; Qt -> Qnil.
Kenichi Handa <handa@m17n.org>
parents:
101943
diff
changeset
|
8821 buffer positions. END is ignored. |
4d3a5c88cb2b
(Fcheck_coding_systems_region): Fix typo; Qt -> Qnil.
Kenichi Handa <handa@m17n.org>
parents:
101943
diff
changeset
|
8822 |
102058
4f60db600648
(Fcheck_coding_systems_region): Fix test for unibyte
Andreas Schwab <schwab@suse.de>
parents:
102055
diff
changeset
|
8823 If the current buffer (or START if it is a string) is unibyte, the value |
102055
4d3a5c88cb2b
(Fcheck_coding_systems_region): Fix typo; Qt -> Qnil.
Kenichi Handa <handa@m17n.org>
parents:
101943
diff
changeset
|
8824 is nil. */) |
109179
8cfee7d2955f
Convert DEFUNs to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109165
diff
changeset
|
8825 (Lisp_Object start, Lisp_Object end, Lisp_Object coding_system_list) |
88365 | 8826 { |
8827 Lisp_Object list; | |
8828 EMACS_INT start_byte, end_byte; | |
8829 int pos; | |
88876
af9012fdad56
(LEADING_CODE_PRIVATE_11, LEADING_CODE_PRIVATE_12,
Kenichi Handa <handa@m17n.org>
parents:
88862
diff
changeset
|
8830 const unsigned char *p, *pbeg, *pend; |
88365 | 8831 int c; |
89732
8acde12aba89
(get_translation_table): New function.
Kenichi Handa <handa@m17n.org>
parents:
89730
diff
changeset
|
8832 Lisp_Object tail, elt, attrs; |
88365 | 8833 |
8834 if (STRINGP (start)) | |
8835 { | |
8836 if (!STRING_MULTIBYTE (start) | |
102058
4f60db600648
(Fcheck_coding_systems_region): Fix test for unibyte
Andreas Schwab <schwab@suse.de>
parents:
102055
diff
changeset
|
8837 || SCHARS (start) == SBYTES (start)) |
88365 | 8838 return Qnil; |
8839 start_byte = 0; | |
89483 | 8840 end_byte = SBYTES (start); |
88365 | 8841 pos = 0; |
30487
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
8842 } |
46859
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
8843 else |
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
8844 { |
88365 | 8845 CHECK_NUMBER_COERCE_MARKER (start); |
8846 CHECK_NUMBER_COERCE_MARKER (end); | |
8847 if (XINT (start) < BEG || XINT (end) > Z || XINT (start) > XINT (end)) | |
8848 args_out_of_range (start, end); | |
8849 if (NILP (current_buffer->enable_multibyte_characters)) | |
8850 return Qnil; | |
8851 start_byte = CHAR_TO_BYTE (XINT (start)); | |
8852 end_byte = CHAR_TO_BYTE (XINT (end)); | |
8853 if (XINT (end) - XINT (start) == end_byte - start_byte) | |
102055
4d3a5c88cb2b
(Fcheck_coding_systems_region): Fix typo; Qt -> Qnil.
Kenichi Handa <handa@m17n.org>
parents:
101943
diff
changeset
|
8854 return Qnil; |
88365 | 8855 |
89394
6ffca50f25b9
(Fcheck_coding_systems_region): Fix type errors.
Dave Love <fx@gnu.org>
parents:
89373
diff
changeset
|
8856 if (XINT (start) < GPT && XINT (end) > GPT) |
88365 | 8857 { |
89394
6ffca50f25b9
(Fcheck_coding_systems_region): Fix type errors.
Dave Love <fx@gnu.org>
parents:
89373
diff
changeset
|
8858 if ((GPT - XINT (start)) < (XINT (end) - GPT)) |
6ffca50f25b9
(Fcheck_coding_systems_region): Fix type errors.
Dave Love <fx@gnu.org>
parents:
89373
diff
changeset
|
8859 move_gap_both (XINT (start), start_byte); |
88365 | 8860 else |
89394
6ffca50f25b9
(Fcheck_coding_systems_region): Fix type errors.
Dave Love <fx@gnu.org>
parents:
89373
diff
changeset
|
8861 move_gap_both (XINT (end), end_byte); |
88365 | 8862 } |
89394
6ffca50f25b9
(Fcheck_coding_systems_region): Fix type errors.
Dave Love <fx@gnu.org>
parents:
89373
diff
changeset
|
8863 pos = XINT (start); |
88365 | 8864 } |
8865 | |
8866 list = Qnil; | |
8867 for (tail = coding_system_list; CONSP (tail); tail = XCDR (tail)) | |
8868 { | |
8869 elt = XCAR (tail); | |
89732
8acde12aba89
(get_translation_table): New function.
Kenichi Handa <handa@m17n.org>
parents:
89730
diff
changeset
|
8870 attrs = AREF (CODING_SYSTEM_SPEC (elt), 0); |
89861
7160ded23e55
(get_translation_table): Allow max_lookup to be NULL.
Kenichi Handa <handa@m17n.org>
parents:
89859
diff
changeset
|
8871 ASET (attrs, coding_attr_trans_tbl, |
7160ded23e55
(get_translation_table): Allow max_lookup to be NULL.
Kenichi Handa <handa@m17n.org>
parents:
89859
diff
changeset
|
8872 get_translation_table (attrs, 1, NULL)); |
89732
8acde12aba89
(get_translation_table): New function.
Kenichi Handa <handa@m17n.org>
parents:
89730
diff
changeset
|
8873 list = Fcons (Fcons (elt, Fcons (attrs, Qnil)), list); |
88365 | 8874 } |
8875 | |
8876 if (STRINGP (start)) | |
89483 | 8877 p = pbeg = SDATA (start); |
88365 | 8878 else |
8879 p = pbeg = BYTE_POS_ADDR (start_byte); | |
8880 pend = p + (end_byte - start_byte); | |
8881 | |
8882 while (p < pend && ASCII_BYTE_P (*p)) p++, pos++; | |
8883 while (p < pend && ASCII_BYTE_P (*(pend - 1))) pend--; | |
8884 | |
8885 while (p < pend) | |
8886 { | |
8887 if (ASCII_BYTE_P (*p)) | |
8888 p++; | |
46859
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
8889 else |
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
8890 { |
88365 | 8891 c = STRING_CHAR_ADVANCE (p); |
8892 | |
8893 charset_map_loaded = 0; | |
8894 for (tail = list; CONSP (tail); tail = XCDR (tail)) | |
8895 { | |
8896 elt = XCDR (XCAR (tail)); | |
8897 if (! char_encodable_p (c, XCAR (elt))) | |
8898 XSETCDR (elt, Fcons (make_number (pos), XCDR (elt))); | |
8899 } | |
8900 if (charset_map_loaded) | |
8901 { | |
8902 EMACS_INT p_offset = p - pbeg, pend_offset = pend - pbeg; | |
8903 | |
8904 if (STRINGP (start)) | |
89483 | 8905 pbeg = SDATA (start); |
88365 | 8906 else |
8907 pbeg = BYTE_POS_ADDR (start_byte); | |
8908 p = pbeg + p_offset; | |
8909 pend = pbeg + pend_offset; | |
8910 } | |
8911 } | |
8912 pos++; | |
8913 } | |
8914 | |
8915 tail = list; | |
8916 list = Qnil; | |
8917 for (; CONSP (tail); tail = XCDR (tail)) | |
8918 { | |
8919 elt = XCAR (tail); | |
8920 if (CONSP (XCDR (XCDR (elt)))) | |
8921 list = Fcons (Fcons (XCAR (elt), Fnreverse (XCDR (XCDR (elt)))), | |
8922 list); | |
8923 } | |
8924 | |
8925 return list; | |
46859
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
8926 } |
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
8927 |
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
8928 |
20803
0fa2183c587d
(ENCODE_ISO_CHARACTER): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
20794
diff
changeset
|
8929 Lisp_Object |
109159
3e9fdeb960d1
* coding.c, sysdep.c: Convert some more functions to standard C.
Juanma Barranquero <lekktu@gmail.com>
parents:
109158
diff
changeset
|
8930 code_convert_region (Lisp_Object start, Lisp_Object end, |
3e9fdeb960d1
* coding.c, sysdep.c: Convert some more functions to standard C.
Juanma Barranquero <lekktu@gmail.com>
parents:
109158
diff
changeset
|
8931 Lisp_Object coding_system, Lisp_Object dst_object, |
3e9fdeb960d1
* coding.c, sysdep.c: Convert some more functions to standard C.
Juanma Barranquero <lekktu@gmail.com>
parents:
109158
diff
changeset
|
8932 int encodep, int norecord) |
20680
dd46027e8412
(code_convert_region): Always count chars inserted
Richard M. Stallman <rms@gnu.org>
parents:
20668
diff
changeset
|
8933 { |
dd46027e8412
(code_convert_region): Always count chars inserted
Richard M. Stallman <rms@gnu.org>
parents:
20668
diff
changeset
|
8934 struct coding_system coding; |
88365 | 8935 EMACS_INT from, from_byte, to, to_byte; |
8936 Lisp_Object src_object; | |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
8937 |
40656
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents:
40461
diff
changeset
|
8938 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
|
8939 CHECK_NUMBER_COERCE_MARKER (end); |
88365 | 8940 if (NILP (coding_system)) |
8941 coding_system = Qno_conversion; | |
8942 else | |
8943 CHECK_CODING_SYSTEM (coding_system); | |
8944 src_object = Fcurrent_buffer (); | |
8945 if (NILP (dst_object)) | |
8946 dst_object = src_object; | |
8947 else if (! EQ (dst_object, Qt)) | |
8948 CHECK_BUFFER (dst_object); | |
20680
dd46027e8412
(code_convert_region): Always count chars inserted
Richard M. Stallman <rms@gnu.org>
parents:
20668
diff
changeset
|
8949 |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
8950 validate_region (&start, &end); |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
8951 from = XFASTINT (start); |
88365 | 8952 from_byte = CHAR_TO_BYTE (from); |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
8953 to = XFASTINT (end); |
88365 | 8954 to_byte = CHAR_TO_BYTE (to); |
8955 | |
8956 setup_coding_system (coding_system, &coding); | |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
8957 coding.mode |= CODING_MODE_LAST_BLOCK; |
88365 | 8958 |
8959 if (encodep) | |
8960 encode_coding_object (&coding, src_object, from, from_byte, to, to_byte, | |
8961 dst_object); | |
8962 else | |
8963 decode_coding_object (&coding, src_object, from, from_byte, to, to_byte, | |
8964 dst_object); | |
8965 if (! norecord) | |
8966 Vlast_coding_system_used = CODING_ID_NAME (coding.id); | |
8967 | |
8968 return (BUFFERP (dst_object) | |
8969 ? make_number (coding.produced_char) | |
8970 : coding.dst_object); | |
20803
0fa2183c587d
(ENCODE_ISO_CHARACTER): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
20794
diff
changeset
|
8971 } |
0fa2183c587d
(ENCODE_ISO_CHARACTER): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
20794
diff
changeset
|
8972 |
0fa2183c587d
(ENCODE_ISO_CHARACTER): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
20794
diff
changeset
|
8973 |
0fa2183c587d
(ENCODE_ISO_CHARACTER): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
20794
diff
changeset
|
8974 DEFUN ("decode-coding-region", Fdecode_coding_region, Sdecode_coding_region, |
88365 | 8975 3, 4, "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
|
8976 doc: /* Decode the current region from the specified coding system. |
88365 | 8977 When called from a program, takes four arguments: |
8978 START, END, CODING-SYSTEM, and DESTINATION. | |
8979 START and END are buffer positions. | |
8980 | |
8981 Optional 4th arguments DESTINATION specifies where the decoded text goes. | |
91083
ff87badce376
(Fdecode_coding_region): Fix typo in docstring.
Kenichi Handa <handa@m17n.org>
parents:
91056
diff
changeset
|
8982 If nil, the region between START and END is replaced by the decoded text. |
98992
d4659edb9b7b
(Fencode_coding_region, Fdecode_coding_region)
Eli Zaretskii <eliz@gnu.org>
parents:
98951
diff
changeset
|
8983 If buffer, the decoded text is inserted in that buffer after point (point |
d4659edb9b7b
(Fencode_coding_region, Fdecode_coding_region)
Eli Zaretskii <eliz@gnu.org>
parents:
98951
diff
changeset
|
8984 does not move). |
95356
90b4a0dc21cc
(Fdecode_coding_region, Fencode_coding_region, Fencode_coding_string):
Juanma Barranquero <lekktu@gmail.com>
parents:
95353
diff
changeset
|
8985 In those cases, the length of the decoded text is returned. |
95353
96d35f50fe34
(encode_coding_raw_text): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
95345
diff
changeset
|
8986 If DESTINATION is t, the decoded text is returned. |
88365 | 8987 |
40713
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
8988 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
|
8989 used (which may be different from CODING-SYSTEM if CODING-SYSTEM is |
95353
96d35f50fe34
(encode_coding_raw_text): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
95345
diff
changeset
|
8990 not fully specified.) */) |
109179
8cfee7d2955f
Convert DEFUNs to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109165
diff
changeset
|
8991 (Lisp_Object start, Lisp_Object end, Lisp_Object coding_system, Lisp_Object destination) |
20803
0fa2183c587d
(ENCODE_ISO_CHARACTER): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
20794
diff
changeset
|
8992 { |
88365 | 8993 return code_convert_region (start, end, coding_system, destination, 0, 0); |
20680
dd46027e8412
(code_convert_region): Always count chars inserted
Richard M. Stallman <rms@gnu.org>
parents:
20668
diff
changeset
|
8994 } |
dd46027e8412
(code_convert_region): Always count chars inserted
Richard M. Stallman <rms@gnu.org>
parents:
20668
diff
changeset
|
8995 |
dd46027e8412
(code_convert_region): Always count chars inserted
Richard M. Stallman <rms@gnu.org>
parents:
20668
diff
changeset
|
8996 DEFUN ("encode-coding-region", Fencode_coding_region, Sencode_coding_region, |
88365 | 8997 3, 4, "r\nzCoding system: ", |
8998 doc: /* Encode the current region by specified coding system. | |
95088
524350e4961c
(Fcoding_system_p): Rename argument to match docstring.
Juanma Barranquero <lekktu@gmail.com>
parents:
94963
diff
changeset
|
8999 When called from a program, takes four arguments: |
524350e4961c
(Fcoding_system_p): Rename argument to match docstring.
Juanma Barranquero <lekktu@gmail.com>
parents:
94963
diff
changeset
|
9000 START, END, CODING-SYSTEM and DESTINATION. |
524350e4961c
(Fcoding_system_p): Rename argument to match docstring.
Juanma Barranquero <lekktu@gmail.com>
parents:
94963
diff
changeset
|
9001 START and END are buffer positions. |
88365 | 9002 |
9003 Optional 4th arguments DESTINATION specifies where the encoded text goes. | |
9004 If nil, the region between START and END is replace by the encoded text. | |
98992
d4659edb9b7b
(Fencode_coding_region, Fdecode_coding_region)
Eli Zaretskii <eliz@gnu.org>
parents:
98951
diff
changeset
|
9005 If buffer, the encoded text is inserted in that buffer after point (point |
d4659edb9b7b
(Fencode_coding_region, Fdecode_coding_region)
Eli Zaretskii <eliz@gnu.org>
parents:
98951
diff
changeset
|
9006 does not move). |
95356
90b4a0dc21cc
(Fdecode_coding_region, Fencode_coding_region, Fencode_coding_string):
Juanma Barranquero <lekktu@gmail.com>
parents:
95353
diff
changeset
|
9007 In those cases, the length of the encoded text is returned. |
95353
96d35f50fe34
(encode_coding_raw_text): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
95345
diff
changeset
|
9008 If DESTINATION is t, the encoded text is returned. |
88365 | 9009 |
40713
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
9010 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
|
9011 used (which may be different from CODING-SYSTEM if CODING-SYSTEM is |
95353
96d35f50fe34
(encode_coding_raw_text): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
95345
diff
changeset
|
9012 not fully specified.) */) |
109179
8cfee7d2955f
Convert DEFUNs to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109165
diff
changeset
|
9013 (Lisp_Object start, Lisp_Object end, Lisp_Object coding_system, Lisp_Object destination) |
20680
dd46027e8412
(code_convert_region): Always count chars inserted
Richard M. Stallman <rms@gnu.org>
parents:
20668
diff
changeset
|
9014 { |
88365 | 9015 return code_convert_region (start, end, coding_system, destination, 1, 0); |
17052 | 9016 } |
9017 | |
20803
0fa2183c587d
(ENCODE_ISO_CHARACTER): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
20794
diff
changeset
|
9018 Lisp_Object |
109360
f37b85834f7e
Convert more function definitions to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109179
diff
changeset
|
9019 code_convert_string (Lisp_Object string, Lisp_Object coding_system, |
f37b85834f7e
Convert more function definitions to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109179
diff
changeset
|
9020 Lisp_Object dst_object, int encodep, int nocopy, int norecord) |
17052 | 9021 { |
9022 struct coding_system coding; | |
88365 | 9023 EMACS_INT chars, bytes; |
17052 | 9024 |
40656
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents:
40461
diff
changeset
|
9025 CHECK_STRING (string); |
88365 | 9026 if (NILP (coding_system)) |
9027 { | |
9028 if (! norecord) | |
9029 Vlast_coding_system_used = Qno_conversion; | |
9030 if (NILP (dst_object)) | |
9031 return (nocopy ? Fcopy_sequence (string) : string); | |
9032 } | |
17052 | 9033 |
70520
b6740a317343
(setup_coding_system): For invalid coding-system, set
Kenichi Handa <handa@m17n.org>
parents:
69995
diff
changeset
|
9034 if (NILP (coding_system)) |
88365 | 9035 coding_system = Qno_conversion; |
9036 else | |
9037 CHECK_CODING_SYSTEM (coding_system); | |
9038 if (NILP (dst_object)) | |
9039 dst_object = Qt; | |
9040 else if (! EQ (dst_object, Qt)) | |
9041 CHECK_BUFFER (dst_object); | |
9042 | |
9043 setup_coding_system (coding_system, &coding); | |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
9044 coding.mode |= CODING_MODE_LAST_BLOCK; |
89483 | 9045 chars = SCHARS (string); |
9046 bytes = SBYTES (string); | |
88365 | 9047 if (encodep) |
9048 encode_coding_object (&coding, string, 0, 0, chars, bytes, dst_object); | |
9049 else | |
9050 decode_coding_object (&coding, string, 0, 0, chars, bytes, dst_object); | |
9051 if (! norecord) | |
9052 Vlast_coding_system_used = CODING_ID_NAME (coding.id); | |
9053 | |
9054 return (BUFFERP (dst_object) | |
9055 ? make_number (coding.produced_char) | |
9056 : coding.dst_object); | |
20803
0fa2183c587d
(ENCODE_ISO_CHARACTER): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
20794
diff
changeset
|
9057 } |
0fa2183c587d
(ENCODE_ISO_CHARACTER): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
20794
diff
changeset
|
9058 |
0fa2183c587d
(ENCODE_ISO_CHARACTER): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
20794
diff
changeset
|
9059 |
22341
572ba933a4bf
(code_convert_string_norecord): New function.
Karl Heuer <kwzh@gnu.org>
parents:
22329
diff
changeset
|
9060 /* Encode or decode STRING according to CODING_SYSTEM. |
26847 | 9061 Do not set Vlast_coding_system_used. |
9062 | |
9063 This function is called only from macros DECODE_FILE and | |
9064 ENCODE_FILE, thus we ignore character composition. */ | |
22341
572ba933a4bf
(code_convert_string_norecord): New function.
Karl Heuer <kwzh@gnu.org>
parents:
22329
diff
changeset
|
9065 |
572ba933a4bf
(code_convert_string_norecord): New function.
Karl Heuer <kwzh@gnu.org>
parents:
22329
diff
changeset
|
9066 Lisp_Object |
109159
3e9fdeb960d1
* coding.c, sysdep.c: Convert some more functions to standard C.
Juanma Barranquero <lekktu@gmail.com>
parents:
109158
diff
changeset
|
9067 code_convert_string_norecord (Lisp_Object string, Lisp_Object coding_system, |
3e9fdeb960d1
* coding.c, sysdep.c: Convert some more functions to standard C.
Juanma Barranquero <lekktu@gmail.com>
parents:
109158
diff
changeset
|
9068 int encodep) |
22341
572ba933a4bf
(code_convert_string_norecord): New function.
Karl Heuer <kwzh@gnu.org>
parents:
22329
diff
changeset
|
9069 { |
88430
6418a272b97e
* coding.c: Delete unused variables.
Kenichi Handa <handa@m17n.org>
parents:
88365
diff
changeset
|
9070 return code_convert_string (string, coding_system, Qt, encodep, 0, 1); |
22341
572ba933a4bf
(code_convert_string_norecord): New function.
Karl Heuer <kwzh@gnu.org>
parents:
22329
diff
changeset
|
9071 } |
88365 | 9072 |
9073 | |
9074 DEFUN ("decode-coding-string", Fdecode_coding_string, Sdecode_coding_string, | |
9075 2, 4, 0, | |
9076 doc: /* Decode STRING which is encoded in CODING-SYSTEM, and return the result. | |
9077 | |
9078 Optional third arg NOCOPY non-nil means it is OK to return STRING itself | |
9079 if the decoding operation is trivial. | |
9080 | |
95088
524350e4961c
(Fcoding_system_p): Rename argument to match docstring.
Juanma Barranquero <lekktu@gmail.com>
parents:
94963
diff
changeset
|
9081 Optional fourth arg BUFFER non-nil means that the decoded text is |
98992
d4659edb9b7b
(Fencode_coding_region, Fdecode_coding_region)
Eli Zaretskii <eliz@gnu.org>
parents:
98951
diff
changeset
|
9082 inserted in that buffer after point (point does not move). In this |
d4659edb9b7b
(Fencode_coding_region, Fdecode_coding_region)
Eli Zaretskii <eliz@gnu.org>
parents:
98951
diff
changeset
|
9083 case, the return value is the length of the decoded text. |
88365 | 9084 |
9085 This function sets `last-coding-system-used' to the precise coding system | |
9086 used (which may be different from CODING-SYSTEM if CODING-SYSTEM is | |
95088
524350e4961c
(Fcoding_system_p): Rename argument to match docstring.
Juanma Barranquero <lekktu@gmail.com>
parents:
94963
diff
changeset
|
9087 not fully specified.) */) |
109179
8cfee7d2955f
Convert DEFUNs to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109165
diff
changeset
|
9088 (Lisp_Object string, Lisp_Object coding_system, Lisp_Object nocopy, Lisp_Object buffer) |
88365 | 9089 { |
9090 return code_convert_string (string, coding_system, buffer, | |
9091 0, ! NILP (nocopy), 0); | |
9092 } | |
9093 | |
9094 DEFUN ("encode-coding-string", Fencode_coding_string, Sencode_coding_string, | |
9095 2, 4, 0, | |
9096 doc: /* Encode STRING to CODING-SYSTEM, and return the result. | |
9097 | |
9098 Optional third arg NOCOPY non-nil means it is OK to return STRING | |
9099 itself if the encoding operation is trivial. | |
9100 | |
95088
524350e4961c
(Fcoding_system_p): Rename argument to match docstring.
Juanma Barranquero <lekktu@gmail.com>
parents:
94963
diff
changeset
|
9101 Optional fourth arg BUFFER non-nil means that the encoded text is |
98992
d4659edb9b7b
(Fencode_coding_region, Fdecode_coding_region)
Eli Zaretskii <eliz@gnu.org>
parents:
98951
diff
changeset
|
9102 inserted in that buffer after point (point does not move). In this |
d4659edb9b7b
(Fencode_coding_region, Fdecode_coding_region)
Eli Zaretskii <eliz@gnu.org>
parents:
98951
diff
changeset
|
9103 case, the return value is the length of the encoded text. |
88365 | 9104 |
9105 This function sets `last-coding-system-used' to the precise coding system | |
9106 used (which may be different from CODING-SYSTEM if CODING-SYSTEM is | |
9107 not fully specified.) */) | |
109179
8cfee7d2955f
Convert DEFUNs to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109165
diff
changeset
|
9108 (Lisp_Object string, Lisp_Object coding_system, Lisp_Object nocopy, Lisp_Object buffer) |
88365 | 9109 { |
9110 return code_convert_string (string, coding_system, buffer, | |
88856 | 9111 1, ! NILP (nocopy), 1); |
88365 | 9112 } |
9113 | |
20680
dd46027e8412
(code_convert_region): Always count chars inserted
Richard M. Stallman <rms@gnu.org>
parents:
20668
diff
changeset
|
9114 |
17052 | 9115 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
|
9116 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
|
9117 Return the corresponding character. */) |
109179
8cfee7d2955f
Convert DEFUNs to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109165
diff
changeset
|
9118 (Lisp_Object code) |
17052 | 9119 { |
88365 | 9120 Lisp_Object spec, attrs, val; |
9121 struct charset *charset_roman, *charset_kanji, *charset_kana, *charset; | |
9122 int c; | |
9123 | |
9124 CHECK_NATNUM (code); | |
9125 c = XFASTINT (code); | |
9126 CHECK_CODING_SYSTEM_GET_SPEC (Vsjis_coding_system, spec); | |
9127 attrs = AREF (spec, 0); | |
9128 | |
9129 if (ASCII_BYTE_P (c) | |
9130 && ! NILP (CODING_ATTR_ASCII_COMPAT (attrs))) | |
9131 return code; | |
9132 | |
9133 val = CODING_ATTR_CHARSET_LIST (attrs); | |
9134 charset_roman = CHARSET_FROM_ID (XINT (XCAR (val))), val = XCDR (val); | |
88497
d2b9e0d4c2f6
(Fdecode_sjis_char): Fix typo (0x7F->0xFF). Fix the
Kenichi Handa <handa@m17n.org>
parents:
88485
diff
changeset
|
9135 charset_kana = CHARSET_FROM_ID (XINT (XCAR (val))), val = XCDR (val); |
d2b9e0d4c2f6
(Fdecode_sjis_char): Fix typo (0x7F->0xFF). Fix the
Kenichi Handa <handa@m17n.org>
parents:
88485
diff
changeset
|
9136 charset_kanji = CHARSET_FROM_ID (XINT (XCAR (val))); |
88365 | 9137 |
9138 if (c <= 0x7F) | |
9139 charset = charset_roman; | |
9140 else if (c >= 0xA0 && c < 0xDF) | |
9141 { | |
9142 charset = charset_kana; | |
9143 c -= 0x80; | |
24065
7e291dea6141
(Fdecode_sjis_char): Decode Japanese Katakana character
Kenichi Handa <handa@m17n.org>
parents:
24056
diff
changeset
|
9144 } |
7e291dea6141
(Fdecode_sjis_char): Decode Japanese Katakana character
Kenichi Handa <handa@m17n.org>
parents:
24056
diff
changeset
|
9145 else |
7e291dea6141
(Fdecode_sjis_char): Decode Japanese Katakana character
Kenichi Handa <handa@m17n.org>
parents:
24056
diff
changeset
|
9146 { |
88497
d2b9e0d4c2f6
(Fdecode_sjis_char): Fix typo (0x7F->0xFF). Fix the
Kenichi Handa <handa@m17n.org>
parents:
88485
diff
changeset
|
9147 int s1 = c >> 8, s2 = c & 0xFF; |
88365 | 9148 |
9149 if (s1 < 0x81 || (s1 > 0x9F && s1 < 0xE0) || s1 > 0xEF | |
9150 || s2 < 0x40 || s2 == 0x7F || s2 > 0xFC) | |
9151 error ("Invalid code: %d", code); | |
9152 SJIS_TO_JIS (c); | |
9153 charset = charset_kanji; | |
9154 } | |
9155 c = DECODE_CHAR (charset, c); | |
9156 if (c < 0) | |
9157 error ("Invalid code: %d", code); | |
9158 return make_number (c); | |
17052 | 9159 } |
9160 | |
9161 | |
9162 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
|
9163 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
|
9164 Return the corresponding code in SJIS. */) |
109179
8cfee7d2955f
Convert DEFUNs to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109165
diff
changeset
|
9165 (Lisp_Object ch) |
17052 | 9166 { |
88365 | 9167 Lisp_Object spec, attrs, charset_list; |
9168 int c; | |
9169 struct charset *charset; | |
9170 unsigned code; | |
9171 | |
9172 CHECK_CHARACTER (ch); | |
9173 c = XFASTINT (ch); | |
9174 CHECK_CODING_SYSTEM_GET_SPEC (Vsjis_coding_system, spec); | |
9175 attrs = AREF (spec, 0); | |
9176 | |
9177 if (ASCII_CHAR_P (c) | |
9178 && ! NILP (CODING_ATTR_ASCII_COMPAT (attrs))) | |
9179 return ch; | |
9180 | |
9181 charset_list = CODING_ATTR_CHARSET_LIST (attrs); | |
9182 charset = char_charset (c, charset_list, &code); | |
9183 if (code == CHARSET_INVALID_CODE (charset)) | |
9184 error ("Can't encode by shift_jis encoding: %d", c); | |
9185 JIS_TO_SJIS (code); | |
9186 | |
9187 return make_number (code); | |
17052 | 9188 } |
9189 | |
9190 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
|
9191 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
|
9192 Return the corresponding character. */) |
109179
8cfee7d2955f
Convert DEFUNs to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109165
diff
changeset
|
9193 (Lisp_Object code) |
17052 | 9194 { |
88365 | 9195 Lisp_Object spec, attrs, val; |
9196 struct charset *charset_roman, *charset_big5, *charset; | |
9197 int c; | |
9198 | |
9199 CHECK_NATNUM (code); | |
9200 c = XFASTINT (code); | |
9201 CHECK_CODING_SYSTEM_GET_SPEC (Vbig5_coding_system, spec); | |
9202 attrs = AREF (spec, 0); | |
9203 | |
9204 if (ASCII_BYTE_P (c) | |
9205 && ! NILP (CODING_ATTR_ASCII_COMPAT (attrs))) | |
9206 return code; | |
9207 | |
9208 val = CODING_ATTR_CHARSET_LIST (attrs); | |
9209 charset_roman = CHARSET_FROM_ID (XINT (XCAR (val))), val = XCDR (val); | |
9210 charset_big5 = CHARSET_FROM_ID (XINT (XCAR (val))); | |
9211 | |
9212 if (c <= 0x7F) | |
9213 charset = charset_roman; | |
24324
2eec590faf26
(Fdecode_sjis_char, Fencode_sjis_char): Hanlde
Kenichi Handa <handa@m17n.org>
parents:
24316
diff
changeset
|
9214 else |
2eec590faf26
(Fdecode_sjis_char, Fencode_sjis_char): Hanlde
Kenichi Handa <handa@m17n.org>
parents:
24316
diff
changeset
|
9215 { |
88365 | 9216 int b1 = c >> 8, b2 = c & 0x7F; |
9217 if (b1 < 0xA1 || b1 > 0xFE | |
9218 || b2 < 0x40 || (b2 > 0x7E && b2 < 0xA1) || b2 > 0xFE) | |
9219 error ("Invalid code: %d", code); | |
9220 charset = charset_big5; | |
9221 } | |
9222 c = DECODE_CHAR (charset, (unsigned )c); | |
9223 if (c < 0) | |
9224 error ("Invalid code: %d", code); | |
9225 return make_number (c); | |
17052 | 9226 } |
9227 | |
9228 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
|
9229 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
|
9230 Return the corresponding character code in Big5. */) |
109179
8cfee7d2955f
Convert DEFUNs to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109165
diff
changeset
|
9231 (Lisp_Object ch) |
17052 | 9232 { |
88365 | 9233 Lisp_Object spec, attrs, charset_list; |
9234 struct charset *charset; | |
9235 int c; | |
9236 unsigned code; | |
9237 | |
9238 CHECK_CHARACTER (ch); | |
9239 c = XFASTINT (ch); | |
9240 CHECK_CODING_SYSTEM_GET_SPEC (Vbig5_coding_system, spec); | |
9241 attrs = AREF (spec, 0); | |
9242 if (ASCII_CHAR_P (c) | |
9243 && ! NILP (CODING_ATTR_ASCII_COMPAT (attrs))) | |
9244 return ch; | |
9245 | |
9246 charset_list = CODING_ATTR_CHARSET_LIST (attrs); | |
9247 charset = char_charset (c, charset_list, &code); | |
9248 if (code == CHARSET_INVALID_CODE (charset)) | |
9249 error ("Can't encode by Big5 encoding: %d", c); | |
9250 | |
9251 return make_number (code); | |
17052 | 9252 } |
88365 | 9253 |
20680
dd46027e8412
(code_convert_region): Always count chars inserted
Richard M. Stallman <rms@gnu.org>
parents:
20668
diff
changeset
|
9254 |
48182
9474e269efd1
Reformat some DEFUNs so that etags works.
Dave Love <fx@gnu.org>
parents:
48125
diff
changeset
|
9255 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
|
9256 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
|
9257 doc: /* Internal use only. */) |
109179
8cfee7d2955f
Convert DEFUNs to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109165
diff
changeset
|
9258 (Lisp_Object coding_system, Lisp_Object terminal) |
17052 | 9259 { |
83431
76396de7f50a
Rename `struct device' to `struct terminal'. Rename some terminal-related functions similarly.
Karoly Lorentey <lorentey@elte.hu>
parents:
83423
diff
changeset
|
9260 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
|
9261 CHECK_SYMBOL (coding_system); |
83127
5182815e0ee1
Make terminal_coding and keyboard_coding display-local.
Karoly Lorentey <lorentey@elte.hu>
parents:
54320
diff
changeset
|
9262 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
|
9263 /* We had better not send unsafe characters to terminal. */ |
91041 | 9264 terminal_coding->mode |= CODING_MODE_SAFE_ENCODING; |
88365 | 9265 /* Characer composition should be disabled. */ |
91041 | 9266 terminal_coding->common_flags &= ~CODING_ANNOTATE_COMPOSITION_MASK; |
83127
5182815e0ee1
Make terminal_coding and keyboard_coding display-local.
Karoly Lorentey <lorentey@elte.hu>
parents:
54320
diff
changeset
|
9267 terminal_coding->src_multibyte = 1; |
5182815e0ee1
Make terminal_coding and keyboard_coding display-local.
Karoly Lorentey <lorentey@elte.hu>
parents:
54320
diff
changeset
|
9268 terminal_coding->dst_multibyte = 0; |
17052 | 9269 return Qnil; |
9270 } | |
9271 | |
19280
e755044718ee
(ENCODE_ISO_CHARACTER_DIMENSION1): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
19193
diff
changeset
|
9272 DEFUN ("set-safe-terminal-coding-system-internal", |
e755044718ee
(ENCODE_ISO_CHARACTER_DIMENSION1): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
19193
diff
changeset
|
9273 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
|
9274 Sset_safe_terminal_coding_system_internal, 1, 1, 0, |
41006 | 9275 doc: /* Internal use only. */) |
109179
8cfee7d2955f
Convert DEFUNs to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109165
diff
changeset
|
9276 (Lisp_Object coding_system) |
19280
e755044718ee
(ENCODE_ISO_CHARACTER_DIMENSION1): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
19193
diff
changeset
|
9277 { |
40656
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents:
40461
diff
changeset
|
9278 CHECK_SYMBOL (coding_system); |
19280
e755044718ee
(ENCODE_ISO_CHARACTER_DIMENSION1): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
19193
diff
changeset
|
9279 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
|
9280 &safe_terminal_coding); |
88365 | 9281 /* Characer composition should be disabled. */ |
9282 safe_terminal_coding.common_flags &= ~CODING_ANNOTATE_COMPOSITION_MASK; | |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
9283 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
|
9284 safe_terminal_coding.dst_multibyte = 0; |
19280
e755044718ee
(ENCODE_ISO_CHARACTER_DIMENSION1): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
19193
diff
changeset
|
9285 return Qnil; |
e755044718ee
(ENCODE_ISO_CHARACTER_DIMENSION1): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
19193
diff
changeset
|
9286 } |
e755044718ee
(ENCODE_ISO_CHARACTER_DIMENSION1): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
19193
diff
changeset
|
9287 |
48182
9474e269efd1
Reformat some DEFUNs so that etags works.
Dave Love <fx@gnu.org>
parents:
48125
diff
changeset
|
9288 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
|
9289 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
|
9290 doc: /* Return coding system specified for terminal output on the given terminal. |
103052
e68707cf48a5
* keyboard.c (Fset_input_meta_mode): Doc fix.
Chong Yidong <cyd@stupidchicken.com>
parents:
103035
diff
changeset
|
9291 TERMINAL may be a terminal object, a frame, or nil for the selected |
83431
76396de7f50a
Rename `struct device' to `struct terminal'. Rename some terminal-related functions similarly.
Karoly Lorentey <lorentey@elte.hu>
parents:
83423
diff
changeset
|
9292 frame's terminal device. */) |
109179
8cfee7d2955f
Convert DEFUNs to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109165
diff
changeset
|
9293 (Lisp_Object terminal) |
17052 | 9294 { |
91046 | 9295 struct coding_system *terminal_coding |
9296 = TERMINAL_TERMINAL_CODING (get_terminal (terminal, 1)); | |
9297 Lisp_Object coding_system = CODING_ID_NAME (terminal_coding->id); | |
9298 | |
90011
26cef35a1562
(setup_coding_system): If coding_system is nil, use
Kenichi Handa <handa@m17n.org>
parents:
89976
diff
changeset
|
9299 /* For backward compatibility, return nil if it is `undecided'. */ |
90359
041f75914d0c
(produce_composition): Compare charbuf[i] instead of
Kenichi Handa <handa@m17n.org>
parents:
90354
diff
changeset
|
9300 return (! EQ (coding_system, Qundecided) ? coding_system : Qnil); |
17052 | 9301 } |
9302 | |
48182
9474e269efd1
Reformat some DEFUNs so that etags works.
Dave Love <fx@gnu.org>
parents:
48125
diff
changeset
|
9303 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
|
9304 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
|
9305 doc: /* Internal use only. */) |
109179
8cfee7d2955f
Convert DEFUNs to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109165
diff
changeset
|
9306 (Lisp_Object coding_system, Lisp_Object terminal) |
17052 | 9307 { |
83431
76396de7f50a
Rename `struct device' to `struct terminal'. Rename some terminal-related functions similarly.
Karoly Lorentey <lorentey@elte.hu>
parents:
83423
diff
changeset
|
9308 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
|
9309 CHECK_SYMBOL (coding_system); |
103655
e2d67c929da2
(setup_coding_system): Initialize
Kenichi Handa <handa@m17n.org>
parents:
103486
diff
changeset
|
9310 if (NILP (coding_system)) |
e2d67c929da2
(setup_coding_system): Initialize
Kenichi Handa <handa@m17n.org>
parents:
103486
diff
changeset
|
9311 coding_system = Qno_conversion; |
e2d67c929da2
(setup_coding_system): Initialize
Kenichi Handa <handa@m17n.org>
parents:
103486
diff
changeset
|
9312 else |
e2d67c929da2
(setup_coding_system): Initialize
Kenichi Handa <handa@m17n.org>
parents:
103486
diff
changeset
|
9313 Fcheck_coding_system (coding_system); |
e2d67c929da2
(setup_coding_system): Initialize
Kenichi Handa <handa@m17n.org>
parents:
103486
diff
changeset
|
9314 setup_coding_system (coding_system, TERMINAL_KEYBOARD_CODING (t)); |
88365 | 9315 /* Characer composition should be disabled. */ |
91041 | 9316 TERMINAL_KEYBOARD_CODING (t)->common_flags |
9317 &= ~CODING_ANNOTATE_COMPOSITION_MASK; | |
17052 | 9318 return Qnil; |
9319 } | |
9320 | |
9321 DEFUN ("keyboard-coding-system", | |
91046 | 9322 Fkeyboard_coding_system, Skeyboard_coding_system, 0, 1, 0, |
40713
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
9323 doc: /* Return coding system specified for decoding keyboard input. */) |
109179
8cfee7d2955f
Convert DEFUNs to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109165
diff
changeset
|
9324 (Lisp_Object terminal) |
17052 | 9325 { |
91046 | 9326 return CODING_ID_NAME (TERMINAL_KEYBOARD_CODING |
9327 (get_terminal (terminal, 1))->id); | |
17052 | 9328 } |
9329 | |
9330 | |
18536
69c0e220b626
(Vstandard_character_unification_table_for_decode):
Kenichi Handa <handa@m17n.org>
parents:
18523
diff
changeset
|
9331 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
|
9332 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
|
9333 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
|
9334 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
|
9335 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
|
9336 \(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
|
9337 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
|
9338 |
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
9339 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
|
9340 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
|
9341 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
|
9342 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
|
9343 |
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
9344 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
|
9345 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
|
9346 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
|
9347 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
|
9348 |
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
9349 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
|
9350 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
|
9351 For process I/O, TARGET is a process name. |
95088
524350e4961c
(Fcoding_system_p): Rename argument to match docstring.
Juanma Barranquero <lekktu@gmail.com>
parents:
94963
diff
changeset
|
9352 For network I/O, TARGET is a service name or a port number. |
524350e4961c
(Fcoding_system_p): Rename argument to match docstring.
Juanma Barranquero <lekktu@gmail.com>
parents:
94963
diff
changeset
|
9353 |
524350e4961c
(Fcoding_system_p): Rename argument to match docstring.
Juanma Barranquero <lekktu@gmail.com>
parents:
94963
diff
changeset
|
9354 This function looks up what is specified for TARGET in |
40713
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
9355 `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
|
9356 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
|
9357 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
|
9358 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
|
9359 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
|
9360 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
|
9361 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
|
9362 `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
|
9363 |
70948
7ea8b1c11d80
(Ffind_operation_coding_system): Allow (FILENAME . BUFFER) in TARGET.
Kenichi Handa <handa@m17n.org>
parents:
70704
diff
changeset
|
9364 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
|
9365 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
|
9366 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
|
9367 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
|
9368 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
|
9369 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
|
9370 |
78152
5e5f359984e5
(Ffind_operation_coding_system): Doc fix.
Juanma Barranquero <lekktu@gmail.com>
parents:
75348
diff
changeset
|
9371 usage: (find-operation-coding-system OPERATION ARGUMENTS...) */) |
109179
8cfee7d2955f
Convert DEFUNs to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109165
diff
changeset
|
9372 (int nargs, Lisp_Object *args) |
17052 | 9373 { |
9374 Lisp_Object operation, target_idx, target, val; | |
9375 register Lisp_Object chain; | |
9376 | |
9377 if (nargs < 2) | |
9378 error ("Too few arguments"); | |
9379 operation = args[0]; | |
9380 if (!SYMBOLP (operation) | |
9381 || !INTEGERP (target_idx = Fget (operation, Qtarget_idx))) | |
93877
62d97ebb13a9
* coding.c (detect_coding_emacs_mule)
Michael Albinus <michael.albinus@gmx.de>
parents:
93595
diff
changeset
|
9382 error ("Invalid first argument"); |
17052 | 9383 if (nargs < 1 + XINT (target_idx)) |
9384 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
|
9385 SDATA (SYMBOL_NAME (operation))); |
17052 | 9386 target = args[XINT (target_idx) + 1]; |
9387 if (!(STRINGP (target) | |
70948
7ea8b1c11d80
(Ffind_operation_coding_system): Allow (FILENAME . BUFFER) in TARGET.
Kenichi Handa <handa@m17n.org>
parents:
70704
diff
changeset
|
9388 || (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
|
9389 && STRINGP (XCAR (target)) && BUFFERP (XCDR (target))) |
17052 | 9390 || (EQ (operation, Qopen_network_stream) && INTEGERP (target)))) |
88365 | 9391 error ("Invalid %dth argument", XINT (target_idx) + 1); |
70948
7ea8b1c11d80
(Ffind_operation_coding_system): Allow (FILENAME . BUFFER) in TARGET.
Kenichi Handa <handa@m17n.org>
parents:
70704
diff
changeset
|
9392 if (CONSP (target)) |
7ea8b1c11d80
(Ffind_operation_coding_system): Allow (FILENAME . BUFFER) in TARGET.
Kenichi Handa <handa@m17n.org>
parents:
70704
diff
changeset
|
9393 target = XCAR (target); |
17052 | 9394 |
18613
614b916ff5bf
Fix bugs with inappropriate mixing of Lisp_Object with int.
Richard M. Stallman <rms@gnu.org>
parents:
18536
diff
changeset
|
9395 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
|
9396 || EQ (operation, Qwrite_region)) |
18180
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
9397 ? 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
|
9398 : (EQ (operation, Qopen_network_stream) |
18180
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
9399 ? Vnetwork_coding_system_alist |
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
9400 : Vprocess_coding_system_alist)); |
17052 | 9401 if (NILP (chain)) |
9402 return Qnil; | |
9403 | |
25662
0a7261c1d487
Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25370
diff
changeset
|
9404 for (; CONSP (chain); chain = XCDR (chain)) |
17052 | 9405 { |
19747
bed06df9cbc5
(setup_coding_system, Ffind_operation_coding_system)
Richard M. Stallman <rms@gnu.org>
parents:
19743
diff
changeset
|
9406 Lisp_Object elt; |
88365 | 9407 |
25662
0a7261c1d487
Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25370
diff
changeset
|
9408 elt = XCAR (chain); |
17052 | 9409 if (CONSP (elt) |
9410 && ((STRINGP (target) | |
25662
0a7261c1d487
Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25370
diff
changeset
|
9411 && STRINGP (XCAR (elt)) |
0a7261c1d487
Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25370
diff
changeset
|
9412 && 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
|
9413 || (INTEGERP (target) && EQ (target, XCAR (elt))))) |
18180
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
9414 { |
25662
0a7261c1d487
Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25370
diff
changeset
|
9415 val = XCDR (elt); |
19763
ab2fd2c85986
(Ffind_operation_coding_system): If a function in
Kenichi Handa <handa@m17n.org>
parents:
19758
diff
changeset
|
9416 /* 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
|
9417 function symbol, we return VAL as a coding system. */ |
18180
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
9418 if (CONSP (val)) |
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
9419 return val; |
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
9420 if (! SYMBOLP (val)) |
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
9421 return Qnil; |
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
9422 if (! NILP (Fcoding_system_p (val))) |
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
9423 return Fcons (val, val); |
19763
ab2fd2c85986
(Ffind_operation_coding_system): If a function in
Kenichi Handa <handa@m17n.org>
parents:
19758
diff
changeset
|
9424 if (! NILP (Ffboundp (val))) |
ab2fd2c85986
(Ffind_operation_coding_system): If a function in
Kenichi Handa <handa@m17n.org>
parents:
19758
diff
changeset
|
9425 { |
72188 | 9426 /* We use call1 rather than safe_call1 |
9427 so as to get bug reports about functions called here | |
9428 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
|
9429 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
|
9430 if (CONSP (val)) |
ab2fd2c85986
(Ffind_operation_coding_system): If a function in
Kenichi Handa <handa@m17n.org>
parents:
19758
diff
changeset
|
9431 return val; |
ab2fd2c85986
(Ffind_operation_coding_system): If a function in
Kenichi Handa <handa@m17n.org>
parents:
19758
diff
changeset
|
9432 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
|
9433 return Fcons (val, val); |
ab2fd2c85986
(Ffind_operation_coding_system): If a function in
Kenichi Handa <handa@m17n.org>
parents:
19758
diff
changeset
|
9434 } |
18180
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
9435 return Qnil; |
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
9436 } |
17052 | 9437 } |
9438 return Qnil; | |
9439 } | |
9440 | |
88365 | 9441 DEFUN ("set-coding-system-priority", Fset_coding_system_priority, |
88845
64b8f6168269
(Fset_coding_system_priority): Allow null arg list.
Dave Love <fx@gnu.org>
parents:
88771
diff
changeset
|
9442 Sset_coding_system_priority, 0, MANY, 0, |
88645 | 9443 doc: /* Assign higher priority to the coding systems given as arguments. |
95088
524350e4961c
(Fcoding_system_p): Rename argument to match docstring.
Juanma Barranquero <lekktu@gmail.com>
parents:
94963
diff
changeset
|
9444 If multiple coding systems belong to the same category, |
89519
040a08a2a879
(Fread_coding_system): Fix arg of XSETSTRING.
Dave Love <fx@gnu.org>
parents:
89483
diff
changeset
|
9445 all but the first one are ignored. |
040a08a2a879
(Fread_coding_system): Fix arg of XSETSTRING.
Dave Love <fx@gnu.org>
parents:
89483
diff
changeset
|
9446 |
95088
524350e4961c
(Fcoding_system_p): Rename argument to match docstring.
Juanma Barranquero <lekktu@gmail.com>
parents:
94963
diff
changeset
|
9447 usage: (set-coding-system-priority &rest coding-systems) */) |
109179
8cfee7d2955f
Convert DEFUNs to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109165
diff
changeset
|
9448 (int nargs, Lisp_Object *args) |
88365 | 9449 { |
9450 int i, j; | |
9451 int changed[coding_category_max]; | |
9452 enum coding_category priorities[coding_category_max]; | |
9453 | |
109165
750db9f3e6d8
Replace bcopy, bzero, bcmp by memcpy, memmove, memset, memcmp
Andreas Schwab <schwab@linux-m68k.org>
parents:
109159
diff
changeset
|
9454 memset (changed, 0, sizeof changed); |
88365 | 9455 |
9456 for (i = j = 0; i < nargs; i++) | |
9457 { | |
9458 enum coding_category category; | |
9459 Lisp_Object spec, attrs; | |
9460 | |
9461 CHECK_CODING_SYSTEM_GET_SPEC (args[i], spec); | |
9462 attrs = AREF (spec, 0); | |
9463 category = XINT (CODING_ATTR_CATEGORY (attrs)); | |
9464 if (changed[category]) | |
9465 /* Ignore this coding system because a coding system of the | |
9466 same category already had a higher priority. */ | |
9467 continue; | |
9468 changed[category] = 1; | |
9469 priorities[j++] = category; | |
9470 if (coding_categories[category].id >= 0 | |
9471 && ! EQ (args[i], CODING_ID_NAME (coding_categories[category].id))) | |
9472 setup_coding_system (args[i], &coding_categories[category]); | |
89467
e911ca706166
(Fset_coding_system_priority): Doc fix. Update values
Kenichi Handa <handa@m17n.org>
parents:
89462
diff
changeset
|
9473 Fset (AREF (Vcoding_category_table, category), args[i]); |
88365 | 9474 } |
9475 | |
9476 /* Now we have decided top J priorities. Reflect the order of the | |
9477 original priorities to the remaining priorities. */ | |
9478 | |
9479 for (i = j, j = 0; i < coding_category_max; i++, j++) | |
9480 { | |
9481 while (j < coding_category_max | |
9482 && changed[coding_priorities[j]]) | |
9483 j++; | |
9484 if (j == coding_category_max) | |
9485 abort (); | |
9486 priorities[i] = coding_priorities[j]; | |
9487 } | |
9488 | |
109165
750db9f3e6d8
Replace bcopy, bzero, bcmp by memcpy, memmove, memset, memcmp
Andreas Schwab <schwab@linux-m68k.org>
parents:
109159
diff
changeset
|
9489 memcpy (coding_priorities, priorities, sizeof priorities); |
89467
e911ca706166
(Fset_coding_system_priority): Doc fix. Update values
Kenichi Handa <handa@m17n.org>
parents:
89462
diff
changeset
|
9490 |
e911ca706166
(Fset_coding_system_priority): Doc fix. Update values
Kenichi Handa <handa@m17n.org>
parents:
89462
diff
changeset
|
9491 /* Update `coding-category-list'. */ |
e911ca706166
(Fset_coding_system_priority): Doc fix. Update values
Kenichi Handa <handa@m17n.org>
parents:
89462
diff
changeset
|
9492 Vcoding_category_list = Qnil; |
e911ca706166
(Fset_coding_system_priority): Doc fix. Update values
Kenichi Handa <handa@m17n.org>
parents:
89462
diff
changeset
|
9493 for (i = coding_category_max - 1; i >= 0; i--) |
e911ca706166
(Fset_coding_system_priority): Doc fix. Update values
Kenichi Handa <handa@m17n.org>
parents:
89462
diff
changeset
|
9494 Vcoding_category_list |
e911ca706166
(Fset_coding_system_priority): Doc fix. Update values
Kenichi Handa <handa@m17n.org>
parents:
89462
diff
changeset
|
9495 = Fcons (AREF (Vcoding_category_table, priorities[i]), |
e911ca706166
(Fset_coding_system_priority): Doc fix. Update values
Kenichi Handa <handa@m17n.org>
parents:
89462
diff
changeset
|
9496 Vcoding_category_list); |
22874
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
9497 |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
9498 return Qnil; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
9499 } |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
9500 |
88365 | 9501 DEFUN ("coding-system-priority-list", Fcoding_system_priority_list, |
9502 Scoding_system_priority_list, 0, 1, 0, | |
88645 | 9503 doc: /* Return a list of coding systems ordered by their priorities. |
102737
f556415c326b
(Fdetect_coding_region, Fcoding_system_priority_list): Improve the
Kenichi Handa <handa@m17n.org>
parents:
102422
diff
changeset
|
9504 The list contains a subset of coding systems; i.e. coding systems |
f556415c326b
(Fdetect_coding_region, Fcoding_system_priority_list): Improve the
Kenichi Handa <handa@m17n.org>
parents:
102422
diff
changeset
|
9505 assigned to each coding category (see `coding-category-list'). |
f556415c326b
(Fdetect_coding_region, Fcoding_system_priority_list): Improve the
Kenichi Handa <handa@m17n.org>
parents:
102422
diff
changeset
|
9506 |
88645 | 9507 HIGHESTP non-nil means just return the highest priority one. */) |
109179
8cfee7d2955f
Convert DEFUNs to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109165
diff
changeset
|
9508 (Lisp_Object highestp) |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
9509 { |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
9510 int i; |
22954
928b337d953b
Avoid using initializers for Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents:
22874
diff
changeset
|
9511 Lisp_Object val; |
928b337d953b
Avoid using initializers for Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents:
22874
diff
changeset
|
9512 |
88365 | 9513 for (i = 0, val = Qnil; i < coding_category_max; i++) |
9514 { | |
9515 enum coding_category category = coding_priorities[i]; | |
9516 int id = coding_categories[category].id; | |
9517 Lisp_Object attrs; | |
9518 | |
9519 if (id < 0) | |
9520 continue; | |
9521 attrs = CODING_ID_ATTRS (id); | |
9522 if (! NILP (highestp)) | |
9523 return CODING_ATTR_BASE_NAME (attrs); | |
9524 val = Fcons (CODING_ATTR_BASE_NAME (attrs), val); | |
9525 } | |
9526 return Fnreverse (val); | |
9527 } | |
9528 | |
105959
ba3ffbd9c422
* process.c (ifflag_def): Make flag_sym constant.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105877
diff
changeset
|
9529 static const char *const suffixes[] = { "-unix", "-dos", "-mac" }; |
88631
780b91d4a7e5
(setup_iso_safe_charsets): Fix arg decl for K&R.
Dave Love <fx@gnu.org>
parents:
88607
diff
changeset
|
9530 |
88365 | 9531 static Lisp_Object |
109126
aec1143e8d85
Convert (most) functions in src to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109100
diff
changeset
|
9532 make_subsidiaries (Lisp_Object base) |
88365 | 9533 { |
9534 Lisp_Object subsidiaries; | |
89483 | 9535 int base_name_len = SBYTES (SYMBOL_NAME (base)); |
88365 | 9536 char *buf = (char *) alloca (base_name_len + 6); |
9537 int i; | |
89483 | 9538 |
109165
750db9f3e6d8
Replace bcopy, bzero, bcmp by memcpy, memmove, memset, memcmp
Andreas Schwab <schwab@linux-m68k.org>
parents:
109159
diff
changeset
|
9539 memcpy (buf, SDATA (SYMBOL_NAME (base)), base_name_len); |
88365 | 9540 subsidiaries = Fmake_vector (make_number (3), Qnil); |
9541 for (i = 0; i < 3; i++) | |
9542 { | |
109165
750db9f3e6d8
Replace bcopy, bzero, bcmp by memcpy, memmove, memset, memcmp
Andreas Schwab <schwab@linux-m68k.org>
parents:
109159
diff
changeset
|
9543 memcpy (buf + base_name_len, suffixes[i], strlen (suffixes[i]) + 1); |
88365 | 9544 ASET (subsidiaries, i, intern (buf)); |
9545 } | |
9546 return subsidiaries; | |
9547 } | |
9548 | |
22226
557fac086b1b
(ascii_skip_code): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22186
diff
changeset
|
9549 |
49539
1ad5bfbb831a
(syms_of_coding): Add `...' for symbols in the docstring of
Kenichi Handa <handa@m17n.org>
parents:
48874
diff
changeset
|
9550 DEFUN ("define-coding-system-internal", Fdefine_coding_system_internal, |
88365 | 9551 Sdefine_coding_system_internal, coding_arg_max, MANY, 0, |
88544
f464d728344c
(Vchar_coding_system_table, Qchar_coding_system):
Dave Love <fx@gnu.org>
parents:
88510
diff
changeset
|
9552 doc: /* For internal use only. |
f464d728344c
(Vchar_coding_system_table, Qchar_coding_system):
Dave Love <fx@gnu.org>
parents:
88510
diff
changeset
|
9553 usage: (define-coding-system-internal ...) */) |
109179
8cfee7d2955f
Convert DEFUNs to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109165
diff
changeset
|
9554 (int nargs, Lisp_Object *args) |
88365 | 9555 { |
9556 Lisp_Object name; | |
9557 Lisp_Object spec_vec; /* [ ATTRS ALIASE EOL_TYPE ] */ | |
9558 Lisp_Object attrs; /* Vector of attributes. */ | |
9559 Lisp_Object eol_type; | |
9560 Lisp_Object aliases; | |
9561 Lisp_Object coding_type, charset_list, safe_charsets; | |
9562 enum coding_category category; | |
9563 Lisp_Object tail, val; | |
9564 int max_charset_id = 0; | |
9565 int i; | |
9566 | |
9567 if (nargs < coding_arg_max) | |
9568 goto short_args; | |
9569 | |
9570 attrs = Fmake_vector (make_number (coding_attr_last_index), Qnil); | |
9571 | |
9572 name = args[coding_arg_name]; | |
9573 CHECK_SYMBOL (name); | |
9574 CODING_ATTR_BASE_NAME (attrs) = name; | |
9575 | |
9576 val = args[coding_arg_mnemonic]; | |
9577 if (! STRINGP (val)) | |
9578 CHECK_CHARACTER (val); | |
9579 CODING_ATTR_MNEMONIC (attrs) = val; | |
9580 | |
9581 coding_type = args[coding_arg_coding_type]; | |
9582 CHECK_SYMBOL (coding_type); | |
9583 CODING_ATTR_TYPE (attrs) = coding_type; | |
9584 | |
9585 charset_list = args[coding_arg_charset_list]; | |
9586 if (SYMBOLP (charset_list)) | |
9587 { | |
9588 if (EQ (charset_list, Qiso_2022)) | |
9589 { | |
9590 if (! EQ (coding_type, Qiso_2022)) | |
9591 error ("Invalid charset-list"); | |
9592 charset_list = Viso_2022_charset_list; | |
9593 } | |
9594 else if (EQ (charset_list, Qemacs_mule)) | |
9595 { | |
9596 if (! EQ (coding_type, Qemacs_mule)) | |
9597 error ("Invalid charset-list"); | |
9598 charset_list = Vemacs_mule_charset_list; | |
9599 } | |
9600 for (tail = charset_list; CONSP (tail); tail = XCDR (tail)) | |
9601 if (max_charset_id < XFASTINT (XCAR (tail))) | |
9602 max_charset_id = XFASTINT (XCAR (tail)); | |
9603 } | |
9604 else | |
9605 { | |
9606 charset_list = Fcopy_sequence (charset_list); | |
91046 | 9607 for (tail = charset_list; CONSP (tail); tail = XCDR (tail)) |
88365 | 9608 { |
9609 struct charset *charset; | |
9610 | |
91046 | 9611 val = XCAR (tail); |
88365 | 9612 CHECK_CHARSET_GET_CHARSET (val, charset); |
9613 if (EQ (coding_type, Qiso_2022) | |
9614 ? CHARSET_ISO_FINAL (charset) < 0 | |
9615 : EQ (coding_type, Qemacs_mule) | |
9616 ? CHARSET_EMACS_MULE_ID (charset) < 0 | |
9617 : 0) | |
9618 error ("Can't handle charset `%s'", | |
89483 | 9619 SDATA (SYMBOL_NAME (CHARSET_NAME (charset)))); |
9620 | |
9621 XSETCAR (tail, make_number (charset->id)); | |
88365 | 9622 if (max_charset_id < charset->id) |
9623 max_charset_id = charset->id; | |
9624 } | |
9625 } | |
9626 CODING_ATTR_CHARSET_LIST (attrs) = charset_list; | |
9627 | |
102186
a12d39ca6870
* coding.h (struct coding_system): Make safe_charsets a pointer to
Andreas Schwab <schwab@suse.de>
parents:
102115
diff
changeset
|
9628 safe_charsets = make_uninit_string (max_charset_id + 1); |
a12d39ca6870
* coding.h (struct coding_system): Make safe_charsets a pointer to
Andreas Schwab <schwab@suse.de>
parents:
102115
diff
changeset
|
9629 memset (SDATA (safe_charsets), 255, max_charset_id + 1); |
88365 | 9630 for (tail = charset_list; CONSP (tail); tail = XCDR (tail)) |
89483 | 9631 SSET (safe_charsets, XFASTINT (XCAR (tail)), 0); |
88365 | 9632 CODING_ATTR_SAFE_CHARSETS (attrs) = safe_charsets; |
9633 | |
89225
32058afc72e2
(detect_coding_charset): If only ASCII bytes are found, return 0.
Kenichi Handa <handa@m17n.org>
parents:
89221
diff
changeset
|
9634 CODING_ATTR_ASCII_COMPAT (attrs) = args[coding_arg_ascii_compatible_p]; |
32058afc72e2
(detect_coding_charset): If only ASCII bytes are found, return 0.
Kenichi Handa <handa@m17n.org>
parents:
89221
diff
changeset
|
9635 |
88365 | 9636 val = args[coding_arg_decode_translation_table]; |
89759
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
9637 if (! CHAR_TABLE_P (val) && ! CONSP (val)) |
89732
8acde12aba89
(get_translation_table): New function.
Kenichi Handa <handa@m17n.org>
parents:
89730
diff
changeset
|
9638 CHECK_SYMBOL (val); |
88365 | 9639 CODING_ATTR_DECODE_TBL (attrs) = val; |
9640 | |
9641 val = args[coding_arg_encode_translation_table]; | |
89759
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
9642 if (! CHAR_TABLE_P (val) && ! CONSP (val)) |
89732
8acde12aba89
(get_translation_table): New function.
Kenichi Handa <handa@m17n.org>
parents:
89730
diff
changeset
|
9643 CHECK_SYMBOL (val); |
88365 | 9644 CODING_ATTR_ENCODE_TBL (attrs) = val; |
9645 | |
9646 val = args[coding_arg_post_read_conversion]; | |
9647 CHECK_SYMBOL (val); | |
9648 CODING_ATTR_POST_READ (attrs) = val; | |
9649 | |
9650 val = args[coding_arg_pre_write_conversion]; | |
9651 CHECK_SYMBOL (val); | |
9652 CODING_ATTR_PRE_WRITE (attrs) = val; | |
9653 | |
9654 val = args[coding_arg_default_char]; | |
9655 if (NILP (val)) | |
9656 CODING_ATTR_DEFAULT_CHAR (attrs) = make_number (' '); | |
9657 else | |
9658 { | |
89483 | 9659 CHECK_CHARACTER (val); |
88365 | 9660 CODING_ATTR_DEFAULT_CHAR (attrs) = val; |
9661 } | |
9662 | |
89483 | 9663 val = args[coding_arg_for_unibyte]; |
9664 CODING_ATTR_FOR_UNIBYTE (attrs) = NILP (val) ? Qnil : Qt; | |
9665 | |
88365 | 9666 val = args[coding_arg_plist]; |
9667 CHECK_LIST (val); | |
9668 CODING_ATTR_PLIST (attrs) = val; | |
9669 | |
9670 if (EQ (coding_type, Qcharset)) | |
9671 { | |
88597
74b74f59bc09
(decode_coding_charset): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
88587
diff
changeset
|
9672 /* Generate a lisp vector of 256 elements. Each element is nil, |
74b74f59bc09
(decode_coding_charset): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
88587
diff
changeset
|
9673 integer, or a list of charset IDs. |
74b74f59bc09
(decode_coding_charset): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
88587
diff
changeset
|
9674 |
74b74f59bc09
(decode_coding_charset): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
88587
diff
changeset
|
9675 If Nth element is nil, the byte code N is invalid in this |
74b74f59bc09
(decode_coding_charset): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
88587
diff
changeset
|
9676 coding system. |
74b74f59bc09
(decode_coding_charset): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
88587
diff
changeset
|
9677 |
74b74f59bc09
(decode_coding_charset): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
88587
diff
changeset
|
9678 If Nth element is a number NUM, N is the first byte of a |
74b74f59bc09
(decode_coding_charset): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
88587
diff
changeset
|
9679 charset whose ID is NUM. |
74b74f59bc09
(decode_coding_charset): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
88587
diff
changeset
|
9680 |
74b74f59bc09
(decode_coding_charset): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
88587
diff
changeset
|
9681 If Nth element is a list of charset IDs, N is the first byte |
74b74f59bc09
(decode_coding_charset): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
88587
diff
changeset
|
9682 of one of them. The list is sorted by dimensions of the |
89648
d5641a606e08
(Fdefine_coding_system_internal): Fix checking of ascii compatibility.
Kenichi Handa <handa@m17n.org>
parents:
89644
diff
changeset
|
9683 charsets. A charset of smaller dimension comes firtst. */ |
88365 | 9684 val = Fmake_vector (make_number (256), Qnil); |
9685 | |
89653
cbaa9fd1aa5c
(Fdefine_coding_system_internal): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89648
diff
changeset
|
9686 for (tail = charset_list; CONSP (tail); tail = XCDR (tail)) |
88365 | 9687 { |
88597
74b74f59bc09
(decode_coding_charset): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
88587
diff
changeset
|
9688 struct charset *charset = CHARSET_FROM_ID (XFASTINT (XCAR (tail))); |
74b74f59bc09
(decode_coding_charset): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
88587
diff
changeset
|
9689 int dim = CHARSET_DIMENSION (charset); |
74b74f59bc09
(decode_coding_charset): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
88587
diff
changeset
|
9690 int idx = (dim - 1) * 4; |
89483 | 9691 |
89653
cbaa9fd1aa5c
(Fdefine_coding_system_internal): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89648
diff
changeset
|
9692 if (CHARSET_ASCII_COMPATIBLE_P (charset)) |
89225
32058afc72e2
(detect_coding_charset): If only ASCII bytes are found, return 0.
Kenichi Handa <handa@m17n.org>
parents:
89221
diff
changeset
|
9693 CODING_ATTR_ASCII_COMPAT (attrs) = Qt; |
32058afc72e2
(detect_coding_charset): If only ASCII bytes are found, return 0.
Kenichi Handa <handa@m17n.org>
parents:
89221
diff
changeset
|
9694 |
88477
5f974cbba7b3
(coding_set_source): Delete the local variable beg_byte.
Kenichi Handa <handa@m17n.org>
parents:
88473
diff
changeset
|
9695 for (i = charset->code_space[idx]; |
5f974cbba7b3
(coding_set_source): Delete the local variable beg_byte.
Kenichi Handa <handa@m17n.org>
parents:
88473
diff
changeset
|
9696 i <= charset->code_space[idx + 1]; i++) |
5f974cbba7b3
(coding_set_source): Delete the local variable beg_byte.
Kenichi Handa <handa@m17n.org>
parents:
88473
diff
changeset
|
9697 { |
88597
74b74f59bc09
(decode_coding_charset): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
88587
diff
changeset
|
9698 Lisp_Object tmp, tmp2; |
74b74f59bc09
(decode_coding_charset): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
88587
diff
changeset
|
9699 int dim2; |
74b74f59bc09
(decode_coding_charset): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
88587
diff
changeset
|
9700 |
74b74f59bc09
(decode_coding_charset): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
88587
diff
changeset
|
9701 tmp = AREF (val, i); |
74b74f59bc09
(decode_coding_charset): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
88587
diff
changeset
|
9702 if (NILP (tmp)) |
74b74f59bc09
(decode_coding_charset): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
88587
diff
changeset
|
9703 tmp = XCAR (tail); |
74b74f59bc09
(decode_coding_charset): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
88587
diff
changeset
|
9704 else if (NUMBERP (tmp)) |
74b74f59bc09
(decode_coding_charset): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
88587
diff
changeset
|
9705 { |
74b74f59bc09
(decode_coding_charset): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
88587
diff
changeset
|
9706 dim2 = CHARSET_DIMENSION (CHARSET_FROM_ID (XFASTINT (tmp))); |
74b74f59bc09
(decode_coding_charset): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
88587
diff
changeset
|
9707 if (dim < dim2) |
88607
18436bf3d6dd
(Fdefine_coding_system_internal): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
88598
diff
changeset
|
9708 tmp = Fcons (XCAR (tail), Fcons (tmp, Qnil)); |
88597
74b74f59bc09
(decode_coding_charset): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
88587
diff
changeset
|
9709 else |
88607
18436bf3d6dd
(Fdefine_coding_system_internal): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
88598
diff
changeset
|
9710 tmp = Fcons (tmp, Fcons (XCAR (tail), Qnil)); |
88597
74b74f59bc09
(decode_coding_charset): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
88587
diff
changeset
|
9711 } |
88477
5f974cbba7b3
(coding_set_source): Delete the local variable beg_byte.
Kenichi Handa <handa@m17n.org>
parents:
88473
diff
changeset
|
9712 else |
88597
74b74f59bc09
(decode_coding_charset): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
88587
diff
changeset
|
9713 { |
74b74f59bc09
(decode_coding_charset): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
88587
diff
changeset
|
9714 for (tmp2 = tmp; CONSP (tmp2); tmp2 = XCDR (tmp2)) |
74b74f59bc09
(decode_coding_charset): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
88587
diff
changeset
|
9715 { |
74b74f59bc09
(decode_coding_charset): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
88587
diff
changeset
|
9716 dim2 = CHARSET_DIMENSION (CHARSET_FROM_ID (XFASTINT (XCAR (tmp2)))); |
74b74f59bc09
(decode_coding_charset): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
88587
diff
changeset
|
9717 if (dim < dim2) |
74b74f59bc09
(decode_coding_charset): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
88587
diff
changeset
|
9718 break; |
74b74f59bc09
(decode_coding_charset): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
88587
diff
changeset
|
9719 } |
74b74f59bc09
(decode_coding_charset): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
88587
diff
changeset
|
9720 if (NILP (tmp2)) |
74b74f59bc09
(decode_coding_charset): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
88587
diff
changeset
|
9721 tmp = nconc2 (tmp, Fcons (XCAR (tail), Qnil)); |
74b74f59bc09
(decode_coding_charset): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
88587
diff
changeset
|
9722 else |
74b74f59bc09
(decode_coding_charset): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
88587
diff
changeset
|
9723 { |
74b74f59bc09
(decode_coding_charset): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
88587
diff
changeset
|
9724 XSETCDR (tmp2, Fcons (XCAR (tmp2), XCDR (tmp2))); |
74b74f59bc09
(decode_coding_charset): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
88587
diff
changeset
|
9725 XSETCAR (tmp2, XCAR (tail)); |
74b74f59bc09
(decode_coding_charset): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
88587
diff
changeset
|
9726 } |
74b74f59bc09
(decode_coding_charset): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
88587
diff
changeset
|
9727 } |
74b74f59bc09
(decode_coding_charset): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
88587
diff
changeset
|
9728 ASET (val, i, tmp); |
88477
5f974cbba7b3
(coding_set_source): Delete the local variable beg_byte.
Kenichi Handa <handa@m17n.org>
parents:
88473
diff
changeset
|
9729 } |
88365 | 9730 } |
9731 ASET (attrs, coding_attr_charset_valids, val); | |
9732 category = coding_category_charset; | |
9733 } | |
9734 else if (EQ (coding_type, Qccl)) | |
9735 { | |
9736 Lisp_Object valids; | |
89483 | 9737 |
88365 | 9738 if (nargs < coding_arg_ccl_max) |
9739 goto short_args; | |
9740 | |
9741 val = args[coding_arg_ccl_decoder]; | |
9742 CHECK_CCL_PROGRAM (val); | |
9743 if (VECTORP (val)) | |
9744 val = Fcopy_sequence (val); | |
9745 ASET (attrs, coding_attr_ccl_decoder, val); | |
9746 | |
9747 val = args[coding_arg_ccl_encoder]; | |
9748 CHECK_CCL_PROGRAM (val); | |
9749 if (VECTORP (val)) | |
9750 val = Fcopy_sequence (val); | |
9751 ASET (attrs, coding_attr_ccl_encoder, val); | |
9752 | |
9753 val = args[coding_arg_ccl_valids]; | |
9754 valids = Fmake_string (make_number (256), make_number (0)); | |
9755 for (tail = val; !NILP (tail); tail = Fcdr (tail)) | |
9756 { | |
89373
4cc9e57fcabc
(decode_coding_ccl, encode_coding_ccl): Call ccl_driver
Kenichi Handa <handa@m17n.org>
parents:
89331
diff
changeset
|
9757 int from, to; |
4cc9e57fcabc
(decode_coding_ccl, encode_coding_ccl): Call ccl_driver
Kenichi Handa <handa@m17n.org>
parents:
89331
diff
changeset
|
9758 |
88365 | 9759 val = Fcar (tail); |
9760 if (INTEGERP (val)) | |
89373
4cc9e57fcabc
(decode_coding_ccl, encode_coding_ccl): Call ccl_driver
Kenichi Handa <handa@m17n.org>
parents:
89331
diff
changeset
|
9761 { |
4cc9e57fcabc
(decode_coding_ccl, encode_coding_ccl): Call ccl_driver
Kenichi Handa <handa@m17n.org>
parents:
89331
diff
changeset
|
9762 from = to = XINT (val); |
4cc9e57fcabc
(decode_coding_ccl, encode_coding_ccl): Call ccl_driver
Kenichi Handa <handa@m17n.org>
parents:
89331
diff
changeset
|
9763 if (from < 0 || from > 255) |
4cc9e57fcabc
(decode_coding_ccl, encode_coding_ccl): Call ccl_driver
Kenichi Handa <handa@m17n.org>
parents:
89331
diff
changeset
|
9764 args_out_of_range_3 (val, make_number (0), make_number (255)); |
4cc9e57fcabc
(decode_coding_ccl, encode_coding_ccl): Call ccl_driver
Kenichi Handa <handa@m17n.org>
parents:
89331
diff
changeset
|
9765 } |
88365 | 9766 else |
9767 { | |
9768 CHECK_CONS (val); | |
89483 | 9769 CHECK_NATNUM_CAR (val); |
9770 CHECK_NATNUM_CDR (val); | |
88365 | 9771 from = XINT (XCAR (val)); |
89483 | 9772 if (from > 255) |
89373
4cc9e57fcabc
(decode_coding_ccl, encode_coding_ccl): Call ccl_driver
Kenichi Handa <handa@m17n.org>
parents:
89331
diff
changeset
|
9773 args_out_of_range_3 (XCAR (val), |
4cc9e57fcabc
(decode_coding_ccl, encode_coding_ccl): Call ccl_driver
Kenichi Handa <handa@m17n.org>
parents:
89331
diff
changeset
|
9774 make_number (0), make_number (255)); |
88365 | 9775 to = XINT (XCDR (val)); |
89373
4cc9e57fcabc
(decode_coding_ccl, encode_coding_ccl): Call ccl_driver
Kenichi Handa <handa@m17n.org>
parents:
89331
diff
changeset
|
9776 if (to < from || to > 255) |
4cc9e57fcabc
(decode_coding_ccl, encode_coding_ccl): Call ccl_driver
Kenichi Handa <handa@m17n.org>
parents:
89331
diff
changeset
|
9777 args_out_of_range_3 (XCDR (val), |
4cc9e57fcabc
(decode_coding_ccl, encode_coding_ccl): Call ccl_driver
Kenichi Handa <handa@m17n.org>
parents:
89331
diff
changeset
|
9778 XCAR (val), make_number (255)); |
88365 | 9779 } |
89373
4cc9e57fcabc
(decode_coding_ccl, encode_coding_ccl): Call ccl_driver
Kenichi Handa <handa@m17n.org>
parents:
89331
diff
changeset
|
9780 for (i = from; i <= to; i++) |
89483 | 9781 SSET (valids, i, 1); |
88365 | 9782 } |
9783 ASET (attrs, coding_attr_ccl_valids, valids); | |
89483 | 9784 |
88365 | 9785 category = coding_category_ccl; |
9786 } | |
9787 else if (EQ (coding_type, Qutf_16)) | |
9788 { | |
9789 Lisp_Object bom, endian; | |
9790 | |
89225
32058afc72e2
(detect_coding_charset): If only ASCII bytes are found, return 0.
Kenichi Handa <handa@m17n.org>
parents:
89221
diff
changeset
|
9791 CODING_ATTR_ASCII_COMPAT (attrs) = Qnil; |
32058afc72e2
(detect_coding_charset): If only ASCII bytes are found, return 0.
Kenichi Handa <handa@m17n.org>
parents:
89221
diff
changeset
|
9792 |
88365 | 9793 if (nargs < coding_arg_utf16_max) |
9794 goto short_args; | |
9795 | |
9796 bom = args[coding_arg_utf16_bom]; | |
9797 if (! NILP (bom) && ! EQ (bom, Qt)) | |
22874
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
9798 { |
88365 | 9799 CHECK_CONS (bom); |
89483 | 9800 val = XCAR (bom); |
9801 CHECK_CODING_SYSTEM (val); | |
9802 val = XCDR (bom); | |
9803 CHECK_CODING_SYSTEM (val); | |
88365 | 9804 } |
95397
c99f0a16c077
(CODING_UTF_8_BOM): New macro.
Kenichi Handa <handa@m17n.org>
parents:
95356
diff
changeset
|
9805 ASET (attrs, coding_attr_utf_bom, bom); |
88365 | 9806 |
9807 endian = args[coding_arg_utf16_endian]; | |
89420
c3e67ce6ee0f
(Qsignature, Qendian): Delete these variables.
Kenichi Handa <handa@m17n.org>
parents:
89418
diff
changeset
|
9808 CHECK_SYMBOL (endian); |
c3e67ce6ee0f
(Qsignature, Qendian): Delete these variables.
Kenichi Handa <handa@m17n.org>
parents:
89418
diff
changeset
|
9809 if (NILP (endian)) |
c3e67ce6ee0f
(Qsignature, Qendian): Delete these variables.
Kenichi Handa <handa@m17n.org>
parents:
89418
diff
changeset
|
9810 endian = Qbig; |
c3e67ce6ee0f
(Qsignature, Qendian): Delete these variables.
Kenichi Handa <handa@m17n.org>
parents:
89418
diff
changeset
|
9811 else if (! EQ (endian, Qbig) && ! EQ (endian, Qlittle)) |
89483 | 9812 error ("Invalid endian: %s", SDATA (SYMBOL_NAME (endian))); |
88365 | 9813 ASET (attrs, coding_attr_utf_16_endian, endian); |
9814 | |
9815 category = (CONSP (bom) | |
9816 ? coding_category_utf_16_auto | |
9817 : NILP (bom) | |
89420
c3e67ce6ee0f
(Qsignature, Qendian): Delete these variables.
Kenichi Handa <handa@m17n.org>
parents:
89418
diff
changeset
|
9818 ? (EQ (endian, Qbig) |
88365 | 9819 ? coding_category_utf_16_be_nosig |
9820 : coding_category_utf_16_le_nosig) | |
89420
c3e67ce6ee0f
(Qsignature, Qendian): Delete these variables.
Kenichi Handa <handa@m17n.org>
parents:
89418
diff
changeset
|
9821 : (EQ (endian, Qbig) |
88365 | 9822 ? coding_category_utf_16_be |
9823 : coding_category_utf_16_le)); | |
9824 } | |
9825 else if (EQ (coding_type, Qiso_2022)) | |
9826 { | |
9827 Lisp_Object initial, reg_usage, request, flags; | |
89442
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
9828 int i; |
88365 | 9829 |
9830 if (nargs < coding_arg_iso2022_max) | |
9831 goto short_args; | |
9832 | |
9833 initial = Fcopy_sequence (args[coding_arg_iso2022_initial]); | |
9834 CHECK_VECTOR (initial); | |
9835 for (i = 0; i < 4; i++) | |
9836 { | |
9837 val = Faref (initial, make_number (i)); | |
9838 if (! NILP (val)) | |
9839 { | |
89225
32058afc72e2
(detect_coding_charset): If only ASCII bytes are found, return 0.
Kenichi Handa <handa@m17n.org>
parents:
89221
diff
changeset
|
9840 struct charset *charset; |
32058afc72e2
(detect_coding_charset): If only ASCII bytes are found, return 0.
Kenichi Handa <handa@m17n.org>
parents:
89221
diff
changeset
|
9841 |
32058afc72e2
(detect_coding_charset): If only ASCII bytes are found, return 0.
Kenichi Handa <handa@m17n.org>
parents:
89221
diff
changeset
|
9842 CHECK_CHARSET_GET_CHARSET (val, charset); |
32058afc72e2
(detect_coding_charset): If only ASCII bytes are found, return 0.
Kenichi Handa <handa@m17n.org>
parents:
89221
diff
changeset
|
9843 ASET (initial, i, make_number (CHARSET_ID (charset))); |
32058afc72e2
(detect_coding_charset): If only ASCII bytes are found, return 0.
Kenichi Handa <handa@m17n.org>
parents:
89221
diff
changeset
|
9844 if (i == 0 && CHARSET_ASCII_COMPATIBLE_P (charset)) |
32058afc72e2
(detect_coding_charset): If only ASCII bytes are found, return 0.
Kenichi Handa <handa@m17n.org>
parents:
89221
diff
changeset
|
9845 CODING_ATTR_ASCII_COMPAT (attrs) = Qt; |
88365 | 9846 } |
9847 else | |
9848 ASET (initial, i, make_number (-1)); | |
9849 } | |
9850 | |
9851 reg_usage = args[coding_arg_iso2022_reg_usage]; | |
9852 CHECK_CONS (reg_usage); | |
89483 | 9853 CHECK_NUMBER_CAR (reg_usage); |
9854 CHECK_NUMBER_CDR (reg_usage); | |
88365 | 9855 |
9856 request = Fcopy_sequence (args[coding_arg_iso2022_request]); | |
9857 for (tail = request; ! NILP (tail); tail = Fcdr (tail)) | |
9858 { | |
9859 int id; | |
89483 | 9860 Lisp_Object tmp; |
88365 | 9861 |
9862 val = Fcar (tail); | |
9863 CHECK_CONS (val); | |
89483 | 9864 tmp = XCAR (val); |
9865 CHECK_CHARSET_GET_ID (tmp, id); | |
9866 CHECK_NATNUM_CDR (val); | |
88365 | 9867 if (XINT (XCDR (val)) >= 4) |
9868 error ("Invalid graphic register number: %d", XINT (XCDR (val))); | |
89483 | 9869 XSETCAR (val, make_number (id)); |
88365 | 9870 } |
9871 | |
9872 flags = args[coding_arg_iso2022_flags]; | |
9873 CHECK_NATNUM (flags); | |
9874 i = XINT (flags); | |
9875 if (EQ (args[coding_arg_charset_list], Qiso_2022)) | |
9876 flags = make_number (i | CODING_ISO_FLAG_FULL_SUPPORT); | |
9877 | |
9878 ASET (attrs, coding_attr_iso_initial, initial); | |
9879 ASET (attrs, coding_attr_iso_usage, reg_usage); | |
9880 ASET (attrs, coding_attr_iso_request, request); | |
9881 ASET (attrs, coding_attr_iso_flags, flags); | |
9882 setup_iso_safe_charsets (attrs); | |
9883 | |
9884 if (i & CODING_ISO_FLAG_SEVEN_BITS) | |
9885 category = ((i & (CODING_ISO_FLAG_LOCKING_SHIFT | |
9886 | CODING_ISO_FLAG_SINGLE_SHIFT)) | |
9887 ? coding_category_iso_7_else | |
9888 : EQ (args[coding_arg_charset_list], Qiso_2022) | |
9889 ? coding_category_iso_7 | |
9890 : coding_category_iso_7_tight); | |
9891 else | |
9892 { | |
9893 int id = XINT (AREF (initial, 1)); | |
9894 | |
88977
3b05c02eebf2
(Fdefine_coding_system_internal): Fix category setting
Kenichi Handa <handa@m17n.org>
parents:
88950
diff
changeset
|
9895 category = (((i & CODING_ISO_FLAG_LOCKING_SHIFT) |
88365 | 9896 || EQ (args[coding_arg_charset_list], Qiso_2022) |
9897 || id < 0) | |
9898 ? coding_category_iso_8_else | |
9899 : (CHARSET_DIMENSION (CHARSET_FROM_ID (id)) == 1) | |
9900 ? coding_category_iso_8_1 | |
9901 : coding_category_iso_8_2); | |
22874
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
9902 } |
89227
101ee928c088
(Fdefine_coding_system_internal): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89225
diff
changeset
|
9903 if (category != coding_category_iso_8_1 |
101ee928c088
(Fdefine_coding_system_internal): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89225
diff
changeset
|
9904 && category != coding_category_iso_8_2) |
101ee928c088
(Fdefine_coding_system_internal): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89225
diff
changeset
|
9905 CODING_ATTR_ASCII_COMPAT (attrs) = Qnil; |
88365 | 9906 } |
9907 else if (EQ (coding_type, Qemacs_mule)) | |
9908 { | |
9909 if (EQ (args[coding_arg_charset_list], Qemacs_mule)) | |
9910 ASET (attrs, coding_attr_emacs_mule_full, Qt); | |
89225
32058afc72e2
(detect_coding_charset): If only ASCII bytes are found, return 0.
Kenichi Handa <handa@m17n.org>
parents:
89221
diff
changeset
|
9911 CODING_ATTR_ASCII_COMPAT (attrs) = Qt; |
88365 | 9912 category = coding_category_emacs_mule; |
9913 } | |
9914 else if (EQ (coding_type, Qshift_jis)) | |
9915 { | |
9916 | |
9917 struct charset *charset; | |
9918 | |
89732
8acde12aba89
(get_translation_table): New function.
Kenichi Handa <handa@m17n.org>
parents:
89730
diff
changeset
|
9919 if (XINT (Flength (charset_list)) != 3 |
89739
293c9235be3f
(Fdefine_coding_system_internal): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89732
diff
changeset
|
9920 && XINT (Flength (charset_list)) != 4) |
89732
8acde12aba89
(get_translation_table): New function.
Kenichi Handa <handa@m17n.org>
parents:
89730
diff
changeset
|
9921 error ("There should be three or four charsets"); |
88365 | 9922 |
9923 charset = CHARSET_FROM_ID (XINT (XCAR (charset_list))); | |
9924 if (CHARSET_DIMENSION (charset) != 1) | |
9925 error ("Dimension of charset %s is not one", | |
89483 | 9926 SDATA (SYMBOL_NAME (CHARSET_NAME (charset)))); |
89225
32058afc72e2
(detect_coding_charset): If only ASCII bytes are found, return 0.
Kenichi Handa <handa@m17n.org>
parents:
89221
diff
changeset
|
9927 if (CHARSET_ASCII_COMPATIBLE_P (charset)) |
32058afc72e2
(detect_coding_charset): If only ASCII bytes are found, return 0.
Kenichi Handa <handa@m17n.org>
parents:
89221
diff
changeset
|
9928 CODING_ATTR_ASCII_COMPAT (attrs) = Qt; |
88365 | 9929 |
9930 charset_list = XCDR (charset_list); | |
9931 charset = CHARSET_FROM_ID (XINT (XCAR (charset_list))); | |
9932 if (CHARSET_DIMENSION (charset) != 1) | |
9933 error ("Dimension of charset %s is not one", | |
89483 | 9934 SDATA (SYMBOL_NAME (CHARSET_NAME (charset)))); |
88365 | 9935 |
9936 charset_list = XCDR (charset_list); | |
9937 charset = CHARSET_FROM_ID (XINT (XCAR (charset_list))); | |
9938 if (CHARSET_DIMENSION (charset) != 2) | |
9939 error ("Dimension of charset %s is not two", | |
89483 | 9940 SDATA (SYMBOL_NAME (CHARSET_NAME (charset)))); |
88365 | 9941 |
89732
8acde12aba89
(get_translation_table): New function.
Kenichi Handa <handa@m17n.org>
parents:
89730
diff
changeset
|
9942 charset_list = XCDR (charset_list); |
89740
78c1fd14ed42
(Fdefine_coding_system_internal): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89739
diff
changeset
|
9943 if (! NILP (charset_list)) |
78c1fd14ed42
(Fdefine_coding_system_internal): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89739
diff
changeset
|
9944 { |
78c1fd14ed42
(Fdefine_coding_system_internal): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89739
diff
changeset
|
9945 charset = CHARSET_FROM_ID (XINT (XCAR (charset_list))); |
78c1fd14ed42
(Fdefine_coding_system_internal): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89739
diff
changeset
|
9946 if (CHARSET_DIMENSION (charset) != 2) |
78c1fd14ed42
(Fdefine_coding_system_internal): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89739
diff
changeset
|
9947 error ("Dimension of charset %s is not two", |
78c1fd14ed42
(Fdefine_coding_system_internal): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89739
diff
changeset
|
9948 SDATA (SYMBOL_NAME (CHARSET_NAME (charset)))); |
78c1fd14ed42
(Fdefine_coding_system_internal): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89739
diff
changeset
|
9949 } |
89732
8acde12aba89
(get_translation_table): New function.
Kenichi Handa <handa@m17n.org>
parents:
89730
diff
changeset
|
9950 |
88365 | 9951 category = coding_category_sjis; |
9952 Vsjis_coding_system = name; | |
9953 } | |
9954 else if (EQ (coding_type, Qbig5)) | |
9955 { | |
9956 struct charset *charset; | |
9957 | |
9958 if (XINT (Flength (charset_list)) != 2) | |
9959 error ("There should be just two charsets"); | |
9960 | |
9961 charset = CHARSET_FROM_ID (XINT (XCAR (charset_list))); | |
9962 if (CHARSET_DIMENSION (charset) != 1) | |
9963 error ("Dimension of charset %s is not one", | |
89483 | 9964 SDATA (SYMBOL_NAME (CHARSET_NAME (charset)))); |
89225
32058afc72e2
(detect_coding_charset): If only ASCII bytes are found, return 0.
Kenichi Handa <handa@m17n.org>
parents:
89221
diff
changeset
|
9965 if (CHARSET_ASCII_COMPATIBLE_P (charset)) |
32058afc72e2
(detect_coding_charset): If only ASCII bytes are found, return 0.
Kenichi Handa <handa@m17n.org>
parents:
89221
diff
changeset
|
9966 CODING_ATTR_ASCII_COMPAT (attrs) = Qt; |
88365 | 9967 |
9968 charset_list = XCDR (charset_list); | |
9969 charset = CHARSET_FROM_ID (XINT (XCAR (charset_list))); | |
9970 if (CHARSET_DIMENSION (charset) != 2) | |
9971 error ("Dimension of charset %s is not two", | |
89483 | 9972 SDATA (SYMBOL_NAME (CHARSET_NAME (charset)))); |
88365 | 9973 |
9974 category = coding_category_big5; | |
9975 Vbig5_coding_system = name; | |
9976 } | |
9977 else if (EQ (coding_type, Qraw_text)) | |
89225
32058afc72e2
(detect_coding_charset): If only ASCII bytes are found, return 0.
Kenichi Handa <handa@m17n.org>
parents:
89221
diff
changeset
|
9978 { |
32058afc72e2
(detect_coding_charset): If only ASCII bytes are found, return 0.
Kenichi Handa <handa@m17n.org>
parents:
89221
diff
changeset
|
9979 category = coding_category_raw_text; |
32058afc72e2
(detect_coding_charset): If only ASCII bytes are found, return 0.
Kenichi Handa <handa@m17n.org>
parents:
89221
diff
changeset
|
9980 CODING_ATTR_ASCII_COMPAT (attrs) = Qt; |
32058afc72e2
(detect_coding_charset): If only ASCII bytes are found, return 0.
Kenichi Handa <handa@m17n.org>
parents:
89221
diff
changeset
|
9981 } |
88365 | 9982 else if (EQ (coding_type, Qutf_8)) |
89225
32058afc72e2
(detect_coding_charset): If only ASCII bytes are found, return 0.
Kenichi Handa <handa@m17n.org>
parents:
89221
diff
changeset
|
9983 { |
95397
c99f0a16c077
(CODING_UTF_8_BOM): New macro.
Kenichi Handa <handa@m17n.org>
parents:
95356
diff
changeset
|
9984 Lisp_Object bom; |
c99f0a16c077
(CODING_UTF_8_BOM): New macro.
Kenichi Handa <handa@m17n.org>
parents:
95356
diff
changeset
|
9985 |
89225
32058afc72e2
(detect_coding_charset): If only ASCII bytes are found, return 0.
Kenichi Handa <handa@m17n.org>
parents:
89221
diff
changeset
|
9986 CODING_ATTR_ASCII_COMPAT (attrs) = Qt; |
95397
c99f0a16c077
(CODING_UTF_8_BOM): New macro.
Kenichi Handa <handa@m17n.org>
parents:
95356
diff
changeset
|
9987 |
c99f0a16c077
(CODING_UTF_8_BOM): New macro.
Kenichi Handa <handa@m17n.org>
parents:
95356
diff
changeset
|
9988 if (nargs < coding_arg_utf8_max) |
c99f0a16c077
(CODING_UTF_8_BOM): New macro.
Kenichi Handa <handa@m17n.org>
parents:
95356
diff
changeset
|
9989 goto short_args; |
c99f0a16c077
(CODING_UTF_8_BOM): New macro.
Kenichi Handa <handa@m17n.org>
parents:
95356
diff
changeset
|
9990 |
c99f0a16c077
(CODING_UTF_8_BOM): New macro.
Kenichi Handa <handa@m17n.org>
parents:
95356
diff
changeset
|
9991 bom = args[coding_arg_utf8_bom]; |
c99f0a16c077
(CODING_UTF_8_BOM): New macro.
Kenichi Handa <handa@m17n.org>
parents:
95356
diff
changeset
|
9992 if (! NILP (bom) && ! EQ (bom, Qt)) |
c99f0a16c077
(CODING_UTF_8_BOM): New macro.
Kenichi Handa <handa@m17n.org>
parents:
95356
diff
changeset
|
9993 { |
c99f0a16c077
(CODING_UTF_8_BOM): New macro.
Kenichi Handa <handa@m17n.org>
parents:
95356
diff
changeset
|
9994 CHECK_CONS (bom); |
c99f0a16c077
(CODING_UTF_8_BOM): New macro.
Kenichi Handa <handa@m17n.org>
parents:
95356
diff
changeset
|
9995 val = XCAR (bom); |
c99f0a16c077
(CODING_UTF_8_BOM): New macro.
Kenichi Handa <handa@m17n.org>
parents:
95356
diff
changeset
|
9996 CHECK_CODING_SYSTEM (val); |
c99f0a16c077
(CODING_UTF_8_BOM): New macro.
Kenichi Handa <handa@m17n.org>
parents:
95356
diff
changeset
|
9997 val = XCDR (bom); |
c99f0a16c077
(CODING_UTF_8_BOM): New macro.
Kenichi Handa <handa@m17n.org>
parents:
95356
diff
changeset
|
9998 CHECK_CODING_SYSTEM (val); |
c99f0a16c077
(CODING_UTF_8_BOM): New macro.
Kenichi Handa <handa@m17n.org>
parents:
95356
diff
changeset
|
9999 } |
c99f0a16c077
(CODING_UTF_8_BOM): New macro.
Kenichi Handa <handa@m17n.org>
parents:
95356
diff
changeset
|
10000 ASET (attrs, coding_attr_utf_bom, bom); |
c99f0a16c077
(CODING_UTF_8_BOM): New macro.
Kenichi Handa <handa@m17n.org>
parents:
95356
diff
changeset
|
10001 |
c99f0a16c077
(CODING_UTF_8_BOM): New macro.
Kenichi Handa <handa@m17n.org>
parents:
95356
diff
changeset
|
10002 category = (CONSP (bom) ? coding_category_utf_8_auto |
c99f0a16c077
(CODING_UTF_8_BOM): New macro.
Kenichi Handa <handa@m17n.org>
parents:
95356
diff
changeset
|
10003 : NILP (bom) ? coding_category_utf_8_nosig |
c99f0a16c077
(CODING_UTF_8_BOM): New macro.
Kenichi Handa <handa@m17n.org>
parents:
95356
diff
changeset
|
10004 : coding_category_utf_8_sig); |
89225
32058afc72e2
(detect_coding_charset): If only ASCII bytes are found, return 0.
Kenichi Handa <handa@m17n.org>
parents:
89221
diff
changeset
|
10005 } |
88365 | 10006 else if (EQ (coding_type, Qundecided)) |
10007 category = coding_category_undecided; | |
10008 else | |
10009 error ("Invalid coding system type: %s", | |
89483 | 10010 SDATA (SYMBOL_NAME (coding_type))); |
88365 | 10011 |
10012 CODING_ATTR_CATEGORY (attrs) = make_number (category); | |
89468
7dbbe692f70c
* coding.c (QCcategory): New variable.
Kenichi Handa <handa@m17n.org>
parents:
89467
diff
changeset
|
10013 CODING_ATTR_PLIST (attrs) |
7dbbe692f70c
* coding.c (QCcategory): New variable.
Kenichi Handa <handa@m17n.org>
parents:
89467
diff
changeset
|
10014 = Fcons (QCcategory, Fcons (AREF (Vcoding_category_table, category), |
7dbbe692f70c
* coding.c (QCcategory): New variable.
Kenichi Handa <handa@m17n.org>
parents:
89467
diff
changeset
|
10015 CODING_ATTR_PLIST (attrs))); |
90214
460ee00505d5
(QCascii_compatible_p): New variable.
Kenichi Handa <handa@m17n.org>
parents:
90201
diff
changeset
|
10016 CODING_ATTR_PLIST (attrs) |
93877
62d97ebb13a9
* coding.c (detect_coding_emacs_mule)
Michael Albinus <michael.albinus@gmx.de>
parents:
93595
diff
changeset
|
10017 = Fcons (QCascii_compatible_p, |
90214
460ee00505d5
(QCascii_compatible_p): New variable.
Kenichi Handa <handa@m17n.org>
parents:
90201
diff
changeset
|
10018 Fcons (CODING_ATTR_ASCII_COMPAT (attrs), |
460ee00505d5
(QCascii_compatible_p): New variable.
Kenichi Handa <handa@m17n.org>
parents:
90201
diff
changeset
|
10019 CODING_ATTR_PLIST (attrs))); |
88365 | 10020 |
10021 eol_type = args[coding_arg_eol_type]; | |
10022 if (! NILP (eol_type) | |
10023 && ! EQ (eol_type, Qunix) | |
10024 && ! EQ (eol_type, Qdos) | |
10025 && ! EQ (eol_type, Qmac)) | |
10026 error ("Invalid eol-type"); | |
10027 | |
10028 aliases = Fcons (name, Qnil); | |
10029 | |
10030 if (NILP (eol_type)) | |
10031 { | |
10032 eol_type = make_subsidiaries (name); | |
10033 for (i = 0; i < 3; i++) | |
22874
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
10034 { |
88365 | 10035 Lisp_Object this_spec, this_name, this_aliases, this_eol_type; |
10036 | |
10037 this_name = AREF (eol_type, i); | |
10038 this_aliases = Fcons (this_name, Qnil); | |
10039 this_eol_type = (i == 0 ? Qunix : i == 1 ? Qdos : Qmac); | |
10040 this_spec = Fmake_vector (make_number (3), attrs); | |
10041 ASET (this_spec, 1, this_aliases); | |
10042 ASET (this_spec, 2, this_eol_type); | |
10043 Fputhash (this_name, this_spec, Vcoding_system_hash_table); | |
10044 Vcoding_system_list = Fcons (this_name, Vcoding_system_list); | |
90289
72d8a45f6c9f
(Fdefine_coding_system_internal): Avoid a duplicated
Kenichi Handa <handa@m17n.org>
parents:
90272
diff
changeset
|
10045 val = Fassoc (Fsymbol_name (this_name), Vcoding_system_alist); |
72d8a45f6c9f
(Fdefine_coding_system_internal): Avoid a duplicated
Kenichi Handa <handa@m17n.org>
parents:
90272
diff
changeset
|
10046 if (NILP (val)) |
72d8a45f6c9f
(Fdefine_coding_system_internal): Avoid a duplicated
Kenichi Handa <handa@m17n.org>
parents:
90272
diff
changeset
|
10047 Vcoding_system_alist |
72d8a45f6c9f
(Fdefine_coding_system_internal): Avoid a duplicated
Kenichi Handa <handa@m17n.org>
parents:
90272
diff
changeset
|
10048 = Fcons (Fcons (Fsymbol_name (this_name), Qnil), |
72d8a45f6c9f
(Fdefine_coding_system_internal): Avoid a duplicated
Kenichi Handa <handa@m17n.org>
parents:
90272
diff
changeset
|
10049 Vcoding_system_alist); |
22874
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
10050 } |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
10051 } |
22874
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
10052 |
88365 | 10053 spec_vec = Fmake_vector (make_number (3), attrs); |
10054 ASET (spec_vec, 1, aliases); | |
10055 ASET (spec_vec, 2, eol_type); | |
10056 | |
10057 Fputhash (name, spec_vec, Vcoding_system_hash_table); | |
10058 Vcoding_system_list = Fcons (name, Vcoding_system_list); | |
90289
72d8a45f6c9f
(Fdefine_coding_system_internal): Avoid a duplicated
Kenichi Handa <handa@m17n.org>
parents:
90272
diff
changeset
|
10059 val = Fassoc (Fsymbol_name (name), Vcoding_system_alist); |
72d8a45f6c9f
(Fdefine_coding_system_internal): Avoid a duplicated
Kenichi Handa <handa@m17n.org>
parents:
90272
diff
changeset
|
10060 if (NILP (val)) |
72d8a45f6c9f
(Fdefine_coding_system_internal): Avoid a duplicated
Kenichi Handa <handa@m17n.org>
parents:
90272
diff
changeset
|
10061 Vcoding_system_alist = Fcons (Fcons (Fsymbol_name (name), Qnil), |
72d8a45f6c9f
(Fdefine_coding_system_internal): Avoid a duplicated
Kenichi Handa <handa@m17n.org>
parents:
90272
diff
changeset
|
10062 Vcoding_system_alist); |
88365 | 10063 |
10064 { | |
10065 int id = coding_categories[category].id; | |
10066 | |
10067 if (id < 0 || EQ (name, CODING_ID_NAME (id))) | |
10068 setup_coding_system (name, &coding_categories[category]); | |
10069 } | |
10070 | |
10071 return Qnil; | |
10072 | |
10073 short_args: | |
10074 return Fsignal (Qwrong_number_of_arguments, | |
10075 Fcons (intern ("define-coding-system-internal"), | |
10076 make_number (nargs))); | |
10077 } | |
10078 | |
89571
242f2cc0134b
(Fdefine_coding_system_alias): Update Vcoding_system_list.
Kenichi Handa <handa@m17n.org>
parents:
89562
diff
changeset
|
10079 |
89759
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
10080 DEFUN ("coding-system-put", Fcoding_system_put, Scoding_system_put, |
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
10081 3, 3, 0, |
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
10082 doc: /* Change value in CODING-SYSTEM's property list PROP to VAL. */) |
109179
8cfee7d2955f
Convert DEFUNs to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109165
diff
changeset
|
10083 (Lisp_Object coding_system, Lisp_Object prop, Lisp_Object val) |
89759
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
10084 { |
89924
7d0f6da3ea6e
(detect_coding): Delete unused variables.
Kenichi Handa <handa@m17n.org>
parents:
89917
diff
changeset
|
10085 Lisp_Object spec, attrs; |
89759
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
10086 |
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
10087 CHECK_CODING_SYSTEM_GET_SPEC (coding_system, spec); |
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
10088 attrs = AREF (spec, 0); |
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
10089 if (EQ (prop, QCmnemonic)) |
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
10090 { |
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
10091 if (! STRINGP (val)) |
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
10092 CHECK_CHARACTER (val); |
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
10093 CODING_ATTR_MNEMONIC (attrs) = val; |
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
10094 } |
100303
3e044fa54e4f
* coding.c (QCdefault_char): Rename from QCdefalut_char.
Juanma Barranquero <lekktu@gmail.com>
parents:
100262
diff
changeset
|
10095 else if (EQ (prop, QCdefault_char)) |
89759
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
10096 { |
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
10097 if (NILP (val)) |
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
10098 val = make_number (' '); |
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
10099 else |
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
10100 CHECK_CHARACTER (val); |
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
10101 CODING_ATTR_DEFAULT_CHAR (attrs) = val; |
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
10102 } |
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
10103 else if (EQ (prop, QCdecode_translation_table)) |
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
10104 { |
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
10105 if (! CHAR_TABLE_P (val) && ! CONSP (val)) |
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
10106 CHECK_SYMBOL (val); |
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
10107 CODING_ATTR_DECODE_TBL (attrs) = val; |
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
10108 } |
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
10109 else if (EQ (prop, QCencode_translation_table)) |
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
10110 { |
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
10111 if (! CHAR_TABLE_P (val) && ! CONSP (val)) |
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
10112 CHECK_SYMBOL (val); |
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
10113 CODING_ATTR_ENCODE_TBL (attrs) = val; |
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
10114 } |
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
10115 else if (EQ (prop, QCpost_read_conversion)) |
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
10116 { |
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
10117 CHECK_SYMBOL (val); |
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
10118 CODING_ATTR_POST_READ (attrs) = val; |
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
10119 } |
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
10120 else if (EQ (prop, QCpre_write_conversion)) |
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
10121 { |
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
10122 CHECK_SYMBOL (val); |
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
10123 CODING_ATTR_PRE_WRITE (attrs) = val; |
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
10124 } |
90214
460ee00505d5
(QCascii_compatible_p): New variable.
Kenichi Handa <handa@m17n.org>
parents:
90201
diff
changeset
|
10125 else if (EQ (prop, QCascii_compatible_p)) |
460ee00505d5
(QCascii_compatible_p): New variable.
Kenichi Handa <handa@m17n.org>
parents:
90201
diff
changeset
|
10126 { |
460ee00505d5
(QCascii_compatible_p): New variable.
Kenichi Handa <handa@m17n.org>
parents:
90201
diff
changeset
|
10127 CODING_ATTR_ASCII_COMPAT (attrs) = val; |
460ee00505d5
(QCascii_compatible_p): New variable.
Kenichi Handa <handa@m17n.org>
parents:
90201
diff
changeset
|
10128 } |
89759
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
10129 |
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
10130 CODING_ATTR_PLIST (attrs) |
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
10131 = Fplist_put (CODING_ATTR_PLIST (attrs), prop, val); |
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
10132 return val; |
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
10133 } |
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
10134 |
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
10135 |
88365 | 10136 DEFUN ("define-coding-system-alias", Fdefine_coding_system_alias, |
10137 Sdefine_coding_system_alias, 2, 2, 0, | |
10138 doc: /* Define ALIAS as an alias for CODING-SYSTEM. */) | |
109179
8cfee7d2955f
Convert DEFUNs to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109165
diff
changeset
|
10139 (Lisp_Object alias, Lisp_Object coding_system) |
88365 | 10140 { |
90289
72d8a45f6c9f
(Fdefine_coding_system_internal): Avoid a duplicated
Kenichi Handa <handa@m17n.org>
parents:
90272
diff
changeset
|
10141 Lisp_Object spec, aliases, eol_type, val; |
88365 | 10142 |
10143 CHECK_SYMBOL (alias); | |
10144 CHECK_CODING_SYSTEM_GET_SPEC (coding_system, spec); | |
10145 aliases = AREF (spec, 1); | |
95088
524350e4961c
(Fcoding_system_p): Rename argument to match docstring.
Juanma Barranquero <lekktu@gmail.com>
parents:
94963
diff
changeset
|
10146 /* ALIASES should be a list of length more than zero, and the first |
89571
242f2cc0134b
(Fdefine_coding_system_alias): Update Vcoding_system_list.
Kenichi Handa <handa@m17n.org>
parents:
89562
diff
changeset
|
10147 element is a base coding system. Append ALIAS at the tail of the |
242f2cc0134b
(Fdefine_coding_system_alias): Update Vcoding_system_list.
Kenichi Handa <handa@m17n.org>
parents:
89562
diff
changeset
|
10148 list. */ |
88365 | 10149 while (!NILP (XCDR (aliases))) |
10150 aliases = XCDR (aliases); | |
89483 | 10151 XSETCDR (aliases, Fcons (alias, Qnil)); |
88365 | 10152 |
10153 eol_type = AREF (spec, 2); | |
10154 if (VECTORP (eol_type)) | |
10155 { | |
10156 Lisp_Object subsidiaries; | |
10157 int i; | |
10158 | |
10159 subsidiaries = make_subsidiaries (alias); | |
10160 for (i = 0; i < 3; i++) | |
10161 Fdefine_coding_system_alias (AREF (subsidiaries, i), | |
10162 AREF (eol_type, i)); | |
10163 } | |
10164 | |
10165 Fputhash (alias, spec, Vcoding_system_hash_table); | |
89571
242f2cc0134b
(Fdefine_coding_system_alias): Update Vcoding_system_list.
Kenichi Handa <handa@m17n.org>
parents:
89562
diff
changeset
|
10166 Vcoding_system_list = Fcons (alias, Vcoding_system_list); |
90289
72d8a45f6c9f
(Fdefine_coding_system_internal): Avoid a duplicated
Kenichi Handa <handa@m17n.org>
parents:
90272
diff
changeset
|
10167 val = Fassoc (Fsymbol_name (alias), Vcoding_system_alist); |
72d8a45f6c9f
(Fdefine_coding_system_internal): Avoid a duplicated
Kenichi Handa <handa@m17n.org>
parents:
90272
diff
changeset
|
10168 if (NILP (val)) |
72d8a45f6c9f
(Fdefine_coding_system_internal): Avoid a duplicated
Kenichi Handa <handa@m17n.org>
parents:
90272
diff
changeset
|
10169 Vcoding_system_alist = Fcons (Fcons (Fsymbol_name (alias), Qnil), |
72d8a45f6c9f
(Fdefine_coding_system_internal): Avoid a duplicated
Kenichi Handa <handa@m17n.org>
parents:
90272
diff
changeset
|
10170 Vcoding_system_alist); |
88365 | 10171 |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
10172 return Qnil; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
10173 } |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
10174 |
88365 | 10175 DEFUN ("coding-system-base", Fcoding_system_base, Scoding_system_base, |
10176 1, 1, 0, | |
10177 doc: /* Return the base of CODING-SYSTEM. | |
88645 | 10178 Any alias or subsidiary coding system is not a base coding system. */) |
109179
8cfee7d2955f
Convert DEFUNs to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109165
diff
changeset
|
10179 (Lisp_Object coding_system) |
88365 | 10180 { |
10181 Lisp_Object spec, attrs; | |
10182 | |
10183 if (NILP (coding_system)) | |
10184 return (Qno_conversion); | |
10185 CHECK_CODING_SYSTEM_GET_SPEC (coding_system, spec); | |
10186 attrs = AREF (spec, 0); | |
10187 return CODING_ATTR_BASE_NAME (attrs); | |
10188 } | |
10189 | |
10190 DEFUN ("coding-system-plist", Fcoding_system_plist, Scoding_system_plist, | |
10191 1, 1, 0, | |
10192 doc: "Return the property list of CODING-SYSTEM.") | |
109179
8cfee7d2955f
Convert DEFUNs to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109165
diff
changeset
|
10193 (Lisp_Object coding_system) |
49539
1ad5bfbb831a
(syms_of_coding): Add `...' for symbols in the docstring of
Kenichi Handa <handa@m17n.org>
parents:
48874
diff
changeset
|
10194 { |
88365 | 10195 Lisp_Object spec, attrs; |
10196 | |
10197 if (NILP (coding_system)) | |
10198 coding_system = Qno_conversion; | |
10199 CHECK_CODING_SYSTEM_GET_SPEC (coding_system, spec); | |
10200 attrs = AREF (spec, 0); | |
10201 return CODING_ATTR_PLIST (attrs); | |
10202 } | |
10203 | |
10204 | |
10205 DEFUN ("coding-system-aliases", Fcoding_system_aliases, Scoding_system_aliases, | |
10206 1, 1, 0, | |
88645 | 10207 doc: /* Return the list of aliases of CODING-SYSTEM. */) |
109179
8cfee7d2955f
Convert DEFUNs to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109165
diff
changeset
|
10208 (Lisp_Object coding_system) |
88365 | 10209 { |
10210 Lisp_Object spec; | |
10211 | |
10212 if (NILP (coding_system)) | |
10213 coding_system = Qno_conversion; | |
10214 CHECK_CODING_SYSTEM_GET_SPEC (coding_system, spec); | |
88645 | 10215 return AREF (spec, 1); |
88365 | 10216 } |
10217 | |
10218 DEFUN ("coding-system-eol-type", Fcoding_system_eol_type, | |
10219 Scoding_system_eol_type, 1, 1, 0, | |
10220 doc: /* Return eol-type of CODING-SYSTEM. | |
95088
524350e4961c
(Fcoding_system_p): Rename argument to match docstring.
Juanma Barranquero <lekktu@gmail.com>
parents:
94963
diff
changeset
|
10221 An eol-type is an integer 0, 1, 2, or a vector of coding systems. |
88365 | 10222 |
10223 Integer values 0, 1, and 2 indicate a format of end-of-line; LF, CRLF, | |
10224 and CR respectively. | |
10225 | |
10226 A vector value indicates that a format of end-of-line should be | |
10227 detected automatically. Nth element of the vector is the subsidiary | |
10228 coding system whose eol-type is N. */) | |
109179
8cfee7d2955f
Convert DEFUNs to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109165
diff
changeset
|
10229 (Lisp_Object coding_system) |
88365 | 10230 { |
10231 Lisp_Object spec, eol_type; | |
10232 int n; | |
10233 | |
10234 if (NILP (coding_system)) | |
10235 coding_system = Qno_conversion; | |
10236 if (! CODING_SYSTEM_P (coding_system)) | |
10237 return Qnil; | |
10238 spec = CODING_SYSTEM_SPEC (coding_system); | |
10239 eol_type = AREF (spec, 2); | |
10240 if (VECTORP (eol_type)) | |
10241 return Fcopy_sequence (eol_type); | |
10242 n = EQ (eol_type, Qunix) ? 0 : EQ (eol_type, Qdos) ? 1 : 2; | |
10243 return make_number (n); | |
49539
1ad5bfbb831a
(syms_of_coding): Add `...' for symbols in the docstring of
Kenichi Handa <handa@m17n.org>
parents:
48874
diff
changeset
|
10244 } |
1ad5bfbb831a
(syms_of_coding): Add `...' for symbols in the docstring of
Kenichi Handa <handa@m17n.org>
parents:
48874
diff
changeset
|
10245 |
17052 | 10246 #endif /* emacs */ |
10247 | |
10248 | |
22874
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
10249 /*** 9. Post-amble ***/ |
17052 | 10250 |
21514 | 10251 void |
109126
aec1143e8d85
Convert (most) functions in src to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109100
diff
changeset
|
10252 init_coding_once (void) |
17052 | 10253 { |
10254 int i; | |
10255 | |
88365 | 10256 for (i = 0; i < coding_category_max; i++) |
10257 { | |
10258 coding_categories[i].id = -1; | |
10259 coding_priorities[i] = i; | |
10260 } | |
17052 | 10261 |
10262 /* ISO2022 specific initialize routine. */ | |
10263 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
|
10264 iso_code_class[i] = ISO_control_0; |
17052 | 10265 for (i = 0x21; i < 0x7F; i++) |
10266 iso_code_class[i] = ISO_graphic_plane_0; | |
10267 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
|
10268 iso_code_class[i] = ISO_control_1; |
17052 | 10269 for (i = 0xA1; i < 0xFF; i++) |
10270 iso_code_class[i] = ISO_graphic_plane_1; | |
10271 iso_code_class[0x20] = iso_code_class[0x7F] = ISO_0x20_or_0x7F; | |
10272 iso_code_class[0xA0] = iso_code_class[0xFF] = ISO_0xA0_or_0xFF; | |
10273 iso_code_class[ISO_CODE_SO] = ISO_shift_out; | |
10274 iso_code_class[ISO_CODE_SI] = ISO_shift_in; | |
10275 iso_code_class[ISO_CODE_SS2_7] = ISO_single_shift_2_7; | |
10276 iso_code_class[ISO_CODE_ESC] = ISO_escape; | |
10277 iso_code_class[ISO_CODE_SS2] = ISO_single_shift_2; | |
10278 iso_code_class[ISO_CODE_SS3] = ISO_single_shift_3; | |
10279 iso_code_class[ISO_CODE_CSI] = ISO_control_sequence_introducer; | |
10280 | |
88365 | 10281 for (i = 0; i < 256; i++) |
10282 { | |
10283 emacs_mule_bytes[i] = 1; | |
10284 } | |
88876
af9012fdad56
(LEADING_CODE_PRIVATE_11, LEADING_CODE_PRIVATE_12,
Kenichi Handa <handa@m17n.org>
parents:
88862
diff
changeset
|
10285 emacs_mule_bytes[EMACS_MULE_LEADING_CODE_PRIVATE_11] = 3; |
af9012fdad56
(LEADING_CODE_PRIVATE_11, LEADING_CODE_PRIVATE_12,
Kenichi Handa <handa@m17n.org>
parents:
88862
diff
changeset
|
10286 emacs_mule_bytes[EMACS_MULE_LEADING_CODE_PRIVATE_12] = 3; |
af9012fdad56
(LEADING_CODE_PRIVATE_11, LEADING_CODE_PRIVATE_12,
Kenichi Handa <handa@m17n.org>
parents:
88862
diff
changeset
|
10287 emacs_mule_bytes[EMACS_MULE_LEADING_CODE_PRIVATE_21] = 4; |
af9012fdad56
(LEADING_CODE_PRIVATE_11, LEADING_CODE_PRIVATE_12,
Kenichi Handa <handa@m17n.org>
parents:
88862
diff
changeset
|
10288 emacs_mule_bytes[EMACS_MULE_LEADING_CODE_PRIVATE_22] = 4; |
17119
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
10289 } |
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
10290 |
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
10291 #ifdef emacs |
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
10292 |
21514 | 10293 void |
109126
aec1143e8d85
Convert (most) functions in src to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109100
diff
changeset
|
10294 syms_of_coding (void) |
17119
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
10295 { |
88365 | 10296 staticpro (&Vcoding_system_hash_table); |
89483 | 10297 { |
10298 Lisp_Object args[2]; | |
10299 args[0] = QCtest; | |
10300 args[1] = Qeq; | |
10301 Vcoding_system_hash_table = Fmake_hash_table (2, args); | |
10302 } | |
88365 | 10303 |
10304 staticpro (&Vsjis_coding_system); | |
10305 Vsjis_coding_system = Qnil; | |
10306 | |
10307 staticpro (&Vbig5_coding_system); | |
10308 Vbig5_coding_system = Qnil; | |
10309 | |
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
10310 staticpro (&Vcode_conversion_reused_workbuf); |
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
10311 Vcode_conversion_reused_workbuf = Qnil; |
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
10312 |
58637
ff8a37b5299b
(Vcode_conversion_workbuf_name): New variable.
Kenichi Handa <handa@m17n.org>
parents:
58502
diff
changeset
|
10313 staticpro (&Vcode_conversion_workbuf_name); |
105877
21bdda3ded62
* xterm.c (syms_of_xterm):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105669
diff
changeset
|
10314 Vcode_conversion_workbuf_name = make_pure_c_string (" *code-conversion-work*"); |
58637
ff8a37b5299b
(Vcode_conversion_workbuf_name): New variable.
Kenichi Handa <handa@m17n.org>
parents:
58502
diff
changeset
|
10315 |
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
10316 reused_workbuf_in_use = 0; |
88365 | 10317 |
10318 DEFSYM (Qcharset, "charset"); | |
10319 DEFSYM (Qtarget_idx, "target-idx"); | |
10320 DEFSYM (Qcoding_system_history, "coding-system-history"); | |
19750
95e4e1cba6ac
(Qcoding_system_history): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
19747
diff
changeset
|
10321 Fset (Qcoding_system_history, Qnil); |
95e4e1cba6ac
(Qcoding_system_history): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
19747
diff
changeset
|
10322 |
18650
aa3f2820e2ac
(Qemacs_mule, inhibit_eol_conversion): New variables.
Kenichi Handa <handa@m17n.org>
parents:
18613
diff
changeset
|
10323 /* 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
|
10324 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
|
10325 /* 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
|
10326 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
|
10327 |
88365 | 10328 DEFSYM (Qcall_process, "call-process"); |
18650
aa3f2820e2ac
(Qemacs_mule, inhibit_eol_conversion): New variables.
Kenichi Handa <handa@m17n.org>
parents:
18613
diff
changeset
|
10329 /* 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
|
10330 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
|
10331 |
88365 | 10332 DEFSYM (Qcall_process_region, "call-process-region"); |
18650
aa3f2820e2ac
(Qemacs_mule, inhibit_eol_conversion): New variables.
Kenichi Handa <handa@m17n.org>
parents:
18613
diff
changeset
|
10333 /* 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
|
10334 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
|
10335 |
88365 | 10336 DEFSYM (Qstart_process, "start-process"); |
18650
aa3f2820e2ac
(Qemacs_mule, inhibit_eol_conversion): New variables.
Kenichi Handa <handa@m17n.org>
parents:
18613
diff
changeset
|
10337 /* 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
|
10338 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
|
10339 |
88365 | 10340 DEFSYM (Qopen_network_stream, "open-network-stream"); |
18650
aa3f2820e2ac
(Qemacs_mule, inhibit_eol_conversion): New variables.
Kenichi Handa <handa@m17n.org>
parents:
18613
diff
changeset
|
10341 /* 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
|
10342 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
|
10343 |
88365 | 10344 DEFSYM (Qcoding_system, "coding-system"); |
10345 DEFSYM (Qcoding_aliases, "coding-aliases"); | |
10346 | |
10347 DEFSYM (Qeol_type, "eol-type"); | |
10348 DEFSYM (Qunix, "unix"); | |
10349 DEFSYM (Qdos, "dos"); | |
10350 | |
10351 DEFSYM (Qbuffer_file_coding_system, "buffer-file-coding-system"); | |
10352 DEFSYM (Qpost_read_conversion, "post-read-conversion"); | |
10353 DEFSYM (Qpre_write_conversion, "pre-write-conversion"); | |
10354 DEFSYM (Qdefault_char, "default-char"); | |
10355 DEFSYM (Qundecided, "undecided"); | |
10356 DEFSYM (Qno_conversion, "no-conversion"); | |
10357 DEFSYM (Qraw_text, "raw-text"); | |
10358 | |
10359 DEFSYM (Qiso_2022, "iso-2022"); | |
10360 | |
10361 DEFSYM (Qutf_8, "utf-8"); | |
89483 | 10362 DEFSYM (Qutf_8_emacs, "utf-8-emacs"); |
88365 | 10363 |
10364 DEFSYM (Qutf_16, "utf-16"); | |
10365 DEFSYM (Qbig, "big"); | |
10366 DEFSYM (Qlittle, "little"); | |
10367 | |
10368 DEFSYM (Qshift_jis, "shift-jis"); | |
10369 DEFSYM (Qbig5, "big5"); | |
10370 | |
10371 DEFSYM (Qcoding_system_p, "coding-system-p"); | |
10372 | |
10373 DEFSYM (Qcoding_system_error, "coding-system-error"); | |
17052 | 10374 Fput (Qcoding_system_error, Qerror_conditions, |
105877
21bdda3ded62
* xterm.c (syms_of_xterm):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105669
diff
changeset
|
10375 pure_cons (Qcoding_system_error, pure_cons (Qerror, Qnil))); |
17052 | 10376 Fput (Qcoding_system_error, Qerror_message, |
105877
21bdda3ded62
* xterm.c (syms_of_xterm):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105669
diff
changeset
|
10377 make_pure_c_string ("Invalid coding system")); |
17052 | 10378 |
30487
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
10379 /* 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
|
10380 Setting this variable twice is harmless. |
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
10381 But don't staticpro it here--that is done in alloc.c. */ |
105877
21bdda3ded62
* xterm.c (syms_of_xterm):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105669
diff
changeset
|
10382 Qchar_table_extra_slots = intern_c_string ("char-table-extra-slots"); |
88365 | 10383 |
10384 DEFSYM (Qtranslation_table, "translation-table"); | |
89856
18b52da60a76
(get_translation): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89852
diff
changeset
|
10385 Fput (Qtranslation_table, Qchar_table_extra_slots, make_number (2)); |
88365 | 10386 DEFSYM (Qtranslation_table_id, "translation-table-id"); |
10387 DEFSYM (Qtranslation_table_for_decode, "translation-table-for-decode"); | |
10388 DEFSYM (Qtranslation_table_for_encode, "translation-table-for-encode"); | |
10389 | |
10390 DEFSYM (Qvalid_codes, "valid-codes"); | |
10391 | |
10392 DEFSYM (Qemacs_mule, "emacs-mule"); | |
10393 | |
89468
7dbbe692f70c
* coding.c (QCcategory): New variable.
Kenichi Handa <handa@m17n.org>
parents:
89467
diff
changeset
|
10394 DEFSYM (QCcategory, ":category"); |
89759
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
10395 DEFSYM (QCmnemonic, ":mnemonic"); |
100303
3e044fa54e4f
* coding.c (QCdefault_char): Rename from QCdefalut_char.
Juanma Barranquero <lekktu@gmail.com>
parents:
100262
diff
changeset
|
10396 DEFSYM (QCdefault_char, ":default-char"); |
89759
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
10397 DEFSYM (QCdecode_translation_table, ":decode-translation-table"); |
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
10398 DEFSYM (QCencode_translation_table, ":encode-translation-table"); |
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
10399 DEFSYM (QCpost_read_conversion, ":post-read-conversion"); |
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
10400 DEFSYM (QCpre_write_conversion, ":pre-write-conversion"); |
90214
460ee00505d5
(QCascii_compatible_p): New variable.
Kenichi Handa <handa@m17n.org>
parents:
90201
diff
changeset
|
10401 DEFSYM (QCascii_compatible_p, ":ascii-compatible-p"); |
89468
7dbbe692f70c
* coding.c (QCcategory): New variable.
Kenichi Handa <handa@m17n.org>
parents:
89467
diff
changeset
|
10402 |
88365 | 10403 Vcoding_category_table |
10404 = Fmake_vector (make_number (coding_category_max), Qnil); | |
10405 staticpro (&Vcoding_category_table); | |
10406 /* Followings are target of code detection. */ | |
10407 ASET (Vcoding_category_table, coding_category_iso_7, | |
105877
21bdda3ded62
* xterm.c (syms_of_xterm):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105669
diff
changeset
|
10408 intern_c_string ("coding-category-iso-7")); |
88365 | 10409 ASET (Vcoding_category_table, coding_category_iso_7_tight, |
105877
21bdda3ded62
* xterm.c (syms_of_xterm):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105669
diff
changeset
|
10410 intern_c_string ("coding-category-iso-7-tight")); |
88365 | 10411 ASET (Vcoding_category_table, coding_category_iso_8_1, |
105877
21bdda3ded62
* xterm.c (syms_of_xterm):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105669
diff
changeset
|
10412 intern_c_string ("coding-category-iso-8-1")); |
88365 | 10413 ASET (Vcoding_category_table, coding_category_iso_8_2, |
105877
21bdda3ded62
* xterm.c (syms_of_xterm):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105669
diff
changeset
|
10414 intern_c_string ("coding-category-iso-8-2")); |
88365 | 10415 ASET (Vcoding_category_table, coding_category_iso_7_else, |
105877
21bdda3ded62
* xterm.c (syms_of_xterm):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105669
diff
changeset
|
10416 intern_c_string ("coding-category-iso-7-else")); |
88365 | 10417 ASET (Vcoding_category_table, coding_category_iso_8_else, |
105877
21bdda3ded62
* xterm.c (syms_of_xterm):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105669
diff
changeset
|
10418 intern_c_string ("coding-category-iso-8-else")); |
95397
c99f0a16c077
(CODING_UTF_8_BOM): New macro.
Kenichi Handa <handa@m17n.org>
parents:
95356
diff
changeset
|
10419 ASET (Vcoding_category_table, coding_category_utf_8_auto, |
105877
21bdda3ded62
* xterm.c (syms_of_xterm):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105669
diff
changeset
|
10420 intern_c_string ("coding-category-utf-8-auto")); |
95397
c99f0a16c077
(CODING_UTF_8_BOM): New macro.
Kenichi Handa <handa@m17n.org>
parents:
95356
diff
changeset
|
10421 ASET (Vcoding_category_table, coding_category_utf_8_nosig, |
105877
21bdda3ded62
* xterm.c (syms_of_xterm):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105669
diff
changeset
|
10422 intern_c_string ("coding-category-utf-8")); |
95397
c99f0a16c077
(CODING_UTF_8_BOM): New macro.
Kenichi Handa <handa@m17n.org>
parents:
95356
diff
changeset
|
10423 ASET (Vcoding_category_table, coding_category_utf_8_sig, |
105877
21bdda3ded62
* xterm.c (syms_of_xterm):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105669
diff
changeset
|
10424 intern_c_string ("coding-category-utf-8-sig")); |
88365 | 10425 ASET (Vcoding_category_table, coding_category_utf_16_be, |
105877
21bdda3ded62
* xterm.c (syms_of_xterm):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105669
diff
changeset
|
10426 intern_c_string ("coding-category-utf-16-be")); |
89467
e911ca706166
(Fset_coding_system_priority): Doc fix. Update values
Kenichi Handa <handa@m17n.org>
parents:
89462
diff
changeset
|
10427 ASET (Vcoding_category_table, coding_category_utf_16_auto, |
105877
21bdda3ded62
* xterm.c (syms_of_xterm):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105669
diff
changeset
|
10428 intern_c_string ("coding-category-utf-16-auto")); |
88365 | 10429 ASET (Vcoding_category_table, coding_category_utf_16_le, |
105877
21bdda3ded62
* xterm.c (syms_of_xterm):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105669
diff
changeset
|
10430 intern_c_string ("coding-category-utf-16-le")); |
88365 | 10431 ASET (Vcoding_category_table, coding_category_utf_16_be_nosig, |
105877
21bdda3ded62
* xterm.c (syms_of_xterm):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105669
diff
changeset
|
10432 intern_c_string ("coding-category-utf-16-be-nosig")); |
88365 | 10433 ASET (Vcoding_category_table, coding_category_utf_16_le_nosig, |
105877
21bdda3ded62
* xterm.c (syms_of_xterm):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105669
diff
changeset
|
10434 intern_c_string ("coding-category-utf-16-le-nosig")); |
88365 | 10435 ASET (Vcoding_category_table, coding_category_charset, |
105877
21bdda3ded62
* xterm.c (syms_of_xterm):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105669
diff
changeset
|
10436 intern_c_string ("coding-category-charset")); |
88365 | 10437 ASET (Vcoding_category_table, coding_category_sjis, |
105877
21bdda3ded62
* xterm.c (syms_of_xterm):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105669
diff
changeset
|
10438 intern_c_string ("coding-category-sjis")); |
88365 | 10439 ASET (Vcoding_category_table, coding_category_big5, |
105877
21bdda3ded62
* xterm.c (syms_of_xterm):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105669
diff
changeset
|
10440 intern_c_string ("coding-category-big5")); |
88365 | 10441 ASET (Vcoding_category_table, coding_category_ccl, |
105877
21bdda3ded62
* xterm.c (syms_of_xterm):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105669
diff
changeset
|
10442 intern_c_string ("coding-category-ccl")); |
88365 | 10443 ASET (Vcoding_category_table, coding_category_emacs_mule, |
105877
21bdda3ded62
* xterm.c (syms_of_xterm):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105669
diff
changeset
|
10444 intern_c_string ("coding-category-emacs-mule")); |
88365 | 10445 /* Followings are NOT target of code detection. */ |
10446 ASET (Vcoding_category_table, coding_category_raw_text, | |
105877
21bdda3ded62
* xterm.c (syms_of_xterm):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105669
diff
changeset
|
10447 intern_c_string ("coding-category-raw-text")); |
88365 | 10448 ASET (Vcoding_category_table, coding_category_undecided, |
105877
21bdda3ded62
* xterm.c (syms_of_xterm):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105669
diff
changeset
|
10449 intern_c_string ("coding-category-undecided")); |
88365 | 10450 |
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
10451 DEFSYM (Qinsufficient_source, "insufficient-source"); |
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
10452 DEFSYM (Qinconsistent_eol, "inconsistent-eol"); |
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
10453 DEFSYM (Qinvalid_source, "invalid-source"); |
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
10454 DEFSYM (Qinterrupted, "interrupted"); |
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
10455 DEFSYM (Qinsufficient_memory, "insufficient-memory"); |
90272
f1df126ec7de
Sync to HEAD for handling autoload-coding-system.
Kenichi Handa <handa@m17n.org>
parents:
90263
diff
changeset
|
10456 DEFSYM (Qcoding_system_define_form, "coding-system-define-form"); |
52794
f4d906e31662
(Qcoding_system_define_form): New variable.
Kenichi Handa <handa@m17n.org>
parents:
52401
diff
changeset
|
10457 |
17052 | 10458 defsubr (&Scoding_system_p); |
10459 defsubr (&Sread_coding_system); | |
10460 defsubr (&Sread_non_nil_coding_system); | |
10461 defsubr (&Scheck_coding_system); | |
10462 defsubr (&Sdetect_coding_region); | |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
10463 defsubr (&Sdetect_coding_string); |
30487
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
10464 defsubr (&Sfind_coding_systems_region_internal); |
46859
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
10465 defsubr (&Sunencodable_char_position); |
88365 | 10466 defsubr (&Scheck_coding_systems_region); |
17052 | 10467 defsubr (&Sdecode_coding_region); |
10468 defsubr (&Sencode_coding_region); | |
10469 defsubr (&Sdecode_coding_string); | |
10470 defsubr (&Sencode_coding_string); | |
10471 defsubr (&Sdecode_sjis_char); | |
10472 defsubr (&Sencode_sjis_char); | |
10473 defsubr (&Sdecode_big5_char); | |
10474 defsubr (&Sencode_big5_char); | |
18002
a14261786239
(encode_invocation_designation): Use macro
Kenichi Handa <handa@m17n.org>
parents:
17835
diff
changeset
|
10475 defsubr (&Sset_terminal_coding_system_internal); |
19280
e755044718ee
(ENCODE_ISO_CHARACTER_DIMENSION1): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
19193
diff
changeset
|
10476 defsubr (&Sset_safe_terminal_coding_system_internal); |
17052 | 10477 defsubr (&Sterminal_coding_system); |
18002
a14261786239
(encode_invocation_designation): Use macro
Kenichi Handa <handa@m17n.org>
parents:
17835
diff
changeset
|
10478 defsubr (&Sset_keyboard_coding_system_internal); |
17052 | 10479 defsubr (&Skeyboard_coding_system); |
18536
69c0e220b626
(Vstandard_character_unification_table_for_decode):
Kenichi Handa <handa@m17n.org>
parents:
18523
diff
changeset
|
10480 defsubr (&Sfind_operation_coding_system); |
88365 | 10481 defsubr (&Sset_coding_system_priority); |
49539
1ad5bfbb831a
(syms_of_coding): Add `...' for symbols in the docstring of
Kenichi Handa <handa@m17n.org>
parents:
48874
diff
changeset
|
10482 defsubr (&Sdefine_coding_system_internal); |
88365 | 10483 defsubr (&Sdefine_coding_system_alias); |
89759
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
10484 defsubr (&Scoding_system_put); |
88365 | 10485 defsubr (&Scoding_system_base); |
10486 defsubr (&Scoding_system_plist); | |
10487 defsubr (&Scoding_system_aliases); | |
10488 defsubr (&Scoding_system_eol_type); | |
10489 defsubr (&Scoding_system_priority_list); | |
17052 | 10490 |
20105
c017642863c2
(Qcoding_system_spec): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
19824
diff
changeset
|
10491 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
|
10492 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
|
10493 |
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
10494 Do not alter the value of this variable manually. This variable should be |
88365 | 10495 updated by the functions `define-coding-system' and |
40713
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
10496 `define-coding-system-alias'. */); |
20105
c017642863c2
(Qcoding_system_spec): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
19824
diff
changeset
|
10497 Vcoding_system_list = Qnil; |
c017642863c2
(Qcoding_system_spec): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
19824
diff
changeset
|
10498 |
c017642863c2
(Qcoding_system_spec): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
19824
diff
changeset
|
10499 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
|
10500 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
|
10501 Each element is one element list of coding system name. |
95356
90b4a0dc21cc
(Fdecode_coding_region, Fencode_coding_region, Fencode_coding_string):
Juanma Barranquero <lekktu@gmail.com>
parents:
95353
diff
changeset
|
10502 This variable is given to `completing-read' as COLLECTION argument. |
40713
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
10503 |
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
10504 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
|
10505 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
|
10506 `define-coding-system-alias'. */); |
20105
c017642863c2
(Qcoding_system_spec): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
19824
diff
changeset
|
10507 Vcoding_system_alist = Qnil; |
c017642863c2
(Qcoding_system_spec): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
19824
diff
changeset
|
10508 |
17052 | 10509 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
|
10510 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
|
10511 |
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
10512 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
|
10513 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
|
10514 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
|
10515 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
|
10516 |
61166
e3a6dd630fdf
(Vcoding_category_list): Docstring fix.
Kenichi Handa <handa@m17n.org>
parents:
60907
diff
changeset
|
10517 Don't modify this variable directly, but use `set-coding-priority'. */); |
17052 | 10518 { |
10519 int i; | |
10520 | |
10521 Vcoding_category_list = Qnil; | |
88365 | 10522 for (i = coding_category_max - 1; i >= 0; i--) |
17052 | 10523 Vcoding_category_list |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
10524 = Fcons (XVECTOR (Vcoding_category_table)->contents[i], |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
10525 Vcoding_category_list); |
17052 | 10526 } |
10527 | |
10528 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
|
10529 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
|
10530 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
|
10531 If the value is a coding system, it is used for decoding on read operation. |
95356
90b4a0dc21cc
(Fdecode_coding_region, Fencode_coding_region, Fencode_coding_string):
Juanma Barranquero <lekktu@gmail.com>
parents:
95353
diff
changeset
|
10532 If not, an appropriate element is used from one of the coding system alists. |
90b4a0dc21cc
(Fdecode_coding_region, Fencode_coding_region, Fencode_coding_string):
Juanma Barranquero <lekktu@gmail.com>
parents:
95353
diff
changeset
|
10533 There are three such tables: `file-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
|
10534 `process-coding-system-alist', and `network-coding-system-alist'. */); |
17052 | 10535 Vcoding_system_for_read = Qnil; |
10536 | |
10537 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
|
10538 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
|
10539 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
|
10540 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
|
10541 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
|
10542 |
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
10543 If this does not specify a coding system, an appropriate element |
95356
90b4a0dc21cc
(Fdecode_coding_region, Fencode_coding_region, Fencode_coding_string):
Juanma Barranquero <lekktu@gmail.com>
parents:
95353
diff
changeset
|
10544 is used from one of the coding system alists. |
90b4a0dc21cc
(Fdecode_coding_region, Fencode_coding_region, Fencode_coding_string):
Juanma Barranquero <lekktu@gmail.com>
parents:
95353
diff
changeset
|
10545 There are three such tables: `file-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
|
10546 `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
|
10547 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
|
10548 the value of `buffer-file-coding-system' is used. */); |
17052 | 10549 Vcoding_system_for_write = Qnil; |
10550 | |
10551 DEFVAR_LISP ("last-coding-system-used", &Vlast_coding_system_used, | |
88365 | 10552 doc: /* |
10553 Coding system used in the latest file or process I/O. */); | |
17052 | 10554 Vlast_coding_system_used = Qnil; |
10555 | |
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
10556 DEFVAR_LISP ("last-code-conversion-error", &Vlast_code_conversion_error, |
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
10557 doc: /* |
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
10558 Error status of the last code conversion. |
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
10559 |
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
10560 When an error was detected in the last code conversion, this variable |
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
10561 is set to one of the following symbols. |
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
10562 `insufficient-source' |
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
10563 `inconsistent-eol' |
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
10564 `invalid-source' |
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
10565 `interrupted' |
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
10566 `insufficient-memory' |
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
10567 When no error was detected, the value doesn't change. So, to check |
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
10568 the error status of a code conversion by this variable, you must |
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
10569 explicitly set this variable to nil before performing code |
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
10570 conversion. */); |
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
10571 Vlast_code_conversion_error = Qnil; |
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
10572 |
18650
aa3f2820e2ac
(Qemacs_mule, inhibit_eol_conversion): New variables.
Kenichi Handa <handa@m17n.org>
parents:
18613
diff
changeset
|
10573 DEFVAR_BOOL ("inhibit-eol-conversion", &inhibit_eol_conversion, |
88365 | 10574 doc: /* |
10575 *Non-nil means always inhibit code conversion of end-of-line format. | |
40713
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
10576 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
|
10577 such conversion. */); |
18650
aa3f2820e2ac
(Qemacs_mule, inhibit_eol_conversion): New variables.
Kenichi Handa <handa@m17n.org>
parents:
18613
diff
changeset
|
10578 inhibit_eol_conversion = 0; |
aa3f2820e2ac
(Qemacs_mule, inhibit_eol_conversion): New variables.
Kenichi Handa <handa@m17n.org>
parents:
18613
diff
changeset
|
10579 |
21574
30394e3ae7f8
(syms_of_coding): Declare and define inherit-process-coding-system.
Eli Zaretskii <eliz@gnu.org>
parents:
21520
diff
changeset
|
10580 DEFVAR_BOOL ("inherit-process-coding-system", &inherit_process_coding_system, |
88365 | 10581 doc: /* |
10582 Non-nil means process buffer inherits coding system of process output. | |
40713
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
10583 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
|
10584 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
|
10585 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
|
10586 |
18180
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
10587 DEFVAR_LISP ("file-coding-system-alist", &Vfile_coding_system_alist, |
88365 | 10588 doc: /* |
10589 Alist to decide a coding system to use for a file I/O operation. | |
40713
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
10590 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
|
10591 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
|
10592 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
|
10593 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
|
10594 the file contents. |
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
10595 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
|
10596 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
|
10597 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
|
10598 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
|
10599 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
|
10600 `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
|
10601 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
|
10602 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
|
10603 |
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
10604 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
|
10605 and the variable `auto-coding-alist'. */); |
18180
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
10606 Vfile_coding_system_alist = Qnil; |
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
10607 |
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
10608 DEFVAR_LISP ("process-coding-system-alist", &Vprocess_coding_system_alist, |
88365 | 10609 doc: /* |
10610 Alist to decide a coding system to use for a process I/O operation. | |
40713
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
10611 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
|
10612 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
|
10613 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
|
10614 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
|
10615 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
|
10616 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
|
10617 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
|
10618 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
|
10619 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
|
10620 |
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
10621 See also the function `find-operation-coding-system'. */); |
18180
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
10622 Vprocess_coding_system_alist = Qnil; |
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
10623 |
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
10624 DEFVAR_LISP ("network-coding-system-alist", &Vnetwork_coding_system_alist, |
88365 | 10625 doc: /* |
10626 Alist to decide a coding system to use for a network I/O operation. | |
40713
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
10627 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
|
10628 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
|
10629 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
|
10630 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
|
10631 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
|
10632 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
|
10633 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
|
10634 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
|
10635 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
|
10636 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
|
10637 |
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
10638 See also the function `find-operation-coding-system'. */); |
18180
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
10639 Vnetwork_coding_system_alist = Qnil; |
17052 | 10640 |
26088
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
26067
diff
changeset
|
10641 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
|
10642 doc: /* Coding system to use with system messages. |
6f20449b7e12
(syms_of_coding): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
41006
diff
changeset
|
10643 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
|
10644 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
|
10645 |
29182
1d1c27067af4
(encode_eol): Add null statement after label.
Dave Love <fx@gnu.org>
parents:
29172
diff
changeset
|
10646 /* 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
|
10647 DEFVAR_LISP ("eol-mnemonic-unix", &eol_mnemonic_unix, |
88365 | 10648 doc: /* |
10649 *String displayed in mode line for UNIX-like (LF) end-of-line format. */); | |
105877
21bdda3ded62
* xterm.c (syms_of_xterm):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105669
diff
changeset
|
10650 eol_mnemonic_unix = make_pure_c_string (":"); |
24200
b9d9fccad516
(syms_of_coding): eol-mnemonic-* variables are now
Eli Zaretskii <eliz@gnu.org>
parents:
24178
diff
changeset
|
10651 |
b9d9fccad516
(syms_of_coding): eol-mnemonic-* variables are now
Eli Zaretskii <eliz@gnu.org>
parents:
24178
diff
changeset
|
10652 DEFVAR_LISP ("eol-mnemonic-dos", &eol_mnemonic_dos, |
88365 | 10653 doc: /* |
10654 *String displayed in mode line for DOS-like (CRLF) end-of-line format. */); | |
105877
21bdda3ded62
* xterm.c (syms_of_xterm):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105669
diff
changeset
|
10655 eol_mnemonic_dos = make_pure_c_string ("\\"); |
24200
b9d9fccad516
(syms_of_coding): eol-mnemonic-* variables are now
Eli Zaretskii <eliz@gnu.org>
parents:
24178
diff
changeset
|
10656 |
b9d9fccad516
(syms_of_coding): eol-mnemonic-* variables are now
Eli Zaretskii <eliz@gnu.org>
parents:
24178
diff
changeset
|
10657 DEFVAR_LISP ("eol-mnemonic-mac", &eol_mnemonic_mac, |
88365 | 10658 doc: /* |
10659 *String displayed in mode line for MAC-like (CR) end-of-line format. */); | |
105877
21bdda3ded62
* xterm.c (syms_of_xterm):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105669
diff
changeset
|
10660 eol_mnemonic_mac = make_pure_c_string ("/"); |
24200
b9d9fccad516
(syms_of_coding): eol-mnemonic-* variables are now
Eli Zaretskii <eliz@gnu.org>
parents:
24178
diff
changeset
|
10661 |
b9d9fccad516
(syms_of_coding): eol-mnemonic-* variables are now
Eli Zaretskii <eliz@gnu.org>
parents:
24178
diff
changeset
|
10662 DEFVAR_LISP ("eol-mnemonic-undecided", &eol_mnemonic_undecided, |
88365 | 10663 doc: /* |
10664 *String displayed in mode line when end-of-line format is not yet determined. */); | |
105877
21bdda3ded62
* xterm.c (syms_of_xterm):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105669
diff
changeset
|
10665 eol_mnemonic_undecided = make_pure_c_string (":"); |
17052 | 10666 |
22119
592bb8b9bcfd
Change terms unify/unification to
Kenichi Handa <handa@m17n.org>
parents:
22020
diff
changeset
|
10667 DEFVAR_LISP ("enable-character-translation", &Venable_character_translation, |
88365 | 10668 doc: /* |
10669 *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
|
10670 Venable_character_translation = Qt; |
592bb8b9bcfd
Change terms unify/unification to
Kenichi Handa <handa@m17n.org>
parents:
22020
diff
changeset
|
10671 |
22186
fc4aaf1b1772
Change term "character translation table" to "translation table".
Kenichi Handa <handa@m17n.org>
parents:
22166
diff
changeset
|
10672 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
|
10673 &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
|
10674 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
|
10675 Vstandard_translation_table_for_decode = Qnil; |
fc4aaf1b1772
Change term "character translation table" to "translation table".
Kenichi Handa <handa@m17n.org>
parents:
22166
diff
changeset
|
10676 |
fc4aaf1b1772
Change term "character translation table" to "translation table".
Kenichi Handa <handa@m17n.org>
parents:
22166
diff
changeset
|
10677 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
|
10678 &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
|
10679 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
|
10680 Vstandard_translation_table_for_encode = Qnil; |
17052 | 10681 |
88365 | 10682 DEFVAR_LISP ("charset-revision-table", &Vcharset_revision_table, |
40713
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
10683 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
|
10684 While encoding, if a charset (car part of an element) is found, |
88365 | 10685 designate it with the escape sequence identifying revision (cdr part |
10686 of the element). */); | |
10687 Vcharset_revision_table = Qnil; | |
18180
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
10688 |
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
10689 DEFVAR_LISP ("default-process-coding-system", |
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
10690 &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
|
10691 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
|
10692 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
|
10693 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
|
10694 Vdefault_process_coding_system = Qnil; |
19280
e755044718ee
(ENCODE_ISO_CHARACTER_DIMENSION1): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
19193
diff
changeset
|
10695 |
19365
d9374f5ebd3a
(CODING_FLAG_ISO_LATIN_EXTRA): New macro.
Kenichi Handa <handa@m17n.org>
parents:
19285
diff
changeset
|
10696 DEFVAR_LISP ("latin-extra-code-table", &Vlatin_extra_code_table, |
88365 | 10697 doc: /* |
10698 Table of extra Latin codes in the range 128..159 (inclusive). | |
40713
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
10699 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
|
10700 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
|
10701 \(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
|
10702 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
|
10703 `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
|
10704 or reading output of a subprocess. |
95356
90b4a0dc21cc
(Fdecode_coding_region, Fencode_coding_region, Fencode_coding_string):
Juanma Barranquero <lekktu@gmail.com>
parents:
95353
diff
changeset
|
10705 Only 128th through 159th elements have a meaning. */); |
19365
d9374f5ebd3a
(CODING_FLAG_ISO_LATIN_EXTRA): New macro.
Kenichi Handa <handa@m17n.org>
parents:
19285
diff
changeset
|
10706 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
|
10707 |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
10708 DEFVAR_LISP ("select-safe-coding-system-function", |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
10709 &Vselect_safe_coding_system_function, |
88365 | 10710 doc: /* |
10711 Function to call to select safe coding system for encoding a text. | |
40713
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
10712 |
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
10713 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
|
10714 coding system which can encode the text in the case that a default |
87778
0ec6f8d26078
(select-safe-coding-system-function): Doc fix.
Glenn Morris <rgm@gnu.org>
parents:
87710
diff
changeset
|
10715 coding system used in each operation can't encode the text. The |
0ec6f8d26078
(select-safe-coding-system-function): Doc fix.
Glenn Morris <rgm@gnu.org>
parents:
87710
diff
changeset
|
10716 function should take care that the buffer is not modified while |
0ec6f8d26078
(select-safe-coding-system-function): Doc fix.
Glenn Morris <rgm@gnu.org>
parents:
87710
diff
changeset
|
10717 the coding system is being selected. |
40713
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
10718 |
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
10719 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
|
10720 Vselect_safe_coding_system_function = Qnil; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
10721 |
48874
3002a87cc629
(coding_system_require_warning): New variable.
Kenichi Handa <handa@m17n.org>
parents:
48829
diff
changeset
|
10722 DEFVAR_BOOL ("coding-system-require-warning", |
3002a87cc629
(coding_system_require_warning): New variable.
Kenichi Handa <handa@m17n.org>
parents:
48829
diff
changeset
|
10723 &coding_system_require_warning, |
3002a87cc629
(coding_system_require_warning): New variable.
Kenichi Handa <handa@m17n.org>
parents:
48829
diff
changeset
|
10724 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
|
10725 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
|
10726 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
|
10727 `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
|
10728 coding_system_require_warning = 0; |
3002a87cc629
(coding_system_require_warning): New variable.
Kenichi Handa <handa@m17n.org>
parents:
48829
diff
changeset
|
10729 |
3002a87cc629
(coding_system_require_warning): New variable.
Kenichi Handa <handa@m17n.org>
parents:
48829
diff
changeset
|
10730 |
30292
14a9937df1f5
(syms_of_coding): Fix typo in spelling of variable
Gerd Moellmann <gerd@gnu.org>
parents:
30263
diff
changeset
|
10731 DEFVAR_BOOL ("inhibit-iso-escape-detection", |
30204
35aec8514228
(inhibit_iso_escape_detection): New variable.
Kenichi Handa <handa@m17n.org>
parents:
29985
diff
changeset
|
10732 &inhibit_iso_escape_detection, |
88365 | 10733 doc: /* |
101040 | 10734 If non-nil, Emacs ignores ISO-2022 escape sequences during code detection. |
10735 | |
10736 When Emacs reads text, it tries to detect how the text is encoded. | |
10737 This code detection is sensitive to escape sequences. If Emacs sees | |
10738 a valid ISO-2022 escape sequence, it assumes the text is encoded in one | |
10739 of the ISO2022 encodings, and decodes text by the corresponding coding | |
10740 system (e.g. `iso-2022-7bit'). | |
40713
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
10741 |
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
10742 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
|
10743 a file as is. In such a case, you can set this variable to non-nil. |
101040 | 10744 Then the code detection will ignore any escape sequences, and no text is |
10745 detected as encoded in some ISO-2022 encoding. The result is that all | |
40713
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
10746 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
|
10747 |
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
10748 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
|
10749 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
|
10750 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
|
10751 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
|
10752 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
|
10753 |
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
10754 The other way to read escape sequences in a file without decoding is |
101040 | 10755 to explicitly specify some coding system that doesn't use ISO-2022 |
40713
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
10756 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
|
10757 inhibit_iso_escape_detection = 0; |
48182
9474e269efd1
Reformat some DEFUNs so that etags works.
Dave Love <fx@gnu.org>
parents:
48125
diff
changeset
|
10758 |
101040 | 10759 DEFVAR_BOOL ("inhibit-null-byte-detection", |
10760 &inhibit_null_byte_detection, | |
10761 doc: /* If non-nil, Emacs ignores null bytes on code detection. | |
10762 By default, Emacs treats it as binary data, and does not attempt to | |
10763 decode it. The effect is as if you specified `no-conversion' for | |
10764 reading that text. | |
10765 | |
10766 Set this to non-nil when a regular text happens to include null bytes. | |
10767 Examples are Index nodes of Info files and null-byte delimited output | |
10768 from GNU Find and GNU Grep. Emacs will then ignore the null bytes and | |
10769 decode text as usual. */); | |
10770 inhibit_null_byte_detection = 0; | |
10771 | |
48182
9474e269efd1
Reformat some DEFUNs so that etags works.
Dave Love <fx@gnu.org>
parents:
48125
diff
changeset
|
10772 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
|
10773 doc: /* Char table for translating self-inserting characters. |
95356
90b4a0dc21cc
(Fdecode_coding_region, Fencode_coding_region, Fencode_coding_string):
Juanma Barranquero <lekktu@gmail.com>
parents:
95353
diff
changeset
|
10774 This is applied to the result of input methods, not their input. |
101854
7e576fc18303
(syms_of_coding) <translation-table-for-input>: Modify doc string to
Eli Zaretskii <eliz@gnu.org>
parents:
101776
diff
changeset
|
10775 See also `keyboard-translate-table'. |
7e576fc18303
(syms_of_coding) <translation-table-for-input>: Modify doc string to
Eli Zaretskii <eliz@gnu.org>
parents:
101776
diff
changeset
|
10776 |
7e576fc18303
(syms_of_coding) <translation-table-for-input>: Modify doc string to
Eli Zaretskii <eliz@gnu.org>
parents:
101776
diff
changeset
|
10777 Use of this variable for character code unification was rendered |
7e576fc18303
(syms_of_coding) <translation-table-for-input>: Modify doc string to
Eli Zaretskii <eliz@gnu.org>
parents:
101776
diff
changeset
|
10778 obsolete in Emacs 23.1 and later, since Unicode is now the basis of |
7e576fc18303
(syms_of_coding) <translation-table-for-input>: Modify doc string to
Eli Zaretskii <eliz@gnu.org>
parents:
101776
diff
changeset
|
10779 internal character representation. */); |
48182
9474e269efd1
Reformat some DEFUNs so that etags works.
Dave Love <fx@gnu.org>
parents:
48125
diff
changeset
|
10780 Vtranslation_table_for_input = Qnil; |
89483 | 10781 |
88456
a7b309f72920
(coding_alloc_by_making_gap): Check the case that the
Kenichi Handa <handa@m17n.org>
parents:
88443
diff
changeset
|
10782 { |
a7b309f72920
(coding_alloc_by_making_gap): Check the case that the
Kenichi Handa <handa@m17n.org>
parents:
88443
diff
changeset
|
10783 Lisp_Object args[coding_arg_max]; |
89483 | 10784 Lisp_Object plist[16]; |
88456
a7b309f72920
(coding_alloc_by_making_gap): Check the case that the
Kenichi Handa <handa@m17n.org>
parents:
88443
diff
changeset
|
10785 int i; |
a7b309f72920
(coding_alloc_by_making_gap): Check the case that the
Kenichi Handa <handa@m17n.org>
parents:
88443
diff
changeset
|
10786 |
a7b309f72920
(coding_alloc_by_making_gap): Check the case that the
Kenichi Handa <handa@m17n.org>
parents:
88443
diff
changeset
|
10787 for (i = 0; i < coding_arg_max; i++) |
a7b309f72920
(coding_alloc_by_making_gap): Check the case that the
Kenichi Handa <handa@m17n.org>
parents:
88443
diff
changeset
|
10788 args[i] = Qnil; |
a7b309f72920
(coding_alloc_by_making_gap): Check the case that the
Kenichi Handa <handa@m17n.org>
parents:
88443
diff
changeset
|
10789 |
105877
21bdda3ded62
* xterm.c (syms_of_xterm):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105669
diff
changeset
|
10790 plist[0] = intern_c_string (":name"); |
88456
a7b309f72920
(coding_alloc_by_making_gap): Check the case that the
Kenichi Handa <handa@m17n.org>
parents:
88443
diff
changeset
|
10791 plist[1] = args[coding_arg_name] = Qno_conversion; |
105877
21bdda3ded62
* xterm.c (syms_of_xterm):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105669
diff
changeset
|
10792 plist[2] = intern_c_string (":mnemonic"); |
88456
a7b309f72920
(coding_alloc_by_making_gap): Check the case that the
Kenichi Handa <handa@m17n.org>
parents:
88443
diff
changeset
|
10793 plist[3] = args[coding_arg_mnemonic] = make_number ('='); |
105877
21bdda3ded62
* xterm.c (syms_of_xterm):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105669
diff
changeset
|
10794 plist[4] = intern_c_string (":coding-type"); |
88456
a7b309f72920
(coding_alloc_by_making_gap): Check the case that the
Kenichi Handa <handa@m17n.org>
parents:
88443
diff
changeset
|
10795 plist[5] = args[coding_arg_coding_type] = Qraw_text; |
105877
21bdda3ded62
* xterm.c (syms_of_xterm):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105669
diff
changeset
|
10796 plist[6] = intern_c_string (":ascii-compatible-p"); |
88456
a7b309f72920
(coding_alloc_by_making_gap): Check the case that the
Kenichi Handa <handa@m17n.org>
parents:
88443
diff
changeset
|
10797 plist[7] = args[coding_arg_ascii_compatible_p] = Qt; |
105877
21bdda3ded62
* xterm.c (syms_of_xterm):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105669
diff
changeset
|
10798 plist[8] = intern_c_string (":default-char"); |
88456
a7b309f72920
(coding_alloc_by_making_gap): Check the case that the
Kenichi Handa <handa@m17n.org>
parents:
88443
diff
changeset
|
10799 plist[9] = args[coding_arg_default_char] = make_number (0); |
105877
21bdda3ded62
* xterm.c (syms_of_xterm):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105669
diff
changeset
|
10800 plist[10] = intern_c_string (":for-unibyte"); |
89483 | 10801 plist[11] = args[coding_arg_for_unibyte] = Qt; |
105877
21bdda3ded62
* xterm.c (syms_of_xterm):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105669
diff
changeset
|
10802 plist[12] = intern_c_string (":docstring"); |
21bdda3ded62
* xterm.c (syms_of_xterm):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105669
diff
changeset
|
10803 plist[13] = make_pure_c_string ("Do no conversion.\n\ |
88456
a7b309f72920
(coding_alloc_by_making_gap): Check the case that the
Kenichi Handa <handa@m17n.org>
parents:
88443
diff
changeset
|
10804 \n\ |
a7b309f72920
(coding_alloc_by_making_gap): Check the case that the
Kenichi Handa <handa@m17n.org>
parents:
88443
diff
changeset
|
10805 When you visit a file with this coding, the file is read into a\n\ |
a7b309f72920
(coding_alloc_by_making_gap): Check the case that the
Kenichi Handa <handa@m17n.org>
parents:
88443
diff
changeset
|
10806 unibyte buffer as is, thus each byte of a file is treated as a\n\ |
a7b309f72920
(coding_alloc_by_making_gap): Check the case that the
Kenichi Handa <handa@m17n.org>
parents:
88443
diff
changeset
|
10807 character."); |
105877
21bdda3ded62
* xterm.c (syms_of_xterm):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105669
diff
changeset
|
10808 plist[14] = intern_c_string (":eol-type"); |
89483 | 10809 plist[15] = args[coding_arg_eol_type] = Qunix; |
10810 args[coding_arg_plist] = Flist (16, plist); | |
88456
a7b309f72920
(coding_alloc_by_making_gap): Check the case that the
Kenichi Handa <handa@m17n.org>
parents:
88443
diff
changeset
|
10811 Fdefine_coding_system_internal (coding_arg_max, args); |
90011
26cef35a1562
(setup_coding_system): If coding_system is nil, use
Kenichi Handa <handa@m17n.org>
parents:
89976
diff
changeset
|
10812 |
26cef35a1562
(setup_coding_system): If coding_system is nil, use
Kenichi Handa <handa@m17n.org>
parents:
89976
diff
changeset
|
10813 plist[1] = args[coding_arg_name] = Qundecided; |
26cef35a1562
(setup_coding_system): If coding_system is nil, use
Kenichi Handa <handa@m17n.org>
parents:
89976
diff
changeset
|
10814 plist[3] = args[coding_arg_mnemonic] = make_number ('-'); |
26cef35a1562
(setup_coding_system): If coding_system is nil, use
Kenichi Handa <handa@m17n.org>
parents:
89976
diff
changeset
|
10815 plist[5] = args[coding_arg_coding_type] = Qundecided; |
26cef35a1562
(setup_coding_system): If coding_system is nil, use
Kenichi Handa <handa@m17n.org>
parents:
89976
diff
changeset
|
10816 /* This is already set. |
90214
460ee00505d5
(QCascii_compatible_p): New variable.
Kenichi Handa <handa@m17n.org>
parents:
90201
diff
changeset
|
10817 plist[7] = args[coding_arg_ascii_compatible_p] = Qt; */ |
105877
21bdda3ded62
* xterm.c (syms_of_xterm):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105669
diff
changeset
|
10818 plist[8] = intern_c_string (":charset-list"); |
90011
26cef35a1562
(setup_coding_system): If coding_system is nil, use
Kenichi Handa <handa@m17n.org>
parents:
89976
diff
changeset
|
10819 plist[9] = args[coding_arg_charset_list] = Fcons (Qascii, Qnil); |
26cef35a1562
(setup_coding_system): If coding_system is nil, use
Kenichi Handa <handa@m17n.org>
parents:
89976
diff
changeset
|
10820 plist[11] = args[coding_arg_for_unibyte] = Qnil; |
105877
21bdda3ded62
* xterm.c (syms_of_xterm):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105669
diff
changeset
|
10821 plist[13] = make_pure_c_string ("No conversion on encoding, automatic conversion on decoding."); |
90011
26cef35a1562
(setup_coding_system): If coding_system is nil, use
Kenichi Handa <handa@m17n.org>
parents:
89976
diff
changeset
|
10822 plist[15] = args[coding_arg_eol_type] = Qnil; |
26cef35a1562
(setup_coding_system): If coding_system is nil, use
Kenichi Handa <handa@m17n.org>
parents:
89976
diff
changeset
|
10823 args[coding_arg_plist] = Flist (16, plist); |
26cef35a1562
(setup_coding_system): If coding_system is nil, use
Kenichi Handa <handa@m17n.org>
parents:
89976
diff
changeset
|
10824 Fdefine_coding_system_internal (coding_arg_max, args); |
88456
a7b309f72920
(coding_alloc_by_making_gap): Check the case that the
Kenichi Handa <handa@m17n.org>
parents:
88443
diff
changeset
|
10825 } |
a7b309f72920
(coding_alloc_by_making_gap): Check the case that the
Kenichi Handa <handa@m17n.org>
parents:
88443
diff
changeset
|
10826 |
a7b309f72920
(coding_alloc_by_making_gap): Check the case that the
Kenichi Handa <handa@m17n.org>
parents:
88443
diff
changeset
|
10827 setup_coding_system (Qno_conversion, &safe_terminal_coding); |
89467
e911ca706166
(Fset_coding_system_priority): Doc fix. Update values
Kenichi Handa <handa@m17n.org>
parents:
89462
diff
changeset
|
10828 |
e911ca706166
(Fset_coding_system_priority): Doc fix. Update values
Kenichi Handa <handa@m17n.org>
parents:
89462
diff
changeset
|
10829 { |
e911ca706166
(Fset_coding_system_priority): Doc fix. Update values
Kenichi Handa <handa@m17n.org>
parents:
89462
diff
changeset
|
10830 int i; |
e911ca706166
(Fset_coding_system_priority): Doc fix. Update values
Kenichi Handa <handa@m17n.org>
parents:
89462
diff
changeset
|
10831 |
e911ca706166
(Fset_coding_system_priority): Doc fix. Update values
Kenichi Handa <handa@m17n.org>
parents:
89462
diff
changeset
|
10832 for (i = 0; i < coding_category_max; i++) |
e911ca706166
(Fset_coding_system_priority): Doc fix. Update values
Kenichi Handa <handa@m17n.org>
parents:
89462
diff
changeset
|
10833 Fset (AREF (Vcoding_category_table, i), Qno_conversion); |
e911ca706166
(Fset_coding_system_priority): Doc fix. Update values
Kenichi Handa <handa@m17n.org>
parents:
89462
diff
changeset
|
10834 } |
109158
6175ebc3b6ce
* coding.c: Use SPECPDL_INDEX, DOS_NT.
Juanma Barranquero <lekktu@gmail.com>
parents:
109126
diff
changeset
|
10835 #if defined (DOS_NT) |
90394
263867fe7b55
(system_eol_type): Sync with HEAD.
Kenichi Handa <handa@m17n.org>
parents:
90380
diff
changeset
|
10836 system_eol_type = Qdos; |
263867fe7b55
(system_eol_type): Sync with HEAD.
Kenichi Handa <handa@m17n.org>
parents:
90380
diff
changeset
|
10837 #else |
263867fe7b55
(system_eol_type): Sync with HEAD.
Kenichi Handa <handa@m17n.org>
parents:
90380
diff
changeset
|
10838 system_eol_type = Qunix; |
263867fe7b55
(system_eol_type): Sync with HEAD.
Kenichi Handa <handa@m17n.org>
parents:
90380
diff
changeset
|
10839 #endif |
263867fe7b55
(system_eol_type): Sync with HEAD.
Kenichi Handa <handa@m17n.org>
parents:
90380
diff
changeset
|
10840 staticpro (&system_eol_type); |
17052 | 10841 } |
10842 | |
26088
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
26067
diff
changeset
|
10843 char * |
109126
aec1143e8d85
Convert (most) functions in src to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109100
diff
changeset
|
10844 emacs_strerror (int error_number) |
26088
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
26067
diff
changeset
|
10845 { |
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
26067
diff
changeset
|
10846 char *str; |
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
26067
diff
changeset
|
10847 |
26526
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26240
diff
changeset
|
10848 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
|
10849 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
|
10850 |
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
26067
diff
changeset
|
10851 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
|
10852 { |
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
26067
diff
changeset
|
10853 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
|
10854 Vlocale_coding_system, |
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
26067
diff
changeset
|
10855 0); |
46370
40db0673e6f0
Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents:
46293
diff
changeset
|
10856 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
|
10857 } |
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
26067
diff
changeset
|
10858 |
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
26067
diff
changeset
|
10859 return str; |
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
26067
diff
changeset
|
10860 } |
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
26067
diff
changeset
|
10861 |
17052 | 10862 #endif /* emacs */ |
29184 | 10863 |
52401 | 10864 /* arch-tag: 3a3a2b01-5ff6-4071-9afe-f5b808d9229d |
10865 (do not change this comment) */ |