Mercurial > emacs
annotate src/coding.c @ 29367:f7e5e797d015
(ospeed) [HAVE_SPEED_T]: Don't declare extern.
author | Dave Love <fx@gnu.org> |
---|---|
date | Thu, 01 Jun 2000 15:47:38 +0000 |
parents | b33b38d81020 |
children | ebf778ab6b42 |
rev | line source |
---|---|
17052 | 1 /* Coding system handler (conversion, detection, and etc). |
20708 | 2 Copyright (C) 1995, 1997, 1998 Electrotechnical Laboratory, JAPAN. |
18269
888bfd80db2c
Change copyright notices.
Richard M. Stallman <rms@gnu.org>
parents:
18180
diff
changeset
|
3 Licensed to the Free Software Foundation. |
17052 | 4 |
17071 | 5 This file is part of GNU Emacs. |
6 | |
7 GNU Emacs is free software; you can redistribute it and/or modify | |
8 it under the terms of the GNU General Public License as published by | |
9 the Free Software Foundation; either version 2, or (at your option) | |
10 any later version. | |
11 | |
12 GNU Emacs is distributed in the hope that it will be useful, | |
13 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 GNU General Public License for more details. | |
16 | |
17 You should have received a copy of the GNU General Public License | |
18 along with GNU Emacs; see the file COPYING. If not, write to | |
19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
20 Boston, MA 02111-1307, USA. */ | |
17052 | 21 |
22 /*** TABLE OF CONTENTS *** | |
23 | |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
24 0. General comments |
17052 | 25 1. Preamble |
17835
f36ffb6f1208
Name change through the code:
Kenichi Handa <handa@m17n.org>
parents:
17725
diff
changeset
|
26 2. Emacs' internal format (emacs-mule) handlers |
17052 | 27 3. ISO2022 handlers |
28 4. Shift-JIS and BIG5 handlers | |
22874
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
29 5. CCL handlers |
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
30 6. End-of-line handlers |
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
31 7. C library functions |
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
32 8. Emacs Lisp library functions |
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
33 9. Post-amble |
17052 | 34 |
35 */ | |
36 | |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
37 /*** 0. General comments ***/ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
38 |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
39 |
17052 | 40 /*** GENERAL NOTE on CODING SYSTEM *** |
41 | |
42 Coding system is an encoding mechanism of one or more character | |
43 sets. Here's a list of coding systems which Emacs can handle. When | |
44 we say "decode", it means converting some other coding system to | |
17835
f36ffb6f1208
Name change through the code:
Kenichi Handa <handa@m17n.org>
parents:
17725
diff
changeset
|
45 Emacs' internal format (emacs-internal), and when we say "encode", |
f36ffb6f1208
Name change through the code:
Kenichi Handa <handa@m17n.org>
parents:
17725
diff
changeset
|
46 it means converting the coding system emacs-mule to some other |
f36ffb6f1208
Name change through the code:
Kenichi Handa <handa@m17n.org>
parents:
17725
diff
changeset
|
47 coding system. |
f36ffb6f1208
Name change through the code:
Kenichi Handa <handa@m17n.org>
parents:
17725
diff
changeset
|
48 |
f36ffb6f1208
Name change through the code:
Kenichi Handa <handa@m17n.org>
parents:
17725
diff
changeset
|
49 0. Emacs' internal format (emacs-mule) |
17052 | 50 |
51 Emacs itself holds a multi-lingual character in a buffer and a string | |
18766 | 52 in a special format. Details are described in section 2. |
17052 | 53 |
54 1. ISO2022 | |
55 | |
56 The most famous coding system for multiple character sets. X's | |
18766 | 57 Compound Text, various EUCs (Extended Unix Code), and coding |
58 systems used in Internet communication such as ISO-2022-JP are | |
59 all variants of ISO2022. Details are described in section 3. | |
17052 | 60 |
61 2. SJIS (or Shift-JIS or MS-Kanji-Code) | |
62 | |
63 A coding system to encode character sets: ASCII, JISX0201, and | |
64 JISX0208. Widely used for PC's in Japan. Details are described in | |
18766 | 65 section 4. |
17052 | 66 |
67 3. BIG5 | |
68 | |
69 A coding system to encode character sets: ASCII and Big5. Widely | |
70 used by Chinese (mainly in Taiwan and Hong Kong). Details are | |
18766 | 71 described in section 4. In this file, when we write "BIG5" |
72 (all uppercase), we mean the coding system, and when we write | |
73 "Big5" (capitalized), we mean the character set. | |
74 | |
19612
783efd6c7c1e
(Qno_conversion, Qundecided): New variables.
Kenichi Handa <handa@m17n.org>
parents:
19546
diff
changeset
|
75 4. Raw text |
783efd6c7c1e
(Qno_conversion, Qundecided): New variables.
Kenichi Handa <handa@m17n.org>
parents:
19546
diff
changeset
|
76 |
20105
c017642863c2
(Qcoding_system_spec): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
19824
diff
changeset
|
77 A coding system for a text containing random 8-bit code. Emacs does |
c017642863c2
(Qcoding_system_spec): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
19824
diff
changeset
|
78 no code conversion on such a text except for end-of-line format. |
19612
783efd6c7c1e
(Qno_conversion, Qundecided): New variables.
Kenichi Handa <handa@m17n.org>
parents:
19546
diff
changeset
|
79 |
783efd6c7c1e
(Qno_conversion, Qundecided): New variables.
Kenichi Handa <handa@m17n.org>
parents:
19546
diff
changeset
|
80 5. Other |
18766 | 81 |
82 If a user wants to read/write a text encoded in a coding system not | |
17052 | 83 listed above, he can supply a decoder and an encoder for it in CCL |
84 (Code Conversion Language) programs. Emacs executes the CCL program | |
85 while reading/writing. | |
86 | |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
87 Emacs represents a coding system by a Lisp symbol that has a property |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
88 `coding-system'. But, before actually using the coding system, the |
17052 | 89 information about it is set in a structure of type `struct |
18766 | 90 coding_system' for rapid processing. See section 6 for more details. |
17052 | 91 |
92 */ | |
93 | |
94 /*** GENERAL NOTES on END-OF-LINE FORMAT *** | |
95 | |
96 How end-of-line of a text is encoded depends on a system. For | |
97 instance, Unix's format is just one byte of `line-feed' code, | |
18766 | 98 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
|
99 `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
|
100 `carriage-return'. |
17052 | 101 |
18766 | 102 Since text characters encoding and end-of-line encoding are |
103 independent, any coding system described above can take | |
17052 | 104 any format of end-of-line. So, Emacs has information of format of |
18766 | 105 end-of-line in each coding-system. See section 6 for more details. |
17052 | 106 |
107 */ | |
108 | |
109 /*** GENERAL NOTES on `detect_coding_XXX ()' functions *** | |
110 | |
111 These functions check if a text between SRC and SRC_END is encoded | |
112 in the coding system category XXX. Each returns an integer value in | |
113 which appropriate flag bits for the category XXX is set. The flag | |
114 bits are defined in macros CODING_CATEGORY_MASK_XXX. Below is the | |
115 template of these functions. */ | |
116 #if 0 | |
117 int | |
17835
f36ffb6f1208
Name change through the code:
Kenichi Handa <handa@m17n.org>
parents:
17725
diff
changeset
|
118 detect_coding_emacs_mule (src, src_end) |
17052 | 119 unsigned char *src, *src_end; |
120 { | |
121 ... | |
122 } | |
123 #endif | |
124 | |
125 /*** GENERAL NOTES on `decode_coding_XXX ()' functions *** | |
126 | |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
127 These functions decode SRC_BYTES length of unibyte text at SOURCE |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
128 encoded in CODING to Emacs' internal format. The resulting |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
129 multibyte text goes to a place pointed to by DESTINATION, the length |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
130 of which should not exceed DST_BYTES. |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
131 |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
132 These functions set the information of original and decoded texts in |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
133 the members produced, produced_char, consumed, and consumed_char of |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
134 the structure *CODING. They also set the member result to one of |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
135 CODING_FINISH_XXX indicating how the decoding finished. |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
136 |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
137 DST_BYTES zero means that source area and destination area are |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
138 overlapped, which means that we can produce a decoded text until it |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
139 reaches at the head of not-yet-decoded source text. |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
140 |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
141 Below is a template of these functions. */ |
17052 | 142 #if 0 |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
143 static void |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
144 decode_coding_XXX (coding, source, destination, src_bytes, dst_bytes) |
17052 | 145 struct coding_system *coding; |
146 unsigned char *source, *destination; | |
147 int src_bytes, dst_bytes; | |
148 { | |
149 ... | |
150 } | |
151 #endif | |
152 | |
153 /*** GENERAL NOTES on `encode_coding_XXX ()' functions *** | |
154 | |
17835
f36ffb6f1208
Name change through the code:
Kenichi Handa <handa@m17n.org>
parents:
17725
diff
changeset
|
155 These functions encode SRC_BYTES length text at SOURCE of Emacs' |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
156 internal multibyte format to CODING. The resulting unibyte text |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
157 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
|
158 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
|
159 |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
160 These functions set the information of original and encoded texts in |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
161 the members produced, produced_char, consumed, and consumed_char of |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
162 the structure *CODING. They also set the member result to one of |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
163 CODING_FINISH_XXX indicating how the encoding finished. |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
164 |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
165 DST_BYTES zero means that source area and destination area are |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
166 overlapped, which means that we can produce a encoded text until it |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
167 reaches at the head of not-yet-encoded source text. |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
168 |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
169 Below is a template of these functions. */ |
17052 | 170 #if 0 |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
171 static void |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
172 encode_coding_XXX (coding, source, destination, src_bytes, dst_bytes) |
17052 | 173 struct coding_system *coding; |
174 unsigned char *source, *destination; | |
175 int src_bytes, dst_bytes; | |
176 { | |
177 ... | |
178 } | |
179 #endif | |
180 | |
181 /*** COMMONLY USED MACROS ***/ | |
182 | |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
183 /* The following two macros ONE_MORE_BYTE and TWO_MORE_BYTES safely |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
184 get one, two, and three bytes from the source text respectively. |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
185 If there are not enough bytes in the source, they jump to |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
186 `label_end_of_loop'. The caller should set variables `coding', |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
187 `src' and `src_end' to appropriate pointer in advance. These |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
188 macros are called from decoding routines `decode_coding_XXX', thus |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
189 it is assumed that the source text is unibyte. */ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
190 |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
191 #define ONE_MORE_BYTE(c1) \ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
192 do { \ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
193 if (src >= src_end) \ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
194 { \ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
195 coding->result = CODING_FINISH_INSUFFICIENT_SRC; \ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
196 goto label_end_of_loop; \ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
197 } \ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
198 c1 = *src++; \ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
199 } while (0) |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
200 |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
201 #define TWO_MORE_BYTES(c1, c2) \ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
202 do { \ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
203 if (src + 1 >= src_end) \ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
204 { \ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
205 coding->result = CODING_FINISH_INSUFFICIENT_SRC; \ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
206 goto label_end_of_loop; \ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
207 } \ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
208 c1 = *src++; \ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
209 c2 = *src++; \ |
17052 | 210 } while (0) |
211 | |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
212 |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
213 /* Set C to the next character at the source text pointed by `src'. |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
214 If there are not enough characters in the source, jump to |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
215 `label_end_of_loop'. The caller should set variables `coding' |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
216 `src', `src_end', and `translation_table' to appropriate pointers |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
217 in advance. This macro is used in encoding routines |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
218 `encode_coding_XXX', thus it assumes that the source text is in |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
219 multibyte form except for 8-bit characters. 8-bit characters are |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
220 in multibyte form if coding->src_multibyte is nonzero, else they |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
221 are represented by a single byte. */ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
222 |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
223 #define ONE_MORE_CHAR(c) \ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
224 do { \ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
225 int len = src_end - src; \ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
226 int bytes; \ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
227 if (len <= 0) \ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
228 { \ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
229 coding->result = CODING_FINISH_INSUFFICIENT_SRC; \ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
230 goto label_end_of_loop; \ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
231 } \ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
232 if (coding->src_multibyte \ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
233 || UNIBYTE_STR_AS_MULTIBYTE_P (src, len, bytes)) \ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
234 c = STRING_CHAR_AND_LENGTH (src, len, bytes); \ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
235 else \ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
236 c = *src, bytes = 1; \ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
237 if (!NILP (translation_table)) \ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
238 c = translate_char (translation_table, c, 0, 0, 0); \ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
239 src += bytes; \ |
17052 | 240 } while (0) |
241 | |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
242 |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
243 /* Produce a multibyte form of characater C to `dst'. Jump to |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
244 `label_end_of_loop' if there's not enough space at `dst'. |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
245 |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
246 If we are now in the middle of composition sequence, the decoded |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
247 character may be ALTCHAR (for the current composition). In that |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
248 case, the character goes to coding->cmp_data->data instead of |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
249 `dst'. |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
250 |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
251 This macro is used in decoding routines. */ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
252 |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
253 #define EMIT_CHAR(c) \ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
254 do { \ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
255 if (! COMPOSING_P (coding) \ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
256 || coding->composing == COMPOSITION_RELATIVE \ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
257 || coding->composing == COMPOSITION_WITH_RULE) \ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
258 { \ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
259 int bytes = CHAR_BYTES (c); \ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
260 if ((dst + bytes) > (dst_bytes ? dst_end : src)) \ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
261 { \ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
262 coding->result = CODING_FINISH_INSUFFICIENT_DST; \ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
263 goto label_end_of_loop; \ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
264 } \ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
265 dst += CHAR_STRING (c, dst); \ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
266 coding->produced_char++; \ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
267 } \ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
268 \ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
269 if (COMPOSING_P (coding) \ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
270 && coding->composing != COMPOSITION_RELATIVE) \ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
271 { \ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
272 CODING_ADD_COMPOSITION_COMPONENT (coding, c); \ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
273 coding->composition_rule_follows \ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
274 = coding->composing != COMPOSITION_WITH_ALTCHARS; \ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
275 } \ |
17052 | 276 } while (0) |
277 | |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
278 |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
279 #define EMIT_ONE_BYTE(c) \ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
280 do { \ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
281 if (dst >= (dst_bytes ? dst_end : src)) \ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
282 { \ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
283 coding->result = CODING_FINISH_INSUFFICIENT_DST; \ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
284 goto label_end_of_loop; \ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
285 } \ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
286 *dst++ = c; \ |
17052 | 287 } while (0) |
288 | |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
289 #define EMIT_TWO_BYTES(c1, c2) \ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
290 do { \ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
291 if (dst + 2 > (dst_bytes ? dst_end : src)) \ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
292 { \ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
293 coding->result = CODING_FINISH_INSUFFICIENT_DST; \ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
294 goto label_end_of_loop; \ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
295 } \ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
296 *dst++ = c1, *dst++ = c2; \ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
297 } while (0) |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
298 |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
299 #define EMIT_BYTES(from, to) \ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
300 do { \ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
301 if (dst + (to - from) > (dst_bytes ? dst_end : src)) \ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
302 { \ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
303 coding->result = CODING_FINISH_INSUFFICIENT_DST; \ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
304 goto label_end_of_loop; \ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
305 } \ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
306 while (from < to) \ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
307 *dst++ = *from++; \ |
17052 | 308 } while (0) |
309 | |
310 | |
311 /*** 1. Preamble ***/ | |
312 | |
26088
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
26067
diff
changeset
|
313 #ifdef emacs |
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
26067
diff
changeset
|
314 #include <config.h> |
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
26067
diff
changeset
|
315 #endif |
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
26067
diff
changeset
|
316 |
17052 | 317 #include <stdio.h> |
318 | |
319 #ifdef emacs | |
320 | |
321 #include "lisp.h" | |
322 #include "buffer.h" | |
323 #include "charset.h" | |
26847 | 324 #include "composite.h" |
17052 | 325 #include "ccl.h" |
326 #include "coding.h" | |
327 #include "window.h" | |
328 | |
329 #else /* not emacs */ | |
330 | |
331 #include "mulelib.h" | |
332 | |
333 #endif /* not emacs */ | |
334 | |
335 Lisp_Object Qcoding_system, Qeol_type; | |
336 Lisp_Object Qbuffer_file_coding_system; | |
337 Lisp_Object Qpost_read_conversion, Qpre_write_conversion; | |
19612
783efd6c7c1e
(Qno_conversion, Qundecided): New variables.
Kenichi Handa <handa@m17n.org>
parents:
19546
diff
changeset
|
338 Lisp_Object Qno_conversion, Qundecided; |
19750
95e4e1cba6ac
(Qcoding_system_history): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
19747
diff
changeset
|
339 Lisp_Object Qcoding_system_history; |
20150
402b6e5f4b58
(encode_designation_at_bol): Fix bug of finding graphic
Kenichi Handa <handa@m17n.org>
parents:
20105
diff
changeset
|
340 Lisp_Object Qsafe_charsets; |
22874
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
341 Lisp_Object Qvalid_codes; |
17052 | 342 |
343 extern Lisp_Object Qinsert_file_contents, Qwrite_region; | |
344 Lisp_Object Qcall_process, Qcall_process_region, Qprocess_argument; | |
345 Lisp_Object Qstart_process, Qopen_network_stream; | |
346 Lisp_Object Qtarget_idx; | |
347 | |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
348 Lisp_Object Vselect_safe_coding_system_function; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
349 |
24200
b9d9fccad516
(syms_of_coding): eol-mnemonic-* variables are now
Eli Zaretskii <eliz@gnu.org>
parents:
24178
diff
changeset
|
350 /* 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
|
351 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
|
352 /* Mnemonic string to indicate format of end-of-line is not yet |
17052 | 353 decided. */ |
24200
b9d9fccad516
(syms_of_coding): eol-mnemonic-* variables are now
Eli Zaretskii <eliz@gnu.org>
parents:
24178
diff
changeset
|
354 Lisp_Object eol_mnemonic_undecided; |
17052 | 355 |
18650
aa3f2820e2ac
(Qemacs_mule, inhibit_eol_conversion): New variables.
Kenichi Handa <handa@m17n.org>
parents:
18613
diff
changeset
|
356 /* Format of end-of-line decided by system. This is CODING_EOL_LF on |
aa3f2820e2ac
(Qemacs_mule, inhibit_eol_conversion): New variables.
Kenichi Handa <handa@m17n.org>
parents:
18613
diff
changeset
|
357 Unix, CODING_EOL_CRLF on DOS/Windows, and CODING_EOL_CR on Mac. */ |
aa3f2820e2ac
(Qemacs_mule, inhibit_eol_conversion): New variables.
Kenichi Handa <handa@m17n.org>
parents:
18613
diff
changeset
|
358 int system_eol_type; |
aa3f2820e2ac
(Qemacs_mule, inhibit_eol_conversion): New variables.
Kenichi Handa <handa@m17n.org>
parents:
18613
diff
changeset
|
359 |
17052 | 360 #ifdef emacs |
361 | |
20105
c017642863c2
(Qcoding_system_spec): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
19824
diff
changeset
|
362 Lisp_Object Vcoding_system_list, Vcoding_system_alist; |
c017642863c2
(Qcoding_system_spec): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
19824
diff
changeset
|
363 |
c017642863c2
(Qcoding_system_spec): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
19824
diff
changeset
|
364 Lisp_Object Qcoding_system_p, Qcoding_system_error; |
17052 | 365 |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
366 /* 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
|
367 end-of-line format. */ |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
368 Lisp_Object Qemacs_mule, Qraw_text; |
18650
aa3f2820e2ac
(Qemacs_mule, inhibit_eol_conversion): New variables.
Kenichi Handa <handa@m17n.org>
parents:
18613
diff
changeset
|
369 |
17052 | 370 /* Coding-systems are handed between Emacs Lisp programs and C internal |
371 routines by the following three variables. */ | |
372 /* Coding-system for reading files and receiving data from process. */ | |
373 Lisp_Object Vcoding_system_for_read; | |
374 /* Coding-system for writing files and sending data to process. */ | |
375 Lisp_Object Vcoding_system_for_write; | |
376 /* Coding-system actually used in the latest I/O. */ | |
377 Lisp_Object Vlast_coding_system_used; | |
378 | |
19280
e755044718ee
(ENCODE_ISO_CHARACTER_DIMENSION1): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
19193
diff
changeset
|
379 /* A vector of length 256 which contains information about special |
22529 | 380 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
|
381 Lisp_Object Vlatin_extra_code_table; |
19280
e755044718ee
(ENCODE_ISO_CHARACTER_DIMENSION1): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
19193
diff
changeset
|
382 |
18650
aa3f2820e2ac
(Qemacs_mule, inhibit_eol_conversion): New variables.
Kenichi Handa <handa@m17n.org>
parents:
18613
diff
changeset
|
383 /* 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
|
384 int inhibit_eol_conversion; |
aa3f2820e2ac
(Qemacs_mule, inhibit_eol_conversion): New variables.
Kenichi Handa <handa@m17n.org>
parents:
18613
diff
changeset
|
385 |
21574
30394e3ae7f8
(syms_of_coding): Declare and define inherit-process-coding-system.
Eli Zaretskii <eliz@gnu.org>
parents:
21520
diff
changeset
|
386 /* 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
|
387 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
|
388 |
19280
e755044718ee
(ENCODE_ISO_CHARACTER_DIMENSION1): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
19193
diff
changeset
|
389 /* Coding system to be used to encode text for terminal display. */ |
17052 | 390 struct coding_system terminal_coding; |
391 | |
19280
e755044718ee
(ENCODE_ISO_CHARACTER_DIMENSION1): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
19193
diff
changeset
|
392 /* 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
|
393 terminal coding system is nil. */ |
e755044718ee
(ENCODE_ISO_CHARACTER_DIMENSION1): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
19193
diff
changeset
|
394 struct coding_system safe_terminal_coding; |
e755044718ee
(ENCODE_ISO_CHARACTER_DIMENSION1): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
19193
diff
changeset
|
395 |
e755044718ee
(ENCODE_ISO_CHARACTER_DIMENSION1): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
19193
diff
changeset
|
396 /* Coding system of what is sent from terminal keyboard. */ |
17052 | 397 struct coding_system keyboard_coding; |
398 | |
22979
ceb8e4a89a32
(default_buffer_file_coding): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22964
diff
changeset
|
399 /* Default coding system to be used to write a file. */ |
ceb8e4a89a32
(default_buffer_file_coding): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22964
diff
changeset
|
400 struct coding_system default_buffer_file_coding; |
ceb8e4a89a32
(default_buffer_file_coding): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22964
diff
changeset
|
401 |
18180
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
402 Lisp_Object Vfile_coding_system_alist; |
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
403 Lisp_Object Vprocess_coding_system_alist; |
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
404 Lisp_Object Vnetwork_coding_system_alist; |
17052 | 405 |
26088
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
26067
diff
changeset
|
406 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
|
407 |
17052 | 408 #endif /* emacs */ |
409 | |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
410 Lisp_Object Qcoding_category, Qcoding_category_index; |
17052 | 411 |
412 /* List of symbols `coding-category-xxx' ordered by priority. */ | |
413 Lisp_Object Vcoding_category_list; | |
414 | |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
415 /* Table of coding categories (Lisp symbols). */ |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
416 Lisp_Object Vcoding_category_table; |
17052 | 417 |
418 /* Table of names of symbol for each coding-category. */ | |
419 char *coding_category_name[CODING_CATEGORY_IDX_MAX] = { | |
17835
f36ffb6f1208
Name change through the code:
Kenichi Handa <handa@m17n.org>
parents:
17725
diff
changeset
|
420 "coding-category-emacs-mule", |
17052 | 421 "coding-category-sjis", |
422 "coding-category-iso-7", | |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
423 "coding-category-iso-7-tight", |
17052 | 424 "coding-category-iso-8-1", |
425 "coding-category-iso-8-2", | |
18787
954e6be0a757
(detect_coding_iso2022): Distinguish coding-category-iso-7-else and
Kenichi Handa <handa@m17n.org>
parents:
18766
diff
changeset
|
426 "coding-category-iso-7-else", |
954e6be0a757
(detect_coding_iso2022): Distinguish coding-category-iso-7-else and
Kenichi Handa <handa@m17n.org>
parents:
18766
diff
changeset
|
427 "coding-category-iso-8-else", |
23027
0dc823b2335f
(coding_category_name): Fix the order of initial
Kenichi Handa <handa@m17n.org>
parents:
22979
diff
changeset
|
428 "coding-category-ccl", |
17052 | 429 "coding-category-big5", |
28022
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
430 "coding-category-utf-8", |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
431 "coding-category-utf-16-be", |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
432 "coding-category-utf-16-le", |
19612
783efd6c7c1e
(Qno_conversion, Qundecided): New variables.
Kenichi Handa <handa@m17n.org>
parents:
19546
diff
changeset
|
433 "coding-category-raw-text", |
23027
0dc823b2335f
(coding_category_name): Fix the order of initial
Kenichi Handa <handa@m17n.org>
parents:
22979
diff
changeset
|
434 "coding-category-binary" |
17052 | 435 }; |
436 | |
22226
557fac086b1b
(ascii_skip_code): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22186
diff
changeset
|
437 /* Table of pointers to coding systems corresponding to each coding |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
438 categories. */ |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
439 struct coding_system *coding_system_table[CODING_CATEGORY_IDX_MAX]; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
440 |
22226
557fac086b1b
(ascii_skip_code): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22186
diff
changeset
|
441 /* Table of coding category masks. Nth element is a mask for a coding |
557fac086b1b
(ascii_skip_code): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22186
diff
changeset
|
442 cateogry of which priority is Nth. */ |
557fac086b1b
(ascii_skip_code): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22186
diff
changeset
|
443 static |
557fac086b1b
(ascii_skip_code): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22186
diff
changeset
|
444 int coding_priorities[CODING_CATEGORY_IDX_MAX]; |
557fac086b1b
(ascii_skip_code): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22186
diff
changeset
|
445 |
22186
fc4aaf1b1772
Change term "character translation table" to "translation table".
Kenichi Handa <handa@m17n.org>
parents:
22166
diff
changeset
|
446 /* 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
|
447 conversion. */ |
22119
592bb8b9bcfd
Change terms unify/unification to
Kenichi Handa <handa@m17n.org>
parents:
22020
diff
changeset
|
448 Lisp_Object Venable_character_translation; |
22186
fc4aaf1b1772
Change term "character translation table" to "translation table".
Kenichi Handa <handa@m17n.org>
parents:
22166
diff
changeset
|
449 /* 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
|
450 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
|
451 /* 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
|
452 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
|
453 |
fc4aaf1b1772
Change term "character translation table" to "translation table".
Kenichi Handa <handa@m17n.org>
parents:
22166
diff
changeset
|
454 Lisp_Object Qtranslation_table; |
fc4aaf1b1772
Change term "character translation table" to "translation table".
Kenichi Handa <handa@m17n.org>
parents:
22166
diff
changeset
|
455 Lisp_Object Qtranslation_table_id; |
fc4aaf1b1772
Change term "character translation table" to "translation table".
Kenichi Handa <handa@m17n.org>
parents:
22166
diff
changeset
|
456 Lisp_Object Qtranslation_table_for_decode; |
fc4aaf1b1772
Change term "character translation table" to "translation table".
Kenichi Handa <handa@m17n.org>
parents:
22166
diff
changeset
|
457 Lisp_Object Qtranslation_table_for_encode; |
17052 | 458 |
459 /* Alist of charsets vs revision number. */ | |
460 Lisp_Object Vcharset_revision_alist; | |
461 | |
18180
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
462 /* Default coding systems used for process I/O. */ |
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
463 Lisp_Object Vdefault_process_coding_system; |
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
464 |
26067
f54ca66e2571
(code_convert_string): Add record_unwind_protect to
Kenichi Handa <handa@m17n.org>
parents:
25860
diff
changeset
|
465 /* Global flag to tell that we can't call post-read-conversion and |
f54ca66e2571
(code_convert_string): Add record_unwind_protect to
Kenichi Handa <handa@m17n.org>
parents:
25860
diff
changeset
|
466 pre-write-conversion functions. Usually the value is zero, but it |
f54ca66e2571
(code_convert_string): Add record_unwind_protect to
Kenichi Handa <handa@m17n.org>
parents:
25860
diff
changeset
|
467 is set to 1 temporarily while such functions are running. This is |
f54ca66e2571
(code_convert_string): Add record_unwind_protect to
Kenichi Handa <handa@m17n.org>
parents:
25860
diff
changeset
|
468 to avoid infinite recursive call. */ |
f54ca66e2571
(code_convert_string): Add record_unwind_protect to
Kenichi Handa <handa@m17n.org>
parents:
25860
diff
changeset
|
469 static int inhibit_pre_post_conversion; |
f54ca66e2571
(code_convert_string): Add record_unwind_protect to
Kenichi Handa <handa@m17n.org>
parents:
25860
diff
changeset
|
470 |
17052 | 471 |
17835
f36ffb6f1208
Name change through the code:
Kenichi Handa <handa@m17n.org>
parents:
17725
diff
changeset
|
472 /*** 2. Emacs internal format (emacs-mule) handlers ***/ |
17052 | 473 |
474 /* Emacs' internal format for encoding multiple character sets is a | |
18766 | 475 kind of multi-byte encoding, i.e. characters are encoded by |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
476 variable-length sequences of one-byte codes. |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
477 |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
478 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
|
479 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
|
480 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
|
481 |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
482 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
|
483 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
|
484 code + 0x20). |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
485 |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
486 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
|
487 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
|
488 |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
489 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
|
490 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
|
491 `position-code's. The length of the sequence is determined by the |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
492 base leading-code. Leading-code takes the range 0x80 through 0x9F, |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
493 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
|
494 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
|
495 and position-code. |
18766 | 496 |
17052 | 497 --- 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
|
498 character set range |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
499 ------------- ----- |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
500 ascii 0x00..0x7F |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
501 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
|
502 eight-bit-graphic 0xA0..0xBF |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
503 ELSE 0x81..0x9F + [0xA0..0xFF]+ |
17052 | 504 --------------------------------------------- |
505 | |
506 */ | |
507 | |
508 enum emacs_code_class_type emacs_code_class[256]; | |
509 | |
510 /* See the above "GENERAL NOTES on `detect_coding_XXX ()' functions". | |
511 Check if a text is encoded in Emacs' internal format. If it is, | |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
512 return CODING_CATEGORY_MASK_EMACS_MULE, else return 0. */ |
17052 | 513 |
514 int | |
17835
f36ffb6f1208
Name change through the code:
Kenichi Handa <handa@m17n.org>
parents:
17725
diff
changeset
|
515 detect_coding_emacs_mule (src, src_end) |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
516 unsigned char *src, *src_end; |
17052 | 517 { |
518 unsigned char c; | |
519 int composing = 0; | |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
520 /* Dummy for ONE_MORE_BYTE. */ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
521 struct coding_system dummy_coding; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
522 struct coding_system *coding = &dummy_coding; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
523 |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
524 while (1) |
17052 | 525 { |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
526 ONE_MORE_BYTE (c); |
17052 | 527 |
528 if (composing) | |
529 { | |
530 if (c < 0xA0) | |
531 composing = 0; | |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
532 else if (c == 0xA0) |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
533 { |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
534 ONE_MORE_BYTE (c); |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
535 c &= 0x7F; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
536 } |
17052 | 537 else |
538 c -= 0x20; | |
539 } | |
540 | |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
541 if (c < 0x20) |
17052 | 542 { |
543 if (c == ISO_CODE_ESC || c == ISO_CODE_SI || c == ISO_CODE_SO) | |
544 return 0; | |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
545 } |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
546 else if (c >= 0x80 && c < 0xA0) |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
547 { |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
548 if (c == 0x80) |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
549 /* Old leading code for a composite character. */ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
550 composing = 1; |
26847 | 551 else |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
552 { |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
553 unsigned char *src_base = src - 1; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
554 int bytes; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
555 |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
556 if (!UNIBYTE_STR_AS_MULTIBYTE_P (src_base, src_end - src_base, |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
557 bytes)) |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
558 return 0; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
559 src = src_base + bytes; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
560 } |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
561 } |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
562 } |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
563 label_end_of_loop: |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
564 return CODING_CATEGORY_MASK_EMACS_MULE; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
565 } |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
566 |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
567 |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
568 /* 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
|
569 |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
570 static void |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
571 decode_coding_emacs_mule (coding, source, destination, src_bytes, dst_bytes) |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
572 struct coding_system *coding; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
573 unsigned char *source, *destination; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
574 int src_bytes, dst_bytes; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
575 { |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
576 unsigned char *src = source; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
577 unsigned char *src_end = source + src_bytes; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
578 unsigned char *dst = destination; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
579 unsigned char *dst_end = destination + dst_bytes; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
580 /* SRC_BASE remembers the start position in source in each loop. |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
581 The loop will be exited when there's not enough source code, or |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
582 when there's not enough destination area to produce a |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
583 character. */ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
584 unsigned char *src_base; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
585 |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
586 coding->produced_char = 0; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
587 while (src < src_end) |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
588 { |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
589 unsigned char tmp[MAX_MULTIBYTE_LENGTH], *p; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
590 int bytes; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
591 |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
592 src_base = src; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
593 if (UNIBYTE_STR_AS_MULTIBYTE_P (src, src_end - src, bytes)) |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
594 { |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
595 p = src; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
596 src += bytes; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
597 } |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
598 else |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
599 { |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
600 bytes = CHAR_STRING (*src, tmp); |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
601 p = tmp; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
602 src++; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
603 } |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
604 if (dst + bytes >= (dst_bytes ? dst_end : src)) |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
605 { |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
606 coding->result = CODING_FINISH_INSUFFICIENT_DST; |
17052 | 607 break; |
608 } | |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
609 while (bytes--) *dst++ = *p++; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
610 coding->produced_char++; |
17052 | 611 } |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
612 coding->consumed = coding->consumed_char = src_base - source; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
613 coding->produced = dst - destination; |
17052 | 614 } |
615 | |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
616 #define encode_coding_emacs_mule(coding, source, destination, src_bytes, dst_bytes) \ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
617 encode_eol (coding, source, destination, src_bytes, dst_bytes) |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
618 |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
619 |
17052 | 620 |
621 /*** 3. ISO2022 handlers ***/ | |
622 | |
623 /* 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
|
624 Since the intention of this note is to help understand the |
61c6b3be1d51
Comment for ISO 2022 encoding mechanism modified.
Kenichi Handa <handa@m17n.org>
parents:
24344
diff
changeset
|
625 functions in this file, some parts are NOT ACCURATE or OVERLY |
61c6b3be1d51
Comment for ISO 2022 encoding mechanism modified.
Kenichi Handa <handa@m17n.org>
parents:
24344
diff
changeset
|
626 SIMPLIFIED. For thorough understanding, please refer to the |
17052 | 627 original document of ISO2022. |
628 | |
629 ISO2022 provides many mechanisms to encode several character sets | |
24425
61c6b3be1d51
Comment for ISO 2022 encoding mechanism modified.
Kenichi Handa <handa@m17n.org>
parents:
24344
diff
changeset
|
630 in 7-bit and 8-bit environments. For 7-bite environments, all text |
61c6b3be1d51
Comment for ISO 2022 encoding mechanism modified.
Kenichi Handa <handa@m17n.org>
parents:
24344
diff
changeset
|
631 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
|
632 text a little bit longer, but the text passes more easily through |
61c6b3be1d51
Comment for ISO 2022 encoding mechanism modified.
Kenichi Handa <handa@m17n.org>
parents:
24344
diff
changeset
|
633 several gateways, some of which strip off MSB (Most Signigant Bit). |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
634 |
24425
61c6b3be1d51
Comment for ISO 2022 encoding mechanism modified.
Kenichi Handa <handa@m17n.org>
parents:
24344
diff
changeset
|
635 There are two kinds of character sets: control character set and |
17052 | 636 graphic character set. The former contains control characters such |
637 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
|
638 functions are also provided by escape sequences). The latter |
61c6b3be1d51
Comment for ISO 2022 encoding mechanism modified.
Kenichi Handa <handa@m17n.org>
parents:
24344
diff
changeset
|
639 contains graphic characters such as 'A' and '-'. Emacs recognizes |
17052 | 640 two control character sets and many graphic character sets. |
641 | |
642 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
|
643 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
|
644 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
|
645 - DIMENSION1_CHARS94 |
61c6b3be1d51
Comment for ISO 2022 encoding mechanism modified.
Kenichi Handa <handa@m17n.org>
parents:
24344
diff
changeset
|
646 - DIMENSION1_CHARS96 |
61c6b3be1d51
Comment for ISO 2022 encoding mechanism modified.
Kenichi Handa <handa@m17n.org>
parents:
24344
diff
changeset
|
647 - DIMENSION2_CHARS94 |
61c6b3be1d51
Comment for ISO 2022 encoding mechanism modified.
Kenichi Handa <handa@m17n.org>
parents:
24344
diff
changeset
|
648 - DIMENSION2_CHARS96 |
61c6b3be1d51
Comment for ISO 2022 encoding mechanism modified.
Kenichi Handa <handa@m17n.org>
parents:
24344
diff
changeset
|
649 |
61c6b3be1d51
Comment for ISO 2022 encoding mechanism modified.
Kenichi Handa <handa@m17n.org>
parents:
24344
diff
changeset
|
650 In addition, each character set is assigned an identification tag, |
61c6b3be1d51
Comment for ISO 2022 encoding mechanism modified.
Kenichi Handa <handa@m17n.org>
parents:
24344
diff
changeset
|
651 unique for each set, called "final character" (denoted as <F> |
61c6b3be1d51
Comment for ISO 2022 encoding mechanism modified.
Kenichi Handa <handa@m17n.org>
parents:
24344
diff
changeset
|
652 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
|
653 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
|
654 (0x30..0x3F are for private use only). |
17052 | 655 |
656 Note (*): ECMA = European Computer Manufacturers Association | |
657 | |
658 Here are examples of graphic character set [NAME(<F>)]: | |
659 o DIMENSION1_CHARS94 -- ASCII('B'), right-half-of-JISX0201('I'), ... | |
660 o DIMENSION1_CHARS96 -- right-half-of-ISO8859-1('A'), ... | |
661 o DIMENSION2_CHARS94 -- GB2312('A'), JISX0208('B'), ... | |
662 o DIMENSION2_CHARS96 -- none for the moment | |
663 | |
24425
61c6b3be1d51
Comment for ISO 2022 encoding mechanism modified.
Kenichi Handa <handa@m17n.org>
parents:
24344
diff
changeset
|
664 A code area (1 byte=8 bits) is divided into 4 areas, C0, GL, C1, and GR. |
17052 | 665 C0 [0x00..0x1F] -- control character plane 0 |
666 GL [0x20..0x7F] -- graphic character plane 0 | |
667 C1 [0x80..0x9F] -- control character plane 1 | |
668 GR [0xA0..0xFF] -- graphic character plane 1 | |
669 | |
670 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
|
671 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
|
672 - 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
|
673 - 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
|
674 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
|
675 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
|
676 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
|
677 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
|
678 defined to have corresponding escape sequences. |
17052 | 679 |
680 A graphic character set is at first designated to one of four | |
681 graphic registers (G0 through G3), then these graphic registers are | |
682 invoked to GL or GR. These designations and invocations can be | |
683 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
|
684 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
|
685 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
|
686 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
|
687 |
61c6b3be1d51
Comment for ISO 2022 encoding mechanism modified.
Kenichi Handa <handa@m17n.org>
parents:
24344
diff
changeset
|
688 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
|
689 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
|
690 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
|
691 be used. |
17052 | 692 |
693 There are two ways of invocation: locking-shift and single-shift. | |
694 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
|
695 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
|
696 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
|
697 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
|
698 escape sequences: |
17052 | 699 |
700 ---------------------------------------------------------------------- | |
24425
61c6b3be1d51
Comment for ISO 2022 encoding mechanism modified.
Kenichi Handa <handa@m17n.org>
parents:
24344
diff
changeset
|
701 abbrev function cntrl escape seq description |
17052 | 702 ---------------------------------------------------------------------- |
24425
61c6b3be1d51
Comment for ISO 2022 encoding mechanism modified.
Kenichi Handa <handa@m17n.org>
parents:
24344
diff
changeset
|
703 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
|
704 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
|
705 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
|
706 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
|
707 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
|
708 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
|
709 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
|
710 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
|
711 SS3 (single-shift-3) 0x8F ESC 'O' invoke G3 for one char |
17052 | 712 ---------------------------------------------------------------------- |
24425
61c6b3be1d51
Comment for ISO 2022 encoding mechanism modified.
Kenichi Handa <handa@m17n.org>
parents:
24344
diff
changeset
|
713 (*) 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
|
714 |
61c6b3be1d51
Comment for ISO 2022 encoding mechanism modified.
Kenichi Handa <handa@m17n.org>
parents:
24344
diff
changeset
|
715 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
|
716 ISO_CODE_XXX in `coding.h'. |
61c6b3be1d51
Comment for ISO 2022 encoding mechanism modified.
Kenichi Handa <handa@m17n.org>
parents:
24344
diff
changeset
|
717 |
61c6b3be1d51
Comment for ISO 2022 encoding mechanism modified.
Kenichi Handa <handa@m17n.org>
parents:
24344
diff
changeset
|
718 Designations are done by the following escape sequences: |
17052 | 719 ---------------------------------------------------------------------- |
720 escape sequence description | |
721 ---------------------------------------------------------------------- | |
722 ESC '(' <F> designate DIMENSION1_CHARS94<F> to G0 | |
723 ESC ')' <F> designate DIMENSION1_CHARS94<F> to G1 | |
724 ESC '*' <F> designate DIMENSION1_CHARS94<F> to G2 | |
725 ESC '+' <F> designate DIMENSION1_CHARS94<F> to G3 | |
726 ESC ',' <F> designate DIMENSION1_CHARS96<F> to G0 (*) | |
727 ESC '-' <F> designate DIMENSION1_CHARS96<F> to G1 | |
728 ESC '.' <F> designate DIMENSION1_CHARS96<F> to G2 | |
729 ESC '/' <F> designate DIMENSION1_CHARS96<F> to G3 | |
730 ESC '$' '(' <F> designate DIMENSION2_CHARS94<F> to G0 (**) | |
731 ESC '$' ')' <F> designate DIMENSION2_CHARS94<F> to G1 | |
732 ESC '$' '*' <F> designate DIMENSION2_CHARS94<F> to G2 | |
733 ESC '$' '+' <F> designate DIMENSION2_CHARS94<F> to G3 | |
734 ESC '$' ',' <F> designate DIMENSION2_CHARS96<F> to G0 (*) | |
735 ESC '$' '-' <F> designate DIMENSION2_CHARS96<F> to G1 | |
736 ESC '$' '.' <F> designate DIMENSION2_CHARS96<F> to G2 | |
737 ESC '$' '/' <F> designate DIMENSION2_CHARS96<F> to G3 | |
738 ---------------------------------------------------------------------- | |
739 | |
740 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
|
741 of dimension 1, chars 94, and final character <F>, etc... |
17052 | 742 |
743 Note (*): Although these designations are not allowed in ISO2022, | |
744 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
|
745 CHARS96 character sets in a coding system which is characterized as |
17052 | 746 7-bit environment, non-locking-shift, and non-single-shift. |
747 | |
748 Note (**): If <F> is '@', 'A', or 'B', the intermediate character | |
24425
61c6b3be1d51
Comment for ISO 2022 encoding mechanism modified.
Kenichi Handa <handa@m17n.org>
parents:
24344
diff
changeset
|
749 '(' can be omitted. We refer to this as "short-form" hereafter. |
17052 | 750 |
751 Now you may notice that there are a lot of ways for encoding the | |
24425
61c6b3be1d51
Comment for ISO 2022 encoding mechanism modified.
Kenichi Handa <handa@m17n.org>
parents:
24344
diff
changeset
|
752 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
|
753 coding systems such as Compound Text (used in X11's inter client |
61c6b3be1d51
Comment for ISO 2022 encoding mechanism modified.
Kenichi Handa <handa@m17n.org>
parents:
24344
diff
changeset
|
754 communication, ISO-2022-JP (used in Japanese internet), ISO-2022-KR |
61c6b3be1d51
Comment for ISO 2022 encoding mechanism modified.
Kenichi Handa <handa@m17n.org>
parents:
24344
diff
changeset
|
755 (used in Korean internet), EUC (Extended UNIX Code, used in Asian |
17052 | 756 localized platforms), and all of these are variants of ISO2022. |
757 | |
758 In addition to the above, Emacs handles two more kinds of escape | |
759 sequences: ISO6429's direction specification and Emacs' private | |
760 sequence for specifying character composition. | |
761 | |
24425
61c6b3be1d51
Comment for ISO 2022 encoding mechanism modified.
Kenichi Handa <handa@m17n.org>
parents:
24344
diff
changeset
|
762 ISO6429's direction specification takes the following form: |
17052 | 763 o CSI ']' -- end of the current direction |
764 o CSI '0' ']' -- end of the current direction | |
765 o CSI '1' ']' -- start of left-to-right text | |
766 o CSI '2' ']' -- start of right-to-left text | |
767 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
|
768 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
|
769 |
61c6b3be1d51
Comment for ISO 2022 encoding mechanism modified.
Kenichi Handa <handa@m17n.org>
parents:
24344
diff
changeset
|
770 Character composition specification takes the following form: |
26847 | 771 o ESC '0' -- start relative composition |
772 o ESC '1' -- end composition | |
773 o ESC '2' -- start rule-base composition (*) | |
774 o ESC '3' -- start relative composition with alternate chars (**) | |
775 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
|
776 Since these are not standard escape sequences of any ISO standard, |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
777 the use of them for these meaning is restricted to Emacs only. |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
778 |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
779 (*) This form is used only in Emacs 20.5 and the older versions, |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
780 but the newer versions can safely decode it. |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
781 (**) This form is used only in Emacs 21.1 and the newer versions, |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
782 and the older versions can't decode it. |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
783 |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
784 Here's a list of examples usages of these composition escape |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
785 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
|
786 |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
787 COMPOSITION_RELATIVE: |
26847 | 788 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
|
789 COMPOSITOIN_WITH_RULE: |
26847 | 790 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
|
791 COMPOSITION_WITH_ALTCHARS: |
26847 | 792 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
|
793 COMPOSITION_WITH_RULE_ALTCHARS: |
26847 | 794 ESC 4 ALTCHAR [ RULE ALTCHAR ] ESC 0 CHAR [ CHAR ] ESC 1 */ |
17052 | 795 |
796 enum iso_code_class_type iso_code_class[256]; | |
797 | |
22964
87f4c88f4c59
(CHARSET_OK): Check that coding_system_table[IDX] != 0.
Richard M. Stallman <rms@gnu.org>
parents:
22954
diff
changeset
|
798 #define CHARSET_OK(idx, charset) \ |
87f4c88f4c59
(CHARSET_OK): Check that coding_system_table[IDX] != 0.
Richard M. Stallman <rms@gnu.org>
parents:
22954
diff
changeset
|
799 (coding_system_table[idx] \ |
87f4c88f4c59
(CHARSET_OK): Check that coding_system_table[IDX] != 0.
Richard M. Stallman <rms@gnu.org>
parents:
22954
diff
changeset
|
800 && (coding_system_table[idx]->safe_charsets[charset] \ |
87f4c88f4c59
(CHARSET_OK): Check that coding_system_table[IDX] != 0.
Richard M. Stallman <rms@gnu.org>
parents:
22954
diff
changeset
|
801 || (CODING_SPEC_ISO_REQUESTED_DESIGNATION \ |
87f4c88f4c59
(CHARSET_OK): Check that coding_system_table[IDX] != 0.
Richard M. Stallman <rms@gnu.org>
parents:
22954
diff
changeset
|
802 (coding_system_table[idx], charset) \ |
87f4c88f4c59
(CHARSET_OK): Check that coding_system_table[IDX] != 0.
Richard M. Stallman <rms@gnu.org>
parents:
22954
diff
changeset
|
803 != CODING_SPEC_ISO_NO_REQUESTED_DESIGNATION))) |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
804 |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
805 #define SHIFT_OUT_OK(idx) \ |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
806 (CODING_SPEC_ISO_INITIAL_DESIGNATION (coding_system_table[idx], 1) >= 0) |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
807 |
17052 | 808 /* See the above "GENERAL NOTES on `detect_coding_XXX ()' functions". |
809 Check if a text is encoded in ISO2022. If it is, returns an | |
810 integer in which appropriate flag bits any of: | |
811 CODING_CATEGORY_MASK_ISO_7 | |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
812 CODING_CATEGORY_MASK_ISO_7_TIGHT |
17052 | 813 CODING_CATEGORY_MASK_ISO_8_1 |
814 CODING_CATEGORY_MASK_ISO_8_2 | |
18787
954e6be0a757
(detect_coding_iso2022): Distinguish coding-category-iso-7-else and
Kenichi Handa <handa@m17n.org>
parents:
18766
diff
changeset
|
815 CODING_CATEGORY_MASK_ISO_7_ELSE |
954e6be0a757
(detect_coding_iso2022): Distinguish coding-category-iso-7-else and
Kenichi Handa <handa@m17n.org>
parents:
18766
diff
changeset
|
816 CODING_CATEGORY_MASK_ISO_8_ELSE |
17052 | 817 are set. If a code which should never appear in ISO2022 is found, |
818 returns 0. */ | |
819 | |
820 int | |
821 detect_coding_iso2022 (src, src_end) | |
822 unsigned char *src, *src_end; | |
823 { | |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
824 int mask = CODING_CATEGORY_MASK_ISO; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
825 int mask_found = 0; |
23088
45c36d636f66
(detect_coding_iso2022): Don't check the byte length of
Kenichi Handa <handa@m17n.org>
parents:
23082
diff
changeset
|
826 int reg[4], shift_out = 0, single_shifting = 0; |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
827 int c, c1, i, charset; |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
828 /* Dummy for ONE_MORE_BYTE. */ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
829 struct coding_system dummy_coding; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
830 struct coding_system *coding = &dummy_coding; |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
831 |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
832 reg[0] = CHARSET_ASCII, reg[1] = reg[2] = reg[3] = -1; |
19365
d9374f5ebd3a
(CODING_FLAG_ISO_LATIN_EXTRA): New macro.
Kenichi Handa <handa@m17n.org>
parents:
19285
diff
changeset
|
833 while (mask && src < src_end) |
17052 | 834 { |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
835 ONE_MORE_BYTE (c); |
17052 | 836 switch (c) |
837 { | |
838 case ISO_CODE_ESC: | |
23088
45c36d636f66
(detect_coding_iso2022): Don't check the byte length of
Kenichi Handa <handa@m17n.org>
parents:
23082
diff
changeset
|
839 single_shifting = 0; |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
840 ONE_MORE_BYTE (c); |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
841 if (c >= '(' && c <= '/') |
19134
8fa6e23f8d22
(detect_coding_iso2022): Do not exclude posibility of
Kenichi Handa <handa@m17n.org>
parents:
19118
diff
changeset
|
842 { |
8fa6e23f8d22
(detect_coding_iso2022): Do not exclude posibility of
Kenichi Handa <handa@m17n.org>
parents:
19118
diff
changeset
|
843 /* Designation sequence for a charset of dimension 1. */ |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
844 ONE_MORE_BYTE (c1); |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
845 if (c1 < ' ' || c1 >= 0x80 |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
846 || (charset = iso_charset_table[0][c >= ','][c1]) < 0) |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
847 /* Invalid designation sequence. Just ignore. */ |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
848 break; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
849 reg[(c - '(') % 4] = charset; |
19134
8fa6e23f8d22
(detect_coding_iso2022): Do not exclude posibility of
Kenichi Handa <handa@m17n.org>
parents:
19118
diff
changeset
|
850 } |
8fa6e23f8d22
(detect_coding_iso2022): Do not exclude posibility of
Kenichi Handa <handa@m17n.org>
parents:
19118
diff
changeset
|
851 else if (c == '$') |
17052 | 852 { |
19134
8fa6e23f8d22
(detect_coding_iso2022): Do not exclude posibility of
Kenichi Handa <handa@m17n.org>
parents:
19118
diff
changeset
|
853 /* Designation sequence for a charset of dimension 2. */ |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
854 ONE_MORE_BYTE (c); |
19134
8fa6e23f8d22
(detect_coding_iso2022): Do not exclude posibility of
Kenichi Handa <handa@m17n.org>
parents:
19118
diff
changeset
|
855 if (c >= '@' && c <= 'B') |
8fa6e23f8d22
(detect_coding_iso2022): Do not exclude posibility of
Kenichi Handa <handa@m17n.org>
parents:
19118
diff
changeset
|
856 /* Designation for JISX0208.1978, GB2312, or JISX0208. */ |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
857 reg[0] = charset = iso_charset_table[1][0][c]; |
19134
8fa6e23f8d22
(detect_coding_iso2022): Do not exclude posibility of
Kenichi Handa <handa@m17n.org>
parents:
19118
diff
changeset
|
858 else if (c >= '(' && c <= '/') |
17320
9d15bec5f47e
(detect_coding_iso2022, detect_coding_mask): Ignore
Kenichi Handa <handa@m17n.org>
parents:
17304
diff
changeset
|
859 { |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
860 ONE_MORE_BYTE (c1); |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
861 if (c1 < ' ' || c1 >= 0x80 |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
862 || (charset = iso_charset_table[1][c >= ','][c1]) < 0) |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
863 /* Invalid designation sequence. Just ignore. */ |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
864 break; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
865 reg[(c - '(') % 4] = charset; |
17320
9d15bec5f47e
(detect_coding_iso2022, detect_coding_mask): Ignore
Kenichi Handa <handa@m17n.org>
parents:
17304
diff
changeset
|
866 } |
19134
8fa6e23f8d22
(detect_coding_iso2022): Do not exclude posibility of
Kenichi Handa <handa@m17n.org>
parents:
19118
diff
changeset
|
867 else |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
868 /* Invalid designation sequence. Just ignore. */ |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
869 break; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
870 } |
23116
6736da064f4a
(detect_coding_iso2022): Handle ESC N and ESC O
Kenichi Handa <handa@m17n.org>
parents:
23089
diff
changeset
|
871 else if (c == 'N' || c == 'O') |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
872 { |
23116
6736da064f4a
(detect_coding_iso2022): Handle ESC N and ESC O
Kenichi Handa <handa@m17n.org>
parents:
23089
diff
changeset
|
873 /* ESC <Fe> for SS2 or SS3. */ |
6736da064f4a
(detect_coding_iso2022): Handle ESC N and ESC O
Kenichi Handa <handa@m17n.org>
parents:
23089
diff
changeset
|
874 mask &= CODING_CATEGORY_MASK_ISO_7_ELSE; |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
875 break; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
876 } |
26847 | 877 else if (c >= '0' && c <= '4') |
878 { | |
879 /* ESC <Fp> for start/end composition. */ | |
880 mask_found |= CODING_CATEGORY_MASK_ISO; | |
881 break; | |
882 } | |
19134
8fa6e23f8d22
(detect_coding_iso2022): Do not exclude posibility of
Kenichi Handa <handa@m17n.org>
parents:
19118
diff
changeset
|
883 else |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
884 /* Invalid escape sequence. Just ignore. */ |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
885 break; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
886 |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
887 /* We found a valid designation sequence for CHARSET. */ |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
888 mask &= ~CODING_CATEGORY_MASK_ISO_8BIT; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
889 if (CHARSET_OK (CODING_CATEGORY_IDX_ISO_7, charset)) |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
890 mask_found |= CODING_CATEGORY_MASK_ISO_7; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
891 else |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
892 mask &= ~CODING_CATEGORY_MASK_ISO_7; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
893 if (CHARSET_OK (CODING_CATEGORY_IDX_ISO_7_TIGHT, charset)) |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
894 mask_found |= CODING_CATEGORY_MASK_ISO_7_TIGHT; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
895 else |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
896 mask &= ~CODING_CATEGORY_MASK_ISO_7_TIGHT; |
23116
6736da064f4a
(detect_coding_iso2022): Handle ESC N and ESC O
Kenichi Handa <handa@m17n.org>
parents:
23089
diff
changeset
|
897 if (CHARSET_OK (CODING_CATEGORY_IDX_ISO_7_ELSE, charset)) |
6736da064f4a
(detect_coding_iso2022): Handle ESC N and ESC O
Kenichi Handa <handa@m17n.org>
parents:
23089
diff
changeset
|
898 mask_found |= CODING_CATEGORY_MASK_ISO_7_ELSE; |
6736da064f4a
(detect_coding_iso2022): Handle ESC N and ESC O
Kenichi Handa <handa@m17n.org>
parents:
23089
diff
changeset
|
899 else |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
900 mask &= ~CODING_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
|
901 if (CHARSET_OK (CODING_CATEGORY_IDX_ISO_8_ELSE, charset)) |
6736da064f4a
(detect_coding_iso2022): Handle ESC N and ESC O
Kenichi Handa <handa@m17n.org>
parents:
23089
diff
changeset
|
902 mask_found |= CODING_CATEGORY_MASK_ISO_8_ELSE; |
6736da064f4a
(detect_coding_iso2022): Handle ESC N and ESC O
Kenichi Handa <handa@m17n.org>
parents:
23089
diff
changeset
|
903 else |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
904 mask &= ~CODING_CATEGORY_MASK_ISO_8_ELSE; |
17052 | 905 break; |
906 | |
907 case ISO_CODE_SO: | |
23088
45c36d636f66
(detect_coding_iso2022): Don't check the byte length of
Kenichi Handa <handa@m17n.org>
parents:
23082
diff
changeset
|
908 single_shifting = 0; |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
909 if (shift_out == 0 |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
910 && (reg[1] >= 0 |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
911 || SHIFT_OUT_OK (CODING_CATEGORY_IDX_ISO_7_ELSE) |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
912 || SHIFT_OUT_OK (CODING_CATEGORY_IDX_ISO_8_ELSE))) |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
913 { |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
914 /* Locking shift out. */ |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
915 mask &= ~CODING_CATEGORY_MASK_ISO_7BIT; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
916 mask_found |= CODING_CATEGORY_MASK_ISO_SHIFT; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
917 } |
17119
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
918 break; |
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
919 |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
920 case ISO_CODE_SI: |
23088
45c36d636f66
(detect_coding_iso2022): Don't check the byte length of
Kenichi Handa <handa@m17n.org>
parents:
23082
diff
changeset
|
921 single_shifting = 0; |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
922 if (shift_out == 1) |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
923 { |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
924 /* Locking shift in. */ |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
925 mask &= ~CODING_CATEGORY_MASK_ISO_7BIT; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
926 mask_found |= CODING_CATEGORY_MASK_ISO_SHIFT; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
927 } |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
928 break; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
929 |
17052 | 930 case ISO_CODE_CSI: |
23088
45c36d636f66
(detect_coding_iso2022): Don't check the byte length of
Kenichi Handa <handa@m17n.org>
parents:
23082
diff
changeset
|
931 single_shifting = 0; |
17052 | 932 case ISO_CODE_SS2: |
933 case ISO_CODE_SS3: | |
19365
d9374f5ebd3a
(CODING_FLAG_ISO_LATIN_EXTRA): New macro.
Kenichi Handa <handa@m17n.org>
parents:
19285
diff
changeset
|
934 { |
d9374f5ebd3a
(CODING_FLAG_ISO_LATIN_EXTRA): New macro.
Kenichi Handa <handa@m17n.org>
parents:
19285
diff
changeset
|
935 int newmask = CODING_CATEGORY_MASK_ISO_8_ELSE; |
d9374f5ebd3a
(CODING_FLAG_ISO_LATIN_EXTRA): New macro.
Kenichi Handa <handa@m17n.org>
parents:
19285
diff
changeset
|
936 |
20150
402b6e5f4b58
(encode_designation_at_bol): Fix bug of finding graphic
Kenichi Handa <handa@m17n.org>
parents:
20105
diff
changeset
|
937 if (c != ISO_CODE_CSI) |
402b6e5f4b58
(encode_designation_at_bol): Fix bug of finding graphic
Kenichi Handa <handa@m17n.org>
parents:
20105
diff
changeset
|
938 { |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
939 if (coding_system_table[CODING_CATEGORY_IDX_ISO_8_1]->flags |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
940 & CODING_FLAG_ISO_SINGLE_SHIFT) |
20150
402b6e5f4b58
(encode_designation_at_bol): Fix bug of finding graphic
Kenichi Handa <handa@m17n.org>
parents:
20105
diff
changeset
|
941 newmask |= CODING_CATEGORY_MASK_ISO_8_1; |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
942 if (coding_system_table[CODING_CATEGORY_IDX_ISO_8_2]->flags |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
943 & CODING_FLAG_ISO_SINGLE_SHIFT) |
20150
402b6e5f4b58
(encode_designation_at_bol): Fix bug of finding graphic
Kenichi Handa <handa@m17n.org>
parents:
20105
diff
changeset
|
944 newmask |= CODING_CATEGORY_MASK_ISO_8_2; |
23088
45c36d636f66
(detect_coding_iso2022): Don't check the byte length of
Kenichi Handa <handa@m17n.org>
parents:
23082
diff
changeset
|
945 single_shifting = 1; |
20150
402b6e5f4b58
(encode_designation_at_bol): Fix bug of finding graphic
Kenichi Handa <handa@m17n.org>
parents:
20105
diff
changeset
|
946 } |
19365
d9374f5ebd3a
(CODING_FLAG_ISO_LATIN_EXTRA): New macro.
Kenichi Handa <handa@m17n.org>
parents:
19285
diff
changeset
|
947 if (VECTORP (Vlatin_extra_code_table) |
d9374f5ebd3a
(CODING_FLAG_ISO_LATIN_EXTRA): New macro.
Kenichi Handa <handa@m17n.org>
parents:
19285
diff
changeset
|
948 && !NILP (XVECTOR (Vlatin_extra_code_table)->contents[c])) |
d9374f5ebd3a
(CODING_FLAG_ISO_LATIN_EXTRA): New macro.
Kenichi Handa <handa@m17n.org>
parents:
19285
diff
changeset
|
949 { |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
950 if (coding_system_table[CODING_CATEGORY_IDX_ISO_8_1]->flags |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
951 & CODING_FLAG_ISO_LATIN_EXTRA) |
19365
d9374f5ebd3a
(CODING_FLAG_ISO_LATIN_EXTRA): New macro.
Kenichi Handa <handa@m17n.org>
parents:
19285
diff
changeset
|
952 newmask |= CODING_CATEGORY_MASK_ISO_8_1; |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
953 if (coding_system_table[CODING_CATEGORY_IDX_ISO_8_2]->flags |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
954 & CODING_FLAG_ISO_LATIN_EXTRA) |
19365
d9374f5ebd3a
(CODING_FLAG_ISO_LATIN_EXTRA): New macro.
Kenichi Handa <handa@m17n.org>
parents:
19285
diff
changeset
|
955 newmask |= CODING_CATEGORY_MASK_ISO_8_2; |
d9374f5ebd3a
(CODING_FLAG_ISO_LATIN_EXTRA): New macro.
Kenichi Handa <handa@m17n.org>
parents:
19285
diff
changeset
|
956 } |
d9374f5ebd3a
(CODING_FLAG_ISO_LATIN_EXTRA): New macro.
Kenichi Handa <handa@m17n.org>
parents:
19285
diff
changeset
|
957 mask &= newmask; |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
958 mask_found |= newmask; |
19365
d9374f5ebd3a
(CODING_FLAG_ISO_LATIN_EXTRA): New macro.
Kenichi Handa <handa@m17n.org>
parents:
19285
diff
changeset
|
959 } |
d9374f5ebd3a
(CODING_FLAG_ISO_LATIN_EXTRA): New macro.
Kenichi Handa <handa@m17n.org>
parents:
19285
diff
changeset
|
960 break; |
17052 | 961 |
962 default: | |
963 if (c < 0x80) | |
23088
45c36d636f66
(detect_coding_iso2022): Don't check the byte length of
Kenichi Handa <handa@m17n.org>
parents:
23082
diff
changeset
|
964 { |
45c36d636f66
(detect_coding_iso2022): Don't check the byte length of
Kenichi Handa <handa@m17n.org>
parents:
23082
diff
changeset
|
965 single_shifting = 0; |
45c36d636f66
(detect_coding_iso2022): Don't check the byte length of
Kenichi Handa <handa@m17n.org>
parents:
23082
diff
changeset
|
966 break; |
45c36d636f66
(detect_coding_iso2022): Don't check the byte length of
Kenichi Handa <handa@m17n.org>
parents:
23082
diff
changeset
|
967 } |
17052 | 968 else if (c < 0xA0) |
19280
e755044718ee
(ENCODE_ISO_CHARACTER_DIMENSION1): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
19193
diff
changeset
|
969 { |
23088
45c36d636f66
(detect_coding_iso2022): Don't check the byte length of
Kenichi Handa <handa@m17n.org>
parents:
23082
diff
changeset
|
970 single_shifting = 0; |
19365
d9374f5ebd3a
(CODING_FLAG_ISO_LATIN_EXTRA): New macro.
Kenichi Handa <handa@m17n.org>
parents:
19285
diff
changeset
|
971 if (VECTORP (Vlatin_extra_code_table) |
d9374f5ebd3a
(CODING_FLAG_ISO_LATIN_EXTRA): New macro.
Kenichi Handa <handa@m17n.org>
parents:
19285
diff
changeset
|
972 && !NILP (XVECTOR (Vlatin_extra_code_table)->contents[c])) |
19280
e755044718ee
(ENCODE_ISO_CHARACTER_DIMENSION1): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
19193
diff
changeset
|
973 { |
19365
d9374f5ebd3a
(CODING_FLAG_ISO_LATIN_EXTRA): New macro.
Kenichi Handa <handa@m17n.org>
parents:
19285
diff
changeset
|
974 int newmask = 0; |
d9374f5ebd3a
(CODING_FLAG_ISO_LATIN_EXTRA): New macro.
Kenichi Handa <handa@m17n.org>
parents:
19285
diff
changeset
|
975 |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
976 if (coding_system_table[CODING_CATEGORY_IDX_ISO_8_1]->flags |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
977 & CODING_FLAG_ISO_LATIN_EXTRA) |
19365
d9374f5ebd3a
(CODING_FLAG_ISO_LATIN_EXTRA): New macro.
Kenichi Handa <handa@m17n.org>
parents:
19285
diff
changeset
|
978 newmask |= CODING_CATEGORY_MASK_ISO_8_1; |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
979 if (coding_system_table[CODING_CATEGORY_IDX_ISO_8_2]->flags |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
980 & CODING_FLAG_ISO_LATIN_EXTRA) |
19365
d9374f5ebd3a
(CODING_FLAG_ISO_LATIN_EXTRA): New macro.
Kenichi Handa <handa@m17n.org>
parents:
19285
diff
changeset
|
981 newmask |= CODING_CATEGORY_MASK_ISO_8_2; |
d9374f5ebd3a
(CODING_FLAG_ISO_LATIN_EXTRA): New macro.
Kenichi Handa <handa@m17n.org>
parents:
19285
diff
changeset
|
982 mask &= newmask; |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
983 mask_found |= newmask; |
19280
e755044718ee
(ENCODE_ISO_CHARACTER_DIMENSION1): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
19193
diff
changeset
|
984 } |
19365
d9374f5ebd3a
(CODING_FLAG_ISO_LATIN_EXTRA): New macro.
Kenichi Handa <handa@m17n.org>
parents:
19285
diff
changeset
|
985 else |
d9374f5ebd3a
(CODING_FLAG_ISO_LATIN_EXTRA): New macro.
Kenichi Handa <handa@m17n.org>
parents:
19285
diff
changeset
|
986 return 0; |
19280
e755044718ee
(ENCODE_ISO_CHARACTER_DIMENSION1): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
19193
diff
changeset
|
987 } |
17052 | 988 else |
989 { | |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
990 mask &= ~(CODING_CATEGORY_MASK_ISO_7BIT |
18787
954e6be0a757
(detect_coding_iso2022): Distinguish coding-category-iso-7-else and
Kenichi Handa <handa@m17n.org>
parents:
18766
diff
changeset
|
991 | CODING_CATEGORY_MASK_ISO_7_ELSE); |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
992 mask_found |= CODING_CATEGORY_MASK_ISO_8_1; |
23088
45c36d636f66
(detect_coding_iso2022): Don't check the byte length of
Kenichi Handa <handa@m17n.org>
parents:
23082
diff
changeset
|
993 /* Check the length of succeeding codes of the range |
45c36d636f66
(detect_coding_iso2022): Don't check the byte length of
Kenichi Handa <handa@m17n.org>
parents:
23082
diff
changeset
|
994 0xA0..0FF. If the byte length is odd, we exclude |
45c36d636f66
(detect_coding_iso2022): Don't check the byte length of
Kenichi Handa <handa@m17n.org>
parents:
23082
diff
changeset
|
995 CODING_CATEGORY_MASK_ISO_8_2. We can check this only |
45c36d636f66
(detect_coding_iso2022): Don't check the byte length of
Kenichi Handa <handa@m17n.org>
parents:
23082
diff
changeset
|
996 when we are not single shifting. */ |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
997 if (!single_shifting |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
998 && mask & CODING_CATEGORY_MASK_ISO_8_2) |
23088
45c36d636f66
(detect_coding_iso2022): Don't check the byte length of
Kenichi Handa <handa@m17n.org>
parents:
23082
diff
changeset
|
999 { |
29299
b33b38d81020
(detect_coding_iso2022): Fix code for checking
Kenichi Handa <handa@m17n.org>
parents:
29275
diff
changeset
|
1000 int i = 1; |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1001 while (src < src_end) |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1002 { |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1003 ONE_MORE_BYTE (c); |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1004 if (c < 0xA0) |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1005 break; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1006 i++; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1007 } |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1008 |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1009 if (i & 1 && src < src_end) |
23088
45c36d636f66
(detect_coding_iso2022): Don't check the byte length of
Kenichi Handa <handa@m17n.org>
parents:
23082
diff
changeset
|
1010 mask &= ~CODING_CATEGORY_MASK_ISO_8_2; |
45c36d636f66
(detect_coding_iso2022): Don't check the byte length of
Kenichi Handa <handa@m17n.org>
parents:
23082
diff
changeset
|
1011 else |
45c36d636f66
(detect_coding_iso2022): Don't check the byte length of
Kenichi Handa <handa@m17n.org>
parents:
23082
diff
changeset
|
1012 mask_found |= CODING_CATEGORY_MASK_ISO_8_2; |
45c36d636f66
(detect_coding_iso2022): Don't check the byte length of
Kenichi Handa <handa@m17n.org>
parents:
23082
diff
changeset
|
1013 } |
17052 | 1014 } |
1015 break; | |
1016 } | |
1017 } | |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1018 label_end_of_loop: |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
1019 return (mask & mask_found); |
17052 | 1020 } |
1021 | |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1022 /* Decode a character of which charset is CHARSET, the 1st position |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1023 code is C1, the 2nd position code is C2, and return the decoded |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1024 character code. If the variable `translation_table' is non-nil, |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1025 returned the translated code. */ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1026 |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1027 #define DECODE_ISO_CHARACTER(charset, c1, c2) \ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1028 (NILP (translation_table) \ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1029 ? MAKE_CHAR (charset, c1, c2) \ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1030 : translate_char (translation_table, -1, charset, c1, c2)) |
17052 | 1031 |
1032 /* Set designation state into CODING. */ | |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
1033 #define DECODE_DESIGNATION(reg, dimension, chars, final_char) \ |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
1034 do { \ |
23881
20d595402dea
(DECODE_DESIGNATION): Jump to label_invalid_code if
Kenichi Handa <handa@m17n.org>
parents:
23564
diff
changeset
|
1035 int charset; \ |
20d595402dea
(DECODE_DESIGNATION): Jump to label_invalid_code if
Kenichi Handa <handa@m17n.org>
parents:
23564
diff
changeset
|
1036 \ |
20d595402dea
(DECODE_DESIGNATION): Jump to label_invalid_code if
Kenichi Handa <handa@m17n.org>
parents:
23564
diff
changeset
|
1037 if (final_char < '0' || final_char >= 128) \ |
20d595402dea
(DECODE_DESIGNATION): Jump to label_invalid_code if
Kenichi Handa <handa@m17n.org>
parents:
23564
diff
changeset
|
1038 goto label_invalid_code; \ |
20d595402dea
(DECODE_DESIGNATION): Jump to label_invalid_code if
Kenichi Handa <handa@m17n.org>
parents:
23564
diff
changeset
|
1039 charset = ISO_CHARSET_TABLE (make_number (dimension), \ |
20d595402dea
(DECODE_DESIGNATION): Jump to label_invalid_code if
Kenichi Handa <handa@m17n.org>
parents:
23564
diff
changeset
|
1040 make_number (chars), \ |
20d595402dea
(DECODE_DESIGNATION): Jump to label_invalid_code if
Kenichi Handa <handa@m17n.org>
parents:
23564
diff
changeset
|
1041 make_number (final_char)); \ |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
1042 if (charset >= 0 \ |
21331
4c89837392b3
(CHARSET_OK): Don't reject safe charsets.
Kenichi Handa <handa@m17n.org>
parents:
21321
diff
changeset
|
1043 && (CODING_SPEC_ISO_REQUESTED_DESIGNATION (coding, charset) == reg \ |
4c89837392b3
(CHARSET_OK): Don't reject safe charsets.
Kenichi Handa <handa@m17n.org>
parents:
21321
diff
changeset
|
1044 || coding->safe_charsets[charset])) \ |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
1045 { \ |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
1046 if (coding->spec.iso2022.last_invalid_designation_register == 0 \ |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
1047 && reg == 0 \ |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
1048 && charset == CHARSET_ASCII) \ |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
1049 { \ |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
1050 /* We should insert this designation sequence as is so \ |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
1051 that it is surely written back to a file. */ \ |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
1052 coding->spec.iso2022.last_invalid_designation_register = -1; \ |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
1053 goto label_invalid_code; \ |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
1054 } \ |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
1055 coding->spec.iso2022.last_invalid_designation_register = -1; \ |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
1056 if ((coding->mode & CODING_MODE_DIRECTION) \ |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
1057 && CHARSET_REVERSE_CHARSET (charset) >= 0) \ |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
1058 charset = CHARSET_REVERSE_CHARSET (charset); \ |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
1059 CODING_SPEC_ISO_DESIGNATION (coding, reg) = charset; \ |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
1060 } \ |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
1061 else \ |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
1062 { \ |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
1063 coding->spec.iso2022.last_invalid_designation_register = reg; \ |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
1064 goto label_invalid_code; \ |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
1065 } \ |
17052 | 1066 } while (0) |
1067 | |
26847 | 1068 /* Allocate a memory block for storing information about compositions. |
1069 The block is chained to the already allocated blocks. */ | |
1070 | |
29275
b4ea9178e480
(DECODE_COMPOSITION_START): If coding->cmp_data is not
Kenichi Handa <handa@m17n.org>
parents:
29247
diff
changeset
|
1071 void |
26847 | 1072 coding_allocate_composition_data (coding, char_offset) |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
1073 struct coding_system *coding; |
26847 | 1074 int char_offset; |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
1075 { |
26847 | 1076 struct composition_data *cmp_data |
1077 = (struct composition_data *) xmalloc (sizeof *cmp_data); | |
1078 | |
1079 cmp_data->char_offset = char_offset; | |
1080 cmp_data->used = 0; | |
1081 cmp_data->prev = coding->cmp_data; | |
1082 cmp_data->next = NULL; | |
1083 if (coding->cmp_data) | |
1084 coding->cmp_data->next = cmp_data; | |
1085 coding->cmp_data = cmp_data; | |
1086 coding->cmp_data_start = 0; | |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
1087 } |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
1088 |
26847 | 1089 /* Record the starting position START and METHOD of one composition. */ |
1090 | |
1091 #define CODING_ADD_COMPOSITION_START(coding, start, method) \ | |
1092 do { \ | |
1093 struct composition_data *cmp_data = coding->cmp_data; \ | |
1094 int *data = cmp_data->data + cmp_data->used; \ | |
1095 coding->cmp_data_start = cmp_data->used; \ | |
1096 data[0] = -1; \ | |
1097 data[1] = cmp_data->char_offset + start; \ | |
1098 data[3] = (int) method; \ | |
1099 cmp_data->used += 4; \ | |
1100 } while (0) | |
1101 | |
1102 /* Record the ending position END of the current composition. */ | |
1103 | |
1104 #define CODING_ADD_COMPOSITION_END(coding, end) \ | |
1105 do { \ | |
1106 struct composition_data *cmp_data = coding->cmp_data; \ | |
1107 int *data = cmp_data->data + coding->cmp_data_start; \ | |
1108 data[0] = cmp_data->used - coding->cmp_data_start; \ | |
1109 data[2] = cmp_data->char_offset + end; \ | |
1110 } while (0) | |
1111 | |
1112 /* Record one COMPONENT (alternate character or composition rule). */ | |
1113 | |
1114 #define CODING_ADD_COMPOSITION_COMPONENT(coding, component) \ | |
1115 (coding->cmp_data->data[coding->cmp_data->used++] = component) | |
1116 | |
1117 /* Handle compositoin start sequence ESC 0, ESC 2, ESC 3, or ESC 4. */ | |
1118 | |
29275
b4ea9178e480
(DECODE_COMPOSITION_START): If coding->cmp_data is not
Kenichi Handa <handa@m17n.org>
parents:
29247
diff
changeset
|
1119 #define DECODE_COMPOSITION_START(c1) \ |
b4ea9178e480
(DECODE_COMPOSITION_START): If coding->cmp_data is not
Kenichi Handa <handa@m17n.org>
parents:
29247
diff
changeset
|
1120 do { \ |
b4ea9178e480
(DECODE_COMPOSITION_START): If coding->cmp_data is not
Kenichi Handa <handa@m17n.org>
parents:
29247
diff
changeset
|
1121 if (coding->composing == COMPOSITION_DISABLED) \ |
b4ea9178e480
(DECODE_COMPOSITION_START): If coding->cmp_data is not
Kenichi Handa <handa@m17n.org>
parents:
29247
diff
changeset
|
1122 { \ |
b4ea9178e480
(DECODE_COMPOSITION_START): If coding->cmp_data is not
Kenichi Handa <handa@m17n.org>
parents:
29247
diff
changeset
|
1123 *dst++ = ISO_CODE_ESC; \ |
b4ea9178e480
(DECODE_COMPOSITION_START): If coding->cmp_data is not
Kenichi Handa <handa@m17n.org>
parents:
29247
diff
changeset
|
1124 *dst++ = c1 & 0x7f; \ |
b4ea9178e480
(DECODE_COMPOSITION_START): If coding->cmp_data is not
Kenichi Handa <handa@m17n.org>
parents:
29247
diff
changeset
|
1125 coding->produced_char += 2; \ |
b4ea9178e480
(DECODE_COMPOSITION_START): If coding->cmp_data is not
Kenichi Handa <handa@m17n.org>
parents:
29247
diff
changeset
|
1126 } \ |
b4ea9178e480
(DECODE_COMPOSITION_START): If coding->cmp_data is not
Kenichi Handa <handa@m17n.org>
parents:
29247
diff
changeset
|
1127 else if (!COMPOSING_P (coding)) \ |
b4ea9178e480
(DECODE_COMPOSITION_START): If coding->cmp_data is not
Kenichi Handa <handa@m17n.org>
parents:
29247
diff
changeset
|
1128 { \ |
b4ea9178e480
(DECODE_COMPOSITION_START): If coding->cmp_data is not
Kenichi Handa <handa@m17n.org>
parents:
29247
diff
changeset
|
1129 /* This is surely the start of a composition. We must be sure \ |
b4ea9178e480
(DECODE_COMPOSITION_START): If coding->cmp_data is not
Kenichi Handa <handa@m17n.org>
parents:
29247
diff
changeset
|
1130 that coding->cmp_data has enough space to store the \ |
b4ea9178e480
(DECODE_COMPOSITION_START): If coding->cmp_data is not
Kenichi Handa <handa@m17n.org>
parents:
29247
diff
changeset
|
1131 information about the composition. If not, terminate the \ |
b4ea9178e480
(DECODE_COMPOSITION_START): If coding->cmp_data is not
Kenichi Handa <handa@m17n.org>
parents:
29247
diff
changeset
|
1132 current decoding loop, allocate one more memory block for \ |
b4ea9178e480
(DECODE_COMPOSITION_START): If coding->cmp_data is not
Kenichi Handa <handa@m17n.org>
parents:
29247
diff
changeset
|
1133 coding->cmp_data in the calller, then start the decoding \ |
b4ea9178e480
(DECODE_COMPOSITION_START): If coding->cmp_data is not
Kenichi Handa <handa@m17n.org>
parents:
29247
diff
changeset
|
1134 loop again. We can't allocate memory here directly because \ |
b4ea9178e480
(DECODE_COMPOSITION_START): If coding->cmp_data is not
Kenichi Handa <handa@m17n.org>
parents:
29247
diff
changeset
|
1135 it may cause buffer/string relocation. */ \ |
b4ea9178e480
(DECODE_COMPOSITION_START): If coding->cmp_data is not
Kenichi Handa <handa@m17n.org>
parents:
29247
diff
changeset
|
1136 if (!coding->cmp_data \ |
b4ea9178e480
(DECODE_COMPOSITION_START): If coding->cmp_data is not
Kenichi Handa <handa@m17n.org>
parents:
29247
diff
changeset
|
1137 || (coding->cmp_data->used + COMPOSITION_DATA_MAX_BUNCH_LENGTH \ |
b4ea9178e480
(DECODE_COMPOSITION_START): If coding->cmp_data is not
Kenichi Handa <handa@m17n.org>
parents:
29247
diff
changeset
|
1138 >= COMPOSITION_DATA_SIZE)) \ |
b4ea9178e480
(DECODE_COMPOSITION_START): If coding->cmp_data is not
Kenichi Handa <handa@m17n.org>
parents:
29247
diff
changeset
|
1139 { \ |
b4ea9178e480
(DECODE_COMPOSITION_START): If coding->cmp_data is not
Kenichi Handa <handa@m17n.org>
parents:
29247
diff
changeset
|
1140 coding->result = CODING_FINISH_INSUFFICIENT_CMP; \ |
b4ea9178e480
(DECODE_COMPOSITION_START): If coding->cmp_data is not
Kenichi Handa <handa@m17n.org>
parents:
29247
diff
changeset
|
1141 goto label_end_of_loop; \ |
b4ea9178e480
(DECODE_COMPOSITION_START): If coding->cmp_data is not
Kenichi Handa <handa@m17n.org>
parents:
29247
diff
changeset
|
1142 } \ |
b4ea9178e480
(DECODE_COMPOSITION_START): If coding->cmp_data is not
Kenichi Handa <handa@m17n.org>
parents:
29247
diff
changeset
|
1143 coding->composing = (c1 == '0' ? COMPOSITION_RELATIVE \ |
b4ea9178e480
(DECODE_COMPOSITION_START): If coding->cmp_data is not
Kenichi Handa <handa@m17n.org>
parents:
29247
diff
changeset
|
1144 : c1 == '2' ? COMPOSITION_WITH_RULE \ |
b4ea9178e480
(DECODE_COMPOSITION_START): If coding->cmp_data is not
Kenichi Handa <handa@m17n.org>
parents:
29247
diff
changeset
|
1145 : c1 == '3' ? COMPOSITION_WITH_ALTCHARS \ |
b4ea9178e480
(DECODE_COMPOSITION_START): If coding->cmp_data is not
Kenichi Handa <handa@m17n.org>
parents:
29247
diff
changeset
|
1146 : COMPOSITION_WITH_RULE_ALTCHARS); \ |
b4ea9178e480
(DECODE_COMPOSITION_START): If coding->cmp_data is not
Kenichi Handa <handa@m17n.org>
parents:
29247
diff
changeset
|
1147 CODING_ADD_COMPOSITION_START (coding, coding->produced_char, \ |
b4ea9178e480
(DECODE_COMPOSITION_START): If coding->cmp_data is not
Kenichi Handa <handa@m17n.org>
parents:
29247
diff
changeset
|
1148 coding->composing); \ |
b4ea9178e480
(DECODE_COMPOSITION_START): If coding->cmp_data is not
Kenichi Handa <handa@m17n.org>
parents:
29247
diff
changeset
|
1149 coding->composition_rule_follows = 0; \ |
b4ea9178e480
(DECODE_COMPOSITION_START): If coding->cmp_data is not
Kenichi Handa <handa@m17n.org>
parents:
29247
diff
changeset
|
1150 } \ |
b4ea9178e480
(DECODE_COMPOSITION_START): If coding->cmp_data is not
Kenichi Handa <handa@m17n.org>
parents:
29247
diff
changeset
|
1151 else \ |
b4ea9178e480
(DECODE_COMPOSITION_START): If coding->cmp_data is not
Kenichi Handa <handa@m17n.org>
parents:
29247
diff
changeset
|
1152 { \ |
b4ea9178e480
(DECODE_COMPOSITION_START): If coding->cmp_data is not
Kenichi Handa <handa@m17n.org>
parents:
29247
diff
changeset
|
1153 /* We are already handling a composition. If the method is \ |
b4ea9178e480
(DECODE_COMPOSITION_START): If coding->cmp_data is not
Kenichi Handa <handa@m17n.org>
parents:
29247
diff
changeset
|
1154 the following two, the codes following the current escape \ |
b4ea9178e480
(DECODE_COMPOSITION_START): If coding->cmp_data is not
Kenichi Handa <handa@m17n.org>
parents:
29247
diff
changeset
|
1155 sequence are actual characters stored in a buffer. */ \ |
b4ea9178e480
(DECODE_COMPOSITION_START): If coding->cmp_data is not
Kenichi Handa <handa@m17n.org>
parents:
29247
diff
changeset
|
1156 if (coding->composing == COMPOSITION_WITH_ALTCHARS \ |
b4ea9178e480
(DECODE_COMPOSITION_START): If coding->cmp_data is not
Kenichi Handa <handa@m17n.org>
parents:
29247
diff
changeset
|
1157 || coding->composing == COMPOSITION_WITH_RULE_ALTCHARS) \ |
b4ea9178e480
(DECODE_COMPOSITION_START): If coding->cmp_data is not
Kenichi Handa <handa@m17n.org>
parents:
29247
diff
changeset
|
1158 { \ |
b4ea9178e480
(DECODE_COMPOSITION_START): If coding->cmp_data is not
Kenichi Handa <handa@m17n.org>
parents:
29247
diff
changeset
|
1159 coding->composing = COMPOSITION_RELATIVE; \ |
b4ea9178e480
(DECODE_COMPOSITION_START): If coding->cmp_data is not
Kenichi Handa <handa@m17n.org>
parents:
29247
diff
changeset
|
1160 coding->composition_rule_follows = 0; \ |
b4ea9178e480
(DECODE_COMPOSITION_START): If coding->cmp_data is not
Kenichi Handa <handa@m17n.org>
parents:
29247
diff
changeset
|
1161 } \ |
b4ea9178e480
(DECODE_COMPOSITION_START): If coding->cmp_data is not
Kenichi Handa <handa@m17n.org>
parents:
29247
diff
changeset
|
1162 } \ |
26847 | 1163 } while (0) |
1164 | |
1165 /* Handle compositoin end sequence ESC 1. */ | |
1166 | |
1167 #define DECODE_COMPOSITION_END(c1) \ | |
1168 do { \ | |
1169 if (coding->composing == COMPOSITION_DISABLED) \ | |
1170 { \ | |
1171 *dst++ = ISO_CODE_ESC; \ | |
1172 *dst++ = c1; \ | |
1173 coding->produced_char += 2; \ | |
1174 } \ | |
1175 else \ | |
1176 { \ | |
1177 CODING_ADD_COMPOSITION_END (coding, coding->produced_char); \ | |
1178 coding->composing = COMPOSITION_NO; \ | |
1179 } \ | |
1180 } while (0) | |
1181 | |
1182 /* Decode a composition rule from the byte C1 (and maybe one more byte | |
1183 from SRC) and store one encoded composition rule in | |
1184 coding->cmp_data. */ | |
1185 | |
1186 #define DECODE_COMPOSITION_RULE(c1) \ | |
1187 do { \ | |
1188 int rule = 0; \ | |
1189 (c1) -= 32; \ | |
1190 if (c1 < 81) /* old format (before ver.21) */ \ | |
1191 { \ | |
1192 int gref = (c1) / 9; \ | |
1193 int nref = (c1) % 9; \ | |
1194 if (gref == 4) gref = 10; \ | |
1195 if (nref == 4) nref = 10; \ | |
1196 rule = COMPOSITION_ENCODE_RULE (gref, nref); \ | |
1197 } \ | |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1198 else if (c1 < 93) /* new format (after ver.21) */ \ |
26847 | 1199 { \ |
1200 ONE_MORE_BYTE (c2); \ | |
1201 rule = COMPOSITION_ENCODE_RULE (c1 - 81, c2 - 32); \ | |
1202 } \ | |
1203 CODING_ADD_COMPOSITION_COMPONENT (coding, rule); \ | |
1204 coding->composition_rule_follows = 0; \ | |
1205 } while (0) | |
1206 | |
1207 | |
17052 | 1208 /* See the above "GENERAL NOTES on `decode_coding_XXX ()' functions". */ |
1209 | |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1210 static void |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
1211 decode_coding_iso2022 (coding, source, destination, src_bytes, dst_bytes) |
17052 | 1212 struct coding_system *coding; |
1213 unsigned char *source, *destination; | |
1214 int src_bytes, dst_bytes; | |
1215 { | |
1216 unsigned char *src = source; | |
1217 unsigned char *src_end = source + src_bytes; | |
1218 unsigned char *dst = destination; | |
1219 unsigned char *dst_end = destination + dst_bytes; | |
1220 /* Charsets invoked to graphic plane 0 and 1 respectively. */ | |
1221 int charset0 = CODING_SPEC_ISO_PLANE_CHARSET (coding, 0); | |
1222 int charset1 = CODING_SPEC_ISO_PLANE_CHARSET (coding, 1); | |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1223 /* SRC_BASE remembers the start position in source in each loop. |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1224 The loop will be exited when there's not enough source code |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1225 (within macro ONE_MORE_BYTE), or when there's not enough |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1226 destination area to produce a character (within macro |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1227 EMIT_CHAR). */ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1228 unsigned char *src_base; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1229 int c, charset; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1230 Lisp_Object translation_table; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1231 |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1232 if (NILP (Venable_character_translation)) |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1233 translation_table = Qnil; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1234 else |
17052 | 1235 { |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1236 translation_table = coding->translation_table_for_decode; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1237 if (NILP (translation_table)) |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1238 translation_table = Vstandard_translation_table_for_decode; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1239 } |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1240 |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1241 coding->result = CODING_FINISH_NORMAL; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1242 |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1243 while (1) |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1244 { |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1245 int c1, c2; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1246 |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1247 src_base = src; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1248 ONE_MORE_BYTE (c1); |
17052 | 1249 |
26847 | 1250 /* We produce no character or one character. */ |
17052 | 1251 switch (iso_code_class [c1]) |
1252 { | |
1253 case ISO_0x20_or_0x7F: | |
26847 | 1254 if (COMPOSING_P (coding) && coding->composition_rule_follows) |
1255 { | |
1256 DECODE_COMPOSITION_RULE (c1); | |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1257 continue; |
26847 | 1258 } |
1259 if (charset0 < 0 || CHARSET_CHARS (charset0) == 94) | |
17052 | 1260 { |
1261 /* This is SPACE or DEL. */ | |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1262 charset = CHARSET_ASCII; |
17052 | 1263 break; |
1264 } | |
1265 /* This is a graphic character, we fall down ... */ | |
1266 | |
1267 case ISO_graphic_plane_0: | |
26847 | 1268 if (COMPOSING_P (coding) && coding->composition_rule_follows) |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1269 { |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1270 DECODE_COMPOSITION_RULE (c1); |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1271 continue; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1272 } |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1273 charset = charset0; |
17052 | 1274 break; |
1275 | |
1276 case ISO_0xA0_or_0xFF: | |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
1277 if (charset1 < 0 || CHARSET_CHARS (charset1) == 94 |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
1278 || coding->flags & CODING_FLAG_ISO_SEVEN_BITS) |
20931
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
1279 goto label_invalid_code; |
17052 | 1280 /* This is a graphic character, we fall down ... */ |
1281 | |
1282 case ISO_graphic_plane_1: | |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1283 if (charset1 < 0) |
20931
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
1284 goto label_invalid_code; |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1285 charset = charset1; |
17052 | 1286 break; |
1287 | |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1288 case ISO_control_0: |
26847 | 1289 if (COMPOSING_P (coding)) |
1290 DECODE_COMPOSITION_END ('1'); | |
1291 | |
17052 | 1292 /* All ISO2022 control characters in this class have the |
1293 same representation in Emacs internal format. */ | |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
1294 if (c1 == '\n' |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
1295 && (coding->mode & CODING_MODE_INHIBIT_INCONSISTENT_EOL) |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
1296 && (coding->eol_type == CODING_EOL_CR |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
1297 || coding->eol_type == CODING_EOL_CRLF)) |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
1298 { |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1299 coding->result = CODING_FINISH_INCONSISTENT_EOL; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1300 goto label_end_of_loop; |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
1301 } |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1302 charset = CHARSET_ASCII; |
17052 | 1303 break; |
1304 | |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1305 case ISO_control_1: |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1306 if (COMPOSING_P (coding)) |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1307 DECODE_COMPOSITION_END ('1'); |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1308 goto label_invalid_code; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1309 |
17052 | 1310 case ISO_carriage_return: |
26847 | 1311 if (COMPOSING_P (coding)) |
1312 DECODE_COMPOSITION_END ('1'); | |
1313 | |
17052 | 1314 if (coding->eol_type == CODING_EOL_CR) |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1315 c1 = '\n'; |
17052 | 1316 else if (coding->eol_type == CODING_EOL_CRLF) |
1317 { | |
1318 ONE_MORE_BYTE (c1); | |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1319 if (c1 != ISO_CODE_LF) |
17052 | 1320 { |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
1321 if (coding->mode & CODING_MODE_INHIBIT_INCONSISTENT_EOL) |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
1322 { |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1323 coding->result = CODING_FINISH_INCONSISTENT_EOL; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1324 goto label_end_of_loop; |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
1325 } |
17052 | 1326 src--; |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1327 c1 = '\r'; |
17052 | 1328 } |
1329 } | |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1330 charset = CHARSET_ASCII; |
17052 | 1331 break; |
1332 | |
1333 case ISO_shift_out: | |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
1334 if (! (coding->flags & CODING_FLAG_ISO_LOCKING_SHIFT) |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
1335 || CODING_SPEC_ISO_DESIGNATION (coding, 1) < 0) |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
1336 goto label_invalid_code; |
17052 | 1337 CODING_SPEC_ISO_INVOCATION (coding, 0) = 1; |
1338 charset0 = CODING_SPEC_ISO_PLANE_CHARSET (coding, 0); | |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1339 continue; |
17052 | 1340 |
1341 case ISO_shift_in: | |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
1342 if (! (coding->flags & CODING_FLAG_ISO_LOCKING_SHIFT)) |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
1343 goto label_invalid_code; |
17052 | 1344 CODING_SPEC_ISO_INVOCATION (coding, 0) = 0; |
1345 charset0 = CODING_SPEC_ISO_PLANE_CHARSET (coding, 0); | |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1346 continue; |
17052 | 1347 |
1348 case ISO_single_shift_2_7: | |
1349 case ISO_single_shift_2: | |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
1350 if (! (coding->flags & CODING_FLAG_ISO_SINGLE_SHIFT)) |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
1351 goto label_invalid_code; |
17052 | 1352 /* SS2 is handled as an escape sequence of ESC 'N' */ |
1353 c1 = 'N'; | |
1354 goto label_escape_sequence; | |
1355 | |
1356 case ISO_single_shift_3: | |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
1357 if (! (coding->flags & CODING_FLAG_ISO_SINGLE_SHIFT)) |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
1358 goto label_invalid_code; |
17052 | 1359 /* SS2 is handled as an escape sequence of ESC 'O' */ |
1360 c1 = 'O'; | |
1361 goto label_escape_sequence; | |
1362 | |
1363 case ISO_control_sequence_introducer: | |
1364 /* CSI is handled as an escape sequence of ESC '[' ... */ | |
1365 c1 = '['; | |
1366 goto label_escape_sequence; | |
1367 | |
1368 case ISO_escape: | |
1369 ONE_MORE_BYTE (c1); | |
1370 label_escape_sequence: | |
1371 /* Escape sequences handled by Emacs are invocation, | |
1372 designation, direction specification, and character | |
1373 composition specification. */ | |
1374 switch (c1) | |
1375 { | |
1376 case '&': /* revision of following character set */ | |
1377 ONE_MORE_BYTE (c1); | |
1378 if (!(c1 >= '@' && c1 <= '~')) | |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
1379 goto label_invalid_code; |
17052 | 1380 ONE_MORE_BYTE (c1); |
1381 if (c1 != ISO_CODE_ESC) | |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
1382 goto label_invalid_code; |
17052 | 1383 ONE_MORE_BYTE (c1); |
1384 goto label_escape_sequence; | |
1385 | |
1386 case '$': /* designation of 2-byte character set */ | |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
1387 if (! (coding->flags & CODING_FLAG_ISO_DESIGNATION)) |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
1388 goto label_invalid_code; |
17052 | 1389 ONE_MORE_BYTE (c1); |
1390 if (c1 >= '@' && c1 <= 'B') | |
1391 { /* 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
|
1392 or JISX0208.1980 */ |
17052 | 1393 DECODE_DESIGNATION (0, 2, 94, c1); |
1394 } | |
1395 else if (c1 >= 0x28 && c1 <= 0x2B) | |
1396 { /* designation of DIMENSION2_CHARS94 character set */ | |
1397 ONE_MORE_BYTE (c2); | |
1398 DECODE_DESIGNATION (c1 - 0x28, 2, 94, c2); | |
1399 } | |
1400 else if (c1 >= 0x2C && c1 <= 0x2F) | |
1401 { /* designation of DIMENSION2_CHARS96 character set */ | |
1402 ONE_MORE_BYTE (c2); | |
1403 DECODE_DESIGNATION (c1 - 0x2C, 2, 96, c2); | |
1404 } | |
1405 else | |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
1406 goto label_invalid_code; |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1407 /* We must update these variables now. */ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1408 charset0 = CODING_SPEC_ISO_PLANE_CHARSET (coding, 0); |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1409 charset1 = CODING_SPEC_ISO_PLANE_CHARSET (coding, 1); |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1410 continue; |
17052 | 1411 |
1412 case 'n': /* invocation of locking-shift-2 */ | |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
1413 if (! (coding->flags & CODING_FLAG_ISO_LOCKING_SHIFT) |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
1414 || CODING_SPEC_ISO_DESIGNATION (coding, 2) < 0) |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
1415 goto label_invalid_code; |
17052 | 1416 CODING_SPEC_ISO_INVOCATION (coding, 0) = 2; |
17119
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
1417 charset0 = CODING_SPEC_ISO_PLANE_CHARSET (coding, 0); |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1418 continue; |
17052 | 1419 |
1420 case 'o': /* invocation of locking-shift-3 */ | |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
1421 if (! (coding->flags & CODING_FLAG_ISO_LOCKING_SHIFT) |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
1422 || CODING_SPEC_ISO_DESIGNATION (coding, 3) < 0) |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
1423 goto label_invalid_code; |
17052 | 1424 CODING_SPEC_ISO_INVOCATION (coding, 0) = 3; |
17119
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
1425 charset0 = CODING_SPEC_ISO_PLANE_CHARSET (coding, 0); |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1426 continue; |
17052 | 1427 |
1428 case 'N': /* invocation of single-shift-2 */ | |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
1429 if (! (coding->flags & CODING_FLAG_ISO_SINGLE_SHIFT) |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
1430 || CODING_SPEC_ISO_DESIGNATION (coding, 2) < 0) |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
1431 goto label_invalid_code; |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1432 charset = CODING_SPEC_ISO_DESIGNATION (coding, 2); |
17052 | 1433 ONE_MORE_BYTE (c1); |
1434 break; | |
1435 | |
1436 case 'O': /* invocation of single-shift-3 */ | |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
1437 if (! (coding->flags & CODING_FLAG_ISO_SINGLE_SHIFT) |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
1438 || CODING_SPEC_ISO_DESIGNATION (coding, 3) < 0) |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
1439 goto label_invalid_code; |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1440 charset = CODING_SPEC_ISO_DESIGNATION (coding, 3); |
17052 | 1441 ONE_MORE_BYTE (c1); |
1442 break; | |
1443 | |
26847 | 1444 case '0': case '2': case '3': case '4': /* start composition */ |
1445 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
|
1446 continue; |
17052 | 1447 |
26847 | 1448 case '1': /* end composition */ |
1449 DECODE_COMPOSITION_END (c1); | |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1450 continue; |
17052 | 1451 |
1452 case '[': /* specification of direction */ | |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
1453 if (coding->flags & CODING_FLAG_ISO_NO_DIRECTION) |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
1454 goto label_invalid_code; |
17052 | 1455 /* 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
|
1456 So, `coding->mode & CODING_MODE_DIRECTION' zero means |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
1457 left-to-right, and nozero means right-to-left. */ |
17052 | 1458 ONE_MORE_BYTE (c1); |
1459 switch (c1) | |
1460 { | |
1461 case ']': /* end of the current direction */ | |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
1462 coding->mode &= ~CODING_MODE_DIRECTION; |
17052 | 1463 |
1464 case '0': /* end of the current direction */ | |
1465 case '1': /* start of left-to-right direction */ | |
1466 ONE_MORE_BYTE (c1); | |
1467 if (c1 == ']') | |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
1468 coding->mode &= ~CODING_MODE_DIRECTION; |
17052 | 1469 else |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
1470 goto label_invalid_code; |
17052 | 1471 break; |
1472 | |
1473 case '2': /* start of right-to-left direction */ | |
1474 ONE_MORE_BYTE (c1); | |
1475 if (c1 == ']') | |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
1476 coding->mode |= CODING_MODE_DIRECTION; |
17052 | 1477 else |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
1478 goto label_invalid_code; |
17052 | 1479 break; |
1480 | |
1481 default: | |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
1482 goto label_invalid_code; |
17052 | 1483 } |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1484 continue; |
17052 | 1485 |
1486 default: | |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
1487 if (! (coding->flags & CODING_FLAG_ISO_DESIGNATION)) |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
1488 goto label_invalid_code; |
17052 | 1489 if (c1 >= 0x28 && c1 <= 0x2B) |
1490 { /* designation of DIMENSION1_CHARS94 character set */ | |
1491 ONE_MORE_BYTE (c2); | |
1492 DECODE_DESIGNATION (c1 - 0x28, 1, 94, c2); | |
1493 } | |
1494 else if (c1 >= 0x2C && c1 <= 0x2F) | |
1495 { /* designation of DIMENSION1_CHARS96 character set */ | |
1496 ONE_MORE_BYTE (c2); | |
1497 DECODE_DESIGNATION (c1 - 0x2C, 1, 96, c2); | |
1498 } | |
1499 else | |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1500 goto label_invalid_code; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1501 /* We must update these variables now. */ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1502 charset0 = CODING_SPEC_ISO_PLANE_CHARSET (coding, 0); |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1503 charset1 = CODING_SPEC_ISO_PLANE_CHARSET (coding, 1); |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1504 continue; |
17052 | 1505 } |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1506 } |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1507 |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1508 /* Now we know CHARSET and 1st position code C1 of a character. |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1509 Produce a multibyte sequence for that character while getting |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1510 2nd position code C2 if necessary. */ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1511 if (CHARSET_DIMENSION (charset) == 2) |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1512 { |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1513 ONE_MORE_BYTE (c2); |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1514 if (c1 < 0x80 ? c2 < 0x20 || c2 >= 0x80 : c2 < 0xA0) |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1515 /* C2 is not in a valid range. */ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1516 goto label_invalid_code; |
17052 | 1517 } |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1518 c = DECODE_ISO_CHARACTER (charset, c1, c2); |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1519 EMIT_CHAR (c); |
17052 | 1520 continue; |
1521 | |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1522 label_invalid_code: |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1523 coding->errors++; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1524 if (COMPOSING_P (coding)) |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1525 DECODE_COMPOSITION_END ('1'); |
17052 | 1526 src = src_base; |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1527 c = *src++; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1528 EMIT_CHAR (c); |
17052 | 1529 } |
1530 | |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1531 label_end_of_loop: |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1532 coding->consumed = coding->consumed_char = src_base - source; |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
1533 coding->produced = dst - destination; |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1534 return; |
17052 | 1535 } |
1536 | |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1537 |
18766 | 1538 /* ISO2022 encoding stuff. */ |
17052 | 1539 |
1540 /* | |
18766 | 1541 It is not enough to say just "ISO2022" on encoding, we have to |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
1542 specify more details. In Emacs, each coding system of ISO2022 |
17052 | 1543 variant has the following specifications: |
1544 1. Initial designation to G0 thru G3. | |
1545 2. Allows short-form designation? | |
1546 3. ASCII should be designated to G0 before control characters? | |
1547 4. ASCII should be designated to G0 at end of line? | |
1548 5. 7-bit environment or 8-bit environment? | |
1549 6. Use locking-shift? | |
1550 7. Use Single-shift? | |
1551 And the following two are only for Japanese: | |
1552 8. Use ASCII in place of JIS0201-1976-Roman? | |
1553 9. Use JISX0208-1983 in place of JISX0208-1978? | |
1554 These specifications are encoded in `coding->flags' as flag bits | |
1555 defined by macros CODING_FLAG_ISO_XXX. See `coding.h' for more | |
18766 | 1556 details. |
17052 | 1557 */ |
1558 | |
1559 /* 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
|
1560 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
|
1561 '@', '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
|
1562 designation sequence of short-form. */ |
17052 | 1563 |
1564 #define ENCODE_DESIGNATION(charset, reg, coding) \ | |
1565 do { \ | |
1566 unsigned char final_char = CHARSET_ISO_FINAL_CHAR (charset); \ | |
1567 char *intermediate_char_94 = "()*+"; \ | |
1568 char *intermediate_char_96 = ",-./"; \ | |
20150
402b6e5f4b58
(encode_designation_at_bol): Fix bug of finding graphic
Kenichi Handa <handa@m17n.org>
parents:
20105
diff
changeset
|
1569 int revision = CODING_SPEC_ISO_REVISION_NUMBER(coding, charset); \ |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1570 \ |
20150
402b6e5f4b58
(encode_designation_at_bol): Fix bug of finding graphic
Kenichi Handa <handa@m17n.org>
parents:
20105
diff
changeset
|
1571 if (revision < 255) \ |
402b6e5f4b58
(encode_designation_at_bol): Fix bug of finding graphic
Kenichi Handa <handa@m17n.org>
parents:
20105
diff
changeset
|
1572 { \ |
17052 | 1573 *dst++ = ISO_CODE_ESC; \ |
1574 *dst++ = '&'; \ | |
20150
402b6e5f4b58
(encode_designation_at_bol): Fix bug of finding graphic
Kenichi Handa <handa@m17n.org>
parents:
20105
diff
changeset
|
1575 *dst++ = '@' + revision; \ |
17052 | 1576 } \ |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1577 *dst++ = ISO_CODE_ESC; \ |
17052 | 1578 if (CHARSET_DIMENSION (charset) == 1) \ |
1579 { \ | |
1580 if (CHARSET_CHARS (charset) == 94) \ | |
1581 *dst++ = (unsigned char) (intermediate_char_94[reg]); \ | |
1582 else \ | |
1583 *dst++ = (unsigned char) (intermediate_char_96[reg]); \ | |
1584 } \ | |
1585 else \ | |
1586 { \ | |
1587 *dst++ = '$'; \ | |
1588 if (CHARSET_CHARS (charset) == 94) \ | |
1589 { \ | |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1590 if (! (coding->flags & CODING_FLAG_ISO_SHORT_FORM) \ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1591 || reg != 0 \ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1592 || final_char < '@' || final_char > 'B') \ |
17052 | 1593 *dst++ = (unsigned char) (intermediate_char_94[reg]); \ |
1594 } \ | |
1595 else \ | |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1596 *dst++ = (unsigned char) (intermediate_char_96[reg]); \ |
17052 | 1597 } \ |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1598 *dst++ = final_char; \ |
17052 | 1599 CODING_SPEC_ISO_DESIGNATION (coding, reg) = charset; \ |
1600 } while (0) | |
1601 | |
1602 /* The following two macros produce codes (control character or escape | |
1603 sequence) for ISO2022 single-shift functions (single-shift-2 and | |
1604 single-shift-3). */ | |
1605 | |
1606 #define ENCODE_SINGLE_SHIFT_2 \ | |
1607 do { \ | |
1608 if (coding->flags & CODING_FLAG_ISO_SEVEN_BITS) \ | |
1609 *dst++ = ISO_CODE_ESC, *dst++ = 'N'; \ | |
1610 else \ | |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1611 *dst++ = ISO_CODE_SS2; \ |
17052 | 1612 CODING_SPEC_ISO_SINGLE_SHIFTING (coding) = 1; \ |
1613 } while (0) | |
1614 | |
20931
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
1615 #define ENCODE_SINGLE_SHIFT_3 \ |
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
1616 do { \ |
17052 | 1617 if (coding->flags & CODING_FLAG_ISO_SEVEN_BITS) \ |
20931
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
1618 *dst++ = ISO_CODE_ESC, *dst++ = 'O'; \ |
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
1619 else \ |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1620 *dst++ = ISO_CODE_SS3; \ |
17052 | 1621 CODING_SPEC_ISO_SINGLE_SHIFTING (coding) = 1; \ |
1622 } while (0) | |
1623 | |
1624 /* The following four macros produce codes (control character or | |
1625 escape sequence) for ISO2022 locking-shift functions (shift-in, | |
1626 shift-out, locking-shift-2, and locking-shift-3). */ | |
1627 | |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1628 #define ENCODE_SHIFT_IN \ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1629 do { \ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1630 *dst++ = ISO_CODE_SI; \ |
17052 | 1631 CODING_SPEC_ISO_INVOCATION (coding, 0) = 0; \ |
1632 } while (0) | |
1633 | |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1634 #define ENCODE_SHIFT_OUT \ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1635 do { \ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1636 *dst++ = ISO_CODE_SO; \ |
17052 | 1637 CODING_SPEC_ISO_INVOCATION (coding, 0) = 1; \ |
1638 } while (0) | |
1639 | |
1640 #define ENCODE_LOCKING_SHIFT_2 \ | |
1641 do { \ | |
1642 *dst++ = ISO_CODE_ESC, *dst++ = 'n'; \ | |
1643 CODING_SPEC_ISO_INVOCATION (coding, 0) = 2; \ | |
1644 } while (0) | |
1645 | |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1646 #define ENCODE_LOCKING_SHIFT_3 \ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1647 do { \ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1648 *dst++ = ISO_CODE_ESC, *dst++ = 'o'; \ |
17052 | 1649 CODING_SPEC_ISO_INVOCATION (coding, 0) = 3; \ |
1650 } while (0) | |
1651 | |
18766 | 1652 /* Produce codes for a DIMENSION1 character whose character set is |
1653 CHARSET and whose position-code is C1. Designation and invocation | |
17052 | 1654 sequences are also produced in advance if necessary. */ |
1655 | |
19285
af3d00fde172
(Fset_terminal_coding_system_internal): Set
Kenichi Handa <handa@m17n.org>
parents:
19280
diff
changeset
|
1656 #define ENCODE_ISO_CHARACTER_DIMENSION1(charset, c1) \ |
af3d00fde172
(Fset_terminal_coding_system_internal): Set
Kenichi Handa <handa@m17n.org>
parents:
19280
diff
changeset
|
1657 do { \ |
af3d00fde172
(Fset_terminal_coding_system_internal): Set
Kenichi Handa <handa@m17n.org>
parents:
19280
diff
changeset
|
1658 if (CODING_SPEC_ISO_SINGLE_SHIFTING (coding)) \ |
af3d00fde172
(Fset_terminal_coding_system_internal): Set
Kenichi Handa <handa@m17n.org>
parents:
19280
diff
changeset
|
1659 { \ |
af3d00fde172
(Fset_terminal_coding_system_internal): Set
Kenichi Handa <handa@m17n.org>
parents:
19280
diff
changeset
|
1660 if (coding->flags & CODING_FLAG_ISO_SEVEN_BITS) \ |
af3d00fde172
(Fset_terminal_coding_system_internal): Set
Kenichi Handa <handa@m17n.org>
parents:
19280
diff
changeset
|
1661 *dst++ = c1 & 0x7F; \ |
af3d00fde172
(Fset_terminal_coding_system_internal): Set
Kenichi Handa <handa@m17n.org>
parents:
19280
diff
changeset
|
1662 else \ |
af3d00fde172
(Fset_terminal_coding_system_internal): Set
Kenichi Handa <handa@m17n.org>
parents:
19280
diff
changeset
|
1663 *dst++ = c1 | 0x80; \ |
af3d00fde172
(Fset_terminal_coding_system_internal): Set
Kenichi Handa <handa@m17n.org>
parents:
19280
diff
changeset
|
1664 CODING_SPEC_ISO_SINGLE_SHIFTING (coding) = 0; \ |
af3d00fde172
(Fset_terminal_coding_system_internal): Set
Kenichi Handa <handa@m17n.org>
parents:
19280
diff
changeset
|
1665 break; \ |
af3d00fde172
(Fset_terminal_coding_system_internal): Set
Kenichi Handa <handa@m17n.org>
parents:
19280
diff
changeset
|
1666 } \ |
af3d00fde172
(Fset_terminal_coding_system_internal): Set
Kenichi Handa <handa@m17n.org>
parents:
19280
diff
changeset
|
1667 else if (charset == CODING_SPEC_ISO_PLANE_CHARSET (coding, 0)) \ |
af3d00fde172
(Fset_terminal_coding_system_internal): Set
Kenichi Handa <handa@m17n.org>
parents:
19280
diff
changeset
|
1668 { \ |
af3d00fde172
(Fset_terminal_coding_system_internal): Set
Kenichi Handa <handa@m17n.org>
parents:
19280
diff
changeset
|
1669 *dst++ = c1 & 0x7F; \ |
af3d00fde172
(Fset_terminal_coding_system_internal): Set
Kenichi Handa <handa@m17n.org>
parents:
19280
diff
changeset
|
1670 break; \ |
af3d00fde172
(Fset_terminal_coding_system_internal): Set
Kenichi Handa <handa@m17n.org>
parents:
19280
diff
changeset
|
1671 } \ |
af3d00fde172
(Fset_terminal_coding_system_internal): Set
Kenichi Handa <handa@m17n.org>
parents:
19280
diff
changeset
|
1672 else if (charset == CODING_SPEC_ISO_PLANE_CHARSET (coding, 1)) \ |
af3d00fde172
(Fset_terminal_coding_system_internal): Set
Kenichi Handa <handa@m17n.org>
parents:
19280
diff
changeset
|
1673 { \ |
af3d00fde172
(Fset_terminal_coding_system_internal): Set
Kenichi Handa <handa@m17n.org>
parents:
19280
diff
changeset
|
1674 *dst++ = c1 | 0x80; \ |
af3d00fde172
(Fset_terminal_coding_system_internal): Set
Kenichi Handa <handa@m17n.org>
parents:
19280
diff
changeset
|
1675 break; \ |
af3d00fde172
(Fset_terminal_coding_system_internal): Set
Kenichi Handa <handa@m17n.org>
parents:
19280
diff
changeset
|
1676 } \ |
af3d00fde172
(Fset_terminal_coding_system_internal): Set
Kenichi Handa <handa@m17n.org>
parents:
19280
diff
changeset
|
1677 else if (coding->flags & CODING_FLAG_ISO_SAFE \ |
20150
402b6e5f4b58
(encode_designation_at_bol): Fix bug of finding graphic
Kenichi Handa <handa@m17n.org>
parents:
20105
diff
changeset
|
1678 && !coding->safe_charsets[charset]) \ |
19285
af3d00fde172
(Fset_terminal_coding_system_internal): Set
Kenichi Handa <handa@m17n.org>
parents:
19280
diff
changeset
|
1679 { \ |
af3d00fde172
(Fset_terminal_coding_system_internal): Set
Kenichi Handa <handa@m17n.org>
parents:
19280
diff
changeset
|
1680 /* We should not encode this character, instead produce one or \ |
af3d00fde172
(Fset_terminal_coding_system_internal): Set
Kenichi Handa <handa@m17n.org>
parents:
19280
diff
changeset
|
1681 two `?'s. */ \ |
af3d00fde172
(Fset_terminal_coding_system_internal): Set
Kenichi Handa <handa@m17n.org>
parents:
19280
diff
changeset
|
1682 *dst++ = CODING_INHIBIT_CHARACTER_SUBSTITUTION; \ |
af3d00fde172
(Fset_terminal_coding_system_internal): Set
Kenichi Handa <handa@m17n.org>
parents:
19280
diff
changeset
|
1683 if (CHARSET_WIDTH (charset) == 2) \ |
af3d00fde172
(Fset_terminal_coding_system_internal): Set
Kenichi Handa <handa@m17n.org>
parents:
19280
diff
changeset
|
1684 *dst++ = CODING_INHIBIT_CHARACTER_SUBSTITUTION; \ |
af3d00fde172
(Fset_terminal_coding_system_internal): Set
Kenichi Handa <handa@m17n.org>
parents:
19280
diff
changeset
|
1685 break; \ |
af3d00fde172
(Fset_terminal_coding_system_internal): Set
Kenichi Handa <handa@m17n.org>
parents:
19280
diff
changeset
|
1686 } \ |
af3d00fde172
(Fset_terminal_coding_system_internal): Set
Kenichi Handa <handa@m17n.org>
parents:
19280
diff
changeset
|
1687 else \ |
af3d00fde172
(Fset_terminal_coding_system_internal): Set
Kenichi Handa <handa@m17n.org>
parents:
19280
diff
changeset
|
1688 /* 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
|
1689 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
|
1690 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
|
1691 character. */ \ |
af3d00fde172
(Fset_terminal_coding_system_internal): Set
Kenichi Handa <handa@m17n.org>
parents:
19280
diff
changeset
|
1692 dst = encode_invocation_designation (charset, coding, dst); \ |
17052 | 1693 } while (1) |
1694 | |
18766 | 1695 /* Produce codes for a DIMENSION2 character whose character set is |
1696 CHARSET and whose position-codes are C1 and C2. Designation and | |
17052 | 1697 invocation codes are also produced in advance if necessary. */ |
1698 | |
19285
af3d00fde172
(Fset_terminal_coding_system_internal): Set
Kenichi Handa <handa@m17n.org>
parents:
19280
diff
changeset
|
1699 #define ENCODE_ISO_CHARACTER_DIMENSION2(charset, c1, c2) \ |
af3d00fde172
(Fset_terminal_coding_system_internal): Set
Kenichi Handa <handa@m17n.org>
parents:
19280
diff
changeset
|
1700 do { \ |
af3d00fde172
(Fset_terminal_coding_system_internal): Set
Kenichi Handa <handa@m17n.org>
parents:
19280
diff
changeset
|
1701 if (CODING_SPEC_ISO_SINGLE_SHIFTING (coding)) \ |
af3d00fde172
(Fset_terminal_coding_system_internal): Set
Kenichi Handa <handa@m17n.org>
parents:
19280
diff
changeset
|
1702 { \ |
af3d00fde172
(Fset_terminal_coding_system_internal): Set
Kenichi Handa <handa@m17n.org>
parents:
19280
diff
changeset
|
1703 if (coding->flags & CODING_FLAG_ISO_SEVEN_BITS) \ |
af3d00fde172
(Fset_terminal_coding_system_internal): Set
Kenichi Handa <handa@m17n.org>
parents:
19280
diff
changeset
|
1704 *dst++ = c1 & 0x7F, *dst++ = c2 & 0x7F; \ |
af3d00fde172
(Fset_terminal_coding_system_internal): Set
Kenichi Handa <handa@m17n.org>
parents:
19280
diff
changeset
|
1705 else \ |
af3d00fde172
(Fset_terminal_coding_system_internal): Set
Kenichi Handa <handa@m17n.org>
parents:
19280
diff
changeset
|
1706 *dst++ = c1 | 0x80, *dst++ = c2 | 0x80; \ |
af3d00fde172
(Fset_terminal_coding_system_internal): Set
Kenichi Handa <handa@m17n.org>
parents:
19280
diff
changeset
|
1707 CODING_SPEC_ISO_SINGLE_SHIFTING (coding) = 0; \ |
af3d00fde172
(Fset_terminal_coding_system_internal): Set
Kenichi Handa <handa@m17n.org>
parents:
19280
diff
changeset
|
1708 break; \ |
af3d00fde172
(Fset_terminal_coding_system_internal): Set
Kenichi Handa <handa@m17n.org>
parents:
19280
diff
changeset
|
1709 } \ |
af3d00fde172
(Fset_terminal_coding_system_internal): Set
Kenichi Handa <handa@m17n.org>
parents:
19280
diff
changeset
|
1710 else if (charset == CODING_SPEC_ISO_PLANE_CHARSET (coding, 0)) \ |
af3d00fde172
(Fset_terminal_coding_system_internal): Set
Kenichi Handa <handa@m17n.org>
parents:
19280
diff
changeset
|
1711 { \ |
af3d00fde172
(Fset_terminal_coding_system_internal): Set
Kenichi Handa <handa@m17n.org>
parents:
19280
diff
changeset
|
1712 *dst++ = c1 & 0x7F, *dst++= c2 & 0x7F; \ |
af3d00fde172
(Fset_terminal_coding_system_internal): Set
Kenichi Handa <handa@m17n.org>
parents:
19280
diff
changeset
|
1713 break; \ |
af3d00fde172
(Fset_terminal_coding_system_internal): Set
Kenichi Handa <handa@m17n.org>
parents:
19280
diff
changeset
|
1714 } \ |
af3d00fde172
(Fset_terminal_coding_system_internal): Set
Kenichi Handa <handa@m17n.org>
parents:
19280
diff
changeset
|
1715 else if (charset == CODING_SPEC_ISO_PLANE_CHARSET (coding, 1)) \ |
af3d00fde172
(Fset_terminal_coding_system_internal): Set
Kenichi Handa <handa@m17n.org>
parents:
19280
diff
changeset
|
1716 { \ |
af3d00fde172
(Fset_terminal_coding_system_internal): Set
Kenichi Handa <handa@m17n.org>
parents:
19280
diff
changeset
|
1717 *dst++ = c1 | 0x80, *dst++= c2 | 0x80; \ |
af3d00fde172
(Fset_terminal_coding_system_internal): Set
Kenichi Handa <handa@m17n.org>
parents:
19280
diff
changeset
|
1718 break; \ |
af3d00fde172
(Fset_terminal_coding_system_internal): Set
Kenichi Handa <handa@m17n.org>
parents:
19280
diff
changeset
|
1719 } \ |
af3d00fde172
(Fset_terminal_coding_system_internal): Set
Kenichi Handa <handa@m17n.org>
parents:
19280
diff
changeset
|
1720 else if (coding->flags & CODING_FLAG_ISO_SAFE \ |
20150
402b6e5f4b58
(encode_designation_at_bol): Fix bug of finding graphic
Kenichi Handa <handa@m17n.org>
parents:
20105
diff
changeset
|
1721 && !coding->safe_charsets[charset]) \ |
19285
af3d00fde172
(Fset_terminal_coding_system_internal): Set
Kenichi Handa <handa@m17n.org>
parents:
19280
diff
changeset
|
1722 { \ |
af3d00fde172
(Fset_terminal_coding_system_internal): Set
Kenichi Handa <handa@m17n.org>
parents:
19280
diff
changeset
|
1723 /* We should not encode this character, instead produce one or \ |
af3d00fde172
(Fset_terminal_coding_system_internal): Set
Kenichi Handa <handa@m17n.org>
parents:
19280
diff
changeset
|
1724 two `?'s. */ \ |
af3d00fde172
(Fset_terminal_coding_system_internal): Set
Kenichi Handa <handa@m17n.org>
parents:
19280
diff
changeset
|
1725 *dst++ = CODING_INHIBIT_CHARACTER_SUBSTITUTION; \ |
af3d00fde172
(Fset_terminal_coding_system_internal): Set
Kenichi Handa <handa@m17n.org>
parents:
19280
diff
changeset
|
1726 if (CHARSET_WIDTH (charset) == 2) \ |
af3d00fde172
(Fset_terminal_coding_system_internal): Set
Kenichi Handa <handa@m17n.org>
parents:
19280
diff
changeset
|
1727 *dst++ = CODING_INHIBIT_CHARACTER_SUBSTITUTION; \ |
af3d00fde172
(Fset_terminal_coding_system_internal): Set
Kenichi Handa <handa@m17n.org>
parents:
19280
diff
changeset
|
1728 break; \ |
af3d00fde172
(Fset_terminal_coding_system_internal): Set
Kenichi Handa <handa@m17n.org>
parents:
19280
diff
changeset
|
1729 } \ |
af3d00fde172
(Fset_terminal_coding_system_internal): Set
Kenichi Handa <handa@m17n.org>
parents:
19280
diff
changeset
|
1730 else \ |
af3d00fde172
(Fset_terminal_coding_system_internal): Set
Kenichi Handa <handa@m17n.org>
parents:
19280
diff
changeset
|
1731 /* 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
|
1732 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
|
1733 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
|
1734 character. */ \ |
af3d00fde172
(Fset_terminal_coding_system_internal): Set
Kenichi Handa <handa@m17n.org>
parents:
19280
diff
changeset
|
1735 dst = encode_invocation_designation (charset, coding, dst); \ |
17052 | 1736 } while (1) |
1737 | |
24506
219c99669e4b
(ENCODE_ISO_CHARACTER): Check validity of CHARSET. If
Kenichi Handa <handa@m17n.org>
parents:
24460
diff
changeset
|
1738 #define ENCODE_ISO_CHARACTER(charset, c1, c2) \ |
219c99669e4b
(ENCODE_ISO_CHARACTER): Check validity of CHARSET. If
Kenichi Handa <handa@m17n.org>
parents:
24460
diff
changeset
|
1739 do { \ |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1740 int alt_charset = charset; \ |
26847 | 1741 \ |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1742 if (CHARSET_DEFINED_P (charset)) \ |
24506
219c99669e4b
(ENCODE_ISO_CHARACTER): Check validity of CHARSET. If
Kenichi Handa <handa@m17n.org>
parents:
24460
diff
changeset
|
1743 { \ |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1744 if (CHARSET_DIMENSION (charset) == 1) \ |
24506
219c99669e4b
(ENCODE_ISO_CHARACTER): Check validity of CHARSET. If
Kenichi Handa <handa@m17n.org>
parents:
24460
diff
changeset
|
1745 { \ |
219c99669e4b
(ENCODE_ISO_CHARACTER): Check validity of CHARSET. If
Kenichi Handa <handa@m17n.org>
parents:
24460
diff
changeset
|
1746 if (charset == CHARSET_ASCII \ |
219c99669e4b
(ENCODE_ISO_CHARACTER): Check validity of CHARSET. If
Kenichi Handa <handa@m17n.org>
parents:
24460
diff
changeset
|
1747 && coding->flags & CODING_FLAG_ISO_USE_ROMAN) \ |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1748 alt_charset = charset_latin_jisx0201; \ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1749 ENCODE_ISO_CHARACTER_DIMENSION1 (alt_charset, c1); \ |
24506
219c99669e4b
(ENCODE_ISO_CHARACTER): Check validity of CHARSET. If
Kenichi Handa <handa@m17n.org>
parents:
24460
diff
changeset
|
1750 } \ |
219c99669e4b
(ENCODE_ISO_CHARACTER): Check validity of CHARSET. If
Kenichi Handa <handa@m17n.org>
parents:
24460
diff
changeset
|
1751 else \ |
219c99669e4b
(ENCODE_ISO_CHARACTER): Check validity of CHARSET. If
Kenichi Handa <handa@m17n.org>
parents:
24460
diff
changeset
|
1752 { \ |
219c99669e4b
(ENCODE_ISO_CHARACTER): Check validity of CHARSET. If
Kenichi Handa <handa@m17n.org>
parents:
24460
diff
changeset
|
1753 if (charset == charset_jisx0208 \ |
219c99669e4b
(ENCODE_ISO_CHARACTER): Check validity of CHARSET. If
Kenichi Handa <handa@m17n.org>
parents:
24460
diff
changeset
|
1754 && coding->flags & CODING_FLAG_ISO_USE_OLDJIS) \ |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1755 alt_charset = charset_jisx0208_1978; \ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1756 ENCODE_ISO_CHARACTER_DIMENSION2 (alt_charset, c1, c2); \ |
24506
219c99669e4b
(ENCODE_ISO_CHARACTER): Check validity of CHARSET. If
Kenichi Handa <handa@m17n.org>
parents:
24460
diff
changeset
|
1757 } \ |
219c99669e4b
(ENCODE_ISO_CHARACTER): Check validity of CHARSET. If
Kenichi Handa <handa@m17n.org>
parents:
24460
diff
changeset
|
1758 } \ |
219c99669e4b
(ENCODE_ISO_CHARACTER): Check validity of CHARSET. If
Kenichi Handa <handa@m17n.org>
parents:
24460
diff
changeset
|
1759 else \ |
219c99669e4b
(ENCODE_ISO_CHARACTER): Check validity of CHARSET. If
Kenichi Handa <handa@m17n.org>
parents:
24460
diff
changeset
|
1760 { \ |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1761 *dst++ = c1; \ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1762 if (c2 >= 0) \ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1763 *dst++ = c2; \ |
24506
219c99669e4b
(ENCODE_ISO_CHARACTER): Check validity of CHARSET. If
Kenichi Handa <handa@m17n.org>
parents:
24460
diff
changeset
|
1764 } \ |
22119
592bb8b9bcfd
Change terms unify/unification to
Kenichi Handa <handa@m17n.org>
parents:
22020
diff
changeset
|
1765 } while (0) |
17725
92f042f73be2
(Valternate_charset_table): The valiable deleted.
Kenichi Handa <handa@m17n.org>
parents:
17717
diff
changeset
|
1766 |
17052 | 1767 /* Produce designation and invocation codes at a place pointed by DST |
1768 to use CHARSET. The element `spec.iso2022' of *CODING is updated. | |
1769 Return new DST. */ | |
1770 | |
1771 unsigned char * | |
1772 encode_invocation_designation (charset, coding, dst) | |
1773 int charset; | |
1774 struct coding_system *coding; | |
1775 unsigned char *dst; | |
1776 { | |
1777 int reg; /* graphic register number */ | |
1778 | |
1779 /* At first, check designations. */ | |
1780 for (reg = 0; reg < 4; reg++) | |
1781 if (charset == CODING_SPEC_ISO_DESIGNATION (coding, reg)) | |
1782 break; | |
1783 | |
1784 if (reg >= 4) | |
1785 { | |
1786 /* CHARSET is not yet designated to any graphic registers. */ | |
1787 /* At first check the requested designation. */ | |
1788 reg = CODING_SPEC_ISO_REQUESTED_DESIGNATION (coding, charset); | |
18002
a14261786239
(encode_invocation_designation): Use macro
Kenichi Handa <handa@m17n.org>
parents:
17835
diff
changeset
|
1789 if (reg == CODING_SPEC_ISO_NO_REQUESTED_DESIGNATION) |
a14261786239
(encode_invocation_designation): Use macro
Kenichi Handa <handa@m17n.org>
parents:
17835
diff
changeset
|
1790 /* Since CHARSET requests no special designation, designate it |
a14261786239
(encode_invocation_designation): Use macro
Kenichi Handa <handa@m17n.org>
parents:
17835
diff
changeset
|
1791 to graphic register 0. */ |
17052 | 1792 reg = 0; |
1793 | |
1794 ENCODE_DESIGNATION (charset, reg, coding); | |
1795 } | |
1796 | |
1797 if (CODING_SPEC_ISO_INVOCATION (coding, 0) != reg | |
1798 && CODING_SPEC_ISO_INVOCATION (coding, 1) != reg) | |
1799 { | |
1800 /* Since the graphic register REG is not invoked to any graphic | |
1801 planes, invoke it to graphic plane 0. */ | |
1802 switch (reg) | |
1803 { | |
1804 case 0: /* graphic register 0 */ | |
1805 ENCODE_SHIFT_IN; | |
1806 break; | |
1807 | |
1808 case 1: /* graphic register 1 */ | |
1809 ENCODE_SHIFT_OUT; | |
1810 break; | |
1811 | |
1812 case 2: /* graphic register 2 */ | |
1813 if (coding->flags & CODING_FLAG_ISO_SINGLE_SHIFT) | |
1814 ENCODE_SINGLE_SHIFT_2; | |
1815 else | |
1816 ENCODE_LOCKING_SHIFT_2; | |
1817 break; | |
1818 | |
1819 case 3: /* graphic register 3 */ | |
1820 if (coding->flags & CODING_FLAG_ISO_SINGLE_SHIFT) | |
1821 ENCODE_SINGLE_SHIFT_3; | |
1822 else | |
1823 ENCODE_LOCKING_SHIFT_3; | |
1824 break; | |
1825 } | |
1826 } | |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1827 |
17052 | 1828 return dst; |
1829 } | |
1830 | |
26847 | 1831 /* Produce 2-byte codes for encoded composition rule RULE. */ |
1832 | |
1833 #define ENCODE_COMPOSITION_RULE(rule) \ | |
1834 do { \ | |
1835 int gref, nref; \ | |
1836 COMPOSITION_DECODE_RULE (rule, gref, nref); \ | |
1837 *dst++ = 32 + 81 + gref; \ | |
1838 *dst++ = 32 + nref; \ | |
1839 } while (0) | |
1840 | |
1841 /* Produce codes for indicating the start of a composition sequence | |
1842 (ESC 0, ESC 3, or ESC 4). DATA points to an array of integers | |
1843 which specify information about the composition. See the comment | |
1844 in coding.h for the format of DATA. */ | |
1845 | |
1846 #define ENCODE_COMPOSITION_START(coding, data) \ | |
1847 do { \ | |
1848 coding->composing = data[3]; \ | |
1849 *dst++ = ISO_CODE_ESC; \ | |
1850 if (coding->composing == COMPOSITION_RELATIVE) \ | |
1851 *dst++ = '0'; \ | |
1852 else \ | |
1853 { \ | |
1854 *dst++ = (coding->composing == COMPOSITION_WITH_ALTCHARS \ | |
1855 ? '3' : '4'); \ | |
1856 coding->cmp_data_index = coding->cmp_data_start + 4; \ | |
1857 coding->composition_rule_follows = 0; \ | |
1858 } \ | |
1859 } while (0) | |
1860 | |
1861 /* Produce codes for indicating the end of the current composition. */ | |
1862 | |
1863 #define ENCODE_COMPOSITION_END(coding, data) \ | |
1864 do { \ | |
1865 *dst++ = ISO_CODE_ESC; \ | |
1866 *dst++ = '1'; \ | |
1867 coding->cmp_data_start += data[0]; \ | |
1868 coding->composing = COMPOSITION_NO; \ | |
1869 if (coding->cmp_data_start == coding->cmp_data->used \ | |
1870 && coding->cmp_data->next) \ | |
1871 { \ | |
1872 coding->cmp_data = coding->cmp_data->next; \ | |
1873 coding->cmp_data_start = 0; \ | |
1874 } \ | |
1875 } while (0) | |
1876 | |
1877 /* Produce composition start sequence ESC 0. Here, this sequence | |
1878 doesn't mean the start of a new composition but means that we have | |
1879 just produced components (alternate chars and composition rules) of | |
1880 the composition and the actual text follows in SRC. */ | |
1881 | |
1882 #define ENCODE_COMPOSITION_FAKE_START(coding) \ | |
1883 do { \ | |
1884 *dst++ = ISO_CODE_ESC; \ | |
1885 *dst++ = '0'; \ | |
1886 coding->composing = COMPOSITION_RELATIVE; \ | |
1887 } while (0) | |
17052 | 1888 |
1889 /* The following three macros produce codes for indicating direction | |
1890 of text. */ | |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1891 #define ENCODE_CONTROL_SEQUENCE_INTRODUCER \ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1892 do { \ |
17052 | 1893 if (coding->flags == CODING_FLAG_ISO_SEVEN_BITS) \ |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1894 *dst++ = ISO_CODE_ESC, *dst++ = '['; \ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1895 else \ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1896 *dst++ = ISO_CODE_CSI; \ |
17052 | 1897 } while (0) |
1898 | |
1899 #define ENCODE_DIRECTION_R2L \ | |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1900 ENCODE_CONTROL_SEQUENCE_INTRODUCER (dst), *dst++ = '2', *dst++ = ']' |
17052 | 1901 |
1902 #define ENCODE_DIRECTION_L2R \ | |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1903 ENCODE_CONTROL_SEQUENCE_INTRODUCER (dst), *dst++ = '0', *dst++ = ']' |
17052 | 1904 |
1905 /* Produce codes for designation and invocation to reset the graphic | |
1906 planes and registers to initial state. */ | |
17119
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
1907 #define ENCODE_RESET_PLANE_AND_REGISTER \ |
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
1908 do { \ |
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
1909 int reg; \ |
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
1910 if (CODING_SPEC_ISO_INVOCATION (coding, 0) != 0) \ |
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
1911 ENCODE_SHIFT_IN; \ |
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
1912 for (reg = 0; reg < 4; reg++) \ |
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
1913 if (CODING_SPEC_ISO_INITIAL_DESIGNATION (coding, reg) >= 0 \ |
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
1914 && (CODING_SPEC_ISO_DESIGNATION (coding, reg) \ |
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
1915 != CODING_SPEC_ISO_INITIAL_DESIGNATION (coding, reg))) \ |
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
1916 ENCODE_DESIGNATION \ |
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
1917 (CODING_SPEC_ISO_INITIAL_DESIGNATION (coding, reg), reg, coding); \ |
17052 | 1918 } while (0) |
1919 | |
17725
92f042f73be2
(Valternate_charset_table): The valiable deleted.
Kenichi Handa <handa@m17n.org>
parents:
17717
diff
changeset
|
1920 /* 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
|
1921 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
|
1922 |
92f042f73be2
(Valternate_charset_table): The valiable deleted.
Kenichi Handa <handa@m17n.org>
parents:
17717
diff
changeset
|
1923 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
|
1924 find all the necessary designations. */ |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
1925 |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1926 static unsigned char * |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1927 encode_designation_at_bol (coding, translation_table, src, src_end, dst) |
17119
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
1928 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
|
1929 Lisp_Object translation_table; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1930 unsigned char *src, *src_end, *dst; |
17119
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
1931 { |
17725
92f042f73be2
(Valternate_charset_table): The valiable deleted.
Kenichi Handa <handa@m17n.org>
parents:
17717
diff
changeset
|
1932 int charset, c, found = 0, reg; |
92f042f73be2
(Valternate_charset_table): The valiable deleted.
Kenichi Handa <handa@m17n.org>
parents:
17717
diff
changeset
|
1933 /* 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
|
1934 int r[4]; |
92f042f73be2
(Valternate_charset_table): The valiable deleted.
Kenichi Handa <handa@m17n.org>
parents:
17717
diff
changeset
|
1935 |
92f042f73be2
(Valternate_charset_table): The valiable deleted.
Kenichi Handa <handa@m17n.org>
parents:
17717
diff
changeset
|
1936 for (reg = 0; reg < 4; reg++) |
92f042f73be2
(Valternate_charset_table): The valiable deleted.
Kenichi Handa <handa@m17n.org>
parents:
17717
diff
changeset
|
1937 r[reg] = -1; |
92f042f73be2
(Valternate_charset_table): The valiable deleted.
Kenichi Handa <handa@m17n.org>
parents:
17717
diff
changeset
|
1938 |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1939 while (found < 4) |
17119
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
1940 { |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1941 ONE_MORE_CHAR (c); |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1942 if (c == '\n') |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1943 break; |
17725
92f042f73be2
(Valternate_charset_table): The valiable deleted.
Kenichi Handa <handa@m17n.org>
parents:
17717
diff
changeset
|
1944 |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1945 charset = CHAR_CHARSET (c); |
17725
92f042f73be2
(Valternate_charset_table): The valiable deleted.
Kenichi Handa <handa@m17n.org>
parents:
17717
diff
changeset
|
1946 reg = CODING_SPEC_ISO_REQUESTED_DESIGNATION (coding, charset); |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
1947 if (reg != CODING_SPEC_ISO_NO_REQUESTED_DESIGNATION && r[reg] < 0) |
17725
92f042f73be2
(Valternate_charset_table): The valiable deleted.
Kenichi Handa <handa@m17n.org>
parents:
17717
diff
changeset
|
1948 { |
92f042f73be2
(Valternate_charset_table): The valiable deleted.
Kenichi Handa <handa@m17n.org>
parents:
17717
diff
changeset
|
1949 found++; |
92f042f73be2
(Valternate_charset_table): The valiable deleted.
Kenichi Handa <handa@m17n.org>
parents:
17717
diff
changeset
|
1950 r[reg] = charset; |
17119
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
1951 } |
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
1952 } |
17725
92f042f73be2
(Valternate_charset_table): The valiable deleted.
Kenichi Handa <handa@m17n.org>
parents:
17717
diff
changeset
|
1953 |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1954 label_end_of_loop: |
17725
92f042f73be2
(Valternate_charset_table): The valiable deleted.
Kenichi Handa <handa@m17n.org>
parents:
17717
diff
changeset
|
1955 if (found) |
92f042f73be2
(Valternate_charset_table): The valiable deleted.
Kenichi Handa <handa@m17n.org>
parents:
17717
diff
changeset
|
1956 { |
92f042f73be2
(Valternate_charset_table): The valiable deleted.
Kenichi Handa <handa@m17n.org>
parents:
17717
diff
changeset
|
1957 for (reg = 0; reg < 4; reg++) |
92f042f73be2
(Valternate_charset_table): The valiable deleted.
Kenichi Handa <handa@m17n.org>
parents:
17717
diff
changeset
|
1958 if (r[reg] >= 0 |
92f042f73be2
(Valternate_charset_table): The valiable deleted.
Kenichi Handa <handa@m17n.org>
parents:
17717
diff
changeset
|
1959 && CODING_SPEC_ISO_DESIGNATION (coding, reg) != r[reg]) |
92f042f73be2
(Valternate_charset_table): The valiable deleted.
Kenichi Handa <handa@m17n.org>
parents:
17717
diff
changeset
|
1960 ENCODE_DESIGNATION (r[reg], reg, coding); |
92f042f73be2
(Valternate_charset_table): The valiable deleted.
Kenichi Handa <handa@m17n.org>
parents:
17717
diff
changeset
|
1961 } |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1962 |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1963 return dst; |
17119
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
1964 } |
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
1965 |
17052 | 1966 /* See the above "GENERAL NOTES on `encode_coding_XXX ()' functions". */ |
1967 | |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1968 static void |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
1969 encode_coding_iso2022 (coding, source, destination, src_bytes, dst_bytes) |
17052 | 1970 struct coding_system *coding; |
1971 unsigned char *source, *destination; | |
1972 int src_bytes, dst_bytes; | |
1973 { | |
1974 unsigned char *src = source; | |
1975 unsigned char *src_end = source + src_bytes; | |
1976 unsigned char *dst = destination; | |
1977 unsigned char *dst_end = destination + dst_bytes; | |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1978 /* Since the maximum bytes produced by each loop is 20, we subtract 19 |
17052 | 1979 from DST_END to assure overflow checking is necessary only at the |
1980 head of loop. */ | |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1981 unsigned char *adjusted_dst_end = dst_end - 19; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1982 /* SRC_BASE remembers the start position in source in each loop. |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1983 The loop will be exited when there's not enough source text to |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1984 analyze multi-byte codes (within macro ONE_MORE_CHAR), or when |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1985 there's not enough destination area to produce encoded codes |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1986 (within macro EMIT_BYTES). */ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1987 unsigned char *src_base; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1988 int c; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1989 Lisp_Object translation_table; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1990 |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1991 if (NILP (Venable_character_translation)) |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1992 translation_table = Qnil; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1993 else |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1994 { |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1995 translation_table = coding->translation_table_for_encode; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1996 if (NILP (translation_table)) |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1997 translation_table = Vstandard_translation_table_for_encode; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1998 } |
17052 | 1999 |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
2000 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
|
2001 coding->errors = 0; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2002 while (1) |
17052 | 2003 { |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2004 int charset, c1, c2; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2005 |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2006 src_base = src; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2007 |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2008 if (dst >= (dst_bytes ? adjusted_dst_end : (src - 19))) |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2009 { |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2010 coding->result = CODING_FINISH_INSUFFICIENT_DST; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2011 break; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2012 } |
17052 | 2013 |
17119
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
2014 if (coding->flags & CODING_FLAG_ISO_DESIGNATE_AT_BOL |
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
2015 && CODING_SPEC_ISO_BOL (coding)) |
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
2016 { |
17725
92f042f73be2
(Valternate_charset_table): The valiable deleted.
Kenichi Handa <handa@m17n.org>
parents:
17717
diff
changeset
|
2017 /* We have to produce designation sequences if any now. */ |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2018 dst = encode_designation_at_bol (coding, translation_table, |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2019 src, src_end, dst); |
17119
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
2020 CODING_SPEC_ISO_BOL (coding) = 0; |
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
2021 } |
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
2022 |
26847 | 2023 /* Check composition start and end. */ |
2024 if (coding->composing != COMPOSITION_DISABLED | |
2025 && coding->cmp_data_start < coding->cmp_data->used) | |
17052 | 2026 { |
26847 | 2027 struct composition_data *cmp_data = coding->cmp_data; |
2028 int *data = cmp_data->data + coding->cmp_data_start; | |
2029 int this_pos = cmp_data->char_offset + coding->consumed_char; | |
2030 | |
2031 if (coding->composing == COMPOSITION_RELATIVE) | |
2032 { | |
2033 if (this_pos == data[2]) | |
2034 { | |
2035 ENCODE_COMPOSITION_END (coding, data); | |
2036 cmp_data = coding->cmp_data; | |
2037 data = cmp_data->data + coding->cmp_data_start; | |
2038 } | |
2039 } | |
2040 else if (COMPOSING_P (coding)) | |
17052 | 2041 { |
26847 | 2042 /* COMPOSITION_WITH_ALTCHARS or COMPOSITION_WITH_RULE_ALTCHAR */ |
2043 if (coding->cmp_data_index == coding->cmp_data_start + data[0]) | |
2044 /* We have consumed components of the composition. | |
2045 What follows in SRC is the compositions's base | |
2046 text. */ | |
2047 ENCODE_COMPOSITION_FAKE_START (coding); | |
2048 else | |
17052 | 2049 { |
26847 | 2050 int c = cmp_data->data[coding->cmp_data_index++]; |
2051 if (coding->composition_rule_follows) | |
2052 { | |
2053 ENCODE_COMPOSITION_RULE (c); | |
2054 coding->composition_rule_follows = 0; | |
2055 } | |
2056 else | |
2057 { | |
2058 SPLIT_CHAR (c, charset, c1, c2); | |
2059 ENCODE_ISO_CHARACTER (charset, c1, c2); | |
2060 if (coding->composing == COMPOSITION_WITH_RULE_ALTCHARS) | |
2061 coding->composition_rule_follows = 1; | |
2062 } | |
17052 | 2063 continue; |
2064 } | |
26847 | 2065 } |
2066 if (!COMPOSING_P (coding)) | |
2067 { | |
2068 if (this_pos == data[1]) | |
17052 | 2069 { |
26847 | 2070 ENCODE_COMPOSITION_START (coding, data); |
2071 continue; | |
17052 | 2072 } |
2073 } | |
2074 } | |
26847 | 2075 |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2076 ONE_MORE_CHAR (c); |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2077 |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2078 /* 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
|
2079 if (c < 0x20 || c == 0x7F) |
17052 | 2080 { |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2081 if (c == '\r') |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2082 { |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2083 if (! (coding->mode & CODING_MODE_SELECTIVE_DISPLAY)) |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2084 { |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2085 if (coding->flags & CODING_FLAG_ISO_RESET_AT_CNTL) |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2086 ENCODE_RESET_PLANE_AND_REGISTER; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2087 *dst++ = c; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2088 continue; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2089 } |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2090 /* fall down to treat '\r' as '\n' ... */ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2091 c = '\n'; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2092 } |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2093 if (c == '\n') |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2094 { |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2095 if (coding->flags & CODING_FLAG_ISO_RESET_AT_EOL) |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2096 ENCODE_RESET_PLANE_AND_REGISTER; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2097 if (coding->flags & CODING_FLAG_ISO_INIT_AT_BOL) |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2098 bcopy (coding->spec.iso2022.initial_designation, |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2099 coding->spec.iso2022.current_designation, |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2100 sizeof coding->spec.iso2022.initial_designation); |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2101 if (coding->eol_type == CODING_EOL_LF |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2102 || coding->eol_type == CODING_EOL_UNDECIDED) |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2103 *dst++ = ISO_CODE_LF; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2104 else if (coding->eol_type == CODING_EOL_CRLF) |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2105 *dst++ = ISO_CODE_CR, *dst++ = ISO_CODE_LF; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2106 else |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2107 *dst++ = ISO_CODE_CR; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2108 CODING_SPEC_ISO_BOL (coding) = 1; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2109 } |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2110 else |
17052 | 2111 { |
2112 if (coding->flags & CODING_FLAG_ISO_RESET_AT_CNTL) | |
17119
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
2113 ENCODE_RESET_PLANE_AND_REGISTER; |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2114 *dst++ = c; |
19052
302a7b2a6948
(encode_coding_iso2022): Write out invalid multibyte
Kenichi Handa <handa@m17n.org>
parents:
18910
diff
changeset
|
2115 } |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2116 } |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2117 else if (ASCII_BYTE_P (c)) |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2118 ENCODE_ISO_CHARACTER (CHARSET_ASCII, c, /* dummy */ c1); |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2119 else if (SINGLE_BYTE_CHAR_P (c)) |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2120 { |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2121 *dst++ = c; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2122 coding->errors++; |
17052 | 2123 } |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2124 else |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2125 { |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2126 SPLIT_CHAR (c, charset, c1, c2); |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2127 ENCODE_ISO_CHARACTER (charset, c1, c2); |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2128 } |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2129 |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2130 coding->consumed_char++; |
17052 | 2131 } |
2132 | |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2133 label_end_of_loop: |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2134 coding->consumed = src_base - source; |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
2135 coding->produced = coding->produced_char = dst - destination; |
17052 | 2136 } |
2137 | |
2138 | |
2139 /*** 4. SJIS and BIG5 handlers ***/ | |
2140 | |
18766 | 2141 /* Although SJIS and BIG5 are not ISO's coding system, they are used |
17052 | 2142 quite widely. So, for the moment, Emacs supports them in the bare |
2143 C code. But, in the future, they may be supported only by CCL. */ | |
2144 | |
2145 /* SJIS is a coding system encoding three character sets: ASCII, right | |
2146 half of JISX0201-Kana, and JISX0208. An ASCII character is encoded | |
2147 as is. A character of charset katakana-jisx0201 is encoded by | |
2148 "position-code + 0x80". A character of charset japanese-jisx0208 | |
2149 is encoded in 2-byte but two position-codes are divided and shifted | |
2150 so that it fit in the range below. | |
2151 | |
2152 --- CODE RANGE of SJIS --- | |
2153 (character set) (range) | |
2154 ASCII 0x00 .. 0x7F | |
2155 KATAKANA-JISX0201 0xA0 .. 0xDF | |
24324
2eec590faf26
(Fdecode_sjis_char, Fencode_sjis_char): Hanlde
Kenichi Handa <handa@m17n.org>
parents:
24316
diff
changeset
|
2156 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
|
2157 (2nd byte) 0x40 .. 0x7E and 0x80 .. 0xFC |
17052 | 2158 ------------------------------- |
2159 | |
2160 */ | |
2161 | |
2162 /* BIG5 is a coding system encoding two character sets: ASCII and | |
2163 Big5. An ASCII character is encoded as is. Big5 is a two-byte | |
2164 character set and is encoded in two-byte. | |
2165 | |
2166 --- CODE RANGE of BIG5 --- | |
2167 (character set) (range) | |
2168 ASCII 0x00 .. 0x7F | |
2169 Big5 (1st byte) 0xA1 .. 0xFE | |
2170 (2nd byte) 0x40 .. 0x7E and 0xA1 .. 0xFE | |
2171 -------------------------- | |
2172 | |
2173 Since the number of characters in Big5 is larger than maximum | |
2174 characters in Emacs' charset (96x96), it can't be handled as one | |
2175 charset. So, in Emacs, Big5 is divided into two: `charset-big5-1' | |
2176 and `charset-big5-2'. Both are DIMENSION2 and CHARS94. The former | |
2177 contains frequently used characters and the latter contains less | |
2178 frequently used characters. */ | |
2179 | |
2180 /* Macros to decode or encode a character of Big5 in BIG5. B1 and B2 | |
2181 are the 1st and 2nd position-codes of Big5 in BIG5 coding system. | |
2182 C1 and C2 are the 1st and 2nd position-codes of of Emacs' internal | |
2183 format. CHARSET is `charset_big5_1' or `charset_big5_2'. */ | |
2184 | |
2185 /* Number of Big5 characters which have the same code in 1st byte. */ | |
2186 #define BIG5_SAME_ROW (0xFF - 0xA1 + 0x7F - 0x40) | |
2187 | |
2188 #define DECODE_BIG5(b1, b2, charset, c1, c2) \ | |
2189 do { \ | |
2190 unsigned int temp \ | |
2191 = (b1 - 0xA1) * BIG5_SAME_ROW + b2 - (b2 < 0x7F ? 0x40 : 0x62); \ | |
2192 if (b1 < 0xC9) \ | |
2193 charset = charset_big5_1; \ | |
2194 else \ | |
2195 { \ | |
2196 charset = charset_big5_2; \ | |
2197 temp -= (0xC9 - 0xA1) * BIG5_SAME_ROW; \ | |
2198 } \ | |
2199 c1 = temp / (0xFF - 0xA1) + 0x21; \ | |
2200 c2 = temp % (0xFF - 0xA1) + 0x21; \ | |
2201 } while (0) | |
2202 | |
2203 #define ENCODE_BIG5(charset, c1, c2, b1, b2) \ | |
2204 do { \ | |
2205 unsigned int temp = (c1 - 0x21) * (0xFF - 0xA1) + (c2 - 0x21); \ | |
2206 if (charset == charset_big5_2) \ | |
2207 temp += BIG5_SAME_ROW * (0xC9 - 0xA1); \ | |
2208 b1 = temp / BIG5_SAME_ROW + 0xA1; \ | |
2209 b2 = temp % BIG5_SAME_ROW; \ | |
2210 b2 += b2 < 0x3F ? 0x40 : 0x62; \ | |
2211 } while (0) | |
2212 | |
2213 /* See the above "GENERAL NOTES on `detect_coding_XXX ()' functions". | |
2214 Check if a text is encoded in SJIS. If it is, return | |
2215 CODING_CATEGORY_MASK_SJIS, else return 0. */ | |
2216 | |
2217 int | |
2218 detect_coding_sjis (src, src_end) | |
2219 unsigned char *src, *src_end; | |
2220 { | |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2221 int c; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2222 /* Dummy for ONE_MORE_BYTE. */ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2223 struct coding_system dummy_coding; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2224 struct coding_system *coding = &dummy_coding; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2225 |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2226 while (1) |
17052 | 2227 { |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2228 ONE_MORE_BYTE (c); |
17052 | 2229 if ((c >= 0x80 && c < 0xA0) || c >= 0xE0) |
2230 { | |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2231 ONE_MORE_BYTE (c); |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2232 if (c < 0x40) |
17052 | 2233 return 0; |
2234 } | |
2235 } | |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2236 label_end_of_loop: |
17052 | 2237 return CODING_CATEGORY_MASK_SJIS; |
2238 } | |
2239 | |
2240 /* See the above "GENERAL NOTES on `detect_coding_XXX ()' functions". | |
2241 Check if a text is encoded in BIG5. If it is, return | |
2242 CODING_CATEGORY_MASK_BIG5, else return 0. */ | |
2243 | |
2244 int | |
2245 detect_coding_big5 (src, src_end) | |
2246 unsigned char *src, *src_end; | |
2247 { | |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2248 int c; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2249 /* Dummy for ONE_MORE_BYTE. */ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2250 struct coding_system dummy_coding; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2251 struct coding_system *coding = &dummy_coding; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2252 |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2253 while (1) |
17052 | 2254 { |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2255 ONE_MORE_BYTE (c); |
17052 | 2256 if (c >= 0xA1) |
2257 { | |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2258 ONE_MORE_BYTE (c); |
17052 | 2259 if (c < 0x40 || (c >= 0x7F && c <= 0xA0)) |
2260 return 0; | |
2261 } | |
2262 } | |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2263 label_end_of_loop: |
17052 | 2264 return CODING_CATEGORY_MASK_BIG5; |
2265 } | |
2266 | |
28022
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
2267 /* See the above "GENERAL NOTES on `detect_coding_XXX ()' functions". |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
2268 Check if a text is encoded in UTF-8. If it is, return |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
2269 CODING_CATEGORY_MASK_UTF_8, else return 0. */ |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
2270 |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
2271 #define UTF_8_1_OCTET_P(c) ((c) < 0x80) |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
2272 #define UTF_8_EXTRA_OCTET_P(c) (((c) & 0xC0) == 0x80) |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
2273 #define UTF_8_2_OCTET_LEADING_P(c) (((c) & 0xE0) == 0xC0) |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
2274 #define UTF_8_3_OCTET_LEADING_P(c) (((c) & 0xF0) == 0xE0) |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
2275 #define UTF_8_4_OCTET_LEADING_P(c) (((c) & 0xF8) == 0xF0) |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
2276 #define UTF_8_5_OCTET_LEADING_P(c) (((c) & 0xFC) == 0xF8) |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
2277 #define UTF_8_6_OCTET_LEADING_P(c) (((c) & 0xFE) == 0xFC) |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
2278 |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
2279 int |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
2280 detect_coding_utf_8 (src, src_end) |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
2281 unsigned char *src, *src_end; |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
2282 { |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
2283 unsigned char c; |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
2284 int seq_maybe_bytes; |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2285 /* Dummy for ONE_MORE_BYTE. */ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2286 struct coding_system dummy_coding; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2287 struct coding_system *coding = &dummy_coding; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2288 |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2289 while (1) |
28022
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
2290 { |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2291 ONE_MORE_BYTE (c); |
28022
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
2292 if (UTF_8_1_OCTET_P (c)) |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
2293 continue; |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
2294 else if (UTF_8_2_OCTET_LEADING_P (c)) |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
2295 seq_maybe_bytes = 1; |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
2296 else if (UTF_8_3_OCTET_LEADING_P (c)) |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
2297 seq_maybe_bytes = 2; |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
2298 else if (UTF_8_4_OCTET_LEADING_P (c)) |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
2299 seq_maybe_bytes = 3; |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
2300 else if (UTF_8_5_OCTET_LEADING_P (c)) |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
2301 seq_maybe_bytes = 4; |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
2302 else if (UTF_8_6_OCTET_LEADING_P (c)) |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
2303 seq_maybe_bytes = 5; |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
2304 else |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
2305 return 0; |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
2306 |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
2307 do |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
2308 { |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2309 ONE_MORE_BYTE (c); |
28022
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
2310 if (!UTF_8_EXTRA_OCTET_P (c)) |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
2311 return 0; |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
2312 seq_maybe_bytes--; |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
2313 } |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
2314 while (seq_maybe_bytes > 0); |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
2315 } |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
2316 |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2317 label_end_of_loop: |
28022
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
2318 return CODING_CATEGORY_MASK_UTF_8; |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
2319 } |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
2320 |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
2321 /* See the above "GENERAL NOTES on `detect_coding_XXX ()' functions". |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
2322 Check if a text is encoded in UTF-16 Big Endian (endian == 1) or |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
2323 Little Endian (otherwise). If it is, return |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
2324 CODING_CATEGORY_MASK_UTF_16_BE or CODING_CATEGORY_MASK_UTF_16_LE, |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
2325 else return 0. */ |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
2326 |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
2327 #define UTF_16_INVALID_P(val) \ |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
2328 (((val) == 0xFFFE) \ |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
2329 || ((val) == 0xFFFF)) |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
2330 |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
2331 #define UTF_16_HIGH_SURROGATE_P(val) \ |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
2332 (((val) & 0xD800) == 0xD800) |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
2333 |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
2334 #define UTF_16_LOW_SURROGATE_P(val) \ |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
2335 (((val) & 0xDC00) == 0xDC00) |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
2336 |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
2337 int |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
2338 detect_coding_utf_16 (src, src_end) |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
2339 unsigned char *src, *src_end; |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
2340 { |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2341 unsigned char c1, c2; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2342 /* Dummy for TWO_MORE_BYTES. */ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2343 struct coding_system dummy_coding; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2344 struct coding_system *coding = &dummy_coding; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2345 |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2346 TWO_MORE_BYTES (c1, c2); |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2347 |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2348 if ((c1 == 0xFF) && (c2 == 0xFE)) |
28022
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
2349 return CODING_CATEGORY_MASK_UTF_16_LE; |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2350 else if ((c1 == 0xFE) && (c2 == 0xFF)) |
28022
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
2351 return CODING_CATEGORY_MASK_UTF_16_BE; |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
2352 |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2353 label_end_of_loop: |
28022
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
2354 return 0; |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
2355 } |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
2356 |
17052 | 2357 /* See the above "GENERAL NOTES on `decode_coding_XXX ()' functions". |
2358 If SJIS_P is 1, decode SJIS text, else decode BIG5 test. */ | |
2359 | |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2360 static void |
17052 | 2361 decode_coding_sjis_big5 (coding, source, destination, |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
2362 src_bytes, dst_bytes, sjis_p) |
17052 | 2363 struct coding_system *coding; |
2364 unsigned char *source, *destination; | |
2365 int src_bytes, dst_bytes; | |
2366 int sjis_p; | |
2367 { | |
2368 unsigned char *src = source; | |
2369 unsigned char *src_end = source + src_bytes; | |
2370 unsigned char *dst = destination; | |
2371 unsigned char *dst_end = destination + dst_bytes; | |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2372 /* SRC_BASE remembers the start position in source in each loop. |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2373 The loop will be exited when there's not enough source code |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2374 (within macro ONE_MORE_BYTE), or when there's not enough |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2375 destination area to produce a character (within macro |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2376 EMIT_CHAR). */ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2377 unsigned char *src_base; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2378 Lisp_Object translation_table; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2379 |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2380 if (NILP (Venable_character_translation)) |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2381 translation_table = Qnil; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2382 else |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2383 { |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2384 translation_table = coding->translation_table_for_decode; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2385 if (NILP (translation_table)) |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2386 translation_table = Vstandard_translation_table_for_decode; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2387 } |
17052 | 2388 |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
2389 coding->produced_char = 0; |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2390 while (1) |
17052 | 2391 { |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2392 int c, charset, c1, c2; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2393 |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2394 src_base = src; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2395 ONE_MORE_BYTE (c1); |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2396 |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2397 if (c1 < 0x80) |
17052 | 2398 { |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2399 charset = CHARSET_ASCII; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2400 if (c1 < 0x20) |
17052 | 2401 { |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2402 if (c1 == '\r') |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
2403 { |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2404 if (coding->eol_type == CODING_EOL_CRLF) |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
2405 { |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2406 ONE_MORE_BYTE (c2); |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2407 if (c2 == '\n') |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2408 c1 = c2; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2409 else if (coding->mode |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2410 & CODING_MODE_INHIBIT_INCONSISTENT_EOL) |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2411 { |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2412 coding->result = CODING_FINISH_INCONSISTENT_EOL; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2413 goto label_end_of_loop; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2414 } |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2415 else |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2416 /* To process C2 again, SRC is subtracted by 1. */ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2417 src--; |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
2418 } |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2419 else if (coding->eol_type == CODING_EOL_CR) |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2420 c1 = '\n'; |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
2421 } |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2422 else if (c1 == '\n' |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2423 && (coding->mode & CODING_MODE_INHIBIT_INCONSISTENT_EOL) |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2424 && (coding->eol_type == CODING_EOL_CR |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2425 || coding->eol_type == CODING_EOL_CRLF)) |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2426 { |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2427 coding->result = CODING_FINISH_INCONSISTENT_EOL; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2428 goto label_end_of_loop; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2429 } |
17052 | 2430 } |
2431 } | |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2432 else |
24870
b0f6eab5deeb
(decode_coding_sjis_big5): Avoid compiler warning.
Kenichi Handa <handa@m17n.org>
parents:
24822
diff
changeset
|
2433 { |
17052 | 2434 if (sjis_p) |
2435 { | |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2436 if (c1 >= 0xF0) |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2437 goto label_invalid_code; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2438 if (c1 < 0xA0 || c1 >= 0xE0) |
20931
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
2439 { |
22616
c493ce6a31e4
(setup_raw_text_coding_system): New function.
Kenichi Handa <handa@m17n.org>
parents:
22529
diff
changeset
|
2440 /* SJIS -> JISX0208 */ |
c493ce6a31e4
(setup_raw_text_coding_system): New function.
Kenichi Handa <handa@m17n.org>
parents:
22529
diff
changeset
|
2441 ONE_MORE_BYTE (c2); |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2442 if (c2 < 0x40 || c2 == 0x7F || c2 > 0xFC) |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2443 goto label_invalid_code; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2444 DECODE_SJIS (c1, c2, c1, c2); |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2445 charset = charset_jisx0208; |
24870
b0f6eab5deeb
(decode_coding_sjis_big5): Avoid compiler warning.
Kenichi Handa <handa@m17n.org>
parents:
24822
diff
changeset
|
2446 } |
20931
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
2447 else |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2448 /* SJIS -> JISX0201-Kana */ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2449 charset = charset_katakana_jisx0201; |
20931
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
2450 } |
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
2451 else |
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
2452 { |
22616
c493ce6a31e4
(setup_raw_text_coding_system): New function.
Kenichi Handa <handa@m17n.org>
parents:
22529
diff
changeset
|
2453 /* BIG5 -> Big5 */ |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2454 if (c1 < 0xA1 || c1 > 0xFE) |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2455 goto label_invalid_code; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2456 ONE_MORE_BYTE (c2); |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2457 if (c2 < 0x40 || (c2 > 0x7E && c2 < 0xA1) || c2 > 0xFE) |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2458 goto label_invalid_code; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2459 DECODE_BIG5 (c1, c2, charset, c1, c2); |
20931
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
2460 } |
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
2461 } |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2462 |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2463 c = DECODE_ISO_CHARACTER (charset, c1, c2); |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2464 EMIT_CHAR (c); |
20931
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
2465 continue; |
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
2466 |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2467 label_invalid_code: |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2468 coding->errors++; |
17052 | 2469 src = src_base; |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2470 c = *src++; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2471 EMIT_CHAR (c); |
17052 | 2472 } |
2473 | |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2474 label_end_of_loop: |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2475 coding->consumed = coding->consumed_char = src_base - source; |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
2476 coding->produced = dst - destination; |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2477 return; |
17052 | 2478 } |
2479 | |
2480 /* 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
|
2481 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
|
2482 `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
|
2483 are sure that all these charsets are registered as official charset |
17052 | 2484 (i.e. do not have extended leading-codes). Characters of other |
2485 charsets are produced without any encoding. If SJIS_P is 1, encode | |
2486 SJIS text, else encode BIG5 text. */ | |
2487 | |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2488 static void |
17052 | 2489 encode_coding_sjis_big5 (coding, source, destination, |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
2490 src_bytes, dst_bytes, sjis_p) |
17052 | 2491 struct coding_system *coding; |
2492 unsigned char *source, *destination; | |
2493 int src_bytes, dst_bytes; | |
2494 int sjis_p; | |
2495 { | |
2496 unsigned char *src = source; | |
2497 unsigned char *src_end = source + src_bytes; | |
2498 unsigned char *dst = destination; | |
2499 unsigned char *dst_end = destination + dst_bytes; | |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2500 /* SRC_BASE remembers the start position in source in each loop. |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2501 The loop will be exited when there's not enough source text to |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2502 analyze multi-byte codes (within macro ONE_MORE_CHAR), or when |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2503 there's not enough destination area to produce encoded codes |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2504 (within macro EMIT_BYTES). */ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2505 unsigned char *src_base; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2506 Lisp_Object translation_table; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2507 |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2508 if (NILP (Venable_character_translation)) |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2509 translation_table = Qnil; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2510 else |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2511 { |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2512 translation_table = coding->translation_table_for_decode; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2513 if (NILP (translation_table)) |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2514 translation_table = Vstandard_translation_table_for_decode; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2515 } |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2516 |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2517 while (1) |
17052 | 2518 { |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2519 int c, charset, c1, c2; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2520 |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2521 src_base = src; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2522 ONE_MORE_CHAR (c); |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2523 |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2524 /* 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
|
2525 if (SINGLE_BYTE_CHAR_P (c)) |
17052 | 2526 { |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2527 switch (c) |
17052 | 2528 { |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2529 case '\r': |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2530 if (!coding->mode & CODING_MODE_SELECTIVE_DISPLAY) |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2531 { |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2532 EMIT_ONE_BYTE (c); |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2533 break; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2534 } |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2535 c = '\n'; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2536 case '\n': |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2537 if (coding->eol_type == CODING_EOL_CRLF) |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2538 { |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2539 EMIT_TWO_BYTES ('\r', c); |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2540 break; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2541 } |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2542 else if (coding->eol_type == CODING_EOL_CR) |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2543 c = '\r'; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2544 default: |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2545 EMIT_ONE_BYTE (c); |
17052 | 2546 } |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2547 } |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2548 else |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2549 { |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2550 SPLIT_CHAR (c, charset, c1, c2); |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2551 if (sjis_p) |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2552 { |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2553 if (charset == charset_jisx0208 |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2554 || charset == charset_jisx0208_1978) |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2555 { |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2556 ENCODE_SJIS (c1, c2, c1, c2); |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2557 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
|
2558 } |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2559 else if (charset == charset_latin_jisx0201) |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2560 EMIT_ONE_BYTE (c1); |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2561 else |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2562 /* There's no way other than producing the internal |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2563 codes as is. */ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2564 EMIT_BYTES (src_base, src); |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2565 } |
17052 | 2566 else |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2567 { |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2568 if (charset == charset_big5_1 || charset == charset_big5_2) |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2569 { |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2570 ENCODE_BIG5 (charset, c1, c2, c1, c2); |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2571 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
|
2572 } |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2573 else |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2574 /* There's no way other than producing the internal |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2575 codes as is. */ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2576 EMIT_BYTES (src_base, src); |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2577 } |
17052 | 2578 } |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2579 coding->consumed_char++; |
17052 | 2580 } |
2581 | |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2582 label_end_of_loop: |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2583 coding->consumed = src_base - source; |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
2584 coding->produced = coding->produced_char = dst - destination; |
17052 | 2585 } |
2586 | |
2587 | |
22874
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
2588 /*** 5. CCL handlers ***/ |
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
2589 |
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
2590 /* See the above "GENERAL NOTES on `detect_coding_XXX ()' functions". |
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
2591 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
|
2592 encoder/decoder are written in CCL program. If it is, return |
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
2593 CODING_CATEGORY_MASK_CCL, else return 0. */ |
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
2594 |
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
2595 int |
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
2596 detect_coding_ccl (src, src_end) |
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
2597 unsigned char *src, *src_end; |
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
2598 { |
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
2599 unsigned char *valid; |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2600 int c; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2601 /* Dummy for ONE_MORE_BYTE. */ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2602 struct coding_system dummy_coding; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2603 struct coding_system *coding = &dummy_coding; |
22874
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
2604 |
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
2605 /* No coding system is assigned to coding-category-ccl. */ |
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
2606 if (!coding_system_table[CODING_CATEGORY_IDX_CCL]) |
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
2607 return 0; |
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
2608 |
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
2609 valid = coding_system_table[CODING_CATEGORY_IDX_CCL]->spec.ccl.valid_codes; |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2610 while (1) |
22874
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
2611 { |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2612 ONE_MORE_BYTE (c); |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2613 if (! valid[c]) |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2614 return 0; |
22874
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
2615 } |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2616 label_end_of_loop: |
22874
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
2617 return CODING_CATEGORY_MASK_CCL; |
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
2618 } |
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
2619 |
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
2620 |
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
2621 /*** 6. End-of-line handlers ***/ |
17052 | 2622 |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2623 /* 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
|
2624 |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2625 static void |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
2626 decode_eol (coding, source, destination, src_bytes, dst_bytes) |
17052 | 2627 struct coding_system *coding; |
2628 unsigned char *source, *destination; | |
2629 int src_bytes, dst_bytes; | |
2630 { | |
2631 unsigned char *src = source; | |
2632 unsigned char *dst = destination; | |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2633 unsigned char *src_end = src + src_bytes; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2634 unsigned char *dst_end = dst + dst_bytes; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2635 Lisp_Object translation_table; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2636 /* SRC_BASE remembers the start position in source in each loop. |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2637 The loop will be exited when there's not enough source code |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2638 (within macro ONE_MORE_BYTE), or when there's not enough |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2639 destination area to produce a character (within macro |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2640 EMIT_CHAR). */ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2641 unsigned char *src_base; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2642 int c; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2643 |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2644 translation_table = Qnil; |
17052 | 2645 switch (coding->eol_type) |
2646 { | |
2647 case CODING_EOL_CRLF: | |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2648 while (1) |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2649 { |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2650 src_base = src; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2651 ONE_MORE_BYTE (c); |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2652 if (c == '\r') |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2653 { |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2654 ONE_MORE_BYTE (c); |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2655 if (c != '\n') |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2656 { |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2657 if (coding->mode & CODING_MODE_INHIBIT_INCONSISTENT_EOL) |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2658 { |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2659 coding->result = CODING_FINISH_INCONSISTENT_EOL; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2660 goto label_end_of_loop; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2661 } |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2662 src--; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2663 c = '\r'; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2664 } |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2665 } |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2666 else if (c == '\n' |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2667 && (coding->mode & CODING_MODE_INHIBIT_INCONSISTENT_EOL)) |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2668 { |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2669 coding->result = CODING_FINISH_INCONSISTENT_EOL; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2670 goto label_end_of_loop; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2671 } |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2672 EMIT_CHAR (c); |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2673 } |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
2674 break; |
17052 | 2675 |
2676 case CODING_EOL_CR: | |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2677 while (1) |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
2678 { |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2679 src_base = src; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2680 ONE_MORE_BYTE (c); |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2681 if (c == '\n') |
20931
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
2682 { |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2683 if (coding->mode & CODING_MODE_INHIBIT_INCONSISTENT_EOL) |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2684 { |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2685 coding->result = CODING_FINISH_INCONSISTENT_EOL; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2686 goto label_end_of_loop; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2687 } |
20931
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
2688 } |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2689 else if (c == '\r') |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2690 c = '\n'; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2691 EMIT_CHAR (c); |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
2692 } |
17052 | 2693 break; |
2694 | |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2695 default: /* no need for EOL handling */ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2696 while (1) |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
2697 { |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2698 src_base = src; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2699 ONE_MORE_BYTE (c); |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2700 EMIT_CHAR (c); |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
2701 } |
17052 | 2702 } |
2703 | |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2704 label_end_of_loop: |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2705 coding->consumed = coding->consumed_char = src_base - source; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2706 coding->produced = dst - destination; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2707 return; |
17052 | 2708 } |
2709 | |
2710 /* See "GENERAL NOTES about `encode_coding_XXX ()' functions". Encode | |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2711 format of end-of-line according to `coding->eol_type'. It also |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2712 convert multibyte form 8-bit characers to unibyte if |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2713 CODING->src_multibyte is nonzero. If `coding->mode & |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2714 CODING_MODE_SELECTIVE_DISPLAY' is nonzero, code '\r' in source text |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2715 also means end-of-line. */ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2716 |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2717 static void |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
2718 encode_eol (coding, source, destination, src_bytes, dst_bytes) |
17052 | 2719 struct coding_system *coding; |
2720 unsigned char *source, *destination; | |
2721 int src_bytes, dst_bytes; | |
2722 { | |
2723 unsigned char *src = source; | |
2724 unsigned char *dst = destination; | |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2725 unsigned char *src_end = src + src_bytes; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2726 unsigned char *dst_end = dst + dst_bytes; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2727 Lisp_Object translation_table; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2728 /* SRC_BASE remembers the start position in source in each loop. |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2729 The loop will be exited when there's not enough source text to |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2730 analyze multi-byte codes (within macro ONE_MORE_CHAR), or when |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2731 there's not enough destination area to produce encoded codes |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2732 (within macro EMIT_BYTES). */ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2733 unsigned char *src_base; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2734 int c; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2735 int selective_display = coding->mode & CODING_MODE_SELECTIVE_DISPLAY; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2736 |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2737 translation_table = Qnil; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2738 if (coding->src_multibyte |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2739 && *(src_end - 1) == LEADING_CODE_8_BIT_CONTROL) |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2740 { |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2741 src_end--; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2742 src_bytes--; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2743 coding->result = CODING_FINISH_INSUFFICIENT_SRC; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2744 } |
20931
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
2745 |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
2746 if (coding->eol_type == CODING_EOL_CRLF) |
17052 | 2747 { |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2748 while (src < src_end) |
17052 | 2749 { |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2750 src_base = src; |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
2751 c = *src++; |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2752 if (c >= 0x20) |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2753 EMIT_ONE_BYTE (c); |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2754 else if (c == '\n' || (c == '\r' && selective_display)) |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2755 EMIT_TWO_BYTES ('\r', '\n'); |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
2756 else |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2757 EMIT_ONE_BYTE (c); |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
2758 } |
29093
176708661b08
(encode_eol): Fix a bug of DOS style EOL encoding.
Kenichi Handa <handa@m17n.org>
parents:
29005
diff
changeset
|
2759 src_base = src; |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2760 label_end_of_loop: |
29182
1d1c27067af4
(encode_eol): Add null statement after label.
Dave Love <fx@gnu.org>
parents:
29172
diff
changeset
|
2761 ; |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
2762 } |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
2763 else |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
2764 { |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2765 if (src_bytes <= dst_bytes) |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
2766 { |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2767 safe_bcopy (src, dst, src_bytes); |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2768 src_base = src_end; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2769 dst += src_bytes; |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
2770 } |
20931
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
2771 else |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
2772 { |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2773 if (coding->src_multibyte |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2774 && *(src + dst_bytes - 1) == LEADING_CODE_8_BIT_CONTROL) |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2775 dst_bytes--; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2776 safe_bcopy (src, dst, dst_bytes); |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2777 src_base = src + dst_bytes; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2778 dst = destination + dst_bytes; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2779 coding->result = CODING_FINISH_INSUFFICIENT_DST; |
17052 | 2780 } |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2781 if (coding->eol_type == CODING_EOL_CR) |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2782 { |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2783 for (src = destination; src < dst; src++) |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2784 if (*src == '\n') *src = '\r'; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2785 } |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2786 else if (selective_display) |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2787 { |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2788 for (src = destination; src < dst; src++) |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2789 if (*src == '\r') *src = '\n'; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2790 } |
17052 | 2791 } |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2792 if (coding->src_multibyte) |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2793 dst = destination + str_as_unibyte (destination, dst - destination); |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2794 |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2795 coding->consumed = src_base - source; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2796 coding->produced = dst - destination; |
17052 | 2797 } |
2798 | |
2799 | |
22874
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
2800 /*** 7. C library functions ***/ |
17052 | 2801 |
2802 /* In Emacs Lisp, coding system is represented by a Lisp symbol which | |
2803 has a property `coding-system'. The value of this property is a | |
2804 vector of length 5 (called as coding-vector). Among elements of | |
2805 this vector, the first (element[0]) and the fifth (element[4]) | |
2806 carry important information for decoding/encoding. Before | |
2807 decoding/encoding, this information should be set in fields of a | |
2808 structure of type `coding_system'. | |
2809 | |
2810 A value of property `coding-system' can be a symbol of another | |
2811 subsidiary coding-system. In that case, Emacs gets coding-vector | |
2812 from that symbol. | |
2813 | |
2814 `element[0]' contains information to be set in `coding->type'. The | |
2815 value and its meaning is as follows: | |
2816 | |
17835
f36ffb6f1208
Name change through the code:
Kenichi Handa <handa@m17n.org>
parents:
17725
diff
changeset
|
2817 0 -- coding_type_emacs_mule |
f36ffb6f1208
Name change through the code:
Kenichi Handa <handa@m17n.org>
parents:
17725
diff
changeset
|
2818 1 -- coding_type_sjis |
f36ffb6f1208
Name change through the code:
Kenichi Handa <handa@m17n.org>
parents:
17725
diff
changeset
|
2819 2 -- coding_type_iso2022 |
f36ffb6f1208
Name change through the code:
Kenichi Handa <handa@m17n.org>
parents:
17725
diff
changeset
|
2820 3 -- coding_type_big5 |
f36ffb6f1208
Name change through the code:
Kenichi Handa <handa@m17n.org>
parents:
17725
diff
changeset
|
2821 4 -- coding_type_ccl encoder/decoder written in CCL |
f36ffb6f1208
Name change through the code:
Kenichi Handa <handa@m17n.org>
parents:
17725
diff
changeset
|
2822 nil -- coding_type_no_conversion |
f36ffb6f1208
Name change through the code:
Kenichi Handa <handa@m17n.org>
parents:
17725
diff
changeset
|
2823 t -- coding_type_undecided (automatic conversion on decoding, |
f36ffb6f1208
Name change through the code:
Kenichi Handa <handa@m17n.org>
parents:
17725
diff
changeset
|
2824 no-conversion on encoding) |
17052 | 2825 |
2826 `element[4]' contains information to be set in `coding->flags' and | |
2827 `coding->spec'. The meaning varies by `coding->type'. | |
2828 | |
2829 If `coding->type' is `coding_type_iso2022', element[4] is a vector | |
2830 of length 32 (of which the first 13 sub-elements are used now). | |
2831 Meanings of these sub-elements are: | |
2832 | |
2833 sub-element[N] where N is 0 through 3: to be set in `coding->spec.iso2022' | |
2834 If the value is an integer of valid charset, the charset is | |
2835 assumed to be designated to graphic register N initially. | |
2836 | |
2837 If the value is minus, it is a minus value of charset which | |
2838 reserves graphic register N, which means that the charset is | |
2839 not designated initially but should be designated to graphic | |
2840 register N just before encoding a character in that charset. | |
2841 | |
2842 If the value is nil, graphic register N is never used on | |
2843 encoding. | |
2844 | |
2845 sub-element[N] where N is 4 through 11: to be set in `coding->flags' | |
2846 Each value takes t or nil. See the section ISO2022 of | |
2847 `coding.h' for more information. | |
2848 | |
2849 If `coding->type' is `coding_type_big5', element[4] is t to denote | |
2850 BIG5-ETen or nil to denote BIG5-HKU. | |
2851 | |
2852 If `coding->type' takes the other value, element[4] is ignored. | |
2853 | |
2854 Emacs Lisp's coding system also carries information about format of | |
2855 end-of-line in a value of property `eol-type'. If the value is | |
2856 integer, 0 means CODING_EOL_LF, 1 means CODING_EOL_CRLF, and 2 | |
2857 means CODING_EOL_CR. If it is not integer, it should be a vector | |
2858 of subsidiary coding systems of which property `eol-type' has one | |
2859 of above values. | |
2860 | |
2861 */ | |
2862 | |
2863 /* Extract information for decoding/encoding from CODING_SYSTEM_SYMBOL | |
2864 and set it in CODING. If CODING_SYSTEM_SYMBOL is invalid, CODING | |
2865 is setup so that no conversion is necessary and return -1, else | |
2866 return 0. */ | |
2867 | |
2868 int | |
17119
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
2869 setup_coding_system (coding_system, coding) |
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
2870 Lisp_Object coding_system; |
17052 | 2871 struct coding_system *coding; |
2872 { | |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
2873 Lisp_Object coding_spec, coding_type, eol_type, plist; |
20105
c017642863c2
(Qcoding_system_spec): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
19824
diff
changeset
|
2874 Lisp_Object val; |
20150
402b6e5f4b58
(encode_designation_at_bol): Fix bug of finding graphic
Kenichi Handa <handa@m17n.org>
parents:
20105
diff
changeset
|
2875 int i; |
17052 | 2876 |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
2877 /* Initialize some fields required for all kinds of coding systems. */ |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
2878 coding->symbol = coding_system; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
2879 coding->common_flags = 0; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
2880 coding->mode = 0; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
2881 coding->heading_ascii = -1; |
17052 | 2882 coding->post_read_conversion = coding->pre_write_conversion = Qnil; |
26847 | 2883 coding->composing = COMPOSITION_DISABLED; |
2884 coding->cmp_data = NULL; | |
24460
be35d27a4bfb
(setup_coding_system): Check for CODING_SYSTEM = nil.
Kenichi Handa <handa@m17n.org>
parents:
24425
diff
changeset
|
2885 |
be35d27a4bfb
(setup_coding_system): Check for CODING_SYSTEM = nil.
Kenichi Handa <handa@m17n.org>
parents:
24425
diff
changeset
|
2886 if (NILP (coding_system)) |
be35d27a4bfb
(setup_coding_system): Check for CODING_SYSTEM = nil.
Kenichi Handa <handa@m17n.org>
parents:
24425
diff
changeset
|
2887 goto label_invalid_coding_system; |
be35d27a4bfb
(setup_coding_system): Check for CODING_SYSTEM = nil.
Kenichi Handa <handa@m17n.org>
parents:
24425
diff
changeset
|
2888 |
20105
c017642863c2
(Qcoding_system_spec): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
19824
diff
changeset
|
2889 coding_spec = Fget (coding_system, Qcoding_system); |
24460
be35d27a4bfb
(setup_coding_system): Check for CODING_SYSTEM = nil.
Kenichi Handa <handa@m17n.org>
parents:
24425
diff
changeset
|
2890 |
20105
c017642863c2
(Qcoding_system_spec): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
19824
diff
changeset
|
2891 if (!VECTORP (coding_spec) |
c017642863c2
(Qcoding_system_spec): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
19824
diff
changeset
|
2892 || XVECTOR (coding_spec)->size != 5 |
c017642863c2
(Qcoding_system_spec): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
19824
diff
changeset
|
2893 || !CONSP (XVECTOR (coding_spec)->contents[3])) |
17052 | 2894 goto label_invalid_coding_system; |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
2895 |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
2896 eol_type = inhibit_eol_conversion ? Qnil : Fget (coding_system, Qeol_type); |
17052 | 2897 if (VECTORP (eol_type)) |
20227
71008f909642
(setup_coding_system): Initialize common_flags member
Kenichi Handa <handa@m17n.org>
parents:
20150
diff
changeset
|
2898 { |
71008f909642
(setup_coding_system): Initialize common_flags member
Kenichi Handa <handa@m17n.org>
parents:
20150
diff
changeset
|
2899 coding->eol_type = CODING_EOL_UNDECIDED; |
71008f909642
(setup_coding_system): Initialize common_flags member
Kenichi Handa <handa@m17n.org>
parents:
20150
diff
changeset
|
2900 coding->common_flags = CODING_REQUIRE_DETECTION_MASK; |
71008f909642
(setup_coding_system): Initialize common_flags member
Kenichi Handa <handa@m17n.org>
parents:
20150
diff
changeset
|
2901 } |
17052 | 2902 else if (XFASTINT (eol_type) == 1) |
20227
71008f909642
(setup_coding_system): Initialize common_flags member
Kenichi Handa <handa@m17n.org>
parents:
20150
diff
changeset
|
2903 { |
71008f909642
(setup_coding_system): Initialize common_flags member
Kenichi Handa <handa@m17n.org>
parents:
20150
diff
changeset
|
2904 coding->eol_type = CODING_EOL_CRLF; |
71008f909642
(setup_coding_system): Initialize common_flags member
Kenichi Handa <handa@m17n.org>
parents:
20150
diff
changeset
|
2905 coding->common_flags |
71008f909642
(setup_coding_system): Initialize common_flags member
Kenichi Handa <handa@m17n.org>
parents:
20150
diff
changeset
|
2906 = CODING_REQUIRE_DECODING_MASK | CODING_REQUIRE_ENCODING_MASK; |
71008f909642
(setup_coding_system): Initialize common_flags member
Kenichi Handa <handa@m17n.org>
parents:
20150
diff
changeset
|
2907 } |
17052 | 2908 else if (XFASTINT (eol_type) == 2) |
20227
71008f909642
(setup_coding_system): Initialize common_flags member
Kenichi Handa <handa@m17n.org>
parents:
20150
diff
changeset
|
2909 { |
71008f909642
(setup_coding_system): Initialize common_flags member
Kenichi Handa <handa@m17n.org>
parents:
20150
diff
changeset
|
2910 coding->eol_type = CODING_EOL_CR; |
71008f909642
(setup_coding_system): Initialize common_flags member
Kenichi Handa <handa@m17n.org>
parents:
20150
diff
changeset
|
2911 coding->common_flags |
71008f909642
(setup_coding_system): Initialize common_flags member
Kenichi Handa <handa@m17n.org>
parents:
20150
diff
changeset
|
2912 = CODING_REQUIRE_DECODING_MASK | CODING_REQUIRE_ENCODING_MASK; |
71008f909642
(setup_coding_system): Initialize common_flags member
Kenichi Handa <handa@m17n.org>
parents:
20150
diff
changeset
|
2913 } |
17052 | 2914 else |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
2915 coding->eol_type = CODING_EOL_LF; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
2916 |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
2917 coding_type = XVECTOR (coding_spec)->contents[0]; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
2918 /* Try short cut. */ |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
2919 if (SYMBOLP (coding_type)) |
20227
71008f909642
(setup_coding_system): Initialize common_flags member
Kenichi Handa <handa@m17n.org>
parents:
20150
diff
changeset
|
2920 { |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
2921 if (EQ (coding_type, Qt)) |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
2922 { |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
2923 coding->type = coding_type_undecided; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
2924 coding->common_flags |= CODING_REQUIRE_DETECTION_MASK; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
2925 } |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
2926 else |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
2927 coding->type = coding_type_no_conversion; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
2928 return 0; |
20227
71008f909642
(setup_coding_system): Initialize common_flags member
Kenichi Handa <handa@m17n.org>
parents:
20150
diff
changeset
|
2929 } |
17052 | 2930 |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
2931 /* Get values of coding system properties: |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
2932 `post-read-conversion', `pre-write-conversion', |
22186
fc4aaf1b1772
Change term "character translation table" to "translation table".
Kenichi Handa <handa@m17n.org>
parents:
22166
diff
changeset
|
2933 `translation-table-for-decode', `translation-table-for-encode'. */ |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
2934 plist = XVECTOR (coding_spec)->contents[3]; |
26067
f54ca66e2571
(code_convert_string): Add record_unwind_protect to
Kenichi Handa <handa@m17n.org>
parents:
25860
diff
changeset
|
2935 /* Pre & post conversion functions should be disabled if |
f54ca66e2571
(code_convert_string): Add record_unwind_protect to
Kenichi Handa <handa@m17n.org>
parents:
25860
diff
changeset
|
2936 inhibit_eol_conversion is nozero. This is the case that a code |
f54ca66e2571
(code_convert_string): Add record_unwind_protect to
Kenichi Handa <handa@m17n.org>
parents:
25860
diff
changeset
|
2937 conversion function is called while those functions are running. */ |
f54ca66e2571
(code_convert_string): Add record_unwind_protect to
Kenichi Handa <handa@m17n.org>
parents:
25860
diff
changeset
|
2938 if (! inhibit_pre_post_conversion) |
f54ca66e2571
(code_convert_string): Add record_unwind_protect to
Kenichi Handa <handa@m17n.org>
parents:
25860
diff
changeset
|
2939 { |
f54ca66e2571
(code_convert_string): Add record_unwind_protect to
Kenichi Handa <handa@m17n.org>
parents:
25860
diff
changeset
|
2940 coding->post_read_conversion = Fplist_get (plist, Qpost_read_conversion); |
f54ca66e2571
(code_convert_string): Add record_unwind_protect to
Kenichi Handa <handa@m17n.org>
parents:
25860
diff
changeset
|
2941 coding->pre_write_conversion = Fplist_get (plist, Qpre_write_conversion); |
f54ca66e2571
(code_convert_string): Add record_unwind_protect to
Kenichi Handa <handa@m17n.org>
parents:
25860
diff
changeset
|
2942 } |
22186
fc4aaf1b1772
Change term "character translation table" to "translation table".
Kenichi Handa <handa@m17n.org>
parents:
22166
diff
changeset
|
2943 val = Fplist_get (plist, Qtranslation_table_for_decode); |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
2944 if (SYMBOLP (val)) |
22186
fc4aaf1b1772
Change term "character translation table" to "translation table".
Kenichi Handa <handa@m17n.org>
parents:
22166
diff
changeset
|
2945 val = Fget (val, Qtranslation_table_for_decode); |
fc4aaf1b1772
Change term "character translation table" to "translation table".
Kenichi Handa <handa@m17n.org>
parents:
22166
diff
changeset
|
2946 coding->translation_table_for_decode = CHAR_TABLE_P (val) ? val : Qnil; |
fc4aaf1b1772
Change term "character translation table" to "translation table".
Kenichi Handa <handa@m17n.org>
parents:
22166
diff
changeset
|
2947 val = Fplist_get (plist, Qtranslation_table_for_encode); |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
2948 if (SYMBOLP (val)) |
22186
fc4aaf1b1772
Change term "character translation table" to "translation table".
Kenichi Handa <handa@m17n.org>
parents:
22166
diff
changeset
|
2949 val = Fget (val, Qtranslation_table_for_encode); |
fc4aaf1b1772
Change term "character translation table" to "translation table".
Kenichi Handa <handa@m17n.org>
parents:
22166
diff
changeset
|
2950 coding->translation_table_for_encode = CHAR_TABLE_P (val) ? val : Qnil; |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
2951 val = Fplist_get (plist, Qcoding_category); |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
2952 if (!NILP (val)) |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
2953 { |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
2954 val = Fget (val, Qcoding_category_index); |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
2955 if (INTEGERP (val)) |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
2956 coding->category_idx = XINT (val); |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
2957 else |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
2958 goto label_invalid_coding_system; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
2959 } |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
2960 else |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
2961 goto label_invalid_coding_system; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
2962 |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
2963 val = Fplist_get (plist, Qsafe_charsets); |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
2964 if (EQ (val, Qt)) |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
2965 { |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
2966 for (i = 0; i <= MAX_CHARSET; i++) |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
2967 coding->safe_charsets[i] = 1; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
2968 } |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
2969 else |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
2970 { |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
2971 bzero (coding->safe_charsets, MAX_CHARSET + 1); |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
2972 while (CONSP (val)) |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
2973 { |
25662
0a7261c1d487
Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25370
diff
changeset
|
2974 if ((i = get_charset_id (XCAR (val))) >= 0) |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
2975 coding->safe_charsets[i] = 1; |
25662
0a7261c1d487
Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25370
diff
changeset
|
2976 val = XCDR (val); |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
2977 } |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
2978 } |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
2979 |
26847 | 2980 /* If the coding system has non-nil `composition' property, enable |
2981 composition handling. */ | |
2982 val = Fplist_get (plist, Qcomposition); | |
2983 if (!NILP (val)) | |
2984 coding->composing = COMPOSITION_NO; | |
2985 | |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
2986 switch (XFASTINT (coding_type)) |
17052 | 2987 { |
2988 case 0: | |
17835
f36ffb6f1208
Name change through the code:
Kenichi Handa <handa@m17n.org>
parents:
17725
diff
changeset
|
2989 coding->type = coding_type_emacs_mule; |
20227
71008f909642
(setup_coding_system): Initialize common_flags member
Kenichi Handa <handa@m17n.org>
parents:
20150
diff
changeset
|
2990 if (!NILP (coding->post_read_conversion)) |
71008f909642
(setup_coding_system): Initialize common_flags member
Kenichi Handa <handa@m17n.org>
parents:
20150
diff
changeset
|
2991 coding->common_flags |= CODING_REQUIRE_DECODING_MASK; |
71008f909642
(setup_coding_system): Initialize common_flags member
Kenichi Handa <handa@m17n.org>
parents:
20150
diff
changeset
|
2992 if (!NILP (coding->pre_write_conversion)) |
71008f909642
(setup_coding_system): Initialize common_flags member
Kenichi Handa <handa@m17n.org>
parents:
20150
diff
changeset
|
2993 coding->common_flags |= CODING_REQUIRE_ENCODING_MASK; |
17052 | 2994 break; |
2995 | |
2996 case 1: | |
2997 coding->type = coding_type_sjis; | |
20227
71008f909642
(setup_coding_system): Initialize common_flags member
Kenichi Handa <handa@m17n.org>
parents:
20150
diff
changeset
|
2998 coding->common_flags |
71008f909642
(setup_coding_system): Initialize common_flags member
Kenichi Handa <handa@m17n.org>
parents:
20150
diff
changeset
|
2999 |= CODING_REQUIRE_DECODING_MASK | CODING_REQUIRE_ENCODING_MASK; |
17052 | 3000 break; |
3001 | |
3002 case 2: | |
3003 coding->type = coding_type_iso2022; | |
20227
71008f909642
(setup_coding_system): Initialize common_flags member
Kenichi Handa <handa@m17n.org>
parents:
20150
diff
changeset
|
3004 coding->common_flags |
71008f909642
(setup_coding_system): Initialize common_flags member
Kenichi Handa <handa@m17n.org>
parents:
20150
diff
changeset
|
3005 |= CODING_REQUIRE_DECODING_MASK | CODING_REQUIRE_ENCODING_MASK; |
17052 | 3006 { |
20150
402b6e5f4b58
(encode_designation_at_bol): Fix bug of finding graphic
Kenichi Handa <handa@m17n.org>
parents:
20105
diff
changeset
|
3007 Lisp_Object val, temp; |
17052 | 3008 Lisp_Object *flags; |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3009 int i, charset, reg_bits = 0; |
17052 | 3010 |
20105
c017642863c2
(Qcoding_system_spec): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
19824
diff
changeset
|
3011 val = XVECTOR (coding_spec)->contents[4]; |
19747
bed06df9cbc5
(setup_coding_system, Ffind_operation_coding_system)
Richard M. Stallman <rms@gnu.org>
parents:
19743
diff
changeset
|
3012 |
17052 | 3013 if (!VECTORP (val) || XVECTOR (val)->size != 32) |
3014 goto label_invalid_coding_system; | |
3015 | |
3016 flags = XVECTOR (val)->contents; | |
3017 coding->flags | |
3018 = ((NILP (flags[4]) ? 0 : CODING_FLAG_ISO_SHORT_FORM) | |
3019 | (NILP (flags[5]) ? 0 : CODING_FLAG_ISO_RESET_AT_EOL) | |
3020 | (NILP (flags[6]) ? 0 : CODING_FLAG_ISO_RESET_AT_CNTL) | |
3021 | (NILP (flags[7]) ? 0 : CODING_FLAG_ISO_SEVEN_BITS) | |
3022 | (NILP (flags[8]) ? 0 : CODING_FLAG_ISO_LOCKING_SHIFT) | |
3023 | (NILP (flags[9]) ? 0 : CODING_FLAG_ISO_SINGLE_SHIFT) | |
3024 | (NILP (flags[10]) ? 0 : CODING_FLAG_ISO_USE_ROMAN) | |
3025 | (NILP (flags[11]) ? 0 : CODING_FLAG_ISO_USE_OLDJIS) | |
17119
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
3026 | (NILP (flags[12]) ? 0 : CODING_FLAG_ISO_NO_DIRECTION) |
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
3027 | (NILP (flags[13]) ? 0 : CODING_FLAG_ISO_INIT_AT_BOL) |
19280
e755044718ee
(ENCODE_ISO_CHARACTER_DIMENSION1): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
19193
diff
changeset
|
3028 | (NILP (flags[14]) ? 0 : CODING_FLAG_ISO_DESIGNATE_AT_BOL) |
e755044718ee
(ENCODE_ISO_CHARACTER_DIMENSION1): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
19193
diff
changeset
|
3029 | (NILP (flags[15]) ? 0 : CODING_FLAG_ISO_SAFE) |
19365
d9374f5ebd3a
(CODING_FLAG_ISO_LATIN_EXTRA): New macro.
Kenichi Handa <handa@m17n.org>
parents:
19285
diff
changeset
|
3030 | (NILP (flags[16]) ? 0 : CODING_FLAG_ISO_LATIN_EXTRA) |
19280
e755044718ee
(ENCODE_ISO_CHARACTER_DIMENSION1): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
19193
diff
changeset
|
3031 ); |
17052 | 3032 |
3033 /* Invoke graphic register 0 to plane 0. */ | |
3034 CODING_SPEC_ISO_INVOCATION (coding, 0) = 0; | |
3035 /* Invoke graphic register 1 to plane 1 if we can use full 8-bit. */ | |
3036 CODING_SPEC_ISO_INVOCATION (coding, 1) | |
3037 = (coding->flags & CODING_FLAG_ISO_SEVEN_BITS ? -1 : 1); | |
3038 /* Not single shifting at first. */ | |
19285
af3d00fde172
(Fset_terminal_coding_system_internal): Set
Kenichi Handa <handa@m17n.org>
parents:
19280
diff
changeset
|
3039 CODING_SPEC_ISO_SINGLE_SHIFTING (coding) = 0; |
17119
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
3040 /* Beginning of buffer should also be regarded as bol. */ |
19285
af3d00fde172
(Fset_terminal_coding_system_internal): Set
Kenichi Handa <handa@m17n.org>
parents:
19280
diff
changeset
|
3041 CODING_SPEC_ISO_BOL (coding) = 1; |
17052 | 3042 |
20150
402b6e5f4b58
(encode_designation_at_bol): Fix bug of finding graphic
Kenichi Handa <handa@m17n.org>
parents:
20105
diff
changeset
|
3043 for (charset = 0; charset <= MAX_CHARSET; charset++) |
402b6e5f4b58
(encode_designation_at_bol): Fix bug of finding graphic
Kenichi Handa <handa@m17n.org>
parents:
20105
diff
changeset
|
3044 CODING_SPEC_ISO_REVISION_NUMBER (coding, charset) = 255; |
402b6e5f4b58
(encode_designation_at_bol): Fix bug of finding graphic
Kenichi Handa <handa@m17n.org>
parents:
20105
diff
changeset
|
3045 val = Vcharset_revision_alist; |
402b6e5f4b58
(encode_designation_at_bol): Fix bug of finding graphic
Kenichi Handa <handa@m17n.org>
parents:
20105
diff
changeset
|
3046 while (CONSP (val)) |
402b6e5f4b58
(encode_designation_at_bol): Fix bug of finding graphic
Kenichi Handa <handa@m17n.org>
parents:
20105
diff
changeset
|
3047 { |
25662
0a7261c1d487
Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25370
diff
changeset
|
3048 charset = get_charset_id (Fcar_safe (XCAR (val))); |
20150
402b6e5f4b58
(encode_designation_at_bol): Fix bug of finding graphic
Kenichi Handa <handa@m17n.org>
parents:
20105
diff
changeset
|
3049 if (charset >= 0 |
25662
0a7261c1d487
Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25370
diff
changeset
|
3050 && (temp = Fcdr_safe (XCAR (val)), INTEGERP (temp)) |
20150
402b6e5f4b58
(encode_designation_at_bol): Fix bug of finding graphic
Kenichi Handa <handa@m17n.org>
parents:
20105
diff
changeset
|
3051 && (i = XINT (temp), (i >= 0 && (i + '@') < 128))) |
402b6e5f4b58
(encode_designation_at_bol): Fix bug of finding graphic
Kenichi Handa <handa@m17n.org>
parents:
20105
diff
changeset
|
3052 CODING_SPEC_ISO_REVISION_NUMBER (coding, charset) = i; |
25662
0a7261c1d487
Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25370
diff
changeset
|
3053 val = XCDR (val); |
20150
402b6e5f4b58
(encode_designation_at_bol): Fix bug of finding graphic
Kenichi Handa <handa@m17n.org>
parents:
20105
diff
changeset
|
3054 } |
402b6e5f4b58
(encode_designation_at_bol): Fix bug of finding graphic
Kenichi Handa <handa@m17n.org>
parents:
20105
diff
changeset
|
3055 |
17052 | 3056 /* Checks FLAGS[REG] (REG = 0, 1, 2 3) and decide designations. |
3057 FLAGS[REG] can be one of below: | |
3058 integer CHARSET: CHARSET occupies register I, | |
3059 t: designate nothing to REG initially, but can be used | |
3060 by any charsets, | |
3061 list of integer, nil, or t: designate the first | |
3062 element (if integer) to REG initially, the remaining | |
3063 elements (if integer) is designated to REG on request, | |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3064 if an element is t, REG can be used by any charsets, |
17052 | 3065 nil: REG is never used. */ |
17190
6637001cdb4b
Adjusted for the change of MAX_CHARSET.
Kenichi Handa <handa@m17n.org>
parents:
17137
diff
changeset
|
3066 for (charset = 0; charset <= MAX_CHARSET; charset++) |
18002
a14261786239
(encode_invocation_designation): Use macro
Kenichi Handa <handa@m17n.org>
parents:
17835
diff
changeset
|
3067 CODING_SPEC_ISO_REQUESTED_DESIGNATION (coding, charset) |
a14261786239
(encode_invocation_designation): Use macro
Kenichi Handa <handa@m17n.org>
parents:
17835
diff
changeset
|
3068 = CODING_SPEC_ISO_NO_REQUESTED_DESIGNATION; |
17052 | 3069 for (i = 0; i < 4; i++) |
3070 { | |
3071 if (INTEGERP (flags[i]) | |
17119
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
3072 && (charset = XINT (flags[i]), CHARSET_VALID_P (charset)) |
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
3073 || (charset = get_charset_id (flags[i])) >= 0) |
17052 | 3074 { |
3075 CODING_SPEC_ISO_INITIAL_DESIGNATION (coding, i) = charset; | |
3076 CODING_SPEC_ISO_REQUESTED_DESIGNATION (coding, charset) = i; | |
3077 } | |
3078 else if (EQ (flags[i], Qt)) | |
3079 { | |
3080 CODING_SPEC_ISO_INITIAL_DESIGNATION (coding, i) = -1; | |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3081 reg_bits |= 1 << i; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3082 coding->flags |= CODING_FLAG_ISO_DESIGNATION; |
17052 | 3083 } |
3084 else if (CONSP (flags[i])) | |
3085 { | |
22954
928b337d953b
Avoid using initializers for Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents:
22874
diff
changeset
|
3086 Lisp_Object tail; |
928b337d953b
Avoid using initializers for Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents:
22874
diff
changeset
|
3087 tail = flags[i]; |
17052 | 3088 |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3089 coding->flags |= CODING_FLAG_ISO_DESIGNATION; |
25662
0a7261c1d487
Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25370
diff
changeset
|
3090 if (INTEGERP (XCAR (tail)) |
0a7261c1d487
Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25370
diff
changeset
|
3091 && (charset = XINT (XCAR (tail)), |
17119
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
3092 CHARSET_VALID_P (charset)) |
25662
0a7261c1d487
Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25370
diff
changeset
|
3093 || (charset = get_charset_id (XCAR (tail))) >= 0) |
17052 | 3094 { |
3095 CODING_SPEC_ISO_INITIAL_DESIGNATION (coding, i) = charset; | |
3096 CODING_SPEC_ISO_REQUESTED_DESIGNATION (coding, charset) =i; | |
3097 } | |
3098 else | |
3099 CODING_SPEC_ISO_INITIAL_DESIGNATION (coding, i) = -1; | |
25662
0a7261c1d487
Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25370
diff
changeset
|
3100 tail = XCDR (tail); |
17052 | 3101 while (CONSP (tail)) |
3102 { | |
25662
0a7261c1d487
Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25370
diff
changeset
|
3103 if (INTEGERP (XCAR (tail)) |
0a7261c1d487
Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25370
diff
changeset
|
3104 && (charset = XINT (XCAR (tail)), |
17119
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
3105 CHARSET_VALID_P (charset)) |
25662
0a7261c1d487
Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25370
diff
changeset
|
3106 || (charset = get_charset_id (XCAR (tail))) >= 0) |
20150
402b6e5f4b58
(encode_designation_at_bol): Fix bug of finding graphic
Kenichi Handa <handa@m17n.org>
parents:
20105
diff
changeset
|
3107 CODING_SPEC_ISO_REQUESTED_DESIGNATION (coding, charset) |
402b6e5f4b58
(encode_designation_at_bol): Fix bug of finding graphic
Kenichi Handa <handa@m17n.org>
parents:
20105
diff
changeset
|
3108 = i; |
25662
0a7261c1d487
Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25370
diff
changeset
|
3109 else if (EQ (XCAR (tail), Qt)) |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3110 reg_bits |= 1 << i; |
25662
0a7261c1d487
Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25370
diff
changeset
|
3111 tail = XCDR (tail); |
17052 | 3112 } |
3113 } | |
3114 else | |
3115 CODING_SPEC_ISO_INITIAL_DESIGNATION (coding, i) = -1; | |
3116 | |
3117 CODING_SPEC_ISO_DESIGNATION (coding, i) | |
3118 = CODING_SPEC_ISO_INITIAL_DESIGNATION (coding, i); | |
3119 } | |
3120 | |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3121 if (reg_bits && ! (coding->flags & CODING_FLAG_ISO_LOCKING_SHIFT)) |
17052 | 3122 { |
3123 /* REG 1 can be used only by locking shift in 7-bit env. */ | |
3124 if (coding->flags & CODING_FLAG_ISO_SEVEN_BITS) | |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3125 reg_bits &= ~2; |
17052 | 3126 if (! (coding->flags & CODING_FLAG_ISO_SINGLE_SHIFT)) |
3127 /* Without any shifting, only REG 0 and 1 can be used. */ | |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3128 reg_bits &= 3; |
17052 | 3129 } |
3130 | |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3131 if (reg_bits) |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3132 for (charset = 0; charset <= MAX_CHARSET; charset++) |
19285
af3d00fde172
(Fset_terminal_coding_system_internal): Set
Kenichi Handa <handa@m17n.org>
parents:
19280
diff
changeset
|
3133 { |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3134 if (CHARSET_VALID_P (charset)) |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3135 { |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3136 /* There exist some default graphic registers to be |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3137 used CHARSET. */ |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3138 |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3139 /* We had better avoid designating a charset of |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3140 CHARS96 to REG 0 as far as possible. */ |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3141 if (CHARSET_CHARS (charset) == 96) |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3142 CODING_SPEC_ISO_REQUESTED_DESIGNATION (coding, charset) |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3143 = (reg_bits & 2 |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3144 ? 1 : (reg_bits & 4 ? 2 : (reg_bits & 8 ? 3 : 0))); |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3145 else |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3146 CODING_SPEC_ISO_REQUESTED_DESIGNATION (coding, charset) |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3147 = (reg_bits & 1 |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3148 ? 0 : (reg_bits & 2 ? 1 : (reg_bits & 4 ? 2 : 3))); |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3149 } |
19285
af3d00fde172
(Fset_terminal_coding_system_internal): Set
Kenichi Handa <handa@m17n.org>
parents:
19280
diff
changeset
|
3150 } |
17052 | 3151 } |
20227
71008f909642
(setup_coding_system): Initialize common_flags member
Kenichi Handa <handa@m17n.org>
parents:
20150
diff
changeset
|
3152 coding->common_flags |= CODING_REQUIRE_FLUSHING_MASK; |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3153 coding->spec.iso2022.last_invalid_designation_register = -1; |
17052 | 3154 break; |
3155 | |
3156 case 3: | |
3157 coding->type = coding_type_big5; | |
20227
71008f909642
(setup_coding_system): Initialize common_flags member
Kenichi Handa <handa@m17n.org>
parents:
20150
diff
changeset
|
3158 coding->common_flags |
71008f909642
(setup_coding_system): Initialize common_flags member
Kenichi Handa <handa@m17n.org>
parents:
20150
diff
changeset
|
3159 |= CODING_REQUIRE_DECODING_MASK | CODING_REQUIRE_ENCODING_MASK; |
17052 | 3160 coding->flags |
20105
c017642863c2
(Qcoding_system_spec): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
19824
diff
changeset
|
3161 = (NILP (XVECTOR (coding_spec)->contents[4]) |
17052 | 3162 ? CODING_FLAG_BIG5_HKU |
3163 : CODING_FLAG_BIG5_ETEN); | |
3164 break; | |
3165 | |
3166 case 4: | |
3167 coding->type = coding_type_ccl; | |
20227
71008f909642
(setup_coding_system): Initialize common_flags member
Kenichi Handa <handa@m17n.org>
parents:
20150
diff
changeset
|
3168 coding->common_flags |
71008f909642
(setup_coding_system): Initialize common_flags member
Kenichi Handa <handa@m17n.org>
parents:
20150
diff
changeset
|
3169 |= CODING_REQUIRE_DECODING_MASK | CODING_REQUIRE_ENCODING_MASK; |
17052 | 3170 { |
22954
928b337d953b
Avoid using initializers for Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents:
22874
diff
changeset
|
3171 val = XVECTOR (coding_spec)->contents[4]; |
25067
23910b121ced
(setup_coding_system): Get compiled CCL code by just
Kenichi Handa <handa@m17n.org>
parents:
24870
diff
changeset
|
3172 if (! CONSP (val) |
23910b121ced
(setup_coding_system): Get compiled CCL code by just
Kenichi Handa <handa@m17n.org>
parents:
24870
diff
changeset
|
3173 || setup_ccl_program (&(coding->spec.ccl.decoder), |
25662
0a7261c1d487
Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25370
diff
changeset
|
3174 XCAR (val)) < 0 |
25067
23910b121ced
(setup_coding_system): Get compiled CCL code by just
Kenichi Handa <handa@m17n.org>
parents:
24870
diff
changeset
|
3175 || setup_ccl_program (&(coding->spec.ccl.encoder), |
25662
0a7261c1d487
Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25370
diff
changeset
|
3176 XCDR (val)) < 0) |
17052 | 3177 goto label_invalid_coding_system; |
22874
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
3178 |
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
3179 bzero (coding->spec.ccl.valid_codes, 256); |
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
3180 val = Fplist_get (plist, Qvalid_codes); |
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
3181 if (CONSP (val)) |
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
3182 { |
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
3183 Lisp_Object this; |
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
3184 |
25662
0a7261c1d487
Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25370
diff
changeset
|
3185 for (; CONSP (val); val = XCDR (val)) |
22874
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
3186 { |
25662
0a7261c1d487
Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25370
diff
changeset
|
3187 this = XCAR (val); |
22874
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
3188 if (INTEGERP (this) |
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
3189 && XINT (this) >= 0 && XINT (this) < 256) |
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
3190 coding->spec.ccl.valid_codes[XINT (this)] = 1; |
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
3191 else if (CONSP (this) |
25662
0a7261c1d487
Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25370
diff
changeset
|
3192 && INTEGERP (XCAR (this)) |
0a7261c1d487
Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25370
diff
changeset
|
3193 && INTEGERP (XCDR (this))) |
22874
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
3194 { |
25662
0a7261c1d487
Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25370
diff
changeset
|
3195 int start = XINT (XCAR (this)); |
0a7261c1d487
Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25370
diff
changeset
|
3196 int end = XINT (XCDR (this)); |
22874
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
3197 |
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
3198 if (start >= 0 && start <= end && end < 256) |
23514
7bad909cd6f1
(setup_coding_system): Fix setting up
Kenichi Handa <handa@m17n.org>
parents:
23475
diff
changeset
|
3199 while (start <= end) |
22874
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
3200 coding->spec.ccl.valid_codes[start++] = 1; |
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
3201 } |
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
3202 } |
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
3203 } |
17052 | 3204 } |
20227
71008f909642
(setup_coding_system): Initialize common_flags member
Kenichi Handa <handa@m17n.org>
parents:
20150
diff
changeset
|
3205 coding->common_flags |= CODING_REQUIRE_FLUSHING_MASK; |
17052 | 3206 break; |
3207 | |
19612
783efd6c7c1e
(Qno_conversion, Qundecided): New variables.
Kenichi Handa <handa@m17n.org>
parents:
19546
diff
changeset
|
3208 case 5: |
783efd6c7c1e
(Qno_conversion, Qundecided): New variables.
Kenichi Handa <handa@m17n.org>
parents:
19546
diff
changeset
|
3209 coding->type = coding_type_raw_text; |
783efd6c7c1e
(Qno_conversion, Qundecided): New variables.
Kenichi Handa <handa@m17n.org>
parents:
19546
diff
changeset
|
3210 break; |
783efd6c7c1e
(Qno_conversion, Qundecided): New variables.
Kenichi Handa <handa@m17n.org>
parents:
19546
diff
changeset
|
3211 |
17052 | 3212 default: |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3213 goto label_invalid_coding_system; |
17052 | 3214 } |
3215 return 0; | |
3216 | |
3217 label_invalid_coding_system: | |
3218 coding->type = coding_type_no_conversion; | |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3219 coding->category_idx = CODING_CATEGORY_IDX_BINARY; |
20227
71008f909642
(setup_coding_system): Initialize common_flags member
Kenichi Handa <handa@m17n.org>
parents:
20150
diff
changeset
|
3220 coding->common_flags = 0; |
17485
abfa77a2693b
(setup_coding_system): Setup coding->eol_type as LF
Kenichi Handa <handa@m17n.org>
parents:
17368
diff
changeset
|
3221 coding->eol_type = CODING_EOL_LF; |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3222 coding->pre_write_conversion = coding->post_read_conversion = Qnil; |
17052 | 3223 return -1; |
3224 } | |
3225 | |
26847 | 3226 /* Free memory blocks allocated for storing composition information. */ |
3227 | |
3228 void | |
3229 coding_free_composition_data (coding) | |
3230 struct coding_system *coding; | |
3231 { | |
3232 struct composition_data *cmp_data = coding->cmp_data, *next; | |
3233 | |
3234 if (!cmp_data) | |
3235 return; | |
3236 /* Memory blocks are chained. At first, rewind to the first, then, | |
3237 free blocks one by one. */ | |
3238 while (cmp_data->prev) | |
3239 cmp_data = cmp_data->prev; | |
3240 while (cmp_data) | |
3241 { | |
3242 next = cmp_data->next; | |
3243 xfree (cmp_data); | |
3244 cmp_data = next; | |
3245 } | |
3246 coding->cmp_data = NULL; | |
3247 } | |
3248 | |
3249 /* Set `char_offset' member of all memory blocks pointed by | |
3250 coding->cmp_data to POS. */ | |
3251 | |
3252 void | |
3253 coding_adjust_composition_offset (coding, pos) | |
3254 struct coding_system *coding; | |
3255 int pos; | |
3256 { | |
3257 struct composition_data *cmp_data; | |
3258 | |
3259 for (cmp_data = coding->cmp_data; cmp_data; cmp_data = cmp_data->next) | |
3260 cmp_data->char_offset = pos; | |
3261 } | |
3262 | |
22616
c493ce6a31e4
(setup_raw_text_coding_system): New function.
Kenichi Handa <handa@m17n.org>
parents:
22529
diff
changeset
|
3263 /* Setup raw-text or one of its subsidiaries in the structure |
c493ce6a31e4
(setup_raw_text_coding_system): New function.
Kenichi Handa <handa@m17n.org>
parents:
22529
diff
changeset
|
3264 coding_system CODING according to the already setup value eol_type |
c493ce6a31e4
(setup_raw_text_coding_system): New function.
Kenichi Handa <handa@m17n.org>
parents:
22529
diff
changeset
|
3265 in CODING. CODING should be setup for some coding system in |
c493ce6a31e4
(setup_raw_text_coding_system): New function.
Kenichi Handa <handa@m17n.org>
parents:
22529
diff
changeset
|
3266 advance. */ |
c493ce6a31e4
(setup_raw_text_coding_system): New function.
Kenichi Handa <handa@m17n.org>
parents:
22529
diff
changeset
|
3267 |
c493ce6a31e4
(setup_raw_text_coding_system): New function.
Kenichi Handa <handa@m17n.org>
parents:
22529
diff
changeset
|
3268 void |
c493ce6a31e4
(setup_raw_text_coding_system): New function.
Kenichi Handa <handa@m17n.org>
parents:
22529
diff
changeset
|
3269 setup_raw_text_coding_system (coding) |
c493ce6a31e4
(setup_raw_text_coding_system): New function.
Kenichi Handa <handa@m17n.org>
parents:
22529
diff
changeset
|
3270 struct coding_system *coding; |
c493ce6a31e4
(setup_raw_text_coding_system): New function.
Kenichi Handa <handa@m17n.org>
parents:
22529
diff
changeset
|
3271 { |
c493ce6a31e4
(setup_raw_text_coding_system): New function.
Kenichi Handa <handa@m17n.org>
parents:
22529
diff
changeset
|
3272 if (coding->type != coding_type_raw_text) |
c493ce6a31e4
(setup_raw_text_coding_system): New function.
Kenichi Handa <handa@m17n.org>
parents:
22529
diff
changeset
|
3273 { |
c493ce6a31e4
(setup_raw_text_coding_system): New function.
Kenichi Handa <handa@m17n.org>
parents:
22529
diff
changeset
|
3274 coding->symbol = Qraw_text; |
c493ce6a31e4
(setup_raw_text_coding_system): New function.
Kenichi Handa <handa@m17n.org>
parents:
22529
diff
changeset
|
3275 coding->type = coding_type_raw_text; |
c493ce6a31e4
(setup_raw_text_coding_system): New function.
Kenichi Handa <handa@m17n.org>
parents:
22529
diff
changeset
|
3276 if (coding->eol_type != CODING_EOL_UNDECIDED) |
c493ce6a31e4
(setup_raw_text_coding_system): New function.
Kenichi Handa <handa@m17n.org>
parents:
22529
diff
changeset
|
3277 { |
22954
928b337d953b
Avoid using initializers for Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents:
22874
diff
changeset
|
3278 Lisp_Object subsidiaries; |
928b337d953b
Avoid using initializers for Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents:
22874
diff
changeset
|
3279 subsidiaries = Fget (Qraw_text, Qeol_type); |
22616
c493ce6a31e4
(setup_raw_text_coding_system): New function.
Kenichi Handa <handa@m17n.org>
parents:
22529
diff
changeset
|
3280 |
c493ce6a31e4
(setup_raw_text_coding_system): New function.
Kenichi Handa <handa@m17n.org>
parents:
22529
diff
changeset
|
3281 if (VECTORP (subsidiaries) |
c493ce6a31e4
(setup_raw_text_coding_system): New function.
Kenichi Handa <handa@m17n.org>
parents:
22529
diff
changeset
|
3282 && XVECTOR (subsidiaries)->size == 3) |
c493ce6a31e4
(setup_raw_text_coding_system): New function.
Kenichi Handa <handa@m17n.org>
parents:
22529
diff
changeset
|
3283 coding->symbol |
c493ce6a31e4
(setup_raw_text_coding_system): New function.
Kenichi Handa <handa@m17n.org>
parents:
22529
diff
changeset
|
3284 = XVECTOR (subsidiaries)->contents[coding->eol_type]; |
c493ce6a31e4
(setup_raw_text_coding_system): New function.
Kenichi Handa <handa@m17n.org>
parents:
22529
diff
changeset
|
3285 } |
24667 | 3286 setup_coding_system (coding->symbol, coding); |
22616
c493ce6a31e4
(setup_raw_text_coding_system): New function.
Kenichi Handa <handa@m17n.org>
parents:
22529
diff
changeset
|
3287 } |
c493ce6a31e4
(setup_raw_text_coding_system): New function.
Kenichi Handa <handa@m17n.org>
parents:
22529
diff
changeset
|
3288 return; |
c493ce6a31e4
(setup_raw_text_coding_system): New function.
Kenichi Handa <handa@m17n.org>
parents:
22529
diff
changeset
|
3289 } |
c493ce6a31e4
(setup_raw_text_coding_system): New function.
Kenichi Handa <handa@m17n.org>
parents:
22529
diff
changeset
|
3290 |
17052 | 3291 /* Emacs has a mechanism to automatically detect a coding system if it |
3292 is one of Emacs' internal format, ISO2022, SJIS, and BIG5. But, | |
3293 it's impossible to distinguish some coding systems accurately | |
3294 because they use the same range of codes. So, at first, coding | |
3295 systems are categorized into 7, those are: | |
3296 | |
17835
f36ffb6f1208
Name change through the code:
Kenichi Handa <handa@m17n.org>
parents:
17725
diff
changeset
|
3297 o coding-category-emacs-mule |
17052 | 3298 |
3299 The category for a coding system which has the same code range | |
3300 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
|
3301 symbol) `emacs-mule' by default. |
17052 | 3302 |
3303 o coding-category-sjis | |
3304 | |
3305 The category for a coding system which has the same code range | |
3306 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
|
3307 symbol) `japanese-shift-jis' by default. |
17052 | 3308 |
3309 o coding-category-iso-7 | |
3310 | |
3311 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
|
3312 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
|
3313 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
|
3314 charsets. Assigned the coding-system (Lisp symbol) |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3315 `iso-2022-7bit' by default. |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3316 |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3317 o coding-category-iso-7-tight |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3318 |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3319 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
|
3320 encode/decode only the specified charsets. |
17052 | 3321 |
3322 o coding-category-iso-8-1 | |
3323 | |
3324 The category for a coding system which has the same code range | |
3325 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
|
3326 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
|
3327 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
|
3328 symbol) `iso-latin-1' by default. |
17052 | 3329 |
3330 o coding-category-iso-8-2 | |
3331 | |
3332 The category for a coding system which has the same code range | |
3333 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
|
3334 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
|
3335 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
|
3336 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
|
3337 |
954e6be0a757
(detect_coding_iso2022): Distinguish coding-category-iso-7-else and
Kenichi Handa <handa@m17n.org>
parents:
18766
diff
changeset
|
3338 o coding-category-iso-7-else |
17052 | 3339 |
3340 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
|
3341 as ISO2022 of 7-bit environemnt but uses locking shift or |
954e6be0a757
(detect_coding_iso2022): Distinguish coding-category-iso-7-else and
Kenichi Handa <handa@m17n.org>
parents:
18766
diff
changeset
|
3342 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
|
3343 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
|
3344 |
954e6be0a757
(detect_coding_iso2022): Distinguish coding-category-iso-7-else and
Kenichi Handa <handa@m17n.org>
parents:
18766
diff
changeset
|
3345 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
|
3346 |
954e6be0a757
(detect_coding_iso2022): Distinguish coding-category-iso-7-else and
Kenichi Handa <handa@m17n.org>
parents:
18766
diff
changeset
|
3347 The category for a coding system which has the same code range |
954e6be0a757
(detect_coding_iso2022): Distinguish coding-category-iso-7-else and
Kenichi Handa <handa@m17n.org>
parents:
18766
diff
changeset
|
3348 as ISO2022 of 8-bit environemnt but uses locking shift or |
954e6be0a757
(detect_coding_iso2022): Distinguish coding-category-iso-7-else and
Kenichi Handa <handa@m17n.org>
parents:
18766
diff
changeset
|
3349 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
|
3350 symbol) `iso-2022-8bit-ss2' by default. |
17052 | 3351 |
3352 o coding-category-big5 | |
3353 | |
3354 The category for a coding system which has the same code range | |
3355 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
|
3356 `cn-big5' by default. |
17052 | 3357 |
28022
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
3358 o coding-category-utf-8 |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
3359 |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
3360 The category for a coding system which has the same code range |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
3361 as UTF-8 (cf. RFC2279). Assigned the coding-system (Lisp |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
3362 symbol) `utf-8' by default. |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
3363 |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
3364 o coding-category-utf-16-be |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
3365 |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
3366 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
|
3367 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
|
3368 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
|
3369 `utf-16-be' by default. |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
3370 |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
3371 o coding-category-utf-16-le |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
3372 |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
3373 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
|
3374 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
|
3375 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
|
3376 symbol) `utf-16-le' by default. |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
3377 |
22874
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
3378 o coding-category-ccl |
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
3379 |
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
3380 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
|
3381 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
|
3382 coding system is assigned. |
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
3383 |
17052 | 3384 o coding-category-binary |
3385 | |
3386 The category for a coding system not categorized in any of the | |
3387 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
|
3388 `no-conversion' by default. |
17052 | 3389 |
3390 Each of them is a Lisp symbol and the value is an actual | |
3391 `coding-system's (this is also a Lisp symbol) assigned by a user. | |
3392 What Emacs does actually is to detect a category of coding system. | |
3393 Then, it uses a `coding-system' assigned to it. If Emacs can't | |
3394 decide only one possible category, it selects a category of the | |
3395 highest priority. Priorities of categories are also specified by a | |
3396 user in a Lisp variable `coding-category-list'. | |
3397 | |
3398 */ | |
3399 | |
22226
557fac086b1b
(ascii_skip_code): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22186
diff
changeset
|
3400 static |
557fac086b1b
(ascii_skip_code): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22186
diff
changeset
|
3401 int ascii_skip_code[256]; |
557fac086b1b
(ascii_skip_code): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22186
diff
changeset
|
3402 |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3403 /* Detect how a text of length SRC_BYTES pointed by SOURCE is encoded. |
17052 | 3404 If it detects possible coding systems, return an integer in which |
3405 appropriate flag bits are set. Flag bits are defined by macros | |
28022
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
3406 CODING_CATEGORY_MASK_XXX in `coding.h'. If PRIORITIES is non-NULL, |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
3407 it should point the table `coding_priorities'. In that case, only |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
3408 the flag bit for a coding system of the highest priority is set in |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
3409 the returned value. |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3410 |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3411 How many ASCII characters are at the head is returned as *SKIP. */ |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3412 |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3413 static int |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3414 detect_coding_mask (source, src_bytes, priorities, skip) |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3415 unsigned char *source; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3416 int src_bytes, *priorities, *skip; |
17052 | 3417 { |
3418 register unsigned char c; | |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3419 unsigned char *src = source, *src_end = source + src_bytes; |
28022
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
3420 unsigned int mask, utf16_examined_p, iso2022_examined_p; |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
3421 int i, idx; |
17052 | 3422 |
3423 /* At first, skip all ASCII characters and control characters except | |
3424 for three ISO2022 specific control characters. */ | |
22226
557fac086b1b
(ascii_skip_code): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22186
diff
changeset
|
3425 ascii_skip_code[ISO_CODE_SO] = 0; |
557fac086b1b
(ascii_skip_code): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22186
diff
changeset
|
3426 ascii_skip_code[ISO_CODE_SI] = 0; |
557fac086b1b
(ascii_skip_code): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22186
diff
changeset
|
3427 ascii_skip_code[ISO_CODE_ESC] = 0; |
557fac086b1b
(ascii_skip_code): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22186
diff
changeset
|
3428 |
17320
9d15bec5f47e
(detect_coding_iso2022, detect_coding_mask): Ignore
Kenichi Handa <handa@m17n.org>
parents:
17304
diff
changeset
|
3429 label_loop_detect_coding: |
22226
557fac086b1b
(ascii_skip_code): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22186
diff
changeset
|
3430 while (src < src_end && ascii_skip_code[*src]) src++; |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3431 *skip = src - source; |
17052 | 3432 |
3433 if (src >= src_end) | |
3434 /* We found nothing other than ASCII. There's nothing to do. */ | |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3435 return 0; |
17052 | 3436 |
22329
4786b00d2973
(detect_coding_mask): Initilize local variable C.
Kenichi Handa <handa@m17n.org>
parents:
22254
diff
changeset
|
3437 c = *src; |
17052 | 3438 /* The text seems to be encoded in some multilingual coding system. |
3439 Now, try to find in which coding system the text is encoded. */ | |
3440 if (c < 0x80) | |
17320
9d15bec5f47e
(detect_coding_iso2022, detect_coding_mask): Ignore
Kenichi Handa <handa@m17n.org>
parents:
17304
diff
changeset
|
3441 { |
9d15bec5f47e
(detect_coding_iso2022, detect_coding_mask): Ignore
Kenichi Handa <handa@m17n.org>
parents:
17304
diff
changeset
|
3442 /* i.e. (c == ISO_CODE_ESC || c == ISO_CODE_SI || c == ISO_CODE_SO) */ |
9d15bec5f47e
(detect_coding_iso2022, detect_coding_mask): Ignore
Kenichi Handa <handa@m17n.org>
parents:
17304
diff
changeset
|
3443 /* C is an ISO2022 specific control code of C0. */ |
9d15bec5f47e
(detect_coding_iso2022, detect_coding_mask): Ignore
Kenichi Handa <handa@m17n.org>
parents:
17304
diff
changeset
|
3444 mask = detect_coding_iso2022 (src, src_end); |
19743
b228f82192d5
(detect_coding_mask): Re-work previous change.
Richard M. Stallman <rms@gnu.org>
parents:
19688
diff
changeset
|
3445 if (mask == 0) |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3446 { |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3447 /* No valid ISO2022 code follows C. Try again. */ |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3448 src++; |
22226
557fac086b1b
(ascii_skip_code): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22186
diff
changeset
|
3449 if (c == ISO_CODE_ESC) |
557fac086b1b
(ascii_skip_code): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22186
diff
changeset
|
3450 ascii_skip_code[ISO_CODE_ESC] = 1; |
557fac086b1b
(ascii_skip_code): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22186
diff
changeset
|
3451 else |
557fac086b1b
(ascii_skip_code): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22186
diff
changeset
|
3452 ascii_skip_code[ISO_CODE_SO] = ascii_skip_code[ISO_CODE_SI] = 1; |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3453 goto label_loop_detect_coding; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3454 } |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3455 if (priorities) |
28022
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
3456 { |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
3457 for (i = 0; i < CODING_CATEGORY_IDX_MAX; i++) |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
3458 { |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
3459 if (mask & priorities[i]) |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
3460 return priorities[i]; |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
3461 } |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
3462 return CODING_CATEGORY_MASK_RAW_TEXT; |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
3463 } |
19280
e755044718ee
(ENCODE_ISO_CHARACTER_DIMENSION1): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
19193
diff
changeset
|
3464 } |
17052 | 3465 else |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3466 { |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3467 int try; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3468 |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3469 if (c < 0xA0) |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3470 { |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3471 /* C is the first byte of SJIS character code, |
28022
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
3472 or a leading-code of Emacs' internal format (emacs-mule), |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
3473 or the first byte of UTF-16. */ |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
3474 try = (CODING_CATEGORY_MASK_SJIS |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
3475 | CODING_CATEGORY_MASK_EMACS_MULE |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
3476 | CODING_CATEGORY_MASK_UTF_16_BE |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
3477 | CODING_CATEGORY_MASK_UTF_16_LE); |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3478 |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3479 /* Or, if C is a special latin extra code, |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3480 or is an ISO2022 specific control code of C1 (SS2 or SS3), |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3481 or is an ISO2022 control-sequence-introducer (CSI), |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3482 we should also consider the possibility of ISO2022 codings. */ |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3483 if ((VECTORP (Vlatin_extra_code_table) |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3484 && !NILP (XVECTOR (Vlatin_extra_code_table)->contents[c])) |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3485 || (c == ISO_CODE_SS2 || c == ISO_CODE_SS3) |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3486 || (c == ISO_CODE_CSI |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3487 && (src < src_end |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3488 && (*src == ']' |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3489 || ((*src == '0' || *src == '1' || *src == '2') |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3490 && src + 1 < src_end |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3491 && src[1] == ']'))))) |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3492 try |= (CODING_CATEGORY_MASK_ISO_8_ELSE |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3493 | CODING_CATEGORY_MASK_ISO_8BIT); |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3494 } |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3495 else |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3496 /* C is a character of ISO2022 in graphic plane right, |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3497 or a SJIS's 1-byte character code (i.e. JISX0201), |
28022
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
3498 or the first byte of BIG5's 2-byte code, |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
3499 or the first byte of UTF-8/16. */ |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3500 try = (CODING_CATEGORY_MASK_ISO_8_ELSE |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3501 | CODING_CATEGORY_MASK_ISO_8BIT |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3502 | CODING_CATEGORY_MASK_SJIS |
28022
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
3503 | CODING_CATEGORY_MASK_BIG5 |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
3504 | CODING_CATEGORY_MASK_UTF_8 |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
3505 | CODING_CATEGORY_MASK_UTF_16_BE |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
3506 | CODING_CATEGORY_MASK_UTF_16_LE); |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3507 |
22874
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
3508 /* Or, we may have to consider the possibility of CCL. */ |
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
3509 if (coding_system_table[CODING_CATEGORY_IDX_CCL] |
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
3510 && (coding_system_table[CODING_CATEGORY_IDX_CCL] |
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
3511 ->spec.ccl.valid_codes)[c]) |
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
3512 try |= CODING_CATEGORY_MASK_CCL; |
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
3513 |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3514 mask = 0; |
28022
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
3515 utf16_examined_p = iso2022_examined_p = 0; |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3516 if (priorities) |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3517 { |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3518 for (i = 0; i < CODING_CATEGORY_IDX_MAX; i++) |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3519 { |
28022
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
3520 if (!iso2022_examined_p |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
3521 && (priorities[i] & try & CODING_CATEGORY_MASK_ISO)) |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
3522 { |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
3523 mask |= detect_coding_iso2022 (src, src_end); |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
3524 iso2022_examined_p = 1; |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
3525 } |
22009
8a2d45cadd66
(detect_coding_mask): Check also coding-category-binary.
Richard M. Stallman <rms@gnu.org>
parents:
21939
diff
changeset
|
3526 else if (priorities[i] & try & CODING_CATEGORY_MASK_SJIS) |
28022
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
3527 mask |= detect_coding_sjis (src, src_end); |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
3528 else if (priorities[i] & try & CODING_CATEGORY_MASK_UTF_8) |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
3529 mask |= detect_coding_utf_8 (src, src_end); |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
3530 else if (!utf16_examined_p |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
3531 && (priorities[i] & try & |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
3532 CODING_CATEGORY_MASK_UTF_16_BE_LE)) |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
3533 { |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
3534 mask |= detect_coding_utf_16 (src, src_end); |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
3535 utf16_examined_p = 1; |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
3536 } |
22009
8a2d45cadd66
(detect_coding_mask): Check also coding-category-binary.
Richard M. Stallman <rms@gnu.org>
parents:
21939
diff
changeset
|
3537 else if (priorities[i] & try & CODING_CATEGORY_MASK_BIG5) |
28022
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
3538 mask |= detect_coding_big5 (src, src_end); |
22009
8a2d45cadd66
(detect_coding_mask): Check also coding-category-binary.
Richard M. Stallman <rms@gnu.org>
parents:
21939
diff
changeset
|
3539 else if (priorities[i] & try & CODING_CATEGORY_MASK_EMACS_MULE) |
28022
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
3540 mask |= detect_coding_emacs_mule (src, src_end); |
23027
0dc823b2335f
(coding_category_name): Fix the order of initial
Kenichi Handa <handa@m17n.org>
parents:
22979
diff
changeset
|
3541 else if (priorities[i] & try & CODING_CATEGORY_MASK_CCL) |
28022
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
3542 mask |= detect_coding_ccl (src, src_end); |
22009
8a2d45cadd66
(detect_coding_mask): Check also coding-category-binary.
Richard M. Stallman <rms@gnu.org>
parents:
21939
diff
changeset
|
3543 else if (priorities[i] & CODING_CATEGORY_MASK_RAW_TEXT) |
28022
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
3544 mask |= CODING_CATEGORY_MASK_RAW_TEXT; |
22009
8a2d45cadd66
(detect_coding_mask): Check also coding-category-binary.
Richard M. Stallman <rms@gnu.org>
parents:
21939
diff
changeset
|
3545 else if (priorities[i] & CODING_CATEGORY_MASK_BINARY) |
28022
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
3546 mask |= CODING_CATEGORY_MASK_BINARY; |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
3547 if (mask & priorities[i]) |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
3548 return priorities[i]; |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3549 } |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3550 return CODING_CATEGORY_MASK_RAW_TEXT; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3551 } |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3552 if (try & CODING_CATEGORY_MASK_ISO) |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3553 mask |= detect_coding_iso2022 (src, src_end); |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3554 if (try & CODING_CATEGORY_MASK_SJIS) |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3555 mask |= detect_coding_sjis (src, src_end); |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3556 if (try & CODING_CATEGORY_MASK_BIG5) |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3557 mask |= detect_coding_big5 (src, src_end); |
28022
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
3558 if (try & CODING_CATEGORY_MASK_UTF_8) |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
3559 mask |= detect_coding_utf_8 (src, src_end); |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
3560 if (try & CODING_CATEGORY_MASK_UTF_16_BE_LE) |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
3561 mask |= detect_coding_utf_16 (src, src_end); |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3562 if (try & CODING_CATEGORY_MASK_EMACS_MULE) |
22874
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
3563 mask |= detect_coding_emacs_mule (src, src_end); |
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
3564 if (try & CODING_CATEGORY_MASK_CCL) |
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
3565 mask |= detect_coding_ccl (src, src_end); |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3566 } |
22009
8a2d45cadd66
(detect_coding_mask): Check also coding-category-binary.
Richard M. Stallman <rms@gnu.org>
parents:
21939
diff
changeset
|
3567 return (mask | CODING_CATEGORY_MASK_RAW_TEXT | CODING_CATEGORY_MASK_BINARY); |
17052 | 3568 } |
3569 | |
3570 /* Detect how a text of length SRC_BYTES pointed by SRC is encoded. | |
3571 The information of the detected coding system is set in CODING. */ | |
3572 | |
3573 void | |
3574 detect_coding (coding, src, src_bytes) | |
3575 struct coding_system *coding; | |
3576 unsigned char *src; | |
3577 int src_bytes; | |
3578 { | |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3579 unsigned int idx; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3580 int skip, mask, i; |
22954
928b337d953b
Avoid using initializers for Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents:
22874
diff
changeset
|
3581 Lisp_Object val; |
928b337d953b
Avoid using initializers for Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents:
22874
diff
changeset
|
3582 |
928b337d953b
Avoid using initializers for Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents:
22874
diff
changeset
|
3583 val = Vcoding_category_list; |
22226
557fac086b1b
(ascii_skip_code): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22186
diff
changeset
|
3584 mask = detect_coding_mask (src, src_bytes, coding_priorities, &skip); |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3585 coding->heading_ascii = skip; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3586 |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3587 if (!mask) return; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3588 |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3589 /* We found a single coding system of the highest priority in MASK. */ |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3590 idx = 0; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3591 while (mask && ! (mask & 1)) mask >>= 1, idx++; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3592 if (! mask) |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3593 idx = CODING_CATEGORY_IDX_RAW_TEXT; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3594 |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3595 val = XSYMBOL (XVECTOR (Vcoding_category_table)->contents[idx])->value; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3596 |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3597 if (coding->eol_type != CODING_EOL_UNDECIDED) |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3598 { |
22954
928b337d953b
Avoid using initializers for Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents:
22874
diff
changeset
|
3599 Lisp_Object tmp; |
928b337d953b
Avoid using initializers for Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents:
22874
diff
changeset
|
3600 |
928b337d953b
Avoid using initializers for Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents:
22874
diff
changeset
|
3601 tmp = Fget (val, Qeol_type); |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3602 if (VECTORP (tmp)) |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3603 val = XVECTOR (tmp)->contents[coding->eol_type]; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3604 } |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3605 |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3606 /* Setup this new coding system while preserving some slots. */ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3607 { |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3608 int src_multibyte = coding->src_multibyte; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3609 int dst_multibyte = coding->dst_multibyte; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3610 |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3611 setup_coding_system (val, coding); |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3612 coding->src_multibyte = src_multibyte; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3613 coding->dst_multibyte = dst_multibyte; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3614 coding->heading_ascii = skip; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3615 } |
17052 | 3616 } |
3617 | |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3618 /* Detect how end-of-line of a text of length SRC_BYTES pointed by |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3619 SOURCE is encoded. Return one of CODING_EOL_LF, CODING_EOL_CRLF, |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3620 CODING_EOL_CR, and CODING_EOL_UNDECIDED. |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3621 |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3622 How many non-eol characters are at the head is returned as *SKIP. */ |
17052 | 3623 |
19173
04ed7c3f5cee
(detect_eol_type): If EOL representation does not
Richard M. Stallman <rms@gnu.org>
parents:
19134
diff
changeset
|
3624 #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
|
3625 |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3626 static int |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3627 detect_eol_type (source, src_bytes, skip) |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3628 unsigned char *source; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3629 int src_bytes, *skip; |
17052 | 3630 { |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3631 unsigned char *src = source, *src_end = src + src_bytes; |
17052 | 3632 unsigned char c; |
19173
04ed7c3f5cee
(detect_eol_type): If EOL representation does not
Richard M. Stallman <rms@gnu.org>
parents:
19134
diff
changeset
|
3633 int total = 0; /* How many end-of-lines are found so far. */ |
04ed7c3f5cee
(detect_eol_type): If EOL representation does not
Richard M. Stallman <rms@gnu.org>
parents:
19134
diff
changeset
|
3634 int eol_type = CODING_EOL_UNDECIDED; |
04ed7c3f5cee
(detect_eol_type): If EOL representation does not
Richard M. Stallman <rms@gnu.org>
parents:
19134
diff
changeset
|
3635 int this_eol_type; |
04ed7c3f5cee
(detect_eol_type): If EOL representation does not
Richard M. Stallman <rms@gnu.org>
parents:
19134
diff
changeset
|
3636 |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3637 *skip = 0; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3638 |
19173
04ed7c3f5cee
(detect_eol_type): If EOL representation does not
Richard M. Stallman <rms@gnu.org>
parents:
19134
diff
changeset
|
3639 while (src < src_end && total < MAX_EOL_CHECK_COUNT) |
17052 | 3640 { |
3641 c = *src++; | |
19173
04ed7c3f5cee
(detect_eol_type): If EOL representation does not
Richard M. Stallman <rms@gnu.org>
parents:
19134
diff
changeset
|
3642 if (c == '\n' || c == '\r') |
17052 | 3643 { |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3644 if (*skip == 0) |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3645 *skip = src - 1 - source; |
19173
04ed7c3f5cee
(detect_eol_type): If EOL representation does not
Richard M. Stallman <rms@gnu.org>
parents:
19134
diff
changeset
|
3646 total++; |
04ed7c3f5cee
(detect_eol_type): If EOL representation does not
Richard M. Stallman <rms@gnu.org>
parents:
19134
diff
changeset
|
3647 if (c == '\n') |
04ed7c3f5cee
(detect_eol_type): If EOL representation does not
Richard M. Stallman <rms@gnu.org>
parents:
19134
diff
changeset
|
3648 this_eol_type = CODING_EOL_LF; |
04ed7c3f5cee
(detect_eol_type): If EOL representation does not
Richard M. Stallman <rms@gnu.org>
parents:
19134
diff
changeset
|
3649 else if (src >= src_end || *src != '\n') |
04ed7c3f5cee
(detect_eol_type): If EOL representation does not
Richard M. Stallman <rms@gnu.org>
parents:
19134
diff
changeset
|
3650 this_eol_type = CODING_EOL_CR; |
17052 | 3651 else |
19173
04ed7c3f5cee
(detect_eol_type): If EOL representation does not
Richard M. Stallman <rms@gnu.org>
parents:
19134
diff
changeset
|
3652 this_eol_type = CODING_EOL_CRLF, src++; |
04ed7c3f5cee
(detect_eol_type): If EOL representation does not
Richard M. Stallman <rms@gnu.org>
parents:
19134
diff
changeset
|
3653 |
04ed7c3f5cee
(detect_eol_type): If EOL representation does not
Richard M. Stallman <rms@gnu.org>
parents:
19134
diff
changeset
|
3654 if (eol_type == CODING_EOL_UNDECIDED) |
04ed7c3f5cee
(detect_eol_type): If EOL representation does not
Richard M. Stallman <rms@gnu.org>
parents:
19134
diff
changeset
|
3655 /* This is the first end-of-line. */ |
04ed7c3f5cee
(detect_eol_type): If EOL representation does not
Richard M. Stallman <rms@gnu.org>
parents:
19134
diff
changeset
|
3656 eol_type = this_eol_type; |
04ed7c3f5cee
(detect_eol_type): If EOL representation does not
Richard M. Stallman <rms@gnu.org>
parents:
19134
diff
changeset
|
3657 else if (eol_type != this_eol_type) |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3658 { |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3659 /* The found type is different from what found before. */ |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3660 eol_type = CODING_EOL_INCONSISTENT; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3661 break; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3662 } |
17052 | 3663 } |
3664 } | |
19173
04ed7c3f5cee
(detect_eol_type): If EOL representation does not
Richard M. Stallman <rms@gnu.org>
parents:
19134
diff
changeset
|
3665 |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3666 if (*skip == 0) |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3667 *skip = src_end - source; |
19181
917138730635
(detect_eol_type): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
19173
diff
changeset
|
3668 return eol_type; |
17052 | 3669 } |
3670 | |
28022
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
3671 /* Like detect_eol_type, but detect EOL type in 2-octet |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
3672 big-endian/little-endian format for coding systems utf-16-be and |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
3673 utf-16-le. */ |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
3674 |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
3675 static int |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
3676 detect_eol_type_in_2_octet_form (source, src_bytes, skip, big_endian_p) |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
3677 unsigned char *source; |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
3678 int src_bytes, *skip; |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
3679 { |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
3680 unsigned char *src = source, *src_end = src + src_bytes; |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
3681 unsigned int c1, c2; |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
3682 int total = 0; /* How many end-of-lines are found so far. */ |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
3683 int eol_type = CODING_EOL_UNDECIDED; |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
3684 int this_eol_type; |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
3685 int msb, lsb; |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
3686 |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
3687 if (big_endian_p) |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
3688 msb = 0, lsb = 1; |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
3689 else |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
3690 msb = 1, lsb = 0; |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
3691 |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
3692 *skip = 0; |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
3693 |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
3694 while ((src + 1) < src_end && total < MAX_EOL_CHECK_COUNT) |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
3695 { |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
3696 c1 = (src[msb] << 8) | (src[lsb]); |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
3697 src += 2; |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
3698 |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
3699 if (c1 == '\n' || c1 == '\r') |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
3700 { |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
3701 if (*skip == 0) |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
3702 *skip = src - 2 - source; |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
3703 total++; |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
3704 if (c1 == '\n') |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
3705 { |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
3706 this_eol_type = CODING_EOL_LF; |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
3707 } |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
3708 else |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
3709 { |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
3710 if ((src + 1) >= src_end) |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
3711 { |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
3712 this_eol_type = CODING_EOL_CR; |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
3713 } |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
3714 else |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
3715 { |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
3716 c2 = (src[msb] << 8) | (src[lsb]); |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
3717 if (c2 == '\n') |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
3718 this_eol_type = CODING_EOL_CRLF, src += 2; |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
3719 else |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
3720 this_eol_type = CODING_EOL_CR; |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
3721 } |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
3722 } |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
3723 |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
3724 if (eol_type == CODING_EOL_UNDECIDED) |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
3725 /* This is the first end-of-line. */ |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
3726 eol_type = this_eol_type; |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
3727 else if (eol_type != this_eol_type) |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
3728 { |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
3729 /* The found type is different from what found before. */ |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
3730 eol_type = CODING_EOL_INCONSISTENT; |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
3731 break; |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
3732 } |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
3733 } |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
3734 } |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
3735 |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
3736 if (*skip == 0) |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
3737 *skip = src_end - source; |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
3738 return eol_type; |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
3739 } |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
3740 |
17052 | 3741 /* Detect how end-of-line of a text of length SRC_BYTES pointed by SRC |
3742 is encoded. If it detects an appropriate format of end-of-line, it | |
3743 sets the information in *CODING. */ | |
3744 | |
3745 void | |
3746 detect_eol (coding, src, src_bytes) | |
3747 struct coding_system *coding; | |
3748 unsigned char *src; | |
3749 int src_bytes; | |
3750 { | |
20105
c017642863c2
(Qcoding_system_spec): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
19824
diff
changeset
|
3751 Lisp_Object val; |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3752 int skip; |
28022
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
3753 int eol_type; |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
3754 |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
3755 switch (coding->category_idx) |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
3756 { |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
3757 case CODING_CATEGORY_IDX_UTF_16_BE: |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
3758 eol_type = detect_eol_type_in_2_octet_form (src, src_bytes, &skip, 1); |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
3759 break; |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
3760 case CODING_CATEGORY_IDX_UTF_16_LE: |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
3761 eol_type = detect_eol_type_in_2_octet_form (src, src_bytes, &skip, 0); |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
3762 break; |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
3763 default: |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
3764 eol_type = detect_eol_type (src, src_bytes, &skip); |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
3765 break; |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
3766 } |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3767 |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3768 if (coding->heading_ascii > skip) |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3769 coding->heading_ascii = skip; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3770 else |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3771 skip = coding->heading_ascii; |
17052 | 3772 |
17835
f36ffb6f1208
Name change through the code:
Kenichi Handa <handa@m17n.org>
parents:
17725
diff
changeset
|
3773 if (eol_type == CODING_EOL_UNDECIDED) |
17052 | 3774 return; |
19612
783efd6c7c1e
(Qno_conversion, Qundecided): New variables.
Kenichi Handa <handa@m17n.org>
parents:
19546
diff
changeset
|
3775 if (eol_type == CODING_EOL_INCONSISTENT) |
783efd6c7c1e
(Qno_conversion, Qundecided): New variables.
Kenichi Handa <handa@m17n.org>
parents:
19546
diff
changeset
|
3776 { |
783efd6c7c1e
(Qno_conversion, Qundecided): New variables.
Kenichi Handa <handa@m17n.org>
parents:
19546
diff
changeset
|
3777 #if 0 |
783efd6c7c1e
(Qno_conversion, Qundecided): New variables.
Kenichi Handa <handa@m17n.org>
parents:
19546
diff
changeset
|
3778 /* This code is suppressed until we find a better way to |
19613
666288d82ae1
(detect_eol): Do not select no-conversion even if EOL
Kenichi Handa <handa@m17n.org>
parents:
19612
diff
changeset
|
3779 distinguish raw text file and binary file. */ |
19612
783efd6c7c1e
(Qno_conversion, Qundecided): New variables.
Kenichi Handa <handa@m17n.org>
parents:
19546
diff
changeset
|
3780 |
783efd6c7c1e
(Qno_conversion, Qundecided): New variables.
Kenichi Handa <handa@m17n.org>
parents:
19546
diff
changeset
|
3781 /* If we have already detected that the coding is raw-text, the |
783efd6c7c1e
(Qno_conversion, Qundecided): New variables.
Kenichi Handa <handa@m17n.org>
parents:
19546
diff
changeset
|
3782 coding should actually be no-conversion. */ |
783efd6c7c1e
(Qno_conversion, Qundecided): New variables.
Kenichi Handa <handa@m17n.org>
parents:
19546
diff
changeset
|
3783 if (coding->type == coding_type_raw_text) |
783efd6c7c1e
(Qno_conversion, Qundecided): New variables.
Kenichi Handa <handa@m17n.org>
parents:
19546
diff
changeset
|
3784 { |
783efd6c7c1e
(Qno_conversion, Qundecided): New variables.
Kenichi Handa <handa@m17n.org>
parents:
19546
diff
changeset
|
3785 setup_coding_system (Qno_conversion, coding); |
783efd6c7c1e
(Qno_conversion, Qundecided): New variables.
Kenichi Handa <handa@m17n.org>
parents:
19546
diff
changeset
|
3786 return; |
783efd6c7c1e
(Qno_conversion, Qundecided): New variables.
Kenichi Handa <handa@m17n.org>
parents:
19546
diff
changeset
|
3787 } |
783efd6c7c1e
(Qno_conversion, Qundecided): New variables.
Kenichi Handa <handa@m17n.org>
parents:
19546
diff
changeset
|
3788 /* Else, let's decode only text code anyway. */ |
783efd6c7c1e
(Qno_conversion, Qundecided): New variables.
Kenichi Handa <handa@m17n.org>
parents:
19546
diff
changeset
|
3789 #endif /* 0 */ |
19743
b228f82192d5
(detect_coding_mask): Re-work previous change.
Richard M. Stallman <rms@gnu.org>
parents:
19688
diff
changeset
|
3790 eol_type = CODING_EOL_LF; |
19612
783efd6c7c1e
(Qno_conversion, Qundecided): New variables.
Kenichi Handa <handa@m17n.org>
parents:
19546
diff
changeset
|
3791 } |
783efd6c7c1e
(Qno_conversion, Qundecided): New variables.
Kenichi Handa <handa@m17n.org>
parents:
19546
diff
changeset
|
3792 |
20105
c017642863c2
(Qcoding_system_spec): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
19824
diff
changeset
|
3793 val = Fget (coding->symbol, Qeol_type); |
17052 | 3794 if (VECTORP (val) && XVECTOR (val)->size == 3) |
3795 { | |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3796 int src_multibyte = coding->src_multibyte; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3797 int dst_multibyte = coding->dst_multibyte; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3798 |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3799 setup_coding_system (XVECTOR (val)->contents[eol_type], coding); |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3800 coding->src_multibyte = src_multibyte; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3801 coding->dst_multibyte = dst_multibyte; |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3802 coding->heading_ascii = skip; |
17052 | 3803 } |
3804 } | |
3805 | |
3806 #define CONVERSION_BUFFER_EXTRA_ROOM 256 | |
3807 | |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3808 #define DECODING_BUFFER_MAG(coding) \ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3809 (coding->type == coding_type_iso2022 \ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3810 ? 3 \ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3811 : (coding->type == coding_type_ccl \ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3812 ? coding->spec.ccl.decoder.buf_magnification \ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3813 : 2)) |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3814 |
17052 | 3815 /* Return maximum size (bytes) of a buffer enough for decoding |
3816 SRC_BYTES of text encoded in CODING. */ | |
3817 | |
3818 int | |
3819 decoding_buffer_size (coding, src_bytes) | |
3820 struct coding_system *coding; | |
3821 int src_bytes; | |
3822 { | |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3823 return (src_bytes * DECODING_BUFFER_MAG (coding) |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3824 + CONVERSION_BUFFER_EXTRA_ROOM); |
17052 | 3825 } |
3826 | |
3827 /* Return maximum size (bytes) of a buffer enough for encoding | |
3828 SRC_BYTES of text to CODING. */ | |
3829 | |
3830 int | |
3831 encoding_buffer_size (coding, src_bytes) | |
3832 struct coding_system *coding; | |
3833 int src_bytes; | |
3834 { | |
3835 int magnification; | |
3836 | |
3837 if (coding->type == coding_type_ccl) | |
3838 magnification = coding->spec.ccl.encoder.buf_magnification; | |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3839 else if (CODING_REQUIRE_ENCODING (coding)) |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3840 magnification = 3; |
17052 | 3841 else |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3842 magnification = 1; |
17052 | 3843 |
3844 return (src_bytes * magnification + CONVERSION_BUFFER_EXTRA_ROOM); | |
3845 } | |
3846 | |
3847 #ifndef MINIMUM_CONVERSION_BUFFER_SIZE | |
3848 #define MINIMUM_CONVERSION_BUFFER_SIZE 1024 | |
3849 #endif | |
3850 | |
3851 char *conversion_buffer; | |
3852 int conversion_buffer_size; | |
3853 | |
3854 /* Return a pointer to a SIZE bytes of buffer to be used for encoding | |
3855 or decoding. Sufficient memory is allocated automatically. If we | |
3856 run out of memory, return NULL. */ | |
3857 | |
3858 char * | |
3859 get_conversion_buffer (size) | |
3860 int size; | |
3861 { | |
3862 if (size > conversion_buffer_size) | |
3863 { | |
3864 char *buf; | |
3865 int real_size = conversion_buffer_size * 2; | |
3866 | |
3867 while (real_size < size) real_size *= 2; | |
3868 buf = (char *) xmalloc (real_size); | |
3869 xfree (conversion_buffer); | |
3870 conversion_buffer = buf; | |
3871 conversion_buffer_size = real_size; | |
3872 } | |
3873 return conversion_buffer; | |
3874 } | |
3875 | |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3876 int |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3877 ccl_coding_driver (coding, source, destination, src_bytes, dst_bytes, encodep) |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3878 struct coding_system *coding; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3879 unsigned char *source, *destination; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3880 int src_bytes, dst_bytes, encodep; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3881 { |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3882 struct ccl_program *ccl |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3883 = encodep ? &coding->spec.ccl.encoder : &coding->spec.ccl.decoder; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3884 int result; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3885 |
23116
6736da064f4a
(detect_coding_iso2022): Handle ESC N and ESC O
Kenichi Handa <handa@m17n.org>
parents:
23089
diff
changeset
|
3886 ccl->last_block = coding->mode & CODING_MODE_LAST_BLOCK; |
23067
ac788ee31080
(ccl_coding_driver): Setup ccl->last_block properly.
Kenichi Handa <handa@m17n.org>
parents:
23027
diff
changeset
|
3887 |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3888 coding->produced = ccl_driver (ccl, source, destination, |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3889 src_bytes, dst_bytes, &(coding->consumed)); |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3890 if (encodep) |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3891 coding->produced_char = coding->produced; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3892 else |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3893 { |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3894 int bytes |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3895 = dst_bytes ? dst_bytes : source + coding->consumed - destination; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3896 coding->produced = str_as_multibyte (destination, bytes, |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3897 coding->produced, |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3898 &(coding->produced_char)); |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3899 } |
23201
392b44751a22
(ccl_coding_driver): Always calculate correct mulibyte
Kenichi Handa <handa@m17n.org>
parents:
23153
diff
changeset
|
3900 |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3901 switch (ccl->status) |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3902 { |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3903 case CCL_STAT_SUSPEND_BY_SRC: |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3904 result = CODING_FINISH_INSUFFICIENT_SRC; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3905 break; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3906 case CCL_STAT_SUSPEND_BY_DST: |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3907 result = CODING_FINISH_INSUFFICIENT_DST; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3908 break; |
23279
ca159e828a68
(ccl_coding_driver): If ccl_driver is interrupted by a
Kenichi Handa <handa@m17n.org>
parents:
23258
diff
changeset
|
3909 case CCL_STAT_QUIT: |
ca159e828a68
(ccl_coding_driver): If ccl_driver is interrupted by a
Kenichi Handa <handa@m17n.org>
parents:
23258
diff
changeset
|
3910 case CCL_STAT_INVALID_CMD: |
ca159e828a68
(ccl_coding_driver): If ccl_driver is interrupted by a
Kenichi Handa <handa@m17n.org>
parents:
23258
diff
changeset
|
3911 result = CODING_FINISH_INTERRUPT; |
ca159e828a68
(ccl_coding_driver): If ccl_driver is interrupted by a
Kenichi Handa <handa@m17n.org>
parents:
23258
diff
changeset
|
3912 break; |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3913 default: |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3914 result = CODING_FINISH_NORMAL; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3915 break; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3916 } |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3917 return result; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3918 } |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3919 |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3920 /* See "GENERAL NOTES about `decode_coding_XXX ()' functions". Before |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3921 decoding, it may detect coding system and format of end-of-line if |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3922 those are not yet decided. The source should be unibyte, the |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3923 result is multibyte if CODING->dst_multibyte is nonzero, else |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3924 unibyte. */ |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3925 |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3926 int |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3927 decode_coding (coding, source, destination, src_bytes, dst_bytes) |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3928 struct coding_system *coding; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3929 unsigned char *source, *destination; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3930 int src_bytes, dst_bytes; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3931 { |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3932 if (coding->type == coding_type_undecided) |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3933 detect_coding (coding, source, src_bytes); |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3934 |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3935 if (coding->eol_type == CODING_EOL_UNDECIDED) |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3936 detect_eol (coding, source, src_bytes); |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3937 |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3938 coding->produced = coding->produced_char = 0; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3939 coding->consumed = coding->consumed_char = 0; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3940 coding->errors = 0; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3941 coding->result = CODING_FINISH_NORMAL; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3942 |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3943 switch (coding->type) |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3944 { |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3945 case coding_type_sjis: |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3946 decode_coding_sjis_big5 (coding, source, destination, |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3947 src_bytes, dst_bytes, 1); |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3948 break; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3949 |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3950 case coding_type_iso2022: |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3951 decode_coding_iso2022 (coding, source, destination, |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3952 src_bytes, dst_bytes); |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3953 break; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3954 |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3955 case coding_type_big5: |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3956 decode_coding_sjis_big5 (coding, source, destination, |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3957 src_bytes, dst_bytes, 0); |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3958 break; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3959 |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3960 case coding_type_emacs_mule: |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3961 decode_coding_emacs_mule (coding, source, destination, |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3962 src_bytes, dst_bytes); |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3963 break; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3964 |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3965 case coding_type_ccl: |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3966 ccl_coding_driver (coding, source, destination, |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3967 src_bytes, dst_bytes, 0); |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3968 break; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3969 |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3970 default: |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3971 decode_eol (coding, source, destination, src_bytes, dst_bytes); |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3972 } |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3973 |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3974 if (coding->result == CODING_FINISH_INSUFFICIENT_SRC |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3975 && coding->consumed == src_bytes) |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3976 coding->result = CODING_FINISH_NORMAL; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3977 |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3978 if (coding->mode & CODING_MODE_LAST_BLOCK |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3979 && coding->result == CODING_FINISH_INSUFFICIENT_SRC) |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3980 { |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3981 unsigned char *src = source + coding->consumed; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3982 unsigned char *dst = destination + coding->produced; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3983 |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3984 src_bytes -= coding->consumed; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3985 coding->errors++; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3986 if (COMPOSING_P (coding)) |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3987 DECODE_COMPOSITION_END ('1'); |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3988 while (src_bytes--) |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3989 { |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3990 int c = *src++; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3991 dst += CHAR_STRING (c, dst); |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3992 coding->produced_char++; |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3993 } |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3994 coding->consumed = coding->consumed_char = src - source; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3995 coding->produced = dst - destination; |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3996 } |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3997 |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3998 if (!coding->dst_multibyte) |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3999 { |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4000 coding->produced = str_as_unibyte (destination, coding->produced); |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4001 coding->produced_char = coding->produced; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4002 } |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4003 |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4004 return coding->result; |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4005 } |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4006 |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4007 /* See "GENERAL NOTES about `encode_coding_XXX ()' functions". The |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4008 multibyteness of the source is CODING->src_multibyte, the |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4009 multibyteness of the result is always unibyte. */ |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4010 |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4011 int |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4012 encode_coding (coding, source, destination, src_bytes, dst_bytes) |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4013 struct coding_system *coding; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4014 unsigned char *source, *destination; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4015 int src_bytes, dst_bytes; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4016 { |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4017 coding->produced = coding->produced_char = 0; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4018 coding->consumed = coding->consumed_char = 0; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4019 coding->errors = 0; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4020 coding->result = CODING_FINISH_NORMAL; |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4021 |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4022 switch (coding->type) |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4023 { |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4024 case coding_type_sjis: |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4025 encode_coding_sjis_big5 (coding, source, destination, |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4026 src_bytes, dst_bytes, 1); |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4027 break; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4028 |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4029 case coding_type_iso2022: |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4030 encode_coding_iso2022 (coding, source, destination, |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4031 src_bytes, dst_bytes); |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4032 break; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4033 |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4034 case coding_type_big5: |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4035 encode_coding_sjis_big5 (coding, source, destination, |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4036 src_bytes, dst_bytes, 0); |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4037 break; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4038 |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4039 case coding_type_emacs_mule: |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4040 encode_coding_emacs_mule (coding, source, destination, |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4041 src_bytes, dst_bytes); |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4042 break; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4043 |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4044 case coding_type_ccl: |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4045 ccl_coding_driver (coding, source, destination, |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4046 src_bytes, dst_bytes, 1); |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4047 break; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4048 |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4049 default: |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4050 encode_eol (coding, source, destination, src_bytes, dst_bytes); |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4051 } |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4052 |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4053 if (coding->result == CODING_FINISH_INSUFFICIENT_SRC |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4054 && coding->consumed == src_bytes) |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4055 coding->result = CODING_FINISH_NORMAL; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4056 |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4057 if (coding->mode & CODING_MODE_LAST_BLOCK) |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4058 { |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4059 unsigned char *src = source + coding->consumed; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4060 unsigned char *src_end = src + src_bytes; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4061 unsigned char *dst = destination + coding->produced; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4062 |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4063 if (coding->type == coding_type_iso2022) |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4064 ENCODE_RESET_PLANE_AND_REGISTER; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4065 if (COMPOSING_P (coding)) |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4066 *dst++ = ISO_CODE_ESC, *dst++ = '1'; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4067 if (coding->consumed < src_bytes) |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4068 { |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4069 int len = src_bytes - coding->consumed; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4070 |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4071 BCOPY_SHORT (source + coding->consumed, dst, len); |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4072 if (coding->src_multibyte) |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4073 len = str_as_unibyte (dst, len); |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4074 dst += len; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4075 coding->consumed = src_bytes; |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4076 } |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4077 coding->produced = coding->produced_char = dst - destination; |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4078 } |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4079 |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4080 return coding->result; |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4081 } |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4082 |
20931
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
4083 /* Scan text in the region between *BEG and *END (byte positions), |
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
4084 skip characters which we don't have to decode by coding system |
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
4085 CODING at the head and tail, then set *BEG and *END to the region |
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
4086 of the text we actually have to convert. The caller should move |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4087 the gap out of the region in advance if the region is from a |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4088 buffer. |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4089 |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4090 If STR is not NULL, *BEG and *END are indices into STR. */ |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4091 |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4092 static void |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4093 shrink_decoding_region (beg, end, coding, str) |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4094 int *beg, *end; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4095 struct coding_system *coding; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4096 unsigned char *str; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4097 { |
20931
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
4098 unsigned char *begp_orig, *begp, *endp_orig, *endp, c; |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4099 int eol_conversion; |
23339
2da87b489590
(check_composing_code): Fix previous change. Now it
Kenichi Handa <handa@m17n.org>
parents:
23325
diff
changeset
|
4100 Lisp_Object translation_table; |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4101 |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4102 if (coding->type == coding_type_ccl |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4103 || coding->type == coding_type_undecided |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4104 || coding->eol_type != CODING_EOL_LF |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4105 || !NILP (coding->post_read_conversion) |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4106 || coding->composing != COMPOSITION_DISABLED) |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4107 { |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4108 /* We can't skip any data. */ |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4109 return; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4110 } |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4111 if (coding->type == coding_type_no_conversion |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4112 || coding->type == coding_type_raw_text |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4113 || coding->type == coding_type_emacs_mule) |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4114 { |
20931
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
4115 /* We need no conversion, but don't have to skip any data here. |
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
4116 Decoding routine handles them effectively anyway. */ |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4117 return; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4118 } |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4119 |
23339
2da87b489590
(check_composing_code): Fix previous change. Now it
Kenichi Handa <handa@m17n.org>
parents:
23325
diff
changeset
|
4120 translation_table = coding->translation_table_for_decode; |
2da87b489590
(check_composing_code): Fix previous change. Now it
Kenichi Handa <handa@m17n.org>
parents:
23325
diff
changeset
|
4121 if (NILP (translation_table) && !NILP (Venable_character_translation)) |
2da87b489590
(check_composing_code): Fix previous change. Now it
Kenichi Handa <handa@m17n.org>
parents:
23325
diff
changeset
|
4122 translation_table = Vstandard_translation_table_for_decode; |
2da87b489590
(check_composing_code): Fix previous change. Now it
Kenichi Handa <handa@m17n.org>
parents:
23325
diff
changeset
|
4123 if (CHAR_TABLE_P (translation_table)) |
2da87b489590
(check_composing_code): Fix previous change. Now it
Kenichi Handa <handa@m17n.org>
parents:
23325
diff
changeset
|
4124 { |
2da87b489590
(check_composing_code): Fix previous change. Now it
Kenichi Handa <handa@m17n.org>
parents:
23325
diff
changeset
|
4125 int i; |
2da87b489590
(check_composing_code): Fix previous change. Now it
Kenichi Handa <handa@m17n.org>
parents:
23325
diff
changeset
|
4126 for (i = 0; i < 128; i++) |
2da87b489590
(check_composing_code): Fix previous change. Now it
Kenichi Handa <handa@m17n.org>
parents:
23325
diff
changeset
|
4127 if (!NILP (CHAR_TABLE_REF (translation_table, i))) |
2da87b489590
(check_composing_code): Fix previous change. Now it
Kenichi Handa <handa@m17n.org>
parents:
23325
diff
changeset
|
4128 break; |
2da87b489590
(check_composing_code): Fix previous change. Now it
Kenichi Handa <handa@m17n.org>
parents:
23325
diff
changeset
|
4129 if (i < 128) |
29247
c748b4b1c785
(shrink_decoding_region): Initialize eol_conversion.
Dave Love <fx@gnu.org>
parents:
29184
diff
changeset
|
4130 /* Some ASCII character should be translated. We give up |
23339
2da87b489590
(check_composing_code): Fix previous change. Now it
Kenichi Handa <handa@m17n.org>
parents:
23325
diff
changeset
|
4131 shrinking. */ |
2da87b489590
(check_composing_code): Fix previous change. Now it
Kenichi Handa <handa@m17n.org>
parents:
23325
diff
changeset
|
4132 return; |
2da87b489590
(check_composing_code): Fix previous change. Now it
Kenichi Handa <handa@m17n.org>
parents:
23325
diff
changeset
|
4133 } |
2da87b489590
(check_composing_code): Fix previous change. Now it
Kenichi Handa <handa@m17n.org>
parents:
23325
diff
changeset
|
4134 |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4135 if (coding->heading_ascii >= 0) |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4136 /* Detection routine has already found how much we can skip at the |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4137 head. */ |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4138 *beg += coding->heading_ascii; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4139 |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4140 if (str) |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4141 { |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4142 begp_orig = begp = str + *beg; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4143 endp_orig = endp = str + *end; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4144 } |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4145 else |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4146 { |
20931
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
4147 begp_orig = begp = BYTE_POS_ADDR (*beg); |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4148 endp_orig = endp = begp + *end - *beg; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4149 } |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4150 |
29247
c748b4b1c785
(shrink_decoding_region): Initialize eol_conversion.
Dave Love <fx@gnu.org>
parents:
29184
diff
changeset
|
4151 eol_conversion = (coding->eol_type == CODING_EOL_CR |
c748b4b1c785
(shrink_decoding_region): Initialize eol_conversion.
Dave Love <fx@gnu.org>
parents:
29184
diff
changeset
|
4152 || coding->eol_type == CODING_EOL_CRLF); |
c748b4b1c785
(shrink_decoding_region): Initialize eol_conversion.
Dave Love <fx@gnu.org>
parents:
29184
diff
changeset
|
4153 |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4154 switch (coding->type) |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4155 { |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4156 case coding_type_sjis: |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4157 case coding_type_big5: |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4158 /* We can skip all ASCII characters at the head. */ |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4159 if (coding->heading_ascii < 0) |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4160 { |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4161 if (eol_conversion) |
21273
3d9e12cf2e63
(shrink_decoding_region): If EOL_CONVERSION is nonzero,
Kenichi Handa <handa@m17n.org>
parents:
21253
diff
changeset
|
4162 while (begp < endp && *begp < 0x80 && *begp != '\r') begp++; |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4163 else |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4164 while (begp < endp && *begp < 0x80) begp++; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4165 } |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4166 /* We can skip all ASCII characters at the tail except for the |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4167 second byte of SJIS or BIG5 code. */ |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4168 if (eol_conversion) |
21273
3d9e12cf2e63
(shrink_decoding_region): If EOL_CONVERSION is nonzero,
Kenichi Handa <handa@m17n.org>
parents:
21253
diff
changeset
|
4169 while (begp < endp && endp[-1] < 0x80 && endp[-1] != '\r') endp--; |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4170 else |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4171 while (begp < endp && endp[-1] < 0x80) endp--; |
21744
64c815fe1bdc
(shrink_decoding_region): Do not consider LF as ascii
Richard M. Stallman <rms@gnu.org>
parents:
21664
diff
changeset
|
4172 /* Do not consider LF as ascii if preceded by CR, since that |
64c815fe1bdc
(shrink_decoding_region): Do not consider LF as ascii
Richard M. Stallman <rms@gnu.org>
parents:
21664
diff
changeset
|
4173 confuses eol decoding. */ |
64c815fe1bdc
(shrink_decoding_region): Do not consider LF as ascii
Richard M. Stallman <rms@gnu.org>
parents:
21664
diff
changeset
|
4174 if (begp < endp && endp < endp_orig && endp[-1] == '\r' && endp[0] == '\n') |
64c815fe1bdc
(shrink_decoding_region): Do not consider LF as ascii
Richard M. Stallman <rms@gnu.org>
parents:
21664
diff
changeset
|
4175 endp++; |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4176 if (begp < endp && endp < endp_orig && endp[-1] >= 0x80) |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4177 endp++; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4178 break; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4179 |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4180 case coding_type_iso2022: |
23426
088cb2a804c7
(shrink_decoding_region): If a charset other than ascii
Kenichi Handa <handa@m17n.org>
parents:
23402
diff
changeset
|
4181 if (CODING_SPEC_ISO_INITIAL_DESIGNATION (coding, 0) != CHARSET_ASCII) |
088cb2a804c7
(shrink_decoding_region): If a charset other than ascii
Kenichi Handa <handa@m17n.org>
parents:
23402
diff
changeset
|
4182 /* We can't skip any data. */ |
088cb2a804c7
(shrink_decoding_region): If a charset other than ascii
Kenichi Handa <handa@m17n.org>
parents:
23402
diff
changeset
|
4183 break; |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4184 if (coding->heading_ascii < 0) |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4185 { |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4186 /* We can skip all ASCII characters at the head except for a |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4187 few control codes. */ |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4188 while (begp < endp && (c = *begp) < 0x80 |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4189 && c != ISO_CODE_CR && c != ISO_CODE_SO |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4190 && c != ISO_CODE_SI && c != ISO_CODE_ESC |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4191 && (!eol_conversion || c != ISO_CODE_LF)) |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4192 begp++; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4193 } |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4194 switch (coding->category_idx) |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4195 { |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4196 case CODING_CATEGORY_IDX_ISO_8_1: |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4197 case CODING_CATEGORY_IDX_ISO_8_2: |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4198 /* We can skip all ASCII characters at the tail. */ |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4199 if (eol_conversion) |
21273
3d9e12cf2e63
(shrink_decoding_region): If EOL_CONVERSION is nonzero,
Kenichi Handa <handa@m17n.org>
parents:
21253
diff
changeset
|
4200 while (begp < endp && (c = endp[-1]) < 0x80 && c != '\r') endp--; |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4201 else |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4202 while (begp < endp && endp[-1] < 0x80) endp--; |
21744
64c815fe1bdc
(shrink_decoding_region): Do not consider LF as ascii
Richard M. Stallman <rms@gnu.org>
parents:
21664
diff
changeset
|
4203 /* Do not consider LF as ascii if preceded by CR, since that |
64c815fe1bdc
(shrink_decoding_region): Do not consider LF as ascii
Richard M. Stallman <rms@gnu.org>
parents:
21664
diff
changeset
|
4204 confuses eol decoding. */ |
64c815fe1bdc
(shrink_decoding_region): Do not consider LF as ascii
Richard M. Stallman <rms@gnu.org>
parents:
21664
diff
changeset
|
4205 if (begp < endp && endp < endp_orig && endp[-1] == '\r' && endp[0] == '\n') |
64c815fe1bdc
(shrink_decoding_region): Do not consider LF as ascii
Richard M. Stallman <rms@gnu.org>
parents:
21664
diff
changeset
|
4206 endp++; |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4207 break; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4208 |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4209 case CODING_CATEGORY_IDX_ISO_7: |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4210 case CODING_CATEGORY_IDX_ISO_7_TIGHT: |
23325
bbd06336cd0c
(check_composing_code): If the current composing
Kenichi Handa <handa@m17n.org>
parents:
23315
diff
changeset
|
4211 { |
bbd06336cd0c
(check_composing_code): If the current composing
Kenichi Handa <handa@m17n.org>
parents:
23315
diff
changeset
|
4212 /* We can skip all charactes at the tail except for 8-bit |
bbd06336cd0c
(check_composing_code): If the current composing
Kenichi Handa <handa@m17n.org>
parents:
23315
diff
changeset
|
4213 codes and ESC and the following 2-byte at the tail. */ |
bbd06336cd0c
(check_composing_code): If the current composing
Kenichi Handa <handa@m17n.org>
parents:
23315
diff
changeset
|
4214 unsigned char *eight_bit = NULL; |
bbd06336cd0c
(check_composing_code): If the current composing
Kenichi Handa <handa@m17n.org>
parents:
23315
diff
changeset
|
4215 |
bbd06336cd0c
(check_composing_code): If the current composing
Kenichi Handa <handa@m17n.org>
parents:
23315
diff
changeset
|
4216 if (eol_conversion) |
bbd06336cd0c
(check_composing_code): If the current composing
Kenichi Handa <handa@m17n.org>
parents:
23315
diff
changeset
|
4217 while (begp < endp |
bbd06336cd0c
(check_composing_code): If the current composing
Kenichi Handa <handa@m17n.org>
parents:
23315
diff
changeset
|
4218 && (c = endp[-1]) != ISO_CODE_ESC && c != '\r') |
bbd06336cd0c
(check_composing_code): If the current composing
Kenichi Handa <handa@m17n.org>
parents:
23315
diff
changeset
|
4219 { |
bbd06336cd0c
(check_composing_code): If the current composing
Kenichi Handa <handa@m17n.org>
parents:
23315
diff
changeset
|
4220 if (!eight_bit && c & 0x80) eight_bit = endp; |
bbd06336cd0c
(check_composing_code): If the current composing
Kenichi Handa <handa@m17n.org>
parents:
23315
diff
changeset
|
4221 endp--; |
bbd06336cd0c
(check_composing_code): If the current composing
Kenichi Handa <handa@m17n.org>
parents:
23315
diff
changeset
|
4222 } |
bbd06336cd0c
(check_composing_code): If the current composing
Kenichi Handa <handa@m17n.org>
parents:
23315
diff
changeset
|
4223 else |
bbd06336cd0c
(check_composing_code): If the current composing
Kenichi Handa <handa@m17n.org>
parents:
23315
diff
changeset
|
4224 while (begp < endp |
bbd06336cd0c
(check_composing_code): If the current composing
Kenichi Handa <handa@m17n.org>
parents:
23315
diff
changeset
|
4225 && (c = endp[-1]) != ISO_CODE_ESC) |
bbd06336cd0c
(check_composing_code): If the current composing
Kenichi Handa <handa@m17n.org>
parents:
23315
diff
changeset
|
4226 { |
bbd06336cd0c
(check_composing_code): If the current composing
Kenichi Handa <handa@m17n.org>
parents:
23315
diff
changeset
|
4227 if (!eight_bit && c & 0x80) eight_bit = endp; |
bbd06336cd0c
(check_composing_code): If the current composing
Kenichi Handa <handa@m17n.org>
parents:
23315
diff
changeset
|
4228 endp--; |
bbd06336cd0c
(check_composing_code): If the current composing
Kenichi Handa <handa@m17n.org>
parents:
23315
diff
changeset
|
4229 } |
bbd06336cd0c
(check_composing_code): If the current composing
Kenichi Handa <handa@m17n.org>
parents:
23315
diff
changeset
|
4230 /* Do not consider LF as ascii if preceded by CR, since that |
bbd06336cd0c
(check_composing_code): If the current composing
Kenichi Handa <handa@m17n.org>
parents:
23315
diff
changeset
|
4231 confuses eol decoding. */ |
bbd06336cd0c
(check_composing_code): If the current composing
Kenichi Handa <handa@m17n.org>
parents:
23315
diff
changeset
|
4232 if (begp < endp && endp < endp_orig |
bbd06336cd0c
(check_composing_code): If the current composing
Kenichi Handa <handa@m17n.org>
parents:
23315
diff
changeset
|
4233 && endp[-1] == '\r' && endp[0] == '\n') |
bbd06336cd0c
(check_composing_code): If the current composing
Kenichi Handa <handa@m17n.org>
parents:
23315
diff
changeset
|
4234 endp++; |
bbd06336cd0c
(check_composing_code): If the current composing
Kenichi Handa <handa@m17n.org>
parents:
23315
diff
changeset
|
4235 if (begp < endp && endp[-1] == ISO_CODE_ESC) |
bbd06336cd0c
(check_composing_code): If the current composing
Kenichi Handa <handa@m17n.org>
parents:
23315
diff
changeset
|
4236 { |
bbd06336cd0c
(check_composing_code): If the current composing
Kenichi Handa <handa@m17n.org>
parents:
23315
diff
changeset
|
4237 if (endp + 1 < endp_orig && end[0] == '(' && end[1] == 'B') |
bbd06336cd0c
(check_composing_code): If the current composing
Kenichi Handa <handa@m17n.org>
parents:
23315
diff
changeset
|
4238 /* This is an ASCII designation sequence. We can |
bbd06336cd0c
(check_composing_code): If the current composing
Kenichi Handa <handa@m17n.org>
parents:
23315
diff
changeset
|
4239 surely skip the tail. But, if we have |
bbd06336cd0c
(check_composing_code): If the current composing
Kenichi Handa <handa@m17n.org>
parents:
23315
diff
changeset
|
4240 encountered an 8-bit code, skip only the codes |
bbd06336cd0c
(check_composing_code): If the current composing
Kenichi Handa <handa@m17n.org>
parents:
23315
diff
changeset
|
4241 after that. */ |
bbd06336cd0c
(check_composing_code): If the current composing
Kenichi Handa <handa@m17n.org>
parents:
23315
diff
changeset
|
4242 endp = eight_bit ? eight_bit : endp + 2; |
bbd06336cd0c
(check_composing_code): If the current composing
Kenichi Handa <handa@m17n.org>
parents:
23315
diff
changeset
|
4243 else |
bbd06336cd0c
(check_composing_code): If the current composing
Kenichi Handa <handa@m17n.org>
parents:
23315
diff
changeset
|
4244 /* Hmmm, we can't skip the tail. */ |
bbd06336cd0c
(check_composing_code): If the current composing
Kenichi Handa <handa@m17n.org>
parents:
23315
diff
changeset
|
4245 endp = endp_orig; |
bbd06336cd0c
(check_composing_code): If the current composing
Kenichi Handa <handa@m17n.org>
parents:
23315
diff
changeset
|
4246 } |
bbd06336cd0c
(check_composing_code): If the current composing
Kenichi Handa <handa@m17n.org>
parents:
23315
diff
changeset
|
4247 else if (eight_bit) |
bbd06336cd0c
(check_composing_code): If the current composing
Kenichi Handa <handa@m17n.org>
parents:
23315
diff
changeset
|
4248 endp = eight_bit; |
bbd06336cd0c
(check_composing_code): If the current composing
Kenichi Handa <handa@m17n.org>
parents:
23315
diff
changeset
|
4249 } |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4250 } |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4251 break; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4252 |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4253 default: |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4254 abort (); |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4255 } |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4256 *beg += begp - begp_orig; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4257 *end += endp - endp_orig; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4258 return; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4259 } |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4260 |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4261 /* Like shrink_decoding_region but for encoding. */ |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4262 |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4263 static void |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4264 shrink_encoding_region (beg, end, coding, str) |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4265 int *beg, *end; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4266 struct coding_system *coding; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4267 unsigned char *str; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4268 { |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4269 unsigned char *begp_orig, *begp, *endp_orig, *endp; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4270 int eol_conversion; |
23339
2da87b489590
(check_composing_code): Fix previous change. Now it
Kenichi Handa <handa@m17n.org>
parents:
23325
diff
changeset
|
4271 Lisp_Object translation_table; |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4272 |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4273 if (coding->type == coding_type_ccl |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4274 || coding->eol_type == CODING_EOL_CRLF |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4275 || coding->eol_type == CODING_EOL_CR |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4276 || coding->cmp_data && coding->cmp_data->used > 0) |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4277 { |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4278 /* We can't skip any data. */ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4279 return; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4280 } |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4281 if (coding->type == coding_type_no_conversion |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4282 || coding->type == coding_type_raw_text |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4283 || coding->type == coding_type_emacs_mule |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4284 || coding->type == coding_type_undecided) |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4285 { |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4286 /* We need no conversion, but don't have to skip any data here. |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4287 Encoding routine handles them effectively anyway. */ |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4288 return; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4289 } |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4290 |
23339
2da87b489590
(check_composing_code): Fix previous change. Now it
Kenichi Handa <handa@m17n.org>
parents:
23325
diff
changeset
|
4291 translation_table = coding->translation_table_for_encode; |
2da87b489590
(check_composing_code): Fix previous change. Now it
Kenichi Handa <handa@m17n.org>
parents:
23325
diff
changeset
|
4292 if (NILP (translation_table) && !NILP (Venable_character_translation)) |
2da87b489590
(check_composing_code): Fix previous change. Now it
Kenichi Handa <handa@m17n.org>
parents:
23325
diff
changeset
|
4293 translation_table = Vstandard_translation_table_for_encode; |
2da87b489590
(check_composing_code): Fix previous change. Now it
Kenichi Handa <handa@m17n.org>
parents:
23325
diff
changeset
|
4294 if (CHAR_TABLE_P (translation_table)) |
2da87b489590
(check_composing_code): Fix previous change. Now it
Kenichi Handa <handa@m17n.org>
parents:
23325
diff
changeset
|
4295 { |
2da87b489590
(check_composing_code): Fix previous change. Now it
Kenichi Handa <handa@m17n.org>
parents:
23325
diff
changeset
|
4296 int i; |
2da87b489590
(check_composing_code): Fix previous change. Now it
Kenichi Handa <handa@m17n.org>
parents:
23325
diff
changeset
|
4297 for (i = 0; i < 128; i++) |
2da87b489590
(check_composing_code): Fix previous change. Now it
Kenichi Handa <handa@m17n.org>
parents:
23325
diff
changeset
|
4298 if (!NILP (CHAR_TABLE_REF (translation_table, i))) |
2da87b489590
(check_composing_code): Fix previous change. Now it
Kenichi Handa <handa@m17n.org>
parents:
23325
diff
changeset
|
4299 break; |
2da87b489590
(check_composing_code): Fix previous change. Now it
Kenichi Handa <handa@m17n.org>
parents:
23325
diff
changeset
|
4300 if (i < 128) |
2da87b489590
(check_composing_code): Fix previous change. Now it
Kenichi Handa <handa@m17n.org>
parents:
23325
diff
changeset
|
4301 /* Some ASCII character should be tranlsated. We give up |
2da87b489590
(check_composing_code): Fix previous change. Now it
Kenichi Handa <handa@m17n.org>
parents:
23325
diff
changeset
|
4302 shrinking. */ |
2da87b489590
(check_composing_code): Fix previous change. Now it
Kenichi Handa <handa@m17n.org>
parents:
23325
diff
changeset
|
4303 return; |
2da87b489590
(check_composing_code): Fix previous change. Now it
Kenichi Handa <handa@m17n.org>
parents:
23325
diff
changeset
|
4304 } |
2da87b489590
(check_composing_code): Fix previous change. Now it
Kenichi Handa <handa@m17n.org>
parents:
23325
diff
changeset
|
4305 |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4306 if (str) |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4307 { |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4308 begp_orig = begp = str + *beg; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4309 endp_orig = endp = str + *end; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4310 } |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4311 else |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4312 { |
20931
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
4313 begp_orig = begp = BYTE_POS_ADDR (*beg); |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4314 endp_orig = endp = begp + *end - *beg; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4315 } |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4316 |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4317 eol_conversion = (coding->eol_type == CODING_EOL_CR |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4318 || coding->eol_type == CODING_EOL_CRLF); |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4319 |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4320 /* Here, we don't have to check coding->pre_write_conversion because |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4321 the caller is expected to have handled it already. */ |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4322 switch (coding->type) |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4323 { |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4324 case coding_type_iso2022: |
23426
088cb2a804c7
(shrink_decoding_region): If a charset other than ascii
Kenichi Handa <handa@m17n.org>
parents:
23402
diff
changeset
|
4325 if (CODING_SPEC_ISO_INITIAL_DESIGNATION (coding, 0) != CHARSET_ASCII) |
088cb2a804c7
(shrink_decoding_region): If a charset other than ascii
Kenichi Handa <handa@m17n.org>
parents:
23402
diff
changeset
|
4326 /* We can't skip any data. */ |
088cb2a804c7
(shrink_decoding_region): If a charset other than ascii
Kenichi Handa <handa@m17n.org>
parents:
23402
diff
changeset
|
4327 break; |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4328 if (coding->flags & CODING_FLAG_ISO_DESIGNATE_AT_BOL) |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4329 { |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4330 unsigned char *bol = begp; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4331 while (begp < endp && *begp < 0x80) |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4332 { |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4333 begp++; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4334 if (begp[-1] == '\n') |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4335 bol = begp; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4336 } |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4337 begp = bol; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4338 goto label_skip_tail; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4339 } |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4340 /* fall down ... */ |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4341 |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4342 case coding_type_sjis: |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4343 case coding_type_big5: |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4344 /* We can skip all ASCII characters at the head and tail. */ |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4345 if (eol_conversion) |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4346 while (begp < endp && *begp < 0x80 && *begp != '\n') begp++; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4347 else |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4348 while (begp < endp && *begp < 0x80) begp++; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4349 label_skip_tail: |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4350 if (eol_conversion) |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4351 while (begp < endp && endp[-1] < 0x80 && endp[-1] != '\n') endp--; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4352 else |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4353 while (begp < endp && *(endp - 1) < 0x80) endp--; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4354 break; |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4355 |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4356 default: |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4357 abort (); |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4358 } |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4359 |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4360 *beg += begp - begp_orig; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4361 *end += endp - endp_orig; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4362 return; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4363 } |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4364 |
23339
2da87b489590
(check_composing_code): Fix previous change. Now it
Kenichi Handa <handa@m17n.org>
parents:
23325
diff
changeset
|
4365 /* As shrinking conversion region requires some overhead, we don't try |
2da87b489590
(check_composing_code): Fix previous change. Now it
Kenichi Handa <handa@m17n.org>
parents:
23325
diff
changeset
|
4366 shrinking if the length of conversion region is less than this |
2da87b489590
(check_composing_code): Fix previous change. Now it
Kenichi Handa <handa@m17n.org>
parents:
23325
diff
changeset
|
4367 value. */ |
2da87b489590
(check_composing_code): Fix previous change. Now it
Kenichi Handa <handa@m17n.org>
parents:
23325
diff
changeset
|
4368 static int shrink_conversion_region_threshhold = 1024; |
2da87b489590
(check_composing_code): Fix previous change. Now it
Kenichi Handa <handa@m17n.org>
parents:
23325
diff
changeset
|
4369 |
2da87b489590
(check_composing_code): Fix previous change. Now it
Kenichi Handa <handa@m17n.org>
parents:
23325
diff
changeset
|
4370 #define SHRINK_CONVERSION_REGION(beg, end, coding, str, encodep) \ |
2da87b489590
(check_composing_code): Fix previous change. Now it
Kenichi Handa <handa@m17n.org>
parents:
23325
diff
changeset
|
4371 do { \ |
2da87b489590
(check_composing_code): Fix previous change. Now it
Kenichi Handa <handa@m17n.org>
parents:
23325
diff
changeset
|
4372 if (*(end) - *(beg) > shrink_conversion_region_threshhold) \ |
2da87b489590
(check_composing_code): Fix previous change. Now it
Kenichi Handa <handa@m17n.org>
parents:
23325
diff
changeset
|
4373 { \ |
2da87b489590
(check_composing_code): Fix previous change. Now it
Kenichi Handa <handa@m17n.org>
parents:
23325
diff
changeset
|
4374 if (encodep) shrink_encoding_region (beg, end, coding, str); \ |
2da87b489590
(check_composing_code): Fix previous change. Now it
Kenichi Handa <handa@m17n.org>
parents:
23325
diff
changeset
|
4375 else shrink_decoding_region (beg, end, coding, str); \ |
2da87b489590
(check_composing_code): Fix previous change. Now it
Kenichi Handa <handa@m17n.org>
parents:
23325
diff
changeset
|
4376 } \ |
2da87b489590
(check_composing_code): Fix previous change. Now it
Kenichi Handa <handa@m17n.org>
parents:
23325
diff
changeset
|
4377 } while (0) |
2da87b489590
(check_composing_code): Fix previous change. Now it
Kenichi Handa <handa@m17n.org>
parents:
23325
diff
changeset
|
4378 |
26067
f54ca66e2571
(code_convert_string): Add record_unwind_protect to
Kenichi Handa <handa@m17n.org>
parents:
25860
diff
changeset
|
4379 static Lisp_Object |
f54ca66e2571
(code_convert_string): Add record_unwind_protect to
Kenichi Handa <handa@m17n.org>
parents:
25860
diff
changeset
|
4380 code_convert_region_unwind (dummy) |
f54ca66e2571
(code_convert_string): Add record_unwind_protect to
Kenichi Handa <handa@m17n.org>
parents:
25860
diff
changeset
|
4381 Lisp_Object dummy; |
f54ca66e2571
(code_convert_string): Add record_unwind_protect to
Kenichi Handa <handa@m17n.org>
parents:
25860
diff
changeset
|
4382 { |
f54ca66e2571
(code_convert_string): Add record_unwind_protect to
Kenichi Handa <handa@m17n.org>
parents:
25860
diff
changeset
|
4383 inhibit_pre_post_conversion = 0; |
f54ca66e2571
(code_convert_string): Add record_unwind_protect to
Kenichi Handa <handa@m17n.org>
parents:
25860
diff
changeset
|
4384 return Qnil; |
f54ca66e2571
(code_convert_string): Add record_unwind_protect to
Kenichi Handa <handa@m17n.org>
parents:
25860
diff
changeset
|
4385 } |
f54ca66e2571
(code_convert_string): Add record_unwind_protect to
Kenichi Handa <handa@m17n.org>
parents:
25860
diff
changeset
|
4386 |
26847 | 4387 /* Store information about all compositions in the range FROM and TO |
4388 of OBJ in memory blocks pointed by CODING->cmp_data. OBJ is a | |
4389 buffer or a string, defaults to the current buffer. */ | |
4390 | |
4391 void | |
4392 coding_save_composition (coding, from, to, obj) | |
4393 struct coding_system *coding; | |
4394 int from, to; | |
4395 Lisp_Object obj; | |
4396 { | |
4397 Lisp_Object prop; | |
4398 int start, end; | |
4399 | |
27943
c2e0998057f9
(coding_save_composition): Be sure to allocate
Kenichi Handa <handa@m17n.org>
parents:
27271
diff
changeset
|
4400 if (coding->composing == COMPOSITION_DISABLED) |
c2e0998057f9
(coding_save_composition): Be sure to allocate
Kenichi Handa <handa@m17n.org>
parents:
27271
diff
changeset
|
4401 return; |
c2e0998057f9
(coding_save_composition): Be sure to allocate
Kenichi Handa <handa@m17n.org>
parents:
27271
diff
changeset
|
4402 if (!coding->cmp_data) |
c2e0998057f9
(coding_save_composition): Be sure to allocate
Kenichi Handa <handa@m17n.org>
parents:
27271
diff
changeset
|
4403 coding_allocate_composition_data (coding, from); |
26847 | 4404 if (!find_composition (from, to, &start, &end, &prop, obj) |
4405 || end > to) | |
4406 return; | |
4407 if (start < from | |
4408 && (!find_composition (end, to, &start, &end, &prop, obj) | |
4409 || end > to)) | |
4410 return; | |
4411 coding->composing = COMPOSITION_NO; | |
4412 do | |
4413 { | |
4414 if (COMPOSITION_VALID_P (start, end, prop)) | |
4415 { | |
4416 enum composition_method method = COMPOSITION_METHOD (prop); | |
4417 if (coding->cmp_data->used + COMPOSITION_DATA_MAX_BUNCH_LENGTH | |
4418 >= COMPOSITION_DATA_SIZE) | |
4419 coding_allocate_composition_data (coding, from); | |
4420 /* For relative composition, we remember start and end | |
4421 positions, for the other compositions, we also remember | |
4422 components. */ | |
4423 CODING_ADD_COMPOSITION_START (coding, start - from, method); | |
4424 if (method != COMPOSITION_RELATIVE) | |
4425 { | |
4426 /* We must store a*/ | |
4427 Lisp_Object val, ch; | |
4428 | |
4429 val = COMPOSITION_COMPONENTS (prop); | |
4430 if (CONSP (val)) | |
4431 while (CONSP (val)) | |
4432 { | |
4433 ch = XCAR (val), val = XCDR (val); | |
4434 CODING_ADD_COMPOSITION_COMPONENT (coding, XINT (ch)); | |
4435 } | |
4436 else if (VECTORP (val) || STRINGP (val)) | |
4437 { | |
4438 int len = (VECTORP (val) | |
4439 ? XVECTOR (val)->size : XSTRING (val)->size); | |
4440 int i; | |
4441 for (i = 0; i < len; i++) | |
4442 { | |
4443 ch = (STRINGP (val) | |
4444 ? Faref (val, make_number (i)) | |
4445 : XVECTOR (val)->contents[i]); | |
4446 CODING_ADD_COMPOSITION_COMPONENT (coding, XINT (ch)); | |
4447 } | |
4448 } | |
4449 else /* INTEGERP (val) */ | |
4450 CODING_ADD_COMPOSITION_COMPONENT (coding, XINT (val)); | |
4451 } | |
4452 CODING_ADD_COMPOSITION_END (coding, end - from); | |
4453 } | |
4454 start = end; | |
4455 } | |
4456 while (start < to | |
4457 && find_composition (start, to, &start, &end, &prop, obj) | |
4458 && end <= to); | |
4459 | |
4460 /* Make coding->cmp_data point to the first memory block. */ | |
4461 while (coding->cmp_data->prev) | |
4462 coding->cmp_data = coding->cmp_data->prev; | |
4463 coding->cmp_data_start = 0; | |
4464 } | |
4465 | |
4466 /* Reflect the saved information about compositions to OBJ. | |
4467 CODING->cmp_data points to a memory block for the informaiton. OBJ | |
4468 is a buffer or a string, defaults to the current buffer. */ | |
4469 | |
29275
b4ea9178e480
(DECODE_COMPOSITION_START): If coding->cmp_data is not
Kenichi Handa <handa@m17n.org>
parents:
29247
diff
changeset
|
4470 void |
26847 | 4471 coding_restore_composition (coding, obj) |
4472 struct coding_system *coding; | |
4473 Lisp_Object obj; | |
4474 { | |
4475 struct composition_data *cmp_data = coding->cmp_data; | |
4476 | |
4477 if (!cmp_data) | |
4478 return; | |
4479 | |
4480 while (cmp_data->prev) | |
4481 cmp_data = cmp_data->prev; | |
4482 | |
4483 while (cmp_data) | |
4484 { | |
4485 int i; | |
4486 | |
4487 for (i = 0; i < cmp_data->used; i += cmp_data->data[i]) | |
4488 { | |
4489 int *data = cmp_data->data + i; | |
4490 enum composition_method method = (enum composition_method) data[3]; | |
4491 Lisp_Object components; | |
4492 | |
4493 if (method == COMPOSITION_RELATIVE) | |
4494 components = Qnil; | |
4495 else | |
4496 { | |
4497 int len = data[0] - 4, j; | |
4498 Lisp_Object args[MAX_COMPOSITION_COMPONENTS * 2 - 1]; | |
4499 | |
4500 for (j = 0; j < len; j++) | |
4501 args[j] = make_number (data[4 + j]); | |
4502 components = (method == COMPOSITION_WITH_ALTCHARS | |
4503 ? Fstring (len, args) : Fvector (len, args)); | |
4504 } | |
4505 compose_text (data[1], data[2], components, Qnil, obj); | |
4506 } | |
4507 cmp_data = cmp_data->next; | |
4508 } | |
4509 } | |
4510 | |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4511 /* Decode (if ENCODEP is zero) or encode (if ENCODEP is nonzero) the |
20931
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
4512 text from FROM to TO (byte positions are FROM_BYTE and TO_BYTE) by |
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
4513 coding system CODING, and return the status code of code conversion |
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
4514 (currently, this value has no meaning). |
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
4515 |
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
4516 How many characters (and bytes) are converted to how many |
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
4517 characters (and bytes) are recorded in members of the structure |
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
4518 CODING. |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4519 |
21190
d704dd953837
(code_convert_region): The 6th arg name is changed to
Kenichi Handa <handa@m17n.org>
parents:
21140
diff
changeset
|
4520 If REPLACE is nonzero, we do various things as if the original text |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4521 is deleted and a new text is inserted. See the comments in |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4522 replace_range (insdel.c) to know what we are doing. |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4523 |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4524 If REPLACE is zero, it is assumed that the source text is unibyte. |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4525 Otherwize, it is assumed that the source text is multibyte. */ |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4526 |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4527 int |
21190
d704dd953837
(code_convert_region): The 6th arg name is changed to
Kenichi Handa <handa@m17n.org>
parents:
21140
diff
changeset
|
4528 code_convert_region (from, from_byte, to, to_byte, coding, encodep, replace) |
d704dd953837
(code_convert_region): The 6th arg name is changed to
Kenichi Handa <handa@m17n.org>
parents:
21140
diff
changeset
|
4529 int from, from_byte, to, to_byte, encodep, replace; |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4530 struct coding_system *coding; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4531 { |
20931
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
4532 int len = to - from, len_byte = to_byte - from_byte; |
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
4533 int require, inserted, inserted_byte; |
27271
7b495b311f18
(code_convert_region): Initialize total_skip.
Andreas Schwab <schwab@suse.de>
parents:
26900
diff
changeset
|
4534 int head_skip, tail_skip, total_skip = 0; |
22954
928b337d953b
Avoid using initializers for Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents:
22874
diff
changeset
|
4535 Lisp_Object saved_coding_symbol; |
20931
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
4536 int first = 1; |
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
4537 unsigned char *src, *dst; |
22954
928b337d953b
Avoid using initializers for Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents:
22874
diff
changeset
|
4538 Lisp_Object deletion; |
23514
7bad909cd6f1
(setup_coding_system): Fix setting up
Kenichi Handa <handa@m17n.org>
parents:
23475
diff
changeset
|
4539 int orig_point = PT, orig_len = len; |
23537
28cd5faf93dd
(code_convert_region): While preserving the orignal
Kenichi Handa <handa@m17n.org>
parents:
23514
diff
changeset
|
4540 int prev_Z; |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4541 int multibyte_p = !NILP (current_buffer->enable_multibyte_characters); |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4542 |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4543 coding->src_multibyte = replace && multibyte_p; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4544 coding->dst_multibyte = multibyte_p; |
22954
928b337d953b
Avoid using initializers for Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents:
22874
diff
changeset
|
4545 |
928b337d953b
Avoid using initializers for Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents:
22874
diff
changeset
|
4546 deletion = Qnil; |
928b337d953b
Avoid using initializers for Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents:
22874
diff
changeset
|
4547 saved_coding_symbol = Qnil; |
21190
d704dd953837
(code_convert_region): The 6th arg name is changed to
Kenichi Handa <handa@m17n.org>
parents:
21140
diff
changeset
|
4548 |
21576
8043d47984fd
(code_convert_region): If point in the conversion
Kenichi Handa <handa@m17n.org>
parents:
21574
diff
changeset
|
4549 if (from < PT && PT < to) |
23514
7bad909cd6f1
(setup_coding_system): Fix setting up
Kenichi Handa <handa@m17n.org>
parents:
23475
diff
changeset
|
4550 { |
7bad909cd6f1
(setup_coding_system): Fix setting up
Kenichi Handa <handa@m17n.org>
parents:
23475
diff
changeset
|
4551 TEMP_SET_PT_BOTH (from, from_byte); |
7bad909cd6f1
(setup_coding_system): Fix setting up
Kenichi Handa <handa@m17n.org>
parents:
23475
diff
changeset
|
4552 orig_point = from; |
7bad909cd6f1
(setup_coding_system): Fix setting up
Kenichi Handa <handa@m17n.org>
parents:
23475
diff
changeset
|
4553 } |
21576
8043d47984fd
(code_convert_region): If point in the conversion
Kenichi Handa <handa@m17n.org>
parents:
21574
diff
changeset
|
4554 |
21190
d704dd953837
(code_convert_region): The 6th arg name is changed to
Kenichi Handa <handa@m17n.org>
parents:
21140
diff
changeset
|
4555 if (replace) |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4556 { |
20931
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
4557 int saved_from = from; |
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
4558 |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4559 prepare_to_modify_buffer (from, to, &from); |
20931
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
4560 if (saved_from != from) |
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
4561 { |
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
4562 to = from + len; |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4563 from_byte = CHAR_TO_BYTE (from), to_byte = CHAR_TO_BYTE (to); |
20931
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
4564 len_byte = to_byte - from_byte; |
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
4565 } |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4566 } |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4567 |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4568 if (! encodep && CODING_REQUIRE_DETECTION (coding)) |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4569 { |
21321
27b08da98abe
(code_convert_region): Handle skipped ASCII characters
Kenichi Handa <handa@m17n.org>
parents:
21308
diff
changeset
|
4570 /* We must detect encoding of text and eol format. */ |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4571 |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4572 if (from < GPT && to > GPT) |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4573 move_gap_both (from, from_byte); |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4574 if (coding->type == coding_type_undecided) |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4575 { |
20931
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
4576 detect_coding (coding, BYTE_POS_ADDR (from_byte), len_byte); |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4577 if (coding->type == coding_type_undecided) |
21321
27b08da98abe
(code_convert_region): Handle skipped ASCII characters
Kenichi Handa <handa@m17n.org>
parents:
21308
diff
changeset
|
4578 /* It seems that the text contains only ASCII, but we |
27b08da98abe
(code_convert_region): Handle skipped ASCII characters
Kenichi Handa <handa@m17n.org>
parents:
21308
diff
changeset
|
4579 should not left it undecided because the deeper |
27b08da98abe
(code_convert_region): Handle skipped ASCII characters
Kenichi Handa <handa@m17n.org>
parents:
21308
diff
changeset
|
4580 decoding routine (decode_coding) tries to detect the |
27b08da98abe
(code_convert_region): Handle skipped ASCII characters
Kenichi Handa <handa@m17n.org>
parents:
21308
diff
changeset
|
4581 encodings again in vain. */ |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4582 coding->type = coding_type_emacs_mule; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4583 } |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4584 if (coding->eol_type == CODING_EOL_UNDECIDED) |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4585 { |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4586 saved_coding_symbol = coding->symbol; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4587 detect_eol (coding, BYTE_POS_ADDR (from_byte), len_byte); |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4588 if (coding->eol_type == CODING_EOL_UNDECIDED) |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4589 coding->eol_type = CODING_EOL_LF; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4590 /* We had better recover the original eol format if we |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4591 encounter an inconsitent eol format while decoding. */ |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4592 coding->mode |= CODING_MODE_INHIBIT_INCONSISTENT_EOL; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4593 } |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4594 } |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4595 |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4596 /* Now we convert the text. */ |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4597 |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4598 /* For encoding, we must process pre-write-conversion in advance. */ |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4599 if (! inhibit_pre_post_conversion |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4600 && encodep |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4601 && SYMBOLP (coding->pre_write_conversion) |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4602 && ! NILP (Ffboundp (coding->pre_write_conversion))) |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4603 { |
21140
179c73d91f70
(code_convert_region): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
21132
diff
changeset
|
4604 /* The function in pre-write-conversion may put a new text in a |
179c73d91f70
(code_convert_region): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
21132
diff
changeset
|
4605 new buffer. */ |
23542
eaf358b2e8dd
(code_convert_region): Kill the work buffer created by
Kenichi Handa <handa@m17n.org>
parents:
23537
diff
changeset
|
4606 struct buffer *prev = current_buffer; |
eaf358b2e8dd
(code_convert_region): Kill the work buffer created by
Kenichi Handa <handa@m17n.org>
parents:
23537
diff
changeset
|
4607 Lisp_Object new; |
26067
f54ca66e2571
(code_convert_string): Add record_unwind_protect to
Kenichi Handa <handa@m17n.org>
parents:
25860
diff
changeset
|
4608 int count = specpdl_ptr - specpdl; |
f54ca66e2571
(code_convert_string): Add record_unwind_protect to
Kenichi Handa <handa@m17n.org>
parents:
25860
diff
changeset
|
4609 |
f54ca66e2571
(code_convert_string): Add record_unwind_protect to
Kenichi Handa <handa@m17n.org>
parents:
25860
diff
changeset
|
4610 record_unwind_protect (code_convert_region_unwind, Qnil); |
f54ca66e2571
(code_convert_string): Add record_unwind_protect to
Kenichi Handa <handa@m17n.org>
parents:
25860
diff
changeset
|
4611 /* We should not call any more pre-write/post-read-conversion |
f54ca66e2571
(code_convert_string): Add record_unwind_protect to
Kenichi Handa <handa@m17n.org>
parents:
25860
diff
changeset
|
4612 functions while this pre-write-conversion is running. */ |
f54ca66e2571
(code_convert_string): Add record_unwind_protect to
Kenichi Handa <handa@m17n.org>
parents:
25860
diff
changeset
|
4613 inhibit_pre_post_conversion = 1; |
21520
ca4819c36ab9
(code_convert_region): Fix mixing of Lisp_Object and
Andreas Schwab <schwab@suse.de>
parents:
21514
diff
changeset
|
4614 call2 (coding->pre_write_conversion, |
ca4819c36ab9
(code_convert_region): Fix mixing of Lisp_Object and
Andreas Schwab <schwab@suse.de>
parents:
21514
diff
changeset
|
4615 make_number (from), make_number (to)); |
26067
f54ca66e2571
(code_convert_string): Add record_unwind_protect to
Kenichi Handa <handa@m17n.org>
parents:
25860
diff
changeset
|
4616 inhibit_pre_post_conversion = 0; |
f54ca66e2571
(code_convert_string): Add record_unwind_protect to
Kenichi Handa <handa@m17n.org>
parents:
25860
diff
changeset
|
4617 /* Discard the unwind protect. */ |
f54ca66e2571
(code_convert_string): Add record_unwind_protect to
Kenichi Handa <handa@m17n.org>
parents:
25860
diff
changeset
|
4618 specpdl_ptr--; |
f54ca66e2571
(code_convert_string): Add record_unwind_protect to
Kenichi Handa <handa@m17n.org>
parents:
25860
diff
changeset
|
4619 |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4620 if (current_buffer != prev) |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4621 { |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4622 len = ZV - BEGV; |
23542
eaf358b2e8dd
(code_convert_region): Kill the work buffer created by
Kenichi Handa <handa@m17n.org>
parents:
23537
diff
changeset
|
4623 new = Fcurrent_buffer (); |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4624 set_buffer_internal_1 (prev); |
26742
936b39bd05b4
* editfns.c (Fdelete_and_extract_region): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
26526
diff
changeset
|
4625 del_range_2 (from, from_byte, to, to_byte, 0); |
23514
7bad909cd6f1
(setup_coding_system): Fix setting up
Kenichi Handa <handa@m17n.org>
parents:
23475
diff
changeset
|
4626 TEMP_SET_PT_BOTH (from, from_byte); |
23542
eaf358b2e8dd
(code_convert_region): Kill the work buffer created by
Kenichi Handa <handa@m17n.org>
parents:
23537
diff
changeset
|
4627 insert_from_buffer (XBUFFER (new), 1, len, 0); |
eaf358b2e8dd
(code_convert_region): Kill the work buffer created by
Kenichi Handa <handa@m17n.org>
parents:
23537
diff
changeset
|
4628 Fkill_buffer (new); |
23514
7bad909cd6f1
(setup_coding_system): Fix setting up
Kenichi Handa <handa@m17n.org>
parents:
23475
diff
changeset
|
4629 if (orig_point >= to) |
7bad909cd6f1
(setup_coding_system): Fix setting up
Kenichi Handa <handa@m17n.org>
parents:
23475
diff
changeset
|
4630 orig_point += len - orig_len; |
7bad909cd6f1
(setup_coding_system): Fix setting up
Kenichi Handa <handa@m17n.org>
parents:
23475
diff
changeset
|
4631 else if (orig_point > from) |
7bad909cd6f1
(setup_coding_system): Fix setting up
Kenichi Handa <handa@m17n.org>
parents:
23475
diff
changeset
|
4632 orig_point = from; |
7bad909cd6f1
(setup_coding_system): Fix setting up
Kenichi Handa <handa@m17n.org>
parents:
23475
diff
changeset
|
4633 orig_len = len; |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4634 to = from + len; |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4635 from_byte = CHAR_TO_BYTE (from); |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4636 to_byte = CHAR_TO_BYTE (to); |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4637 len_byte = to_byte - from_byte; |
23514
7bad909cd6f1
(setup_coding_system): Fix setting up
Kenichi Handa <handa@m17n.org>
parents:
23475
diff
changeset
|
4638 TEMP_SET_PT_BOTH (from, from_byte); |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4639 } |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4640 } |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4641 |
21321
27b08da98abe
(code_convert_region): Handle skipped ASCII characters
Kenichi Handa <handa@m17n.org>
parents:
21308
diff
changeset
|
4642 if (replace) |
27b08da98abe
(code_convert_region): Handle skipped ASCII characters
Kenichi Handa <handa@m17n.org>
parents:
21308
diff
changeset
|
4643 deletion = make_buffer_string_both (from, from_byte, to, to_byte, 1); |
27b08da98abe
(code_convert_region): Handle skipped ASCII characters
Kenichi Handa <handa@m17n.org>
parents:
21308
diff
changeset
|
4644 |
26847 | 4645 if (coding->composing != COMPOSITION_DISABLED) |
4646 { | |
4647 if (encodep) | |
4648 coding_save_composition (coding, from, to, Fcurrent_buffer ()); | |
4649 else | |
4650 coding_allocate_composition_data (coding, from); | |
4651 } | |
4652 | |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4653 /* Try to skip the heading and tailing ASCIIs. */ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4654 { |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4655 int from_byte_orig = from_byte, to_byte_orig = to_byte; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4656 |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4657 if (from < GPT && GPT < to) |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4658 move_gap_both (from, from_byte); |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4659 SHRINK_CONVERSION_REGION (&from_byte, &to_byte, coding, NULL, encodep); |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4660 if (from_byte == to_byte |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4661 && (encodep || NILP (coding->post_read_conversion)) |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4662 && ! CODING_REQUIRE_FLUSHING (coding)) |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4663 { |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4664 coding->produced = len_byte; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4665 coding->produced_char = len; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4666 if (!replace) |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4667 /* We must record and adjust for this new text now. */ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4668 adjust_after_insert (from, from_byte_orig, to, to_byte_orig, len); |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4669 return 0; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4670 } |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4671 |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4672 head_skip = from_byte - from_byte_orig; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4673 tail_skip = to_byte_orig - to_byte; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4674 total_skip = head_skip + tail_skip; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4675 from += head_skip; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4676 to -= tail_skip; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4677 len -= total_skip; len_byte -= total_skip; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4678 } |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4679 |
23339
2da87b489590
(check_composing_code): Fix previous change. Now it
Kenichi Handa <handa@m17n.org>
parents:
23325
diff
changeset
|
4680 /* The code conversion routine can not preserve text properties for |
23402
6905813a49c6
(code_convert_region): Set inhibit_modification_hooks
Kenichi Handa <handa@m17n.org>
parents:
23339
diff
changeset
|
4681 now. So, we must remove all text properties in the region. |
6905813a49c6
(code_convert_region): Set inhibit_modification_hooks
Kenichi Handa <handa@m17n.org>
parents:
23339
diff
changeset
|
4682 Here, we must suppress all modification hooks. */ |
23339
2da87b489590
(check_composing_code): Fix previous change. Now it
Kenichi Handa <handa@m17n.org>
parents:
23325
diff
changeset
|
4683 if (replace) |
23402
6905813a49c6
(code_convert_region): Set inhibit_modification_hooks
Kenichi Handa <handa@m17n.org>
parents:
23339
diff
changeset
|
4684 { |
6905813a49c6
(code_convert_region): Set inhibit_modification_hooks
Kenichi Handa <handa@m17n.org>
parents:
23339
diff
changeset
|
4685 int saved_inhibit_modification_hooks = inhibit_modification_hooks; |
6905813a49c6
(code_convert_region): Set inhibit_modification_hooks
Kenichi Handa <handa@m17n.org>
parents:
23339
diff
changeset
|
4686 inhibit_modification_hooks = 1; |
6905813a49c6
(code_convert_region): Set inhibit_modification_hooks
Kenichi Handa <handa@m17n.org>
parents:
23339
diff
changeset
|
4687 Fset_text_properties (make_number (from), make_number (to), Qnil, Qnil); |
6905813a49c6
(code_convert_region): Set inhibit_modification_hooks
Kenichi Handa <handa@m17n.org>
parents:
23339
diff
changeset
|
4688 inhibit_modification_hooks = saved_inhibit_modification_hooks; |
6905813a49c6
(code_convert_region): Set inhibit_modification_hooks
Kenichi Handa <handa@m17n.org>
parents:
23339
diff
changeset
|
4689 } |
23339
2da87b489590
(check_composing_code): Fix previous change. Now it
Kenichi Handa <handa@m17n.org>
parents:
23325
diff
changeset
|
4690 |
20931
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
4691 /* For converion, we must put the gap before the text in addition to |
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
4692 making the gap larger for efficient decoding. The required gap |
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
4693 size starts from 2000 which is the magic number used in make_gap. |
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
4694 But, after one batch of conversion, it will be incremented if we |
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
4695 find that it is not enough . */ |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4696 require = 2000; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4697 |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4698 if (GAP_SIZE < require) |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4699 make_gap (require - GAP_SIZE); |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4700 move_gap_both (from, from_byte); |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4701 |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4702 inserted = inserted_byte = 0; |
20931
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
4703 |
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
4704 GAP_SIZE += len_byte; |
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
4705 ZV -= len; |
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
4706 Z -= len; |
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
4707 ZV_BYTE -= len_byte; |
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
4708 Z_BYTE -= len_byte; |
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
4709 |
25370
20d8158841b0
(code_convert_region): Compute beg/end_unchanged per
Gerd Moellmann <gerd@gnu.org>
parents:
25067
diff
changeset
|
4710 if (GPT - BEG < BEG_UNCHANGED) |
20d8158841b0
(code_convert_region): Compute beg/end_unchanged per
Gerd Moellmann <gerd@gnu.org>
parents:
25067
diff
changeset
|
4711 BEG_UNCHANGED = GPT - BEG; |
20d8158841b0
(code_convert_region): Compute beg/end_unchanged per
Gerd Moellmann <gerd@gnu.org>
parents:
25067
diff
changeset
|
4712 if (Z - GPT < END_UNCHANGED) |
20d8158841b0
(code_convert_region): Compute beg/end_unchanged per
Gerd Moellmann <gerd@gnu.org>
parents:
25067
diff
changeset
|
4713 END_UNCHANGED = Z - GPT; |
23258
2f8585bcea90
(code_convert_region): Update beg_unchanged and
Kenichi Handa <handa@m17n.org>
parents:
23201
diff
changeset
|
4714 |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4715 if (!encodep && coding->src_multibyte) |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4716 { |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4717 /* Decoding routines expects that the source text is unibyte. |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4718 We must convert 8-bit characters of multibyte form to |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4719 unibyte. */ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4720 int len_byte_orig = len_byte; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4721 len_byte = str_as_unibyte (GAP_END_ADDR - len_byte, len_byte); |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4722 if (len_byte < len_byte_orig) |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4723 safe_bcopy (GAP_END_ADDR - len_byte_orig, GAP_END_ADDR - len_byte, |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4724 len_byte); |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4725 coding->src_multibyte = 0; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4726 } |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4727 |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4728 for (;;) |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4729 { |
20931
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
4730 int result; |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4731 |
26847 | 4732 /* The buffer memory is now: |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4733 +--------+converted-text+---------+-------original-text-------+---+ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4734 |<-from->|<--inserted-->|---------|<--------len_byte--------->|---| |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4735 |<---------------------- GAP ----------------------->| */ |
26847 | 4736 src = GAP_END_ADDR - len_byte; |
4737 dst = GPT_ADDR + inserted_byte; | |
4738 | |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4739 if (encodep) |
20931
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
4740 result = encode_coding (coding, src, dst, len_byte, 0); |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4741 else |
20931
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
4742 result = decode_coding (coding, src, dst, len_byte, 0); |
26847 | 4743 |
4744 /* The buffer memory is now: | |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4745 +--------+-------converted-text----+--+------original-text----+---+ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4746 |<-from->|<-inserted->|<-produced->|--|<-(len_byte-consumed)->|---| |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4747 |<---------------------- GAP ----------------------->| */ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4748 |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4749 inserted += coding->produced_char; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4750 inserted_byte += coding->produced; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4751 len_byte -= coding->consumed; |
26847 | 4752 |
4753 if (result == CODING_FINISH_INSUFFICIENT_CMP) | |
4754 { | |
4755 coding_allocate_composition_data (coding, from + inserted); | |
4756 continue; | |
4757 } | |
4758 | |
20931
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
4759 src += coding->consumed; |
26240
93f3d2337323
(code_convert_region): Update `dst' correctly.
Kenichi Handa <handa@m17n.org>
parents:
26088
diff
changeset
|
4760 dst += coding->produced; |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4761 |
23279
ca159e828a68
(ccl_coding_driver): If ccl_driver is interrupted by a
Kenichi Handa <handa@m17n.org>
parents:
23258
diff
changeset
|
4762 if (result == CODING_FINISH_NORMAL) |
ca159e828a68
(ccl_coding_driver): If ccl_driver is interrupted by a
Kenichi Handa <handa@m17n.org>
parents:
23258
diff
changeset
|
4763 { |
ca159e828a68
(ccl_coding_driver): If ccl_driver is interrupted by a
Kenichi Handa <handa@m17n.org>
parents:
23258
diff
changeset
|
4764 src += len_byte; |
ca159e828a68
(ccl_coding_driver): If ccl_driver is interrupted by a
Kenichi Handa <handa@m17n.org>
parents:
23258
diff
changeset
|
4765 break; |
ca159e828a68
(ccl_coding_driver): If ccl_driver is interrupted by a
Kenichi Handa <handa@m17n.org>
parents:
23258
diff
changeset
|
4766 } |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4767 if (! encodep && result == CODING_FINISH_INCONSISTENT_EOL) |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4768 { |
20931
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
4769 unsigned char *pend = dst, *p = pend - inserted_byte; |
24706
778b3f056f7f
(code_convert_region): If eol format is inconsistent,
Kenichi Handa <handa@m17n.org>
parents:
24667
diff
changeset
|
4770 Lisp_Object eol_type; |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4771 |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4772 /* Encode LFs back to the original eol format (CR or CRLF). */ |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4773 if (coding->eol_type == CODING_EOL_CR) |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4774 { |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4775 while (p < pend) if (*p++ == '\n') p[-1] = '\r'; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4776 } |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4777 else |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4778 { |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4779 int count = 0; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4780 |
20931
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
4781 while (p < pend) if (*p++ == '\n') count++; |
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
4782 if (src - dst < count) |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4783 { |
24706
778b3f056f7f
(code_convert_region): If eol format is inconsistent,
Kenichi Handa <handa@m17n.org>
parents:
24667
diff
changeset
|
4784 /* We don't have sufficient room for encoding LFs |
20931
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
4785 back to CRLF. We must record converted and |
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
4786 not-yet-converted text back to the buffer |
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
4787 content, enlarge the gap, then record them out of |
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
4788 the buffer contents again. */ |
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
4789 int add = len_byte + inserted_byte; |
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
4790 |
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
4791 GAP_SIZE -= add; |
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
4792 ZV += add; Z += add; ZV_BYTE += add; Z_BYTE += add; |
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
4793 GPT += inserted_byte; GPT_BYTE += inserted_byte; |
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
4794 make_gap (count - GAP_SIZE); |
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
4795 GAP_SIZE += add; |
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
4796 ZV -= add; Z -= add; ZV_BYTE -= add; Z_BYTE -= add; |
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
4797 GPT -= inserted_byte; GPT_BYTE -= inserted_byte; |
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
4798 /* Don't forget to update SRC, DST, and PEND. */ |
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
4799 src = GAP_END_ADDR - len_byte; |
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
4800 dst = GPT_ADDR + inserted_byte; |
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
4801 pend = dst; |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4802 } |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4803 inserted += count; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4804 inserted_byte += count; |
20931
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
4805 coding->produced += count; |
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
4806 p = dst = pend + count; |
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
4807 while (count) |
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
4808 { |
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
4809 *--p = *--pend; |
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
4810 if (*p == '\n') count--, *--p = '\r'; |
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
4811 } |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4812 } |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4813 |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4814 /* Suppress eol-format conversion in the further conversion. */ |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4815 coding->eol_type = CODING_EOL_LF; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4816 |
24706
778b3f056f7f
(code_convert_region): If eol format is inconsistent,
Kenichi Handa <handa@m17n.org>
parents:
24667
diff
changeset
|
4817 /* Set the coding system symbol to that for Unix-like EOL. */ |
778b3f056f7f
(code_convert_region): If eol format is inconsistent,
Kenichi Handa <handa@m17n.org>
parents:
24667
diff
changeset
|
4818 eol_type = Fget (saved_coding_symbol, Qeol_type); |
778b3f056f7f
(code_convert_region): If eol format is inconsistent,
Kenichi Handa <handa@m17n.org>
parents:
24667
diff
changeset
|
4819 if (VECTORP (eol_type) |
778b3f056f7f
(code_convert_region): If eol format is inconsistent,
Kenichi Handa <handa@m17n.org>
parents:
24667
diff
changeset
|
4820 && XVECTOR (eol_type)->size == 3 |
778b3f056f7f
(code_convert_region): If eol format is inconsistent,
Kenichi Handa <handa@m17n.org>
parents:
24667
diff
changeset
|
4821 && SYMBOLP (XVECTOR (eol_type)->contents[CODING_EOL_LF])) |
778b3f056f7f
(code_convert_region): If eol format is inconsistent,
Kenichi Handa <handa@m17n.org>
parents:
24667
diff
changeset
|
4822 coding->symbol = XVECTOR (eol_type)->contents[CODING_EOL_LF]; |
778b3f056f7f
(code_convert_region): If eol format is inconsistent,
Kenichi Handa <handa@m17n.org>
parents:
24667
diff
changeset
|
4823 else |
778b3f056f7f
(code_convert_region): If eol format is inconsistent,
Kenichi Handa <handa@m17n.org>
parents:
24667
diff
changeset
|
4824 coding->symbol = saved_coding_symbol; |
20931
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
4825 |
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
4826 continue; |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4827 } |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4828 if (len_byte <= 0) |
23881
20d595402dea
(DECODE_DESIGNATION): Jump to label_invalid_code if
Kenichi Handa <handa@m17n.org>
parents:
23564
diff
changeset
|
4829 { |
20d595402dea
(DECODE_DESIGNATION): Jump to label_invalid_code if
Kenichi Handa <handa@m17n.org>
parents:
23564
diff
changeset
|
4830 if (coding->type != coding_type_ccl |
20d595402dea
(DECODE_DESIGNATION): Jump to label_invalid_code if
Kenichi Handa <handa@m17n.org>
parents:
23564
diff
changeset
|
4831 || coding->mode & CODING_MODE_LAST_BLOCK) |
20d595402dea
(DECODE_DESIGNATION): Jump to label_invalid_code if
Kenichi Handa <handa@m17n.org>
parents:
23564
diff
changeset
|
4832 break; |
20d595402dea
(DECODE_DESIGNATION): Jump to label_invalid_code if
Kenichi Handa <handa@m17n.org>
parents:
23564
diff
changeset
|
4833 coding->mode |= CODING_MODE_LAST_BLOCK; |
20d595402dea
(DECODE_DESIGNATION): Jump to label_invalid_code if
Kenichi Handa <handa@m17n.org>
parents:
23564
diff
changeset
|
4834 continue; |
20d595402dea
(DECODE_DESIGNATION): Jump to label_invalid_code if
Kenichi Handa <handa@m17n.org>
parents:
23564
diff
changeset
|
4835 } |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4836 if (result == CODING_FINISH_INSUFFICIENT_SRC) |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4837 { |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4838 /* The source text ends in invalid codes. Let's just |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4839 make them valid buffer contents, and finish conversion. */ |
20931
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
4840 inserted += len_byte; |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4841 inserted_byte += len_byte; |
20931
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
4842 while (len_byte--) |
21744
64c815fe1bdc
(shrink_decoding_region): Do not consider LF as ascii
Richard M. Stallman <rms@gnu.org>
parents:
21664
diff
changeset
|
4843 *dst++ = *src++; |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4844 break; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4845 } |
23279
ca159e828a68
(ccl_coding_driver): If ccl_driver is interrupted by a
Kenichi Handa <handa@m17n.org>
parents:
23258
diff
changeset
|
4846 if (result == CODING_FINISH_INTERRUPT) |
ca159e828a68
(ccl_coding_driver): If ccl_driver is interrupted by a
Kenichi Handa <handa@m17n.org>
parents:
23258
diff
changeset
|
4847 { |
ca159e828a68
(ccl_coding_driver): If ccl_driver is interrupted by a
Kenichi Handa <handa@m17n.org>
parents:
23258
diff
changeset
|
4848 /* The conversion procedure was interrupted by a user. */ |
ca159e828a68
(ccl_coding_driver): If ccl_driver is interrupted by a
Kenichi Handa <handa@m17n.org>
parents:
23258
diff
changeset
|
4849 break; |
ca159e828a68
(ccl_coding_driver): If ccl_driver is interrupted by a
Kenichi Handa <handa@m17n.org>
parents:
23258
diff
changeset
|
4850 } |
ca159e828a68
(ccl_coding_driver): If ccl_driver is interrupted by a
Kenichi Handa <handa@m17n.org>
parents:
23258
diff
changeset
|
4851 /* Now RESULT == CODING_FINISH_INSUFFICIENT_DST */ |
ca159e828a68
(ccl_coding_driver): If ccl_driver is interrupted by a
Kenichi Handa <handa@m17n.org>
parents:
23258
diff
changeset
|
4852 if (coding->consumed < 1) |
ca159e828a68
(ccl_coding_driver): If ccl_driver is interrupted by a
Kenichi Handa <handa@m17n.org>
parents:
23258
diff
changeset
|
4853 { |
ca159e828a68
(ccl_coding_driver): If ccl_driver is interrupted by a
Kenichi Handa <handa@m17n.org>
parents:
23258
diff
changeset
|
4854 /* It's quite strange to require more memory without |
ca159e828a68
(ccl_coding_driver): If ccl_driver is interrupted by a
Kenichi Handa <handa@m17n.org>
parents:
23258
diff
changeset
|
4855 consuming any bytes. Perhaps CCL program bug. */ |
ca159e828a68
(ccl_coding_driver): If ccl_driver is interrupted by a
Kenichi Handa <handa@m17n.org>
parents:
23258
diff
changeset
|
4856 break; |
ca159e828a68
(ccl_coding_driver): If ccl_driver is interrupted by a
Kenichi Handa <handa@m17n.org>
parents:
23258
diff
changeset
|
4857 } |
20931
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
4858 if (first) |
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
4859 { |
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
4860 /* We have just done the first batch of conversion which was |
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
4861 stoped because of insufficient gap. Let's reconsider the |
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
4862 required gap size (i.e. SRT - DST) now. |
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
4863 |
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
4864 We have converted ORIG bytes (== coding->consumed) into |
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
4865 NEW bytes (coding->produced). To convert the remaining |
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
4866 LEN bytes, we may need REQUIRE bytes of gap, where: |
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
4867 REQUIRE + LEN_BYTE = LEN_BYTE * (NEW / ORIG) |
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
4868 REQUIRE = LEN_BYTE * (NEW - ORIG) / ORIG |
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
4869 Here, we are sure that NEW >= ORIG. */ |
21190
d704dd953837
(code_convert_region): The 6th arg name is changed to
Kenichi Handa <handa@m17n.org>
parents:
21140
diff
changeset
|
4870 float ratio = coding->produced - coding->consumed; |
d704dd953837
(code_convert_region): The 6th arg name is changed to
Kenichi Handa <handa@m17n.org>
parents:
21140
diff
changeset
|
4871 ratio /= coding->consumed; |
d704dd953837
(code_convert_region): The 6th arg name is changed to
Kenichi Handa <handa@m17n.org>
parents:
21140
diff
changeset
|
4872 require = len_byte * ratio; |
20931
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
4873 first = 0; |
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
4874 } |
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
4875 if ((src - dst) < (require + 2000)) |
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
4876 { |
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
4877 /* See the comment above the previous call of make_gap. */ |
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
4878 int add = len_byte + inserted_byte; |
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
4879 |
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
4880 GAP_SIZE -= add; |
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
4881 ZV += add; Z += add; ZV_BYTE += add; Z_BYTE += add; |
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
4882 GPT += inserted_byte; GPT_BYTE += inserted_byte; |
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
4883 make_gap (require + 2000); |
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
4884 GAP_SIZE += add; |
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
4885 ZV -= add; Z -= add; ZV_BYTE -= add; Z_BYTE -= add; |
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
4886 GPT -= inserted_byte; GPT_BYTE -= inserted_byte; |
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
4887 } |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4888 } |
20931
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
4889 if (src - dst > 0) *dst = 0; /* Put an anchor. */ |
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
4890 |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4891 if (encodep && coding->dst_multibyte) |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4892 { |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4893 /* The output is unibyte. We must convert 8-bit characters to |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4894 multibyte form. */ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4895 if (inserted_byte * 2 > GAP_SIZE) |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4896 { |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4897 GAP_SIZE -= inserted_byte; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4898 ZV += inserted_byte; Z += inserted_byte; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4899 ZV_BYTE += inserted_byte; Z_BYTE += inserted_byte; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4900 GPT += inserted_byte; GPT_BYTE += inserted_byte; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4901 make_gap (inserted_byte - GAP_SIZE); |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4902 GAP_SIZE += inserted_byte; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4903 ZV -= inserted_byte; Z -= inserted_byte; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4904 ZV_BYTE -= inserted_byte; Z_BYTE -= inserted_byte; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4905 GPT -= inserted_byte; GPT_BYTE -= inserted_byte; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4906 } |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4907 inserted_byte = str_to_multibyte (GPT_ADDR, GAP_SIZE, inserted_byte); |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4908 } |
21140
179c73d91f70
(code_convert_region): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
21132
diff
changeset
|
4909 |
21321
27b08da98abe
(code_convert_region): Handle skipped ASCII characters
Kenichi Handa <handa@m17n.org>
parents:
21308
diff
changeset
|
4910 /* If we have shrinked the conversion area, adjust it now. */ |
27b08da98abe
(code_convert_region): Handle skipped ASCII characters
Kenichi Handa <handa@m17n.org>
parents:
21308
diff
changeset
|
4911 if (total_skip > 0) |
27b08da98abe
(code_convert_region): Handle skipped ASCII characters
Kenichi Handa <handa@m17n.org>
parents:
21308
diff
changeset
|
4912 { |
27b08da98abe
(code_convert_region): Handle skipped ASCII characters
Kenichi Handa <handa@m17n.org>
parents:
21308
diff
changeset
|
4913 if (tail_skip > 0) |
27b08da98abe
(code_convert_region): Handle skipped ASCII characters
Kenichi Handa <handa@m17n.org>
parents:
21308
diff
changeset
|
4914 safe_bcopy (GAP_END_ADDR, GPT_ADDR + inserted_byte, tail_skip); |
27b08da98abe
(code_convert_region): Handle skipped ASCII characters
Kenichi Handa <handa@m17n.org>
parents:
21308
diff
changeset
|
4915 inserted += total_skip; inserted_byte += total_skip; |
27b08da98abe
(code_convert_region): Handle skipped ASCII characters
Kenichi Handa <handa@m17n.org>
parents:
21308
diff
changeset
|
4916 GAP_SIZE += total_skip; |
27b08da98abe
(code_convert_region): Handle skipped ASCII characters
Kenichi Handa <handa@m17n.org>
parents:
21308
diff
changeset
|
4917 GPT -= head_skip; GPT_BYTE -= head_skip; |
27b08da98abe
(code_convert_region): Handle skipped ASCII characters
Kenichi Handa <handa@m17n.org>
parents:
21308
diff
changeset
|
4918 ZV -= total_skip; ZV_BYTE -= total_skip; |
27b08da98abe
(code_convert_region): Handle skipped ASCII characters
Kenichi Handa <handa@m17n.org>
parents:
21308
diff
changeset
|
4919 Z -= total_skip; Z_BYTE -= total_skip; |
27b08da98abe
(code_convert_region): Handle skipped ASCII characters
Kenichi Handa <handa@m17n.org>
parents:
21308
diff
changeset
|
4920 from -= head_skip; from_byte -= head_skip; |
27b08da98abe
(code_convert_region): Handle skipped ASCII characters
Kenichi Handa <handa@m17n.org>
parents:
21308
diff
changeset
|
4921 to += tail_skip; to_byte += tail_skip; |
27b08da98abe
(code_convert_region): Handle skipped ASCII characters
Kenichi Handa <handa@m17n.org>
parents:
21308
diff
changeset
|
4922 } |
27b08da98abe
(code_convert_region): Handle skipped ASCII characters
Kenichi Handa <handa@m17n.org>
parents:
21308
diff
changeset
|
4923 |
23537
28cd5faf93dd
(code_convert_region): While preserving the orignal
Kenichi Handa <handa@m17n.org>
parents:
23514
diff
changeset
|
4924 prev_Z = Z; |
21321
27b08da98abe
(code_convert_region): Handle skipped ASCII characters
Kenichi Handa <handa@m17n.org>
parents:
21308
diff
changeset
|
4925 adjust_after_replace (from, from_byte, deletion, inserted, inserted_byte); |
23537
28cd5faf93dd
(code_convert_region): While preserving the orignal
Kenichi Handa <handa@m17n.org>
parents:
23514
diff
changeset
|
4926 inserted = Z - prev_Z; |
21140
179c73d91f70
(code_convert_region): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
21132
diff
changeset
|
4927 |
26847 | 4928 if (!encodep && coding->cmp_data && coding->cmp_data->used) |
4929 coding_restore_composition (coding, Fcurrent_buffer ()); | |
4930 coding_free_composition_data (coding); | |
4931 | |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4932 if (! inhibit_pre_post_conversion |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4933 && ! encodep && ! NILP (coding->post_read_conversion)) |
21062
839b22ad1e42
(code_convert_region): Handle the case that codes
Kenichi Handa <handa@m17n.org>
parents:
20999
diff
changeset
|
4934 { |
21140
179c73d91f70
(code_convert_region): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
21132
diff
changeset
|
4935 Lisp_Object val; |
26067
f54ca66e2571
(code_convert_string): Add record_unwind_protect to
Kenichi Handa <handa@m17n.org>
parents:
25860
diff
changeset
|
4936 int count = specpdl_ptr - specpdl; |
23514
7bad909cd6f1
(setup_coding_system): Fix setting up
Kenichi Handa <handa@m17n.org>
parents:
23475
diff
changeset
|
4937 |
7bad909cd6f1
(setup_coding_system): Fix setting up
Kenichi Handa <handa@m17n.org>
parents:
23475
diff
changeset
|
4938 if (from != PT) |
7bad909cd6f1
(setup_coding_system): Fix setting up
Kenichi Handa <handa@m17n.org>
parents:
23475
diff
changeset
|
4939 TEMP_SET_PT_BOTH (from, from_byte); |
23537
28cd5faf93dd
(code_convert_region): While preserving the orignal
Kenichi Handa <handa@m17n.org>
parents:
23514
diff
changeset
|
4940 prev_Z = Z; |
26067
f54ca66e2571
(code_convert_string): Add record_unwind_protect to
Kenichi Handa <handa@m17n.org>
parents:
25860
diff
changeset
|
4941 record_unwind_protect (code_convert_region_unwind, Qnil); |
f54ca66e2571
(code_convert_string): Add record_unwind_protect to
Kenichi Handa <handa@m17n.org>
parents:
25860
diff
changeset
|
4942 /* We should not call any more pre-write/post-read-conversion |
f54ca66e2571
(code_convert_string): Add record_unwind_protect to
Kenichi Handa <handa@m17n.org>
parents:
25860
diff
changeset
|
4943 functions while this post-read-conversion is running. */ |
f54ca66e2571
(code_convert_string): Add record_unwind_protect to
Kenichi Handa <handa@m17n.org>
parents:
25860
diff
changeset
|
4944 inhibit_pre_post_conversion = 1; |
21140
179c73d91f70
(code_convert_region): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
21132
diff
changeset
|
4945 val = call1 (coding->post_read_conversion, make_number (inserted)); |
26067
f54ca66e2571
(code_convert_string): Add record_unwind_protect to
Kenichi Handa <handa@m17n.org>
parents:
25860
diff
changeset
|
4946 inhibit_pre_post_conversion = 0; |
f54ca66e2571
(code_convert_string): Add record_unwind_protect to
Kenichi Handa <handa@m17n.org>
parents:
25860
diff
changeset
|
4947 /* Discard the unwind protect. */ |
f54ca66e2571
(code_convert_string): Add record_unwind_protect to
Kenichi Handa <handa@m17n.org>
parents:
25860
diff
changeset
|
4948 specpdl_ptr--; |
23537
28cd5faf93dd
(code_convert_region): While preserving the orignal
Kenichi Handa <handa@m17n.org>
parents:
23514
diff
changeset
|
4949 CHECK_NUMBER (val, 0); |
23881
20d595402dea
(DECODE_DESIGNATION): Jump to label_invalid_code if
Kenichi Handa <handa@m17n.org>
parents:
23564
diff
changeset
|
4950 inserted += Z - prev_Z; |
23514
7bad909cd6f1
(setup_coding_system): Fix setting up
Kenichi Handa <handa@m17n.org>
parents:
23475
diff
changeset
|
4951 } |
7bad909cd6f1
(setup_coding_system): Fix setting up
Kenichi Handa <handa@m17n.org>
parents:
23475
diff
changeset
|
4952 |
7bad909cd6f1
(setup_coding_system): Fix setting up
Kenichi Handa <handa@m17n.org>
parents:
23475
diff
changeset
|
4953 if (orig_point >= from) |
7bad909cd6f1
(setup_coding_system): Fix setting up
Kenichi Handa <handa@m17n.org>
parents:
23475
diff
changeset
|
4954 { |
7bad909cd6f1
(setup_coding_system): Fix setting up
Kenichi Handa <handa@m17n.org>
parents:
23475
diff
changeset
|
4955 if (orig_point >= from + orig_len) |
7bad909cd6f1
(setup_coding_system): Fix setting up
Kenichi Handa <handa@m17n.org>
parents:
23475
diff
changeset
|
4956 orig_point += inserted - orig_len; |
7bad909cd6f1
(setup_coding_system): Fix setting up
Kenichi Handa <handa@m17n.org>
parents:
23475
diff
changeset
|
4957 else |
7bad909cd6f1
(setup_coding_system): Fix setting up
Kenichi Handa <handa@m17n.org>
parents:
23475
diff
changeset
|
4958 orig_point = from; |
7bad909cd6f1
(setup_coding_system): Fix setting up
Kenichi Handa <handa@m17n.org>
parents:
23475
diff
changeset
|
4959 TEMP_SET_PT (orig_point); |
21062
839b22ad1e42
(code_convert_region): Handle the case that codes
Kenichi Handa <handa@m17n.org>
parents:
20999
diff
changeset
|
4960 } |
20931
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
4961 |
26847 | 4962 if (replace) |
4963 { | |
4964 signal_after_change (from, to - from, inserted); | |
26900
a8f4cebb614d
(code_convert_region): Fix the secoding arg to
Kenichi Handa <handa@m17n.org>
parents:
26847
diff
changeset
|
4965 update_compositions (from, from + inserted, CHECK_BORDER); |
26847 | 4966 } |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4967 |
20931
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
4968 { |
21321
27b08da98abe
(code_convert_region): Handle skipped ASCII characters
Kenichi Handa <handa@m17n.org>
parents:
21308
diff
changeset
|
4969 coding->consumed = to_byte - from_byte; |
27b08da98abe
(code_convert_region): Handle skipped ASCII characters
Kenichi Handa <handa@m17n.org>
parents:
21308
diff
changeset
|
4970 coding->consumed_char = to - from; |
27b08da98abe
(code_convert_region): Handle skipped ASCII characters
Kenichi Handa <handa@m17n.org>
parents:
21308
diff
changeset
|
4971 coding->produced = inserted_byte; |
27b08da98abe
(code_convert_region): Handle skipped ASCII characters
Kenichi Handa <handa@m17n.org>
parents:
21308
diff
changeset
|
4972 coding->produced_char = inserted; |
20931
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
4973 } |
21132
75c6408013e5
(code_convert_region): Fix previous change. Adjusted
Richard M. Stallman <rms@gnu.org>
parents:
21067
diff
changeset
|
4974 |
20931
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
4975 return 0; |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4976 } |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4977 |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4978 Lisp_Object |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4979 run_pre_post_conversion_on_str (str, coding, encodep) |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4980 Lisp_Object str; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4981 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
|
4982 int encodep; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4983 { |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4984 int count = specpdl_ptr - specpdl; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4985 struct gcpro gcpro1; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4986 struct buffer *prev = current_buffer; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4987 int multibyte = STRING_MULTIBYTE (str); |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4988 |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4989 record_unwind_protect (Fset_buffer, Fcurrent_buffer ()); |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4990 record_unwind_protect (code_convert_region_unwind, Qnil); |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4991 GCPRO1 (str); |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4992 temp_output_buffer_setup (" *code-converting-work*"); |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4993 set_buffer_internal (XBUFFER (Vstandard_output)); |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4994 /* We must insert the contents of STR as is without |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4995 unibyte<->multibyte conversion. For that, we adjust the |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4996 multibyteness of the working buffer to that of STR. */ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4997 Ferase_buffer (); |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4998 current_buffer->enable_multibyte_characters = multibyte ? Qt : Qnil; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4999 insert_from_string (str, 0, 0, |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5000 XSTRING (str)->size, STRING_BYTES (XSTRING (str)), 0); |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5001 UNGCPRO; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5002 inhibit_pre_post_conversion = 1; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5003 if (encodep) |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5004 call2 (coding->pre_write_conversion, make_number (BEG), make_number (Z)); |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5005 else |
29172
46ad5a027334
(run_pre_post_conversion_on_str): Set point to the
Kenichi Handa <handa@m17n.org>
parents:
29093
diff
changeset
|
5006 { |
46ad5a027334
(run_pre_post_conversion_on_str): Set point to the
Kenichi Handa <handa@m17n.org>
parents:
29093
diff
changeset
|
5007 TEMP_SET_PT_BOTH (BEG, BEG_BYTE); |
46ad5a027334
(run_pre_post_conversion_on_str): Set point to the
Kenichi Handa <handa@m17n.org>
parents:
29093
diff
changeset
|
5008 call1 (coding->post_read_conversion, make_number (Z - BEG)); |
46ad5a027334
(run_pre_post_conversion_on_str): Set point to the
Kenichi Handa <handa@m17n.org>
parents:
29093
diff
changeset
|
5009 } |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5010 inhibit_pre_post_conversion = 0; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5011 str = make_buffer_string (BEG, Z, 0); |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5012 return unbind_to (count, str); |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5013 } |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5014 |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5015 Lisp_Object |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5016 decode_coding_string (str, coding, nocopy) |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5017 Lisp_Object str; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5018 struct coding_system *coding; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5019 int nocopy; |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5020 { |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5021 int len; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5022 char *buf; |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5023 int from, to, to_byte; |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5024 struct gcpro gcpro1; |
22954
928b337d953b
Avoid using initializers for Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents:
22874
diff
changeset
|
5025 Lisp_Object saved_coding_symbol; |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5026 int result; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5027 |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5028 from = 0; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5029 to = XSTRING (str)->size; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5030 to_byte = STRING_BYTES (XSTRING (str)); |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5031 |
22954
928b337d953b
Avoid using initializers for Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents:
22874
diff
changeset
|
5032 saved_coding_symbol = Qnil; |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5033 if (CODING_REQUIRE_DETECTION (coding)) |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5034 { |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5035 /* See the comments in code_convert_region. */ |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5036 if (coding->type == coding_type_undecided) |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5037 { |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5038 detect_coding (coding, XSTRING (str)->data, to_byte); |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5039 if (coding->type == coding_type_undecided) |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5040 coding->type = coding_type_emacs_mule; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5041 } |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5042 if (coding->eol_type == CODING_EOL_UNDECIDED) |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5043 { |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5044 saved_coding_symbol = coding->symbol; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5045 detect_eol (coding, XSTRING (str)->data, to_byte); |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5046 if (coding->eol_type == CODING_EOL_UNDECIDED) |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5047 coding->eol_type = CODING_EOL_LF; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5048 /* We had better recover the original eol format if we |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5049 encounter an inconsitent eol format while decoding. */ |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5050 coding->mode |= CODING_MODE_INHIBIT_INCONSISTENT_EOL; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5051 } |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5052 } |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5053 |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5054 if (! CODING_REQUIRE_DECODING (coding)) |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5055 { |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5056 if (!STRING_MULTIBYTE (str)) |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5057 { |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5058 str = Fstring_as_multibyte (str); |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5059 nocopy = 1; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5060 } |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5061 return (nocopy ? str : Fcopy_sequence (str)); |
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 |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5064 if (STRING_MULTIBYTE (str)) |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5065 { |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5066 /* Decoding routines expect the source text to be unibyte. */ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5067 str = Fstring_as_unibyte (str); |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5068 nocopy = 1; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5069 coding->src_multibyte = 0; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5070 } |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5071 coding->dst_multibyte = 1; |
26847 | 5072 |
5073 if (coding->composing != COMPOSITION_DISABLED) | |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5074 coding_allocate_composition_data (coding, from); |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5075 |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5076 /* Try to skip the heading and tailing ASCIIs. */ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5077 { |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5078 int from_orig = from; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5079 |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5080 SHRINK_CONVERSION_REGION (&from, &to_byte, coding, XSTRING (str)->data, |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5081 0); |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5082 if (from == to_byte) |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5083 return (nocopy ? str : Fcopy_sequence (str)); |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5084 } |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5085 |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5086 len = decoding_buffer_size (coding, to_byte - from); |
21244
50929073a0ba
Use STRING_BYTES and SET_STRING_BYTES.
Richard M. Stallman <rms@gnu.org>
parents:
21190
diff
changeset
|
5087 len += from + STRING_BYTES (XSTRING (str)) - to_byte; |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5088 GCPRO1 (str); |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5089 buf = get_conversion_buffer (len); |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5090 UNGCPRO; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5091 |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5092 if (from > 0) |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5093 bcopy (XSTRING (str)->data, buf, from); |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5094 result = decode_coding (coding, XSTRING (str)->data + from, |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5095 buf + from, to_byte - from, len); |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5096 if (result == CODING_FINISH_INCONSISTENT_EOL) |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5097 { |
26847 | 5098 /* We simply try to decode the whole string again but without |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5099 eol-conversion this time. */ |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5100 coding->eol_type = CODING_EOL_LF; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5101 coding->symbol = saved_coding_symbol; |
26847 | 5102 coding_free_composition_data (coding); |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5103 return decode_coding_string (str, coding, nocopy); |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5104 } |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5105 |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5106 bcopy (XSTRING (str)->data + to_byte, buf + from + coding->produced, |
21244
50929073a0ba
Use STRING_BYTES and SET_STRING_BYTES.
Richard M. Stallman <rms@gnu.org>
parents:
21190
diff
changeset
|
5107 STRING_BYTES (XSTRING (str)) - to_byte); |
50929073a0ba
Use STRING_BYTES and SET_STRING_BYTES.
Richard M. Stallman <rms@gnu.org>
parents:
21190
diff
changeset
|
5108 |
50929073a0ba
Use STRING_BYTES and SET_STRING_BYTES.
Richard M. Stallman <rms@gnu.org>
parents:
21190
diff
changeset
|
5109 len = from + STRING_BYTES (XSTRING (str)) - to_byte; |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5110 str = make_multibyte_string (buf, len + coding->produced_char, |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5111 len + coding->produced); |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5112 |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5113 if (coding->cmp_data && coding->cmp_data->used) |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5114 coding_restore_composition (coding, str); |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5115 coding_free_composition_data (coding); |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5116 |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5117 if (SYMBOLP (coding->post_read_conversion) |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5118 && !NILP (Ffboundp (coding->post_read_conversion))) |
29172
46ad5a027334
(run_pre_post_conversion_on_str): Set point to the
Kenichi Handa <handa@m17n.org>
parents:
29093
diff
changeset
|
5119 str = run_pre_post_conversion_on_str (str, coding, 0); |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5120 |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5121 return str; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5122 } |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5123 |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5124 Lisp_Object |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5125 encode_coding_string (str, coding, nocopy) |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5126 Lisp_Object str; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5127 struct coding_system *coding; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5128 int nocopy; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5129 { |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5130 int len; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5131 char *buf; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5132 int from, to, to_byte; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5133 struct gcpro gcpro1; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5134 Lisp_Object saved_coding_symbol; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5135 int result; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5136 |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5137 if (SYMBOLP (coding->pre_write_conversion) |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5138 && !NILP (Ffboundp (coding->pre_write_conversion))) |
29172
46ad5a027334
(run_pre_post_conversion_on_str): Set point to the
Kenichi Handa <handa@m17n.org>
parents:
29093
diff
changeset
|
5139 str = run_pre_post_conversion_on_str (str, coding, 1); |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5140 |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5141 from = 0; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5142 to = XSTRING (str)->size; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5143 to_byte = STRING_BYTES (XSTRING (str)); |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5144 |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5145 saved_coding_symbol = Qnil; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5146 if (! CODING_REQUIRE_ENCODING (coding)) |
22723
04b653d7f842
(code_convert_string): Count characters again if we
Kenichi Handa <handa@m17n.org>
parents:
22717
diff
changeset
|
5147 { |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5148 if (STRING_MULTIBYTE (str)) |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5149 { |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5150 str = Fstring_as_unibyte (str); |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5151 nocopy = 1; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5152 } |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5153 return (nocopy ? str : Fcopy_sequence (str)); |
22723
04b653d7f842
(code_convert_string): Count characters again if we
Kenichi Handa <handa@m17n.org>
parents:
22717
diff
changeset
|
5154 } |
04b653d7f842
(code_convert_string): Count characters again if we
Kenichi Handa <handa@m17n.org>
parents:
22717
diff
changeset
|
5155 |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5156 /* Encoding routines determine the multibyteness of the source text |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5157 by coding->src_multibyte. */ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5158 coding->src_multibyte = STRING_MULTIBYTE (str); |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5159 coding->dst_multibyte = 0; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5160 |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5161 if (coding->composing != COMPOSITION_DISABLED) |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5162 coding_save_composition (coding, from, to, str); |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5163 |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5164 /* Try to skip the heading and tailing ASCIIs. */ |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5165 { |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5166 int from_orig = from; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5167 |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5168 SHRINK_CONVERSION_REGION (&from, &to_byte, coding, XSTRING (str)->data, |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5169 1); |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5170 if (from == to_byte) |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5171 return (nocopy ? str : Fcopy_sequence (str)); |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5172 } |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5173 |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5174 len = encoding_buffer_size (coding, to_byte - from); |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5175 len += from + STRING_BYTES (XSTRING (str)) - to_byte; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5176 GCPRO1 (str); |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5177 buf = get_conversion_buffer (len); |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5178 UNGCPRO; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5179 |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5180 if (from > 0) |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5181 bcopy (XSTRING (str)->data, buf, from); |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5182 result = encode_coding (coding, XSTRING (str)->data + from, |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5183 buf + from, to_byte - from, len); |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5184 bcopy (XSTRING (str)->data + to_byte, buf + from + coding->produced, |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5185 STRING_BYTES (XSTRING (str)) - to_byte); |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5186 |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5187 len = from + STRING_BYTES (XSTRING (str)) - to_byte; |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5188 str = make_unibyte_string (buf, len + coding->produced); |
26847 | 5189 coding_free_composition_data (coding); |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5190 |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5191 return str; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5192 } |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5193 |
17052 | 5194 |
5195 #ifdef emacs | |
22874
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
5196 /*** 8. Emacs Lisp library functions ***/ |
17052 | 5197 |
5198 DEFUN ("coding-system-p", Fcoding_system_p, Scoding_system_p, 1, 1, 0, | |
5199 "Return t if OBJECT is nil or a coding-system.\n\ | |
20680
dd46027e8412
(code_convert_region): Always count chars inserted
Richard M. Stallman <rms@gnu.org>
parents:
20668
diff
changeset
|
5200 See the documentation of `make-coding-system' for information\n\ |
dd46027e8412
(code_convert_region): Always count chars inserted
Richard M. Stallman <rms@gnu.org>
parents:
20668
diff
changeset
|
5201 about coding-system objects.") |
17052 | 5202 (obj) |
5203 Lisp_Object obj; | |
5204 { | |
20105
c017642863c2
(Qcoding_system_spec): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
19824
diff
changeset
|
5205 if (NILP (obj)) |
c017642863c2
(Qcoding_system_spec): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
19824
diff
changeset
|
5206 return Qt; |
c017642863c2
(Qcoding_system_spec): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
19824
diff
changeset
|
5207 if (!SYMBOLP (obj)) |
c017642863c2
(Qcoding_system_spec): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
19824
diff
changeset
|
5208 return Qnil; |
c017642863c2
(Qcoding_system_spec): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
19824
diff
changeset
|
5209 /* Get coding-spec vector for OBJ. */ |
c017642863c2
(Qcoding_system_spec): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
19824
diff
changeset
|
5210 obj = Fget (obj, Qcoding_system); |
c017642863c2
(Qcoding_system_spec): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
19824
diff
changeset
|
5211 return ((VECTORP (obj) && XVECTOR (obj)->size == 5) |
c017642863c2
(Qcoding_system_spec): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
19824
diff
changeset
|
5212 ? Qt : Qnil); |
17052 | 5213 } |
5214 | |
17717
4891aaecc5cc
(Fread_coding_system, Fread_non_nil_coding_system):
Richard M. Stallman <rms@gnu.org>
parents:
17485
diff
changeset
|
5215 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
|
5216 Sread_non_nil_coding_system, 1, 1, 0, |
17119
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
5217 "Read a coding system from the minibuffer, prompting with string PROMPT.") |
17052 | 5218 (prompt) |
5219 Lisp_Object prompt; | |
5220 { | |
17119
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
5221 Lisp_Object val; |
17717
4891aaecc5cc
(Fread_coding_system, Fread_non_nil_coding_system):
Richard M. Stallman <rms@gnu.org>
parents:
17485
diff
changeset
|
5222 do |
4891aaecc5cc
(Fread_coding_system, Fread_non_nil_coding_system):
Richard M. Stallman <rms@gnu.org>
parents:
17485
diff
changeset
|
5223 { |
20105
c017642863c2
(Qcoding_system_spec): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
19824
diff
changeset
|
5224 val = Fcompleting_read (prompt, Vcoding_system_alist, Qnil, |
c017642863c2
(Qcoding_system_spec): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
19824
diff
changeset
|
5225 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
|
5226 } |
4891aaecc5cc
(Fread_coding_system, Fread_non_nil_coding_system):
Richard M. Stallman <rms@gnu.org>
parents:
17485
diff
changeset
|
5227 while (XSTRING (val)->size == 0); |
17119
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
5228 return (Fintern (val, Qnil)); |
17052 | 5229 } |
5230 | |
19758
49a1662b68dd
(Fread_coding_system): New optional arg DEFAULT_CODING_SYSTEM.
Richard M. Stallman <rms@gnu.org>
parents:
19750
diff
changeset
|
5231 DEFUN ("read-coding-system", Fread_coding_system, Sread_coding_system, 1, 2, 0, |
49a1662b68dd
(Fread_coding_system): New optional arg DEFAULT_CODING_SYSTEM.
Richard M. Stallman <rms@gnu.org>
parents:
19750
diff
changeset
|
5232 "Read a coding system from the minibuffer, prompting with string PROMPT.\n\ |
49a1662b68dd
(Fread_coding_system): New optional arg DEFAULT_CODING_SYSTEM.
Richard M. Stallman <rms@gnu.org>
parents:
19750
diff
changeset
|
5233 If the user enters null input, return second argument DEFAULT-CODING-SYSTEM.") |
49a1662b68dd
(Fread_coding_system): New optional arg DEFAULT_CODING_SYSTEM.
Richard M. Stallman <rms@gnu.org>
parents:
19750
diff
changeset
|
5234 (prompt, default_coding_system) |
49a1662b68dd
(Fread_coding_system): New optional arg DEFAULT_CODING_SYSTEM.
Richard M. Stallman <rms@gnu.org>
parents:
19750
diff
changeset
|
5235 Lisp_Object prompt, default_coding_system; |
17052 | 5236 { |
19747
bed06df9cbc5
(setup_coding_system, Ffind_operation_coding_system)
Richard M. Stallman <rms@gnu.org>
parents:
19743
diff
changeset
|
5237 Lisp_Object val; |
19758
49a1662b68dd
(Fread_coding_system): New optional arg DEFAULT_CODING_SYSTEM.
Richard M. Stallman <rms@gnu.org>
parents:
19750
diff
changeset
|
5238 if (SYMBOLP (default_coding_system)) |
49a1662b68dd
(Fread_coding_system): New optional arg DEFAULT_CODING_SYSTEM.
Richard M. Stallman <rms@gnu.org>
parents:
19750
diff
changeset
|
5239 XSETSTRING (default_coding_system, XSYMBOL (default_coding_system)->name); |
20105
c017642863c2
(Qcoding_system_spec): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
19824
diff
changeset
|
5240 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
|
5241 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
|
5242 default_coding_system, Qnil); |
17119
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
5243 return (XSTRING (val)->size == 0 ? Qnil : Fintern (val, Qnil)); |
17052 | 5244 } |
5245 | |
5246 DEFUN ("check-coding-system", Fcheck_coding_system, Scheck_coding_system, | |
5247 1, 1, 0, | |
5248 "Check validity of CODING-SYSTEM.\n\ | |
20680
dd46027e8412
(code_convert_region): Always count chars inserted
Richard M. Stallman <rms@gnu.org>
parents:
20668
diff
changeset
|
5249 If valid, return CODING-SYSTEM, else signal a `coding-system-error' error.\n\ |
dd46027e8412
(code_convert_region): Always count chars inserted
Richard M. Stallman <rms@gnu.org>
parents:
20668
diff
changeset
|
5250 It is valid if it is a symbol with a non-nil `coding-system' property.\n\ |
17052 | 5251 The value of property should be a vector of length 5.") |
5252 (coding_system) | |
5253 Lisp_Object coding_system; | |
5254 { | |
5255 CHECK_SYMBOL (coding_system, 0); | |
5256 if (!NILP (Fcoding_system_p (coding_system))) | |
5257 return coding_system; | |
5258 while (1) | |
18180
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
5259 Fsignal (Qcoding_system_error, Fcons (coding_system, Qnil)); |
17052 | 5260 } |
20680
dd46027e8412
(code_convert_region): Always count chars inserted
Richard M. Stallman <rms@gnu.org>
parents:
20668
diff
changeset
|
5261 |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5262 Lisp_Object |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5263 detect_coding_system (src, src_bytes, highest) |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5264 unsigned char *src; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5265 int src_bytes, highest; |
17052 | 5266 { |
5267 int coding_mask, eol_type; | |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5268 Lisp_Object val, tmp; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5269 int dummy; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5270 |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5271 coding_mask = detect_coding_mask (src, src_bytes, NULL, &dummy); |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5272 eol_type = detect_eol_type (src, src_bytes, &dummy); |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5273 if (eol_type == CODING_EOL_INCONSISTENT) |
23082
910740dcedb5
(detect_coding_system): If detect_eol_type returns
Kenichi Handa <handa@m17n.org>
parents:
23067
diff
changeset
|
5274 eol_type = CODING_EOL_UNDECIDED; |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5275 |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5276 if (!coding_mask) |
17052 | 5277 { |
19612
783efd6c7c1e
(Qno_conversion, Qundecided): New variables.
Kenichi Handa <handa@m17n.org>
parents:
19546
diff
changeset
|
5278 val = Qundecided; |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5279 if (eol_type != CODING_EOL_UNDECIDED) |
17052 | 5280 { |
19747
bed06df9cbc5
(setup_coding_system, Ffind_operation_coding_system)
Richard M. Stallman <rms@gnu.org>
parents:
19743
diff
changeset
|
5281 Lisp_Object val2; |
bed06df9cbc5
(setup_coding_system, Ffind_operation_coding_system)
Richard M. Stallman <rms@gnu.org>
parents:
19743
diff
changeset
|
5282 val2 = Fget (Qundecided, Qeol_type); |
17052 | 5283 if (VECTORP (val2)) |
5284 val = XVECTOR (val2)->contents[eol_type]; | |
5285 } | |
22460
7ca919476042
(detect_coding_system): Always return a list of HIGHEST is zero.
Kenichi Handa <handa@m17n.org>
parents:
22341
diff
changeset
|
5286 return (highest ? val : Fcons (val, Qnil)); |
17052 | 5287 } |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5288 |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5289 /* At first, gather possible coding systems in VAL. */ |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5290 val = Qnil; |
28022
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
5291 for (tmp = Vcoding_category_list; CONSP (tmp); tmp = XCDR (tmp)) |
17052 | 5292 { |
28022
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
5293 Lisp_Object category_val, category_index; |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
5294 |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
5295 category_index = Fget (XCAR (tmp), Qcoding_category_index); |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
5296 category_val = Fsymbol_value (XCAR (tmp)); |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
5297 if (!NILP (category_val) |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
5298 && NATNUMP (category_index) |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
5299 && (coding_mask & (1 << XFASTINT (category_index)))) |
17052 | 5300 { |
28022
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
5301 val = Fcons (category_val, val); |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5302 if (highest) |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5303 break; |
17052 | 5304 } |
5305 } | |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5306 if (!highest) |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5307 val = Fnreverse (val); |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5308 |
22254
1deb7d79af00
(detect_coding_system): Treat CODING_EOL_INCONSISTENT
Richard M. Stallman <rms@gnu.org>
parents:
22226
diff
changeset
|
5309 /* Then, replace the elements with subsidiary coding systems. */ |
28022
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
5310 for (tmp = val; CONSP (tmp); tmp = XCDR (tmp)) |
17052 | 5311 { |
22254
1deb7d79af00
(detect_coding_system): Treat CODING_EOL_INCONSISTENT
Richard M. Stallman <rms@gnu.org>
parents:
22226
diff
changeset
|
5312 if (eol_type != CODING_EOL_UNDECIDED |
1deb7d79af00
(detect_coding_system): Treat CODING_EOL_INCONSISTENT
Richard M. Stallman <rms@gnu.org>
parents:
22226
diff
changeset
|
5313 && eol_type != CODING_EOL_INCONSISTENT) |
17052 | 5314 { |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5315 Lisp_Object eol; |
25662
0a7261c1d487
Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25370
diff
changeset
|
5316 eol = Fget (XCAR (tmp), Qeol_type); |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5317 if (VECTORP (eol)) |
25662
0a7261c1d487
Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25370
diff
changeset
|
5318 XCAR (tmp) = XVECTOR (eol)->contents[eol_type]; |
17052 | 5319 } |
5320 } | |
25662
0a7261c1d487
Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25370
diff
changeset
|
5321 return (highest ? XCAR (val) : val); |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5322 } |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5323 |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5324 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
|
5325 2, 3, 0, |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5326 "Detect coding system of the text in the region between START and END.\n\ |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5327 Return a list of possible coding systems ordered by priority.\n\ |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5328 \n\ |
22460
7ca919476042
(detect_coding_system): Always return a list of HIGHEST is zero.
Kenichi Handa <handa@m17n.org>
parents:
22341
diff
changeset
|
5329 If only ASCII characters are found, it returns a list of single element\n\ |
7ca919476042
(detect_coding_system): Always return a list of HIGHEST is zero.
Kenichi Handa <handa@m17n.org>
parents:
22341
diff
changeset
|
5330 `undecided' or its subsidiary coding system according to a detected\n\ |
7ca919476042
(detect_coding_system): Always return a list of HIGHEST is zero.
Kenichi Handa <handa@m17n.org>
parents:
22341
diff
changeset
|
5331 end-of-line format.\n\ |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5332 \n\ |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5333 If optional argument HIGHEST is non-nil, return the coding system of\n\ |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5334 highest priority.") |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5335 (start, end, highest) |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5336 Lisp_Object start, end, highest; |
17052 | 5337 { |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5338 int from, to; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5339 int from_byte, to_byte; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5340 |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5341 CHECK_NUMBER_COERCE_MARKER (start, 0); |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5342 CHECK_NUMBER_COERCE_MARKER (end, 1); |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5343 |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5344 validate_region (&start, &end); |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5345 from = XINT (start), to = XINT (end); |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5346 from_byte = CHAR_TO_BYTE (from); |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5347 to_byte = CHAR_TO_BYTE (to); |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5348 |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5349 if (from < GPT && to >= GPT) |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5350 move_gap_both (to, to_byte); |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5351 |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5352 return detect_coding_system (BYTE_POS_ADDR (from_byte), |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5353 to_byte - from_byte, |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5354 !NILP (highest)); |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5355 } |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5356 |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5357 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
|
5358 1, 2, 0, |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5359 "Detect coding system of the text in STRING.\n\ |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5360 Return a list of possible coding systems ordered by priority.\n\ |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5361 \n\ |
22460
7ca919476042
(detect_coding_system): Always return a list of HIGHEST is zero.
Kenichi Handa <handa@m17n.org>
parents:
22341
diff
changeset
|
5362 If only ASCII characters are found, it returns a list of single element\n\ |
7ca919476042
(detect_coding_system): Always return a list of HIGHEST is zero.
Kenichi Handa <handa@m17n.org>
parents:
22341
diff
changeset
|
5363 `undecided' or its subsidiary coding system according to a detected\n\ |
7ca919476042
(detect_coding_system): Always return a list of HIGHEST is zero.
Kenichi Handa <handa@m17n.org>
parents:
22341
diff
changeset
|
5364 end-of-line format.\n\ |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5365 \n\ |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5366 If optional argument HIGHEST is non-nil, return the coding system of\n\ |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5367 highest priority.") |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5368 (string, highest) |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5369 Lisp_Object string, highest; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5370 { |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5371 CHECK_STRING (string, 0); |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5372 |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5373 return detect_coding_system (XSTRING (string)->data, |
21244
50929073a0ba
Use STRING_BYTES and SET_STRING_BYTES.
Richard M. Stallman <rms@gnu.org>
parents:
21190
diff
changeset
|
5374 STRING_BYTES (XSTRING (string)), |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5375 !NILP (highest)); |
17052 | 5376 } |
5377 | |
20803
0fa2183c587d
(ENCODE_ISO_CHARACTER): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
20794
diff
changeset
|
5378 Lisp_Object |
0fa2183c587d
(ENCODE_ISO_CHARACTER): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
20794
diff
changeset
|
5379 code_convert_region1 (start, end, coding_system, encodep) |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5380 Lisp_Object start, end, coding_system; |
20803
0fa2183c587d
(ENCODE_ISO_CHARACTER): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
20794
diff
changeset
|
5381 int encodep; |
20680
dd46027e8412
(code_convert_region): Always count chars inserted
Richard M. Stallman <rms@gnu.org>
parents:
20668
diff
changeset
|
5382 { |
dd46027e8412
(code_convert_region): Always count chars inserted
Richard M. Stallman <rms@gnu.org>
parents:
20668
diff
changeset
|
5383 struct coding_system coding; |
20803
0fa2183c587d
(ENCODE_ISO_CHARACTER): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
20794
diff
changeset
|
5384 int from, to, len; |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5385 |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5386 CHECK_NUMBER_COERCE_MARKER (start, 0); |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5387 CHECK_NUMBER_COERCE_MARKER (end, 1); |
20680
dd46027e8412
(code_convert_region): Always count chars inserted
Richard M. Stallman <rms@gnu.org>
parents:
20668
diff
changeset
|
5388 CHECK_SYMBOL (coding_system, 2); |
dd46027e8412
(code_convert_region): Always count chars inserted
Richard M. Stallman <rms@gnu.org>
parents:
20668
diff
changeset
|
5389 |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5390 validate_region (&start, &end); |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5391 from = XFASTINT (start); |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5392 to = XFASTINT (end); |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5393 |
20680
dd46027e8412
(code_convert_region): Always count chars inserted
Richard M. Stallman <rms@gnu.org>
parents:
20668
diff
changeset
|
5394 if (NILP (coding_system)) |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5395 return make_number (to - from); |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5396 |
20680
dd46027e8412
(code_convert_region): Always count chars inserted
Richard M. Stallman <rms@gnu.org>
parents:
20668
diff
changeset
|
5397 if (setup_coding_system (Fcheck_coding_system (coding_system), &coding) < 0) |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5398 error ("Invalid coding system: %s", XSYMBOL (coding_system)->name->data); |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5399 |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5400 coding.mode |= CODING_MODE_LAST_BLOCK; |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5401 coding.src_multibyte = coding.dst_multibyte |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5402 = !NILP (current_buffer->enable_multibyte_characters); |
20931
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
5403 code_convert_region (from, CHAR_TO_BYTE (from), to, CHAR_TO_BYTE (to), |
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
5404 &coding, encodep, 1); |
22020
e144ad749084
(code_convert_region1): Set Vlast_coding_system_used.
Richard M. Stallman <rms@gnu.org>
parents:
22009
diff
changeset
|
5405 Vlast_coding_system_used = coding.symbol; |
20931
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
5406 return make_number (coding.produced_char); |
20803
0fa2183c587d
(ENCODE_ISO_CHARACTER): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
20794
diff
changeset
|
5407 } |
0fa2183c587d
(ENCODE_ISO_CHARACTER): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
20794
diff
changeset
|
5408 |
0fa2183c587d
(ENCODE_ISO_CHARACTER): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
20794
diff
changeset
|
5409 DEFUN ("decode-coding-region", Fdecode_coding_region, Sdecode_coding_region, |
0fa2183c587d
(ENCODE_ISO_CHARACTER): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
20794
diff
changeset
|
5410 3, 3, "r\nzCoding system: ", |
0fa2183c587d
(ENCODE_ISO_CHARACTER): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
20794
diff
changeset
|
5411 "Decode the current region by specified coding system.\n\ |
0fa2183c587d
(ENCODE_ISO_CHARACTER): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
20794
diff
changeset
|
5412 When called from a program, takes three arguments:\n\ |
0fa2183c587d
(ENCODE_ISO_CHARACTER): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
20794
diff
changeset
|
5413 START, END, and CODING-SYSTEM. START and END are buffer positions.\n\ |
22020
e144ad749084
(code_convert_region1): Set Vlast_coding_system_used.
Richard M. Stallman <rms@gnu.org>
parents:
22009
diff
changeset
|
5414 This function sets `last-coding-system-used' to the precise coding system\n\ |
e144ad749084
(code_convert_region1): Set Vlast_coding_system_used.
Richard M. Stallman <rms@gnu.org>
parents:
22009
diff
changeset
|
5415 used (which may be different from CODING-SYSTEM if CODING-SYSTEM is\n\ |
e144ad749084
(code_convert_region1): Set Vlast_coding_system_used.
Richard M. Stallman <rms@gnu.org>
parents:
22009
diff
changeset
|
5416 not fully specified.)\n\ |
e144ad749084
(code_convert_region1): Set Vlast_coding_system_used.
Richard M. Stallman <rms@gnu.org>
parents:
22009
diff
changeset
|
5417 It returns the length of the decoded text.") |
20803
0fa2183c587d
(ENCODE_ISO_CHARACTER): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
20794
diff
changeset
|
5418 (start, end, coding_system) |
0fa2183c587d
(ENCODE_ISO_CHARACTER): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
20794
diff
changeset
|
5419 Lisp_Object start, end, coding_system; |
0fa2183c587d
(ENCODE_ISO_CHARACTER): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
20794
diff
changeset
|
5420 { |
0fa2183c587d
(ENCODE_ISO_CHARACTER): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
20794
diff
changeset
|
5421 return code_convert_region1 (start, end, coding_system, 0); |
20680
dd46027e8412
(code_convert_region): Always count chars inserted
Richard M. Stallman <rms@gnu.org>
parents:
20668
diff
changeset
|
5422 } |
dd46027e8412
(code_convert_region): Always count chars inserted
Richard M. Stallman <rms@gnu.org>
parents:
20668
diff
changeset
|
5423 |
dd46027e8412
(code_convert_region): Always count chars inserted
Richard M. Stallman <rms@gnu.org>
parents:
20668
diff
changeset
|
5424 DEFUN ("encode-coding-region", Fencode_coding_region, Sencode_coding_region, |
dd46027e8412
(code_convert_region): Always count chars inserted
Richard M. Stallman <rms@gnu.org>
parents:
20668
diff
changeset
|
5425 3, 3, "r\nzCoding system: ", |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5426 "Encode the current region by specified coding system.\n\ |
20680
dd46027e8412
(code_convert_region): Always count chars inserted
Richard M. Stallman <rms@gnu.org>
parents:
20668
diff
changeset
|
5427 When called from a program, takes three arguments:\n\ |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5428 START, END, and CODING-SYSTEM. START and END are buffer positions.\n\ |
22020
e144ad749084
(code_convert_region1): Set Vlast_coding_system_used.
Richard M. Stallman <rms@gnu.org>
parents:
22009
diff
changeset
|
5429 This function sets `last-coding-system-used' to the precise coding system\n\ |
e144ad749084
(code_convert_region1): Set Vlast_coding_system_used.
Richard M. Stallman <rms@gnu.org>
parents:
22009
diff
changeset
|
5430 used (which may be different from CODING-SYSTEM if CODING-SYSTEM is\n\ |
e144ad749084
(code_convert_region1): Set Vlast_coding_system_used.
Richard M. Stallman <rms@gnu.org>
parents:
22009
diff
changeset
|
5431 not fully specified.)\n\ |
e144ad749084
(code_convert_region1): Set Vlast_coding_system_used.
Richard M. Stallman <rms@gnu.org>
parents:
22009
diff
changeset
|
5432 It returns the length of the encoded text.") |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5433 (start, end, coding_system) |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5434 Lisp_Object start, end, coding_system; |
20680
dd46027e8412
(code_convert_region): Always count chars inserted
Richard M. Stallman <rms@gnu.org>
parents:
20668
diff
changeset
|
5435 { |
20803
0fa2183c587d
(ENCODE_ISO_CHARACTER): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
20794
diff
changeset
|
5436 return code_convert_region1 (start, end, coding_system, 1); |
17052 | 5437 } |
5438 | |
20803
0fa2183c587d
(ENCODE_ISO_CHARACTER): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
20794
diff
changeset
|
5439 Lisp_Object |
0fa2183c587d
(ENCODE_ISO_CHARACTER): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
20794
diff
changeset
|
5440 code_convert_string1 (string, coding_system, nocopy, encodep) |
17119
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
5441 Lisp_Object string, coding_system, nocopy; |
20803
0fa2183c587d
(ENCODE_ISO_CHARACTER): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
20794
diff
changeset
|
5442 int encodep; |
17052 | 5443 { |
5444 struct coding_system coding; | |
5445 | |
5446 CHECK_STRING (string, 0); | |
5447 CHECK_SYMBOL (coding_system, 1); | |
5448 | |
17119
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
5449 if (NILP (coding_system)) |
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
5450 return (NILP (nocopy) ? Fcopy_sequence (string) : string); |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5451 |
17052 | 5452 if (setup_coding_system (Fcheck_coding_system (coding_system), &coding) < 0) |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5453 error ("Invalid coding system: %s", XSYMBOL (coding_system)->name->data); |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5454 |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5455 coding.mode |= CODING_MODE_LAST_BLOCK; |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5456 string = (encodep |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5457 ? encode_coding_string (string, &coding, !NILP (nocopy)) |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5458 : decode_coding_string (string, &coding, !NILP (nocopy))); |
22020
e144ad749084
(code_convert_region1): Set Vlast_coding_system_used.
Richard M. Stallman <rms@gnu.org>
parents:
22009
diff
changeset
|
5459 Vlast_coding_system_used = coding.symbol; |
26847 | 5460 |
5461 return string; | |
20803
0fa2183c587d
(ENCODE_ISO_CHARACTER): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
20794
diff
changeset
|
5462 } |
0fa2183c587d
(ENCODE_ISO_CHARACTER): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
20794
diff
changeset
|
5463 |
0fa2183c587d
(ENCODE_ISO_CHARACTER): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
20794
diff
changeset
|
5464 DEFUN ("decode-coding-string", Fdecode_coding_string, Sdecode_coding_string, |
0fa2183c587d
(ENCODE_ISO_CHARACTER): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
20794
diff
changeset
|
5465 2, 3, 0, |
0fa2183c587d
(ENCODE_ISO_CHARACTER): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
20794
diff
changeset
|
5466 "Decode STRING which is encoded in CODING-SYSTEM, and return the result.\n\ |
0fa2183c587d
(ENCODE_ISO_CHARACTER): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
20794
diff
changeset
|
5467 Optional arg NOCOPY non-nil means it is ok to return STRING itself\n\ |
22020
e144ad749084
(code_convert_region1): Set Vlast_coding_system_used.
Richard M. Stallman <rms@gnu.org>
parents:
22009
diff
changeset
|
5468 if the decoding operation is trivial.\n\ |
e144ad749084
(code_convert_region1): Set Vlast_coding_system_used.
Richard M. Stallman <rms@gnu.org>
parents:
22009
diff
changeset
|
5469 This function sets `last-coding-system-used' to the precise coding system\n\ |
e144ad749084
(code_convert_region1): Set Vlast_coding_system_used.
Richard M. Stallman <rms@gnu.org>
parents:
22009
diff
changeset
|
5470 used (which may be different from CODING-SYSTEM if CODING-SYSTEM is\n\ |
e144ad749084
(code_convert_region1): Set Vlast_coding_system_used.
Richard M. Stallman <rms@gnu.org>
parents:
22009
diff
changeset
|
5471 not fully specified.)") |
20803
0fa2183c587d
(ENCODE_ISO_CHARACTER): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
20794
diff
changeset
|
5472 (string, coding_system, nocopy) |
0fa2183c587d
(ENCODE_ISO_CHARACTER): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
20794
diff
changeset
|
5473 Lisp_Object string, coding_system, nocopy; |
0fa2183c587d
(ENCODE_ISO_CHARACTER): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
20794
diff
changeset
|
5474 { |
22020
e144ad749084
(code_convert_region1): Set Vlast_coding_system_used.
Richard M. Stallman <rms@gnu.org>
parents:
22009
diff
changeset
|
5475 return code_convert_string1 (string, coding_system, nocopy, 0); |
17052 | 5476 } |
5477 | |
5478 DEFUN ("encode-coding-string", Fencode_coding_string, Sencode_coding_string, | |
17119
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
5479 2, 3, 0, |
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
5480 "Encode STRING to CODING-SYSTEM, and return the result.\n\ |
19815
e68cab4f1f70
(Fencode_coding_string, Fdecode_coding_string): Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents:
19763
diff
changeset
|
5481 Optional arg NOCOPY non-nil means it is ok to return STRING itself\n\ |
22020
e144ad749084
(code_convert_region1): Set Vlast_coding_system_used.
Richard M. Stallman <rms@gnu.org>
parents:
22009
diff
changeset
|
5482 if the encoding operation is trivial.\n\ |
e144ad749084
(code_convert_region1): Set Vlast_coding_system_used.
Richard M. Stallman <rms@gnu.org>
parents:
22009
diff
changeset
|
5483 This function sets `last-coding-system-used' to the precise coding system\n\ |
e144ad749084
(code_convert_region1): Set Vlast_coding_system_used.
Richard M. Stallman <rms@gnu.org>
parents:
22009
diff
changeset
|
5484 used (which may be different from CODING-SYSTEM if CODING-SYSTEM is\n\ |
e144ad749084
(code_convert_region1): Set Vlast_coding_system_used.
Richard M. Stallman <rms@gnu.org>
parents:
22009
diff
changeset
|
5485 not fully specified.)") |
17119
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
5486 (string, coding_system, nocopy) |
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
5487 Lisp_Object string, coding_system, nocopy; |
17052 | 5488 { |
22020
e144ad749084
(code_convert_region1): Set Vlast_coding_system_used.
Richard M. Stallman <rms@gnu.org>
parents:
22009
diff
changeset
|
5489 return code_convert_string1 (string, coding_system, nocopy, 1); |
17052 | 5490 } |
20803
0fa2183c587d
(ENCODE_ISO_CHARACTER): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
20794
diff
changeset
|
5491 |
22341
572ba933a4bf
(code_convert_string_norecord): New function.
Karl Heuer <kwzh@gnu.org>
parents:
22329
diff
changeset
|
5492 /* Encode or decode STRING according to CODING_SYSTEM. |
26847 | 5493 Do not set Vlast_coding_system_used. |
5494 | |
5495 This function is called only from macros DECODE_FILE and | |
5496 ENCODE_FILE, thus we ignore character composition. */ | |
22341
572ba933a4bf
(code_convert_string_norecord): New function.
Karl Heuer <kwzh@gnu.org>
parents:
22329
diff
changeset
|
5497 |
572ba933a4bf
(code_convert_string_norecord): New function.
Karl Heuer <kwzh@gnu.org>
parents:
22329
diff
changeset
|
5498 Lisp_Object |
572ba933a4bf
(code_convert_string_norecord): New function.
Karl Heuer <kwzh@gnu.org>
parents:
22329
diff
changeset
|
5499 code_convert_string_norecord (string, coding_system, encodep) |
572ba933a4bf
(code_convert_string_norecord): New function.
Karl Heuer <kwzh@gnu.org>
parents:
22329
diff
changeset
|
5500 Lisp_Object string, coding_system; |
572ba933a4bf
(code_convert_string_norecord): New function.
Karl Heuer <kwzh@gnu.org>
parents:
22329
diff
changeset
|
5501 int encodep; |
572ba933a4bf
(code_convert_string_norecord): New function.
Karl Heuer <kwzh@gnu.org>
parents:
22329
diff
changeset
|
5502 { |
572ba933a4bf
(code_convert_string_norecord): New function.
Karl Heuer <kwzh@gnu.org>
parents:
22329
diff
changeset
|
5503 struct coding_system coding; |
572ba933a4bf
(code_convert_string_norecord): New function.
Karl Heuer <kwzh@gnu.org>
parents:
22329
diff
changeset
|
5504 |
572ba933a4bf
(code_convert_string_norecord): New function.
Karl Heuer <kwzh@gnu.org>
parents:
22329
diff
changeset
|
5505 CHECK_STRING (string, 0); |
572ba933a4bf
(code_convert_string_norecord): New function.
Karl Heuer <kwzh@gnu.org>
parents:
22329
diff
changeset
|
5506 CHECK_SYMBOL (coding_system, 1); |
572ba933a4bf
(code_convert_string_norecord): New function.
Karl Heuer <kwzh@gnu.org>
parents:
22329
diff
changeset
|
5507 |
572ba933a4bf
(code_convert_string_norecord): New function.
Karl Heuer <kwzh@gnu.org>
parents:
22329
diff
changeset
|
5508 if (NILP (coding_system)) |
572ba933a4bf
(code_convert_string_norecord): New function.
Karl Heuer <kwzh@gnu.org>
parents:
22329
diff
changeset
|
5509 return string; |
572ba933a4bf
(code_convert_string_norecord): New function.
Karl Heuer <kwzh@gnu.org>
parents:
22329
diff
changeset
|
5510 |
572ba933a4bf
(code_convert_string_norecord): New function.
Karl Heuer <kwzh@gnu.org>
parents:
22329
diff
changeset
|
5511 if (setup_coding_system (Fcheck_coding_system (coding_system), &coding) < 0) |
572ba933a4bf
(code_convert_string_norecord): New function.
Karl Heuer <kwzh@gnu.org>
parents:
22329
diff
changeset
|
5512 error ("Invalid coding system: %s", XSYMBOL (coding_system)->name->data); |
572ba933a4bf
(code_convert_string_norecord): New function.
Karl Heuer <kwzh@gnu.org>
parents:
22329
diff
changeset
|
5513 |
26847 | 5514 coding.composing = COMPOSITION_DISABLED; |
22341
572ba933a4bf
(code_convert_string_norecord): New function.
Karl Heuer <kwzh@gnu.org>
parents:
22329
diff
changeset
|
5515 coding.mode |= CODING_MODE_LAST_BLOCK; |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5516 return (encodep |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5517 ? encode_coding_string (string, &coding, 1) |
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5518 : decode_coding_string (string, &coding, 1)); |
22341
572ba933a4bf
(code_convert_string_norecord): New function.
Karl Heuer <kwzh@gnu.org>
parents:
22329
diff
changeset
|
5519 } |
20680
dd46027e8412
(code_convert_region): Always count chars inserted
Richard M. Stallman <rms@gnu.org>
parents:
20668
diff
changeset
|
5520 |
17052 | 5521 DEFUN ("decode-sjis-char", Fdecode_sjis_char, Sdecode_sjis_char, 1, 1, 0, |
24065
7e291dea6141
(Fdecode_sjis_char): Decode Japanese Katakana character
Kenichi Handa <handa@m17n.org>
parents:
24056
diff
changeset
|
5522 "Decode a Japanese character which has CODE in shift_jis encoding.\n\ |
17052 | 5523 Return the corresponding character.") |
5524 (code) | |
5525 Lisp_Object code; | |
5526 { | |
5527 unsigned char c1, c2, s1, s2; | |
5528 Lisp_Object val; | |
5529 | |
5530 CHECK_NUMBER (code, 0); | |
5531 s1 = (XFASTINT (code)) >> 8, s2 = (XFASTINT (code)) & 0xFF; | |
24065
7e291dea6141
(Fdecode_sjis_char): Decode Japanese Katakana character
Kenichi Handa <handa@m17n.org>
parents:
24056
diff
changeset
|
5532 if (s1 == 0) |
7e291dea6141
(Fdecode_sjis_char): Decode Japanese Katakana character
Kenichi Handa <handa@m17n.org>
parents:
24056
diff
changeset
|
5533 { |
24324
2eec590faf26
(Fdecode_sjis_char, Fencode_sjis_char): Hanlde
Kenichi Handa <handa@m17n.org>
parents:
24316
diff
changeset
|
5534 if (s2 < 0x80) |
2eec590faf26
(Fdecode_sjis_char, Fencode_sjis_char): Hanlde
Kenichi Handa <handa@m17n.org>
parents:
24316
diff
changeset
|
5535 XSETFASTINT (val, s2); |
2eec590faf26
(Fdecode_sjis_char, Fencode_sjis_char): Hanlde
Kenichi Handa <handa@m17n.org>
parents:
24316
diff
changeset
|
5536 else if (s2 >= 0xA0 || s2 <= 0xDF) |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5537 XSETFASTINT (val, MAKE_CHAR (charset_katakana_jisx0201, s2, 0)); |
24324
2eec590faf26
(Fdecode_sjis_char, Fencode_sjis_char): Hanlde
Kenichi Handa <handa@m17n.org>
parents:
24316
diff
changeset
|
5538 else |
24344
8b7ef7fb9e2e
(Fdecode_sjis_char): In case of error, use %x for
Kenichi Handa <handa@m17n.org>
parents:
24324
diff
changeset
|
5539 error ("Invalid Shift JIS code: %x", XFASTINT (code)); |
24065
7e291dea6141
(Fdecode_sjis_char): Decode Japanese Katakana character
Kenichi Handa <handa@m17n.org>
parents:
24056
diff
changeset
|
5540 } |
7e291dea6141
(Fdecode_sjis_char): Decode Japanese Katakana character
Kenichi Handa <handa@m17n.org>
parents:
24056
diff
changeset
|
5541 else |
7e291dea6141
(Fdecode_sjis_char): Decode Japanese Katakana character
Kenichi Handa <handa@m17n.org>
parents:
24056
diff
changeset
|
5542 { |
7e291dea6141
(Fdecode_sjis_char): Decode Japanese Katakana character
Kenichi Handa <handa@m17n.org>
parents:
24056
diff
changeset
|
5543 if ((s1 < 0x80 || s1 > 0x9F && s1 < 0xE0 || s1 > 0xEF) |
7e291dea6141
(Fdecode_sjis_char): Decode Japanese Katakana character
Kenichi Handa <handa@m17n.org>
parents:
24056
diff
changeset
|
5544 || (s2 < 0x40 || s2 == 0x7F || s2 > 0xFC)) |
24344
8b7ef7fb9e2e
(Fdecode_sjis_char): In case of error, use %x for
Kenichi Handa <handa@m17n.org>
parents:
24324
diff
changeset
|
5545 error ("Invalid Shift JIS code: %x", XFASTINT (code)); |
24065
7e291dea6141
(Fdecode_sjis_char): Decode Japanese Katakana character
Kenichi Handa <handa@m17n.org>
parents:
24056
diff
changeset
|
5546 DECODE_SJIS (s1, s2, c1, c2); |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5547 XSETFASTINT (val, MAKE_CHAR (charset_jisx0208, c1, c2)); |
24065
7e291dea6141
(Fdecode_sjis_char): Decode Japanese Katakana character
Kenichi Handa <handa@m17n.org>
parents:
24056
diff
changeset
|
5548 } |
17052 | 5549 return val; |
5550 } | |
5551 | |
5552 DEFUN ("encode-sjis-char", Fencode_sjis_char, Sencode_sjis_char, 1, 1, 0, | |
24065
7e291dea6141
(Fdecode_sjis_char): Decode Japanese Katakana character
Kenichi Handa <handa@m17n.org>
parents:
24056
diff
changeset
|
5553 "Encode a Japanese character CHAR to shift_jis encoding.\n\ |
7e291dea6141
(Fdecode_sjis_char): Decode Japanese Katakana character
Kenichi Handa <handa@m17n.org>
parents:
24056
diff
changeset
|
5554 Return the corresponding code in SJIS.") |
17052 | 5555 (ch) |
5556 Lisp_Object ch; | |
5557 { | |
17320
9d15bec5f47e
(detect_coding_iso2022, detect_coding_mask): Ignore
Kenichi Handa <handa@m17n.org>
parents:
17304
diff
changeset
|
5558 int charset, c1, c2, s1, s2; |
17052 | 5559 Lisp_Object val; |
5560 | |
5561 CHECK_NUMBER (ch, 0); | |
5562 SPLIT_CHAR (XFASTINT (ch), charset, c1, c2); | |
24324
2eec590faf26
(Fdecode_sjis_char, Fencode_sjis_char): Hanlde
Kenichi Handa <handa@m17n.org>
parents:
24316
diff
changeset
|
5563 if (charset == CHARSET_ASCII) |
2eec590faf26
(Fdecode_sjis_char, Fencode_sjis_char): Hanlde
Kenichi Handa <handa@m17n.org>
parents:
24316
diff
changeset
|
5564 { |
2eec590faf26
(Fdecode_sjis_char, Fencode_sjis_char): Hanlde
Kenichi Handa <handa@m17n.org>
parents:
24316
diff
changeset
|
5565 val = ch; |
2eec590faf26
(Fdecode_sjis_char, Fencode_sjis_char): Hanlde
Kenichi Handa <handa@m17n.org>
parents:
24316
diff
changeset
|
5566 } |
2eec590faf26
(Fdecode_sjis_char, Fencode_sjis_char): Hanlde
Kenichi Handa <handa@m17n.org>
parents:
24316
diff
changeset
|
5567 else if (charset == charset_jisx0208 |
2eec590faf26
(Fdecode_sjis_char, Fencode_sjis_char): Hanlde
Kenichi Handa <handa@m17n.org>
parents:
24316
diff
changeset
|
5568 && c1 > 0x20 && c1 < 0x7F && c2 > 0x20 && c2 < 0x7F) |
17052 | 5569 { |
5570 ENCODE_SJIS (c1, c2, s1, s2); | |
17320
9d15bec5f47e
(detect_coding_iso2022, detect_coding_mask): Ignore
Kenichi Handa <handa@m17n.org>
parents:
17304
diff
changeset
|
5571 XSETFASTINT (val, (s1 << 8) | s2); |
17052 | 5572 } |
24065
7e291dea6141
(Fdecode_sjis_char): Decode Japanese Katakana character
Kenichi Handa <handa@m17n.org>
parents:
24056
diff
changeset
|
5573 else if (charset == charset_katakana_jisx0201 |
7e291dea6141
(Fdecode_sjis_char): Decode Japanese Katakana character
Kenichi Handa <handa@m17n.org>
parents:
24056
diff
changeset
|
5574 && c1 > 0x20 && c2 < 0xE0) |
7e291dea6141
(Fdecode_sjis_char): Decode Japanese Katakana character
Kenichi Handa <handa@m17n.org>
parents:
24056
diff
changeset
|
5575 { |
7e291dea6141
(Fdecode_sjis_char): Decode Japanese Katakana character
Kenichi Handa <handa@m17n.org>
parents:
24056
diff
changeset
|
5576 XSETFASTINT (val, c1 | 0x80); |
7e291dea6141
(Fdecode_sjis_char): Decode Japanese Katakana character
Kenichi Handa <handa@m17n.org>
parents:
24056
diff
changeset
|
5577 } |
17052 | 5578 else |
24065
7e291dea6141
(Fdecode_sjis_char): Decode Japanese Katakana character
Kenichi Handa <handa@m17n.org>
parents:
24056
diff
changeset
|
5579 error ("Can't encode to shift_jis: %d", XFASTINT (ch)); |
17052 | 5580 return val; |
5581 } | |
5582 | |
5583 DEFUN ("decode-big5-char", Fdecode_big5_char, Sdecode_big5_char, 1, 1, 0, | |
24324
2eec590faf26
(Fdecode_sjis_char, Fencode_sjis_char): Hanlde
Kenichi Handa <handa@m17n.org>
parents:
24316
diff
changeset
|
5584 "Decode a Big5 character which has CODE in BIG5 coding system.\n\ |
17052 | 5585 Return the corresponding character.") |
5586 (code) | |
5587 Lisp_Object code; | |
5588 { | |
5589 int charset; | |
5590 unsigned char b1, b2, c1, c2; | |
5591 Lisp_Object val; | |
5592 | |
5593 CHECK_NUMBER (code, 0); | |
5594 b1 = (XFASTINT (code)) >> 8, b2 = (XFASTINT (code)) & 0xFF; | |
24324
2eec590faf26
(Fdecode_sjis_char, Fencode_sjis_char): Hanlde
Kenichi Handa <handa@m17n.org>
parents:
24316
diff
changeset
|
5595 if (b1 == 0) |
2eec590faf26
(Fdecode_sjis_char, Fencode_sjis_char): Hanlde
Kenichi Handa <handa@m17n.org>
parents:
24316
diff
changeset
|
5596 { |
2eec590faf26
(Fdecode_sjis_char, Fencode_sjis_char): Hanlde
Kenichi Handa <handa@m17n.org>
parents:
24316
diff
changeset
|
5597 if (b2 >= 0x80) |
24344
8b7ef7fb9e2e
(Fdecode_sjis_char): In case of error, use %x for
Kenichi Handa <handa@m17n.org>
parents:
24324
diff
changeset
|
5598 error ("Invalid BIG5 code: %x", XFASTINT (code)); |
24324
2eec590faf26
(Fdecode_sjis_char, Fencode_sjis_char): Hanlde
Kenichi Handa <handa@m17n.org>
parents:
24316
diff
changeset
|
5599 val = code; |
2eec590faf26
(Fdecode_sjis_char, Fencode_sjis_char): Hanlde
Kenichi Handa <handa@m17n.org>
parents:
24316
diff
changeset
|
5600 } |
2eec590faf26
(Fdecode_sjis_char, Fencode_sjis_char): Hanlde
Kenichi Handa <handa@m17n.org>
parents:
24316
diff
changeset
|
5601 else |
2eec590faf26
(Fdecode_sjis_char, Fencode_sjis_char): Hanlde
Kenichi Handa <handa@m17n.org>
parents:
24316
diff
changeset
|
5602 { |
2eec590faf26
(Fdecode_sjis_char, Fencode_sjis_char): Hanlde
Kenichi Handa <handa@m17n.org>
parents:
24316
diff
changeset
|
5603 if ((b1 < 0xA1 || b1 > 0xFE) |
2eec590faf26
(Fdecode_sjis_char, Fencode_sjis_char): Hanlde
Kenichi Handa <handa@m17n.org>
parents:
24316
diff
changeset
|
5604 || (b2 < 0x40 || (b2 > 0x7E && b2 < 0xA1) || b2 > 0xFE)) |
24344
8b7ef7fb9e2e
(Fdecode_sjis_char): In case of error, use %x for
Kenichi Handa <handa@m17n.org>
parents:
24324
diff
changeset
|
5605 error ("Invalid BIG5 code: %x", XFASTINT (code)); |
24324
2eec590faf26
(Fdecode_sjis_char, Fencode_sjis_char): Hanlde
Kenichi Handa <handa@m17n.org>
parents:
24316
diff
changeset
|
5606 DECODE_BIG5 (b1, b2, charset, c1, c2); |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5607 XSETFASTINT (val, MAKE_CHAR (charset, c1, c2)); |
24324
2eec590faf26
(Fdecode_sjis_char, Fencode_sjis_char): Hanlde
Kenichi Handa <handa@m17n.org>
parents:
24316
diff
changeset
|
5608 } |
17052 | 5609 return val; |
5610 } | |
5611 | |
5612 DEFUN ("encode-big5-char", Fencode_big5_char, Sencode_big5_char, 1, 1, 0, | |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5613 "Encode the Big5 character CHAR to BIG5 coding system.\n\ |
17052 | 5614 Return the corresponding character code in Big5.") |
5615 (ch) | |
5616 Lisp_Object ch; | |
5617 { | |
17320
9d15bec5f47e
(detect_coding_iso2022, detect_coding_mask): Ignore
Kenichi Handa <handa@m17n.org>
parents:
17304
diff
changeset
|
5618 int charset, c1, c2, b1, b2; |
17052 | 5619 Lisp_Object val; |
5620 | |
5621 CHECK_NUMBER (ch, 0); | |
5622 SPLIT_CHAR (XFASTINT (ch), charset, c1, c2); | |
24324
2eec590faf26
(Fdecode_sjis_char, Fencode_sjis_char): Hanlde
Kenichi Handa <handa@m17n.org>
parents:
24316
diff
changeset
|
5623 if (charset == CHARSET_ASCII) |
2eec590faf26
(Fdecode_sjis_char, Fencode_sjis_char): Hanlde
Kenichi Handa <handa@m17n.org>
parents:
24316
diff
changeset
|
5624 { |
2eec590faf26
(Fdecode_sjis_char, Fencode_sjis_char): Hanlde
Kenichi Handa <handa@m17n.org>
parents:
24316
diff
changeset
|
5625 val = ch; |
2eec590faf26
(Fdecode_sjis_char, Fencode_sjis_char): Hanlde
Kenichi Handa <handa@m17n.org>
parents:
24316
diff
changeset
|
5626 } |
2eec590faf26
(Fdecode_sjis_char, Fencode_sjis_char): Hanlde
Kenichi Handa <handa@m17n.org>
parents:
24316
diff
changeset
|
5627 else if ((charset == charset_big5_1 |
2eec590faf26
(Fdecode_sjis_char, Fencode_sjis_char): Hanlde
Kenichi Handa <handa@m17n.org>
parents:
24316
diff
changeset
|
5628 && (XFASTINT (ch) >= 0x250a1 && XFASTINT (ch) <= 0x271ec)) |
2eec590faf26
(Fdecode_sjis_char, Fencode_sjis_char): Hanlde
Kenichi Handa <handa@m17n.org>
parents:
24316
diff
changeset
|
5629 || (charset == charset_big5_2 |
2eec590faf26
(Fdecode_sjis_char, Fencode_sjis_char): Hanlde
Kenichi Handa <handa@m17n.org>
parents:
24316
diff
changeset
|
5630 && XFASTINT (ch) >= 0x290a1 && XFASTINT (ch) <= 0x2bdb2)) |
17052 | 5631 { |
5632 ENCODE_BIG5 (charset, c1, c2, b1, b2); | |
17320
9d15bec5f47e
(detect_coding_iso2022, detect_coding_mask): Ignore
Kenichi Handa <handa@m17n.org>
parents:
17304
diff
changeset
|
5633 XSETFASTINT (val, (b1 << 8) | b2); |
17052 | 5634 } |
5635 else | |
24324
2eec590faf26
(Fdecode_sjis_char, Fencode_sjis_char): Hanlde
Kenichi Handa <handa@m17n.org>
parents:
24316
diff
changeset
|
5636 error ("Can't encode to Big5: %d", XFASTINT (ch)); |
17052 | 5637 return val; |
5638 } | |
20680
dd46027e8412
(code_convert_region): Always count chars inserted
Richard M. Stallman <rms@gnu.org>
parents:
20668
diff
changeset
|
5639 |
18002
a14261786239
(encode_invocation_designation): Use macro
Kenichi Handa <handa@m17n.org>
parents:
17835
diff
changeset
|
5640 DEFUN ("set-terminal-coding-system-internal", |
a14261786239
(encode_invocation_designation): Use macro
Kenichi Handa <handa@m17n.org>
parents:
17835
diff
changeset
|
5641 Fset_terminal_coding_system_internal, |
a14261786239
(encode_invocation_designation): Use macro
Kenichi Handa <handa@m17n.org>
parents:
17835
diff
changeset
|
5642 Sset_terminal_coding_system_internal, 1, 1, 0, "") |
17052 | 5643 (coding_system) |
5644 Lisp_Object coding_system; | |
5645 { | |
5646 CHECK_SYMBOL (coding_system, 0); | |
5647 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
|
5648 /* We had better not send unsafe characters to terminal. */ |
19285
af3d00fde172
(Fset_terminal_coding_system_internal): Set
Kenichi Handa <handa@m17n.org>
parents:
19280
diff
changeset
|
5649 terminal_coding.flags |= CODING_FLAG_ISO_SAFE; |
26847 | 5650 /* Characer composition should be disabled. */ |
5651 terminal_coding.composing = COMPOSITION_DISABLED; | |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5652 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
|
5653 terminal_coding.dst_multibyte = 0; |
17052 | 5654 return Qnil; |
5655 } | |
5656 | |
19280
e755044718ee
(ENCODE_ISO_CHARACTER_DIMENSION1): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
19193
diff
changeset
|
5657 DEFUN ("set-safe-terminal-coding-system-internal", |
e755044718ee
(ENCODE_ISO_CHARACTER_DIMENSION1): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
19193
diff
changeset
|
5658 Fset_safe_terminal_coding_system_internal, |
e755044718ee
(ENCODE_ISO_CHARACTER_DIMENSION1): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
19193
diff
changeset
|
5659 Sset_safe_terminal_coding_system_internal, 1, 1, 0, "") |
e755044718ee
(ENCODE_ISO_CHARACTER_DIMENSION1): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
19193
diff
changeset
|
5660 (coding_system) |
e755044718ee
(ENCODE_ISO_CHARACTER_DIMENSION1): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
19193
diff
changeset
|
5661 Lisp_Object coding_system; |
e755044718ee
(ENCODE_ISO_CHARACTER_DIMENSION1): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
19193
diff
changeset
|
5662 { |
e755044718ee
(ENCODE_ISO_CHARACTER_DIMENSION1): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
19193
diff
changeset
|
5663 CHECK_SYMBOL (coding_system, 0); |
e755044718ee
(ENCODE_ISO_CHARACTER_DIMENSION1): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
19193
diff
changeset
|
5664 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
|
5665 &safe_terminal_coding); |
26847 | 5666 /* Characer composition should be disabled. */ |
5667 safe_terminal_coding.composing = COMPOSITION_DISABLED; | |
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5668 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
|
5669 safe_terminal_coding.dst_multibyte = 0; |
19280
e755044718ee
(ENCODE_ISO_CHARACTER_DIMENSION1): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
19193
diff
changeset
|
5670 return Qnil; |
e755044718ee
(ENCODE_ISO_CHARACTER_DIMENSION1): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
19193
diff
changeset
|
5671 } |
e755044718ee
(ENCODE_ISO_CHARACTER_DIMENSION1): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
19193
diff
changeset
|
5672 |
17052 | 5673 DEFUN ("terminal-coding-system", |
5674 Fterminal_coding_system, Sterminal_coding_system, 0, 0, 0, | |
20680
dd46027e8412
(code_convert_region): Always count chars inserted
Richard M. Stallman <rms@gnu.org>
parents:
20668
diff
changeset
|
5675 "Return coding system specified for terminal output.") |
17052 | 5676 () |
5677 { | |
5678 return terminal_coding.symbol; | |
5679 } | |
5680 | |
18002
a14261786239
(encode_invocation_designation): Use macro
Kenichi Handa <handa@m17n.org>
parents:
17835
diff
changeset
|
5681 DEFUN ("set-keyboard-coding-system-internal", |
a14261786239
(encode_invocation_designation): Use macro
Kenichi Handa <handa@m17n.org>
parents:
17835
diff
changeset
|
5682 Fset_keyboard_coding_system_internal, |
a14261786239
(encode_invocation_designation): Use macro
Kenichi Handa <handa@m17n.org>
parents:
17835
diff
changeset
|
5683 Sset_keyboard_coding_system_internal, 1, 1, 0, "") |
17052 | 5684 (coding_system) |
5685 Lisp_Object coding_system; | |
5686 { | |
5687 CHECK_SYMBOL (coding_system, 0); | |
5688 setup_coding_system (Fcheck_coding_system (coding_system), &keyboard_coding); | |
26847 | 5689 /* Characer composition should be disabled. */ |
5690 keyboard_coding.composing = COMPOSITION_DISABLED; | |
17052 | 5691 return Qnil; |
5692 } | |
5693 | |
5694 DEFUN ("keyboard-coding-system", | |
5695 Fkeyboard_coding_system, Skeyboard_coding_system, 0, 0, 0, | |
20680
dd46027e8412
(code_convert_region): Always count chars inserted
Richard M. Stallman <rms@gnu.org>
parents:
20668
diff
changeset
|
5696 "Return coding system specified for decoding keyboard input.") |
17052 | 5697 () |
5698 { | |
5699 return keyboard_coding.symbol; | |
5700 } | |
5701 | |
5702 | |
18536
69c0e220b626
(Vstandard_character_unification_table_for_decode):
Kenichi Handa <handa@m17n.org>
parents:
18523
diff
changeset
|
5703 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
|
5704 Sfind_operation_coding_system, 1, MANY, 0, |
69c0e220b626
(Vstandard_character_unification_table_for_decode):
Kenichi Handa <handa@m17n.org>
parents:
18523
diff
changeset
|
5705 "Choose a coding system for an operation based on the target name.\n\ |
23201
392b44751a22
(ccl_coding_driver): Always calculate correct mulibyte
Kenichi Handa <handa@m17n.org>
parents:
23153
diff
changeset
|
5706 The value names a pair of coding systems: (DECODING-SYSTEM . ENCODING-SYSTEM).\n\ |
18650
aa3f2820e2ac
(Qemacs_mule, inhibit_eol_conversion): New variables.
Kenichi Handa <handa@m17n.org>
parents:
18613
diff
changeset
|
5707 DECODING-SYSTEM is the coding system to use for decoding\n\ |
aa3f2820e2ac
(Qemacs_mule, inhibit_eol_conversion): New variables.
Kenichi Handa <handa@m17n.org>
parents:
18613
diff
changeset
|
5708 \(in case OPERATION does decoding), and ENCODING-SYSTEM is the coding system\n\ |
aa3f2820e2ac
(Qemacs_mule, inhibit_eol_conversion): New variables.
Kenichi Handa <handa@m17n.org>
parents:
18613
diff
changeset
|
5709 for encoding (in case OPERATION does encoding).\n\ |
17304
ecacd8936926
(Ffind_coding_system): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
17190
diff
changeset
|
5710 \n\ |
ecacd8936926
(Ffind_coding_system): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
17190
diff
changeset
|
5711 The first argument OPERATION specifies an I/O primitive:\n\ |
ecacd8936926
(Ffind_coding_system): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
17190
diff
changeset
|
5712 For file I/O, `insert-file-contents' or `write-region'.\n\ |
ecacd8936926
(Ffind_coding_system): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
17190
diff
changeset
|
5713 For process I/O, `call-process', `call-process-region', or `start-process'.\n\ |
ecacd8936926
(Ffind_coding_system): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
17190
diff
changeset
|
5714 For network I/O, `open-network-stream'.\n\ |
ecacd8936926
(Ffind_coding_system): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
17190
diff
changeset
|
5715 \n\ |
ecacd8936926
(Ffind_coding_system): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
17190
diff
changeset
|
5716 The remaining arguments should be the same arguments that were passed\n\ |
ecacd8936926
(Ffind_coding_system): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
17190
diff
changeset
|
5717 to the primitive. Depending on which primitive, one of those arguments\n\ |
ecacd8936926
(Ffind_coding_system): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
17190
diff
changeset
|
5718 is selected as the TARGET. For example, if OPERATION does file I/O,\n\ |
ecacd8936926
(Ffind_coding_system): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
17190
diff
changeset
|
5719 whichever argument specifies the file name is TARGET.\n\ |
ecacd8936926
(Ffind_coding_system): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
17190
diff
changeset
|
5720 \n\ |
ecacd8936926
(Ffind_coding_system): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
17190
diff
changeset
|
5721 TARGET has a meaning which depends on OPERATION:\n\ |
17052 | 5722 For file I/O, TARGET is a file name.\n\ |
5723 For process I/O, TARGET is a process name.\n\ | |
5724 For network I/O, TARGET is a service name or a port number\n\ | |
5725 \n\ | |
18180
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
5726 This function looks up what specified for TARGET in,\n\ |
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
5727 `file-coding-system-alist', `process-coding-system-alist',\n\ |
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
5728 or `network-coding-system-alist' depending on OPERATION.\n\ |
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
5729 They may specify a coding system, a cons of coding systems,\n\ |
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
5730 or a function symbol to call.\n\ |
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
5731 In the last case, we call the function with one argument,\n\ |
18650
aa3f2820e2ac
(Qemacs_mule, inhibit_eol_conversion): New variables.
Kenichi Handa <handa@m17n.org>
parents:
18613
diff
changeset
|
5732 which is a list of all the arguments given to this function.") |
17052 | 5733 (nargs, args) |
5734 int nargs; | |
5735 Lisp_Object *args; | |
5736 { | |
5737 Lisp_Object operation, target_idx, target, val; | |
5738 register Lisp_Object chain; | |
5739 | |
5740 if (nargs < 2) | |
5741 error ("Too few arguments"); | |
5742 operation = args[0]; | |
5743 if (!SYMBOLP (operation) | |
5744 || !INTEGERP (target_idx = Fget (operation, Qtarget_idx))) | |
5745 error ("Invalid first arguement"); | |
5746 if (nargs < 1 + XINT (target_idx)) | |
5747 error ("Too few arguments for operation: %s", | |
5748 XSYMBOL (operation)->name->data); | |
5749 target = args[XINT (target_idx) + 1]; | |
5750 if (!(STRINGP (target) | |
5751 || (EQ (operation, Qopen_network_stream) && INTEGERP (target)))) | |
5752 error ("Invalid %dth argument", XINT (target_idx) + 1); | |
5753 | |
18613
614b916ff5bf
Fix bugs with inappropriate mixing of Lisp_Object with int.
Richard M. Stallman <rms@gnu.org>
parents:
18536
diff
changeset
|
5754 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
|
5755 || EQ (operation, Qwrite_region)) |
18180
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
5756 ? 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
|
5757 : (EQ (operation, Qopen_network_stream) |
18180
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
5758 ? Vnetwork_coding_system_alist |
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
5759 : Vprocess_coding_system_alist)); |
17052 | 5760 if (NILP (chain)) |
5761 return Qnil; | |
5762 | |
25662
0a7261c1d487
Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25370
diff
changeset
|
5763 for (; CONSP (chain); chain = XCDR (chain)) |
17052 | 5764 { |
19747
bed06df9cbc5
(setup_coding_system, Ffind_operation_coding_system)
Richard M. Stallman <rms@gnu.org>
parents:
19743
diff
changeset
|
5765 Lisp_Object elt; |
25662
0a7261c1d487
Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25370
diff
changeset
|
5766 elt = XCAR (chain); |
17052 | 5767 |
5768 if (CONSP (elt) | |
5769 && ((STRINGP (target) | |
25662
0a7261c1d487
Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25370
diff
changeset
|
5770 && STRINGP (XCAR (elt)) |
0a7261c1d487
Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25370
diff
changeset
|
5771 && 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
|
5772 || (INTEGERP (target) && EQ (target, XCAR (elt))))) |
18180
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
5773 { |
25662
0a7261c1d487
Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25370
diff
changeset
|
5774 val = XCDR (elt); |
19763
ab2fd2c85986
(Ffind_operation_coding_system): If a function in
Kenichi Handa <handa@m17n.org>
parents:
19758
diff
changeset
|
5775 /* 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
|
5776 function symbol, we return VAL as a coding system. */ |
18180
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
5777 if (CONSP (val)) |
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
5778 return val; |
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
5779 if (! SYMBOLP (val)) |
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
5780 return Qnil; |
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
5781 if (! NILP (Fcoding_system_p (val))) |
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
5782 return Fcons (val, val); |
19763
ab2fd2c85986
(Ffind_operation_coding_system): If a function in
Kenichi Handa <handa@m17n.org>
parents:
19758
diff
changeset
|
5783 if (! NILP (Ffboundp (val))) |
ab2fd2c85986
(Ffind_operation_coding_system): If a function in
Kenichi Handa <handa@m17n.org>
parents:
19758
diff
changeset
|
5784 { |
ab2fd2c85986
(Ffind_operation_coding_system): If a function in
Kenichi Handa <handa@m17n.org>
parents:
19758
diff
changeset
|
5785 val = call1 (val, Flist (nargs, args)); |
ab2fd2c85986
(Ffind_operation_coding_system): If a function in
Kenichi Handa <handa@m17n.org>
parents:
19758
diff
changeset
|
5786 if (CONSP (val)) |
ab2fd2c85986
(Ffind_operation_coding_system): If a function in
Kenichi Handa <handa@m17n.org>
parents:
19758
diff
changeset
|
5787 return val; |
ab2fd2c85986
(Ffind_operation_coding_system): If a function in
Kenichi Handa <handa@m17n.org>
parents:
19758
diff
changeset
|
5788 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
|
5789 return Fcons (val, val); |
ab2fd2c85986
(Ffind_operation_coding_system): If a function in
Kenichi Handa <handa@m17n.org>
parents:
19758
diff
changeset
|
5790 } |
18180
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
5791 return Qnil; |
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
5792 } |
17052 | 5793 } |
5794 return Qnil; | |
5795 } | |
5796 | |
22874
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
5797 DEFUN ("update-coding-systems-internal", Fupdate_coding_systems_internal, |
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
5798 Supdate_coding_systems_internal, 0, 0, 0, |
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
5799 "Update internal database for ISO2022 and CCL based coding systems.\n\ |
28022
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
5800 When values of any coding categories are changed, you must\n\ |
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
5801 call this function") |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5802 () |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5803 { |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5804 int i; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5805 |
28022
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
5806 for (i = CODING_CATEGORY_IDX_EMACS_MULE; i < CODING_CATEGORY_IDX_MAX; i++) |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5807 { |
22874
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
5808 Lisp_Object val; |
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
5809 |
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
5810 val = XSYMBOL (XVECTOR (Vcoding_category_table)->contents[i])->value; |
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
5811 if (!NILP (val)) |
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
5812 { |
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
5813 if (! coding_system_table[i]) |
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
5814 coding_system_table[i] = ((struct coding_system *) |
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
5815 xmalloc (sizeof (struct coding_system))); |
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
5816 setup_coding_system (val, coding_system_table[i]); |
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
5817 } |
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
5818 else if (coding_system_table[i]) |
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
5819 { |
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
5820 xfree (coding_system_table[i]); |
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
5821 coding_system_table[i] = NULL; |
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
5822 } |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5823 } |
22874
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
5824 |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5825 return Qnil; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5826 } |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5827 |
22226
557fac086b1b
(ascii_skip_code): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22186
diff
changeset
|
5828 DEFUN ("set-coding-priority-internal", Fset_coding_priority_internal, |
557fac086b1b
(ascii_skip_code): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22186
diff
changeset
|
5829 Sset_coding_priority_internal, 0, 0, 0, |
557fac086b1b
(ascii_skip_code): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22186
diff
changeset
|
5830 "Update internal database for the current value of `coding-category-list'.\n\ |
557fac086b1b
(ascii_skip_code): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22186
diff
changeset
|
5831 This function is internal use only.") |
557fac086b1b
(ascii_skip_code): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22186
diff
changeset
|
5832 () |
557fac086b1b
(ascii_skip_code): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22186
diff
changeset
|
5833 { |
557fac086b1b
(ascii_skip_code): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22186
diff
changeset
|
5834 int i = 0, idx; |
22954
928b337d953b
Avoid using initializers for Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents:
22874
diff
changeset
|
5835 Lisp_Object val; |
928b337d953b
Avoid using initializers for Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents:
22874
diff
changeset
|
5836 |
928b337d953b
Avoid using initializers for Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents:
22874
diff
changeset
|
5837 val = Vcoding_category_list; |
22226
557fac086b1b
(ascii_skip_code): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22186
diff
changeset
|
5838 |
557fac086b1b
(ascii_skip_code): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22186
diff
changeset
|
5839 while (CONSP (val) && i < CODING_CATEGORY_IDX_MAX) |
557fac086b1b
(ascii_skip_code): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22186
diff
changeset
|
5840 { |
25662
0a7261c1d487
Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25370
diff
changeset
|
5841 if (! SYMBOLP (XCAR (val))) |
22226
557fac086b1b
(ascii_skip_code): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22186
diff
changeset
|
5842 break; |
25662
0a7261c1d487
Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25370
diff
changeset
|
5843 idx = XFASTINT (Fget (XCAR (val), Qcoding_category_index)); |
22226
557fac086b1b
(ascii_skip_code): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22186
diff
changeset
|
5844 if (idx >= CODING_CATEGORY_IDX_MAX) |
557fac086b1b
(ascii_skip_code): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22186
diff
changeset
|
5845 break; |
557fac086b1b
(ascii_skip_code): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22186
diff
changeset
|
5846 coding_priorities[i++] = (1 << idx); |
25662
0a7261c1d487
Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25370
diff
changeset
|
5847 val = XCDR (val); |
22226
557fac086b1b
(ascii_skip_code): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22186
diff
changeset
|
5848 } |
557fac086b1b
(ascii_skip_code): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22186
diff
changeset
|
5849 /* If coding-category-list is valid and contains all coding |
557fac086b1b
(ascii_skip_code): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22186
diff
changeset
|
5850 categories, `i' should be CODING_CATEGORY_IDX_MAX now. If not, |
28022
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
5851 the following code saves Emacs from crashing. */ |
22226
557fac086b1b
(ascii_skip_code): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22186
diff
changeset
|
5852 while (i < CODING_CATEGORY_IDX_MAX) |
557fac086b1b
(ascii_skip_code): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22186
diff
changeset
|
5853 coding_priorities[i++] = CODING_CATEGORY_MASK_RAW_TEXT; |
557fac086b1b
(ascii_skip_code): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22186
diff
changeset
|
5854 |
557fac086b1b
(ascii_skip_code): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22186
diff
changeset
|
5855 return Qnil; |
557fac086b1b
(ascii_skip_code): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22186
diff
changeset
|
5856 } |
557fac086b1b
(ascii_skip_code): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22186
diff
changeset
|
5857 |
17052 | 5858 #endif /* emacs */ |
5859 | |
5860 | |
22874
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
5861 /*** 9. Post-amble ***/ |
17052 | 5862 |
21514 | 5863 void |
22790
7ab6c2f70b0b
(init_coding): New function.
Kenichi Handa <handa@m17n.org>
parents:
22723
diff
changeset
|
5864 init_coding () |
7ab6c2f70b0b
(init_coding): New function.
Kenichi Handa <handa@m17n.org>
parents:
22723
diff
changeset
|
5865 { |
7ab6c2f70b0b
(init_coding): New function.
Kenichi Handa <handa@m17n.org>
parents:
22723
diff
changeset
|
5866 conversion_buffer = (char *) xmalloc (MINIMUM_CONVERSION_BUFFER_SIZE); |
7ab6c2f70b0b
(init_coding): New function.
Kenichi Handa <handa@m17n.org>
parents:
22723
diff
changeset
|
5867 } |
7ab6c2f70b0b
(init_coding): New function.
Kenichi Handa <handa@m17n.org>
parents:
22723
diff
changeset
|
5868 |
7ab6c2f70b0b
(init_coding): New function.
Kenichi Handa <handa@m17n.org>
parents:
22723
diff
changeset
|
5869 void |
17052 | 5870 init_coding_once () |
5871 { | |
5872 int i; | |
5873 | |
17835
f36ffb6f1208
Name change through the code:
Kenichi Handa <handa@m17n.org>
parents:
17725
diff
changeset
|
5874 /* Emacs' internal format specific initialize routine. */ |
17052 | 5875 for (i = 0; i <= 0x20; i++) |
5876 emacs_code_class[i] = EMACS_control_code; | |
5877 emacs_code_class[0x0A] = EMACS_linefeed_code; | |
5878 emacs_code_class[0x0D] = EMACS_carriage_return_code; | |
5879 for (i = 0x21 ; i < 0x7F; i++) | |
5880 emacs_code_class[i] = EMACS_ascii_code; | |
5881 emacs_code_class[0x7F] = EMACS_control_code; | |
26847 | 5882 for (i = 0x80; i < 0xFF; i++) |
17052 | 5883 emacs_code_class[i] = EMACS_invalid_code; |
5884 emacs_code_class[LEADING_CODE_PRIVATE_11] = EMACS_leading_code_3; | |
5885 emacs_code_class[LEADING_CODE_PRIVATE_12] = EMACS_leading_code_3; | |
5886 emacs_code_class[LEADING_CODE_PRIVATE_21] = EMACS_leading_code_4; | |
5887 emacs_code_class[LEADING_CODE_PRIVATE_22] = EMACS_leading_code_4; | |
5888 | |
5889 /* ISO2022 specific initialize routine. */ | |
5890 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
|
5891 iso_code_class[i] = ISO_control_0; |
17052 | 5892 for (i = 0x21; i < 0x7F; i++) |
5893 iso_code_class[i] = ISO_graphic_plane_0; | |
5894 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
|
5895 iso_code_class[i] = ISO_control_1; |
17052 | 5896 for (i = 0xA1; i < 0xFF; i++) |
5897 iso_code_class[i] = ISO_graphic_plane_1; | |
5898 iso_code_class[0x20] = iso_code_class[0x7F] = ISO_0x20_or_0x7F; | |
5899 iso_code_class[0xA0] = iso_code_class[0xFF] = ISO_0xA0_or_0xFF; | |
5900 iso_code_class[ISO_CODE_CR] = ISO_carriage_return; | |
5901 iso_code_class[ISO_CODE_SO] = ISO_shift_out; | |
5902 iso_code_class[ISO_CODE_SI] = ISO_shift_in; | |
5903 iso_code_class[ISO_CODE_SS2_7] = ISO_single_shift_2_7; | |
5904 iso_code_class[ISO_CODE_ESC] = ISO_escape; | |
5905 iso_code_class[ISO_CODE_SS2] = ISO_single_shift_2; | |
5906 iso_code_class[ISO_CODE_SS3] = ISO_single_shift_3; | |
5907 iso_code_class[ISO_CODE_CSI] = ISO_control_sequence_introducer; | |
5908 | |
17119
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
5909 conversion_buffer_size = MINIMUM_CONVERSION_BUFFER_SIZE; |
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
5910 |
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
5911 setup_coding_system (Qnil, &keyboard_coding); |
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
5912 setup_coding_system (Qnil, &terminal_coding); |
19280
e755044718ee
(ENCODE_ISO_CHARACTER_DIMENSION1): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
19193
diff
changeset
|
5913 setup_coding_system (Qnil, &safe_terminal_coding); |
22979
ceb8e4a89a32
(default_buffer_file_coding): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22964
diff
changeset
|
5914 setup_coding_system (Qnil, &default_buffer_file_coding); |
18650
aa3f2820e2ac
(Qemacs_mule, inhibit_eol_conversion): New variables.
Kenichi Handa <handa@m17n.org>
parents:
18613
diff
changeset
|
5915 |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5916 bzero (coding_system_table, sizeof coding_system_table); |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5917 |
22226
557fac086b1b
(ascii_skip_code): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22186
diff
changeset
|
5918 bzero (ascii_skip_code, sizeof ascii_skip_code); |
557fac086b1b
(ascii_skip_code): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22186
diff
changeset
|
5919 for (i = 0; i < 128; i++) |
557fac086b1b
(ascii_skip_code): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22186
diff
changeset
|
5920 ascii_skip_code[i] = 1; |
557fac086b1b
(ascii_skip_code): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22186
diff
changeset
|
5921 |
18650
aa3f2820e2ac
(Qemacs_mule, inhibit_eol_conversion): New variables.
Kenichi Handa <handa@m17n.org>
parents:
18613
diff
changeset
|
5922 #if defined (MSDOS) || defined (WINDOWSNT) |
aa3f2820e2ac
(Qemacs_mule, inhibit_eol_conversion): New variables.
Kenichi Handa <handa@m17n.org>
parents:
18613
diff
changeset
|
5923 system_eol_type = CODING_EOL_CRLF; |
aa3f2820e2ac
(Qemacs_mule, inhibit_eol_conversion): New variables.
Kenichi Handa <handa@m17n.org>
parents:
18613
diff
changeset
|
5924 #else |
aa3f2820e2ac
(Qemacs_mule, inhibit_eol_conversion): New variables.
Kenichi Handa <handa@m17n.org>
parents:
18613
diff
changeset
|
5925 system_eol_type = CODING_EOL_LF; |
aa3f2820e2ac
(Qemacs_mule, inhibit_eol_conversion): New variables.
Kenichi Handa <handa@m17n.org>
parents:
18613
diff
changeset
|
5926 #endif |
26067
f54ca66e2571
(code_convert_string): Add record_unwind_protect to
Kenichi Handa <handa@m17n.org>
parents:
25860
diff
changeset
|
5927 |
f54ca66e2571
(code_convert_string): Add record_unwind_protect to
Kenichi Handa <handa@m17n.org>
parents:
25860
diff
changeset
|
5928 inhibit_pre_post_conversion = 0; |
17119
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
5929 } |
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
5930 |
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
5931 #ifdef emacs |
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
5932 |
21514 | 5933 void |
17119
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
5934 syms_of_coding () |
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
5935 { |
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
5936 Qtarget_idx = intern ("target-idx"); |
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
5937 staticpro (&Qtarget_idx); |
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
5938 |
19750
95e4e1cba6ac
(Qcoding_system_history): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
19747
diff
changeset
|
5939 Qcoding_system_history = intern ("coding-system-history"); |
95e4e1cba6ac
(Qcoding_system_history): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
19747
diff
changeset
|
5940 staticpro (&Qcoding_system_history); |
95e4e1cba6ac
(Qcoding_system_history): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
19747
diff
changeset
|
5941 Fset (Qcoding_system_history, Qnil); |
95e4e1cba6ac
(Qcoding_system_history): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
19747
diff
changeset
|
5942 |
18650
aa3f2820e2ac
(Qemacs_mule, inhibit_eol_conversion): New variables.
Kenichi Handa <handa@m17n.org>
parents:
18613
diff
changeset
|
5943 /* 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
|
5944 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
|
5945 /* 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
|
5946 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
|
5947 |
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
5948 Qcall_process = intern ("call-process"); |
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
5949 staticpro (&Qcall_process); |
18650
aa3f2820e2ac
(Qemacs_mule, inhibit_eol_conversion): New variables.
Kenichi Handa <handa@m17n.org>
parents:
18613
diff
changeset
|
5950 /* 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
|
5951 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
|
5952 |
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
5953 Qcall_process_region = intern ("call-process-region"); |
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
5954 staticpro (&Qcall_process_region); |
18650
aa3f2820e2ac
(Qemacs_mule, inhibit_eol_conversion): New variables.
Kenichi Handa <handa@m17n.org>
parents:
18613
diff
changeset
|
5955 /* 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
|
5956 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
|
5957 |
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
5958 Qstart_process = intern ("start-process"); |
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
5959 staticpro (&Qstart_process); |
18650
aa3f2820e2ac
(Qemacs_mule, inhibit_eol_conversion): New variables.
Kenichi Handa <handa@m17n.org>
parents:
18613
diff
changeset
|
5960 /* 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
|
5961 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
|
5962 |
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
5963 Qopen_network_stream = intern ("open-network-stream"); |
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
5964 staticpro (&Qopen_network_stream); |
18650
aa3f2820e2ac
(Qemacs_mule, inhibit_eol_conversion): New variables.
Kenichi Handa <handa@m17n.org>
parents:
18613
diff
changeset
|
5965 /* 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
|
5966 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
|
5967 |
17052 | 5968 Qcoding_system = intern ("coding-system"); |
5969 staticpro (&Qcoding_system); | |
5970 | |
5971 Qeol_type = intern ("eol-type"); | |
5972 staticpro (&Qeol_type); | |
5973 | |
5974 Qbuffer_file_coding_system = intern ("buffer-file-coding-system"); | |
5975 staticpro (&Qbuffer_file_coding_system); | |
5976 | |
5977 Qpost_read_conversion = intern ("post-read-conversion"); | |
5978 staticpro (&Qpost_read_conversion); | |
5979 | |
5980 Qpre_write_conversion = intern ("pre-write-conversion"); | |
5981 staticpro (&Qpre_write_conversion); | |
5982 | |
19612
783efd6c7c1e
(Qno_conversion, Qundecided): New variables.
Kenichi Handa <handa@m17n.org>
parents:
19546
diff
changeset
|
5983 Qno_conversion = intern ("no-conversion"); |
783efd6c7c1e
(Qno_conversion, Qundecided): New variables.
Kenichi Handa <handa@m17n.org>
parents:
19546
diff
changeset
|
5984 staticpro (&Qno_conversion); |
783efd6c7c1e
(Qno_conversion, Qundecided): New variables.
Kenichi Handa <handa@m17n.org>
parents:
19546
diff
changeset
|
5985 |
783efd6c7c1e
(Qno_conversion, Qundecided): New variables.
Kenichi Handa <handa@m17n.org>
parents:
19546
diff
changeset
|
5986 Qundecided = intern ("undecided"); |
783efd6c7c1e
(Qno_conversion, Qundecided): New variables.
Kenichi Handa <handa@m17n.org>
parents:
19546
diff
changeset
|
5987 staticpro (&Qundecided); |
783efd6c7c1e
(Qno_conversion, Qundecided): New variables.
Kenichi Handa <handa@m17n.org>
parents:
19546
diff
changeset
|
5988 |
17052 | 5989 Qcoding_system_p = intern ("coding-system-p"); |
5990 staticpro (&Qcoding_system_p); | |
5991 | |
5992 Qcoding_system_error = intern ("coding-system-error"); | |
5993 staticpro (&Qcoding_system_error); | |
5994 | |
5995 Fput (Qcoding_system_error, Qerror_conditions, | |
5996 Fcons (Qcoding_system_error, Fcons (Qerror, Qnil))); | |
5997 Fput (Qcoding_system_error, Qerror_message, | |
18650
aa3f2820e2ac
(Qemacs_mule, inhibit_eol_conversion): New variables.
Kenichi Handa <handa@m17n.org>
parents:
18613
diff
changeset
|
5998 build_string ("Invalid coding system")); |
17052 | 5999 |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
6000 Qcoding_category = intern ("coding-category"); |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
6001 staticpro (&Qcoding_category); |
17052 | 6002 Qcoding_category_index = intern ("coding-category-index"); |
6003 staticpro (&Qcoding_category_index); | |
6004 | |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
6005 Vcoding_category_table |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
6006 = Fmake_vector (make_number (CODING_CATEGORY_IDX_MAX), Qnil); |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
6007 staticpro (&Vcoding_category_table); |
17052 | 6008 { |
6009 int i; | |
6010 for (i = 0; i < CODING_CATEGORY_IDX_MAX; i++) | |
6011 { | |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
6012 XVECTOR (Vcoding_category_table)->contents[i] |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
6013 = intern (coding_category_name[i]); |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
6014 Fput (XVECTOR (Vcoding_category_table)->contents[i], |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
6015 Qcoding_category_index, make_number (i)); |
17052 | 6016 } |
6017 } | |
6018 | |
22186
fc4aaf1b1772
Change term "character translation table" to "translation table".
Kenichi Handa <handa@m17n.org>
parents:
22166
diff
changeset
|
6019 Qtranslation_table = intern ("translation-table"); |
fc4aaf1b1772
Change term "character translation table" to "translation table".
Kenichi Handa <handa@m17n.org>
parents:
22166
diff
changeset
|
6020 staticpro (&Qtranslation_table); |
22874
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
6021 Fput (Qtranslation_table, Qchar_table_extra_slots, make_number (1)); |
22186
fc4aaf1b1772
Change term "character translation table" to "translation table".
Kenichi Handa <handa@m17n.org>
parents:
22166
diff
changeset
|
6022 |
fc4aaf1b1772
Change term "character translation table" to "translation table".
Kenichi Handa <handa@m17n.org>
parents:
22166
diff
changeset
|
6023 Qtranslation_table_id = intern ("translation-table-id"); |
fc4aaf1b1772
Change term "character translation table" to "translation table".
Kenichi Handa <handa@m17n.org>
parents:
22166
diff
changeset
|
6024 staticpro (&Qtranslation_table_id); |
fc4aaf1b1772
Change term "character translation table" to "translation table".
Kenichi Handa <handa@m17n.org>
parents:
22166
diff
changeset
|
6025 |
fc4aaf1b1772
Change term "character translation table" to "translation table".
Kenichi Handa <handa@m17n.org>
parents:
22166
diff
changeset
|
6026 Qtranslation_table_for_decode = intern ("translation-table-for-decode"); |
fc4aaf1b1772
Change term "character translation table" to "translation table".
Kenichi Handa <handa@m17n.org>
parents:
22166
diff
changeset
|
6027 staticpro (&Qtranslation_table_for_decode); |
fc4aaf1b1772
Change term "character translation table" to "translation table".
Kenichi Handa <handa@m17n.org>
parents:
22166
diff
changeset
|
6028 |
fc4aaf1b1772
Change term "character translation table" to "translation table".
Kenichi Handa <handa@m17n.org>
parents:
22166
diff
changeset
|
6029 Qtranslation_table_for_encode = intern ("translation-table-for-encode"); |
fc4aaf1b1772
Change term "character translation table" to "translation table".
Kenichi Handa <handa@m17n.org>
parents:
22166
diff
changeset
|
6030 staticpro (&Qtranslation_table_for_encode); |
18536
69c0e220b626
(Vstandard_character_unification_table_for_decode):
Kenichi Handa <handa@m17n.org>
parents:
18523
diff
changeset
|
6031 |
20150
402b6e5f4b58
(encode_designation_at_bol): Fix bug of finding graphic
Kenichi Handa <handa@m17n.org>
parents:
20105
diff
changeset
|
6032 Qsafe_charsets = intern ("safe-charsets"); |
402b6e5f4b58
(encode_designation_at_bol): Fix bug of finding graphic
Kenichi Handa <handa@m17n.org>
parents:
20105
diff
changeset
|
6033 staticpro (&Qsafe_charsets); |
402b6e5f4b58
(encode_designation_at_bol): Fix bug of finding graphic
Kenichi Handa <handa@m17n.org>
parents:
20105
diff
changeset
|
6034 |
22874
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
6035 Qvalid_codes = intern ("valid-codes"); |
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
6036 staticpro (&Qvalid_codes); |
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
6037 |
18650
aa3f2820e2ac
(Qemacs_mule, inhibit_eol_conversion): New variables.
Kenichi Handa <handa@m17n.org>
parents:
18613
diff
changeset
|
6038 Qemacs_mule = intern ("emacs-mule"); |
aa3f2820e2ac
(Qemacs_mule, inhibit_eol_conversion): New variables.
Kenichi Handa <handa@m17n.org>
parents:
18613
diff
changeset
|
6039 staticpro (&Qemacs_mule); |
aa3f2820e2ac
(Qemacs_mule, inhibit_eol_conversion): New variables.
Kenichi Handa <handa@m17n.org>
parents:
18613
diff
changeset
|
6040 |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
6041 Qraw_text = intern ("raw-text"); |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
6042 staticpro (&Qraw_text); |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
6043 |
17052 | 6044 defsubr (&Scoding_system_p); |
6045 defsubr (&Sread_coding_system); | |
6046 defsubr (&Sread_non_nil_coding_system); | |
6047 defsubr (&Scheck_coding_system); | |
6048 defsubr (&Sdetect_coding_region); | |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
6049 defsubr (&Sdetect_coding_string); |
17052 | 6050 defsubr (&Sdecode_coding_region); |
6051 defsubr (&Sencode_coding_region); | |
6052 defsubr (&Sdecode_coding_string); | |
6053 defsubr (&Sencode_coding_string); | |
6054 defsubr (&Sdecode_sjis_char); | |
6055 defsubr (&Sencode_sjis_char); | |
6056 defsubr (&Sdecode_big5_char); | |
6057 defsubr (&Sencode_big5_char); | |
18002
a14261786239
(encode_invocation_designation): Use macro
Kenichi Handa <handa@m17n.org>
parents:
17835
diff
changeset
|
6058 defsubr (&Sset_terminal_coding_system_internal); |
19280
e755044718ee
(ENCODE_ISO_CHARACTER_DIMENSION1): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
19193
diff
changeset
|
6059 defsubr (&Sset_safe_terminal_coding_system_internal); |
17052 | 6060 defsubr (&Sterminal_coding_system); |
18002
a14261786239
(encode_invocation_designation): Use macro
Kenichi Handa <handa@m17n.org>
parents:
17835
diff
changeset
|
6061 defsubr (&Sset_keyboard_coding_system_internal); |
17052 | 6062 defsubr (&Skeyboard_coding_system); |
18536
69c0e220b626
(Vstandard_character_unification_table_for_decode):
Kenichi Handa <handa@m17n.org>
parents:
18523
diff
changeset
|
6063 defsubr (&Sfind_operation_coding_system); |
22874
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
6064 defsubr (&Supdate_coding_systems_internal); |
22226
557fac086b1b
(ascii_skip_code): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22186
diff
changeset
|
6065 defsubr (&Sset_coding_priority_internal); |
17052 | 6066 |
20105
c017642863c2
(Qcoding_system_spec): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
19824
diff
changeset
|
6067 DEFVAR_LISP ("coding-system-list", &Vcoding_system_list, |
c017642863c2
(Qcoding_system_spec): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
19824
diff
changeset
|
6068 "List of coding systems.\n\ |
c017642863c2
(Qcoding_system_spec): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
19824
diff
changeset
|
6069 \n\ |
c017642863c2
(Qcoding_system_spec): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
19824
diff
changeset
|
6070 Do not alter the value of this variable manually. This variable should be\n\ |
c017642863c2
(Qcoding_system_spec): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
19824
diff
changeset
|
6071 updated by the functions `make-coding-system' and\n\ |
c017642863c2
(Qcoding_system_spec): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
19824
diff
changeset
|
6072 `define-coding-system-alias'."); |
c017642863c2
(Qcoding_system_spec): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
19824
diff
changeset
|
6073 Vcoding_system_list = Qnil; |
c017642863c2
(Qcoding_system_spec): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
19824
diff
changeset
|
6074 |
c017642863c2
(Qcoding_system_spec): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
19824
diff
changeset
|
6075 DEFVAR_LISP ("coding-system-alist", &Vcoding_system_alist, |
c017642863c2
(Qcoding_system_spec): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
19824
diff
changeset
|
6076 "Alist of coding system names.\n\ |
c017642863c2
(Qcoding_system_spec): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
19824
diff
changeset
|
6077 Each element is one element list of coding system name.\n\ |
c017642863c2
(Qcoding_system_spec): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
19824
diff
changeset
|
6078 This variable is given to `completing-read' as TABLE argument.\n\ |
c017642863c2
(Qcoding_system_spec): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
19824
diff
changeset
|
6079 \n\ |
c017642863c2
(Qcoding_system_spec): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
19824
diff
changeset
|
6080 Do not alter the value of this variable manually. This variable should be\n\ |
c017642863c2
(Qcoding_system_spec): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
19824
diff
changeset
|
6081 updated by the functions `make-coding-system' and\n\ |
c017642863c2
(Qcoding_system_spec): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
19824
diff
changeset
|
6082 `define-coding-system-alias'."); |
c017642863c2
(Qcoding_system_spec): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
19824
diff
changeset
|
6083 Vcoding_system_alist = Qnil; |
c017642863c2
(Qcoding_system_spec): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
19824
diff
changeset
|
6084 |
17052 | 6085 DEFVAR_LISP ("coding-category-list", &Vcoding_category_list, |
6086 "List of coding-categories (symbols) ordered by priority."); | |
6087 { | |
6088 int i; | |
6089 | |
6090 Vcoding_category_list = Qnil; | |
6091 for (i = CODING_CATEGORY_IDX_MAX - 1; i >= 0; i--) | |
6092 Vcoding_category_list | |
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
6093 = Fcons (XVECTOR (Vcoding_category_table)->contents[i], |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
6094 Vcoding_category_list); |
17052 | 6095 } |
6096 | |
6097 DEFVAR_LISP ("coding-system-for-read", &Vcoding_system_for_read, | |
19118
16ef8c28e4e0
(detect_coding_mask): Include CODING_CATEGORY_MASK_BINARY in the
Richard M. Stallman <rms@gnu.org>
parents:
19068
diff
changeset
|
6098 "Specify the coding system for read operations.\n\ |
19193
1701f2296f99
(syms_of_coding): Doc syntax fixes.
Richard M. Stallman <rms@gnu.org>
parents:
19181
diff
changeset
|
6099 It is useful to bind this variable with `let', but do not set it globally.\n\ |
17052 | 6100 If the value is a coding system, it is used for decoding on read operation.\n\ |
18910
50c89868f8c7
(syms_of_coding): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
18860
diff
changeset
|
6101 If not, an appropriate element is used from one of the coding system alists:\n\ |
19118
16ef8c28e4e0
(detect_coding_mask): Include CODING_CATEGORY_MASK_BINARY in the
Richard M. Stallman <rms@gnu.org>
parents:
19068
diff
changeset
|
6102 There are three such tables, `file-coding-system-alist',\n\ |
18910
50c89868f8c7
(syms_of_coding): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
18860
diff
changeset
|
6103 `process-coding-system-alist', and `network-coding-system-alist'."); |
17052 | 6104 Vcoding_system_for_read = Qnil; |
6105 | |
6106 DEFVAR_LISP ("coding-system-for-write", &Vcoding_system_for_write, | |
19118
16ef8c28e4e0
(detect_coding_mask): Include CODING_CATEGORY_MASK_BINARY in the
Richard M. Stallman <rms@gnu.org>
parents:
19068
diff
changeset
|
6107 "Specify the coding system for write operations.\n\ |
24766
c15dcedcb81c
(syms_of_coding): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
24706
diff
changeset
|
6108 Programs bind this variable with `let', but you should not set it globally.\n\ |
c15dcedcb81c
(syms_of_coding): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
24706
diff
changeset
|
6109 If the value is a coding system, it is used for encoding of output,\n\ |
c15dcedcb81c
(syms_of_coding): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
24706
diff
changeset
|
6110 when writing it to a file and when sending it to a file or subprocess.\n\ |
c15dcedcb81c
(syms_of_coding): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
24706
diff
changeset
|
6111 \n\ |
c15dcedcb81c
(syms_of_coding): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
24706
diff
changeset
|
6112 If this does not specify a coding system, an appropriate element\n\ |
c15dcedcb81c
(syms_of_coding): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
24706
diff
changeset
|
6113 is used from one of the coding system alists:\n\ |
19118
16ef8c28e4e0
(detect_coding_mask): Include CODING_CATEGORY_MASK_BINARY in the
Richard M. Stallman <rms@gnu.org>
parents:
19068
diff
changeset
|
6114 There are three such tables, `file-coding-system-alist',\n\ |
24766
c15dcedcb81c
(syms_of_coding): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
24706
diff
changeset
|
6115 `process-coding-system-alist', and `network-coding-system-alist'.\n\ |
c15dcedcb81c
(syms_of_coding): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
24706
diff
changeset
|
6116 For output to files, if the above procedure does not specify a coding system,\n\ |
c15dcedcb81c
(syms_of_coding): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
24706
diff
changeset
|
6117 the value of `buffer-file-coding-system' is used."); |
17052 | 6118 Vcoding_system_for_write = Qnil; |
6119 | |
6120 DEFVAR_LISP ("last-coding-system-used", &Vlast_coding_system_used, | |
18910
50c89868f8c7
(syms_of_coding): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
18860
diff
changeset
|
6121 "Coding system used in the latest file or process I/O."); |
17052 | 6122 Vlast_coding_system_used = Qnil; |
6123 | |
18650
aa3f2820e2ac
(Qemacs_mule, inhibit_eol_conversion): New variables.
Kenichi Handa <handa@m17n.org>
parents:
18613
diff
changeset
|
6124 DEFVAR_BOOL ("inhibit-eol-conversion", &inhibit_eol_conversion, |
24056
d20160af7b6e
(syms_of_coding): Doc fix for inhibit-eol-conversion.
Dave Love <fx@gnu.org>
parents:
23881
diff
changeset
|
6125 "*Non-nil means always inhibit code conversion of end-of-line format.\n\ |
24178
38e26ebed6f7
(syms_of_coding): Doc fix for inhibit-eol-conversion.
Dave Love <fx@gnu.org>
parents:
24065
diff
changeset
|
6126 See info node `Coding Systems' and info node `Text and Binary' concerning\n\ |
38e26ebed6f7
(syms_of_coding): Doc fix for inhibit-eol-conversion.
Dave Love <fx@gnu.org>
parents:
24065
diff
changeset
|
6127 such conversion."); |
18650
aa3f2820e2ac
(Qemacs_mule, inhibit_eol_conversion): New variables.
Kenichi Handa <handa@m17n.org>
parents:
18613
diff
changeset
|
6128 inhibit_eol_conversion = 0; |
aa3f2820e2ac
(Qemacs_mule, inhibit_eol_conversion): New variables.
Kenichi Handa <handa@m17n.org>
parents:
18613
diff
changeset
|
6129 |
21574
30394e3ae7f8
(syms_of_coding): Declare and define inherit-process-coding-system.
Eli Zaretskii <eliz@gnu.org>
parents:
21520
diff
changeset
|
6130 DEFVAR_BOOL ("inherit-process-coding-system", &inherit_process_coding_system, |
30394e3ae7f8
(syms_of_coding): Declare and define inherit-process-coding-system.
Eli Zaretskii <eliz@gnu.org>
parents:
21520
diff
changeset
|
6131 "Non-nil means process buffer inherits coding system of process output.\n\ |
30394e3ae7f8
(syms_of_coding): Declare and define inherit-process-coding-system.
Eli Zaretskii <eliz@gnu.org>
parents:
21520
diff
changeset
|
6132 Bind it to t if the process output is to be treated as if it were a file\n\ |
30394e3ae7f8
(syms_of_coding): Declare and define inherit-process-coding-system.
Eli Zaretskii <eliz@gnu.org>
parents:
21520
diff
changeset
|
6133 read from some filesystem."); |
30394e3ae7f8
(syms_of_coding): Declare and define inherit-process-coding-system.
Eli Zaretskii <eliz@gnu.org>
parents:
21520
diff
changeset
|
6134 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
|
6135 |
18180
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
6136 DEFVAR_LISP ("file-coding-system-alist", &Vfile_coding_system_alist, |
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
6137 "Alist to decide a coding system to use for a file I/O operation.\n\ |
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
6138 The format is ((PATTERN . VAL) ...),\n\ |
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
6139 where PATTERN is a regular expression matching a file name,\n\ |
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
6140 VAL is a coding system, a cons of coding systems, or a function symbol.\n\ |
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
6141 If VAL is a coding system, it is used for both decoding and encoding\n\ |
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
6142 the file contents.\n\ |
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
6143 If VAL is a cons of coding systems, the car part is used for decoding,\n\ |
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
6144 and the cdr part is used for encoding.\n\ |
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
6145 If VAL is a function symbol, the function must return a coding system\n\ |
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
6146 or a cons of coding systems which are used as above.\n\ |
17119
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
6147 \n\ |
23089
20486aa49e7d
(file-coding-system-alist, select-safe-coding-system-function): Doc fix.
Andreas Schwab <schwab@suse.de>
parents:
23088
diff
changeset
|
6148 See also the function `find-operation-coding-system'\n\ |
22812
70f58e77fda7
(syms_of_coding): Mention auto-coding-alist in the
Kenichi Handa <handa@m17n.org>
parents:
22790
diff
changeset
|
6149 and the variable `auto-coding-alist'."); |
18180
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
6150 Vfile_coding_system_alist = Qnil; |
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
6151 |
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
6152 DEFVAR_LISP ("process-coding-system-alist", &Vprocess_coding_system_alist, |
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
6153 "Alist to decide a coding system to use for a process I/O operation.\n\ |
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
6154 The format is ((PATTERN . VAL) ...),\n\ |
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
6155 where PATTERN is a regular expression matching a program name,\n\ |
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
6156 VAL is a coding system, a cons of coding systems, or a function symbol.\n\ |
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
6157 If VAL is a coding system, it is used for both decoding what received\n\ |
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
6158 from the program and encoding what sent to the program.\n\ |
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
6159 If VAL is a cons of coding systems, the car part is used for decoding,\n\ |
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
6160 and the cdr part is used for encoding.\n\ |
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
6161 If VAL is a function symbol, the function must return a coding system\n\ |
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
6162 or a cons of coding systems which are used as above.\n\ |
17052 | 6163 \n\ |
18650
aa3f2820e2ac
(Qemacs_mule, inhibit_eol_conversion): New variables.
Kenichi Handa <handa@m17n.org>
parents:
18613
diff
changeset
|
6164 See also the function `find-operation-coding-system'."); |
18180
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
6165 Vprocess_coding_system_alist = Qnil; |
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
6166 |
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
6167 DEFVAR_LISP ("network-coding-system-alist", &Vnetwork_coding_system_alist, |
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
6168 "Alist to decide a coding system to use for a network I/O operation.\n\ |
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
6169 The format is ((PATTERN . VAL) ...),\n\ |
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
6170 where PATTERN is a regular expression matching a network service name\n\ |
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
6171 or is a port number to connect to,\n\ |
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
6172 VAL is a coding system, a cons of coding systems, or a function symbol.\n\ |
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
6173 If VAL is a coding system, it is used for both decoding what received\n\ |
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
6174 from the network stream and encoding what sent to the network stream.\n\ |
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
6175 If VAL is a cons of coding systems, the car part is used for decoding,\n\ |
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
6176 and the cdr part is used for encoding.\n\ |
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
6177 If VAL is a function symbol, the function must return a coding system\n\ |
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
6178 or a cons of coding systems which are used as above.\n\ |
17052 | 6179 \n\ |
18650
aa3f2820e2ac
(Qemacs_mule, inhibit_eol_conversion): New variables.
Kenichi Handa <handa@m17n.org>
parents:
18613
diff
changeset
|
6180 See also the function `find-operation-coding-system'."); |
18180
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
6181 Vnetwork_coding_system_alist = Qnil; |
17052 | 6182 |
26088
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
26067
diff
changeset
|
6183 DEFVAR_LISP ("locale-coding-system", &Vlocale_coding_system, |
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
26067
diff
changeset
|
6184 "Coding system to use with system messages."); |
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
26067
diff
changeset
|
6185 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
|
6186 |
29182
1d1c27067af4
(encode_eol): Add null statement after label.
Dave Love <fx@gnu.org>
parents:
29172
diff
changeset
|
6187 /* 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
|
6188 DEFVAR_LISP ("eol-mnemonic-unix", &eol_mnemonic_unix, |
b9d9fccad516
(syms_of_coding): eol-mnemonic-* variables are now
Eli Zaretskii <eliz@gnu.org>
parents:
24178
diff
changeset
|
6189 "*String displayed in mode line for UNIX-like (LF) end-of-line format."); |
b9d9fccad516
(syms_of_coding): eol-mnemonic-* variables are now
Eli Zaretskii <eliz@gnu.org>
parents:
24178
diff
changeset
|
6190 eol_mnemonic_unix = build_string (":"); |
b9d9fccad516
(syms_of_coding): eol-mnemonic-* variables are now
Eli Zaretskii <eliz@gnu.org>
parents:
24178
diff
changeset
|
6191 |
b9d9fccad516
(syms_of_coding): eol-mnemonic-* variables are now
Eli Zaretskii <eliz@gnu.org>
parents:
24178
diff
changeset
|
6192 DEFVAR_LISP ("eol-mnemonic-dos", &eol_mnemonic_dos, |
b9d9fccad516
(syms_of_coding): eol-mnemonic-* variables are now
Eli Zaretskii <eliz@gnu.org>
parents:
24178
diff
changeset
|
6193 "*String displayed in mode line for DOS-like (CRLF) end-of-line format."); |
b9d9fccad516
(syms_of_coding): eol-mnemonic-* variables are now
Eli Zaretskii <eliz@gnu.org>
parents:
24178
diff
changeset
|
6194 eol_mnemonic_dos = build_string ("\\"); |
b9d9fccad516
(syms_of_coding): eol-mnemonic-* variables are now
Eli Zaretskii <eliz@gnu.org>
parents:
24178
diff
changeset
|
6195 |
b9d9fccad516
(syms_of_coding): eol-mnemonic-* variables are now
Eli Zaretskii <eliz@gnu.org>
parents:
24178
diff
changeset
|
6196 DEFVAR_LISP ("eol-mnemonic-mac", &eol_mnemonic_mac, |
b9d9fccad516
(syms_of_coding): eol-mnemonic-* variables are now
Eli Zaretskii <eliz@gnu.org>
parents:
24178
diff
changeset
|
6197 "*String displayed in mode line for MAC-like (CR) end-of-line format."); |
b9d9fccad516
(syms_of_coding): eol-mnemonic-* variables are now
Eli Zaretskii <eliz@gnu.org>
parents:
24178
diff
changeset
|
6198 eol_mnemonic_mac = build_string ("/"); |
b9d9fccad516
(syms_of_coding): eol-mnemonic-* variables are now
Eli Zaretskii <eliz@gnu.org>
parents:
24178
diff
changeset
|
6199 |
b9d9fccad516
(syms_of_coding): eol-mnemonic-* variables are now
Eli Zaretskii <eliz@gnu.org>
parents:
24178
diff
changeset
|
6200 DEFVAR_LISP ("eol-mnemonic-undecided", &eol_mnemonic_undecided, |
b9d9fccad516
(syms_of_coding): eol-mnemonic-* variables are now
Eli Zaretskii <eliz@gnu.org>
parents:
24178
diff
changeset
|
6201 "*String displayed in mode line when end-of-line format is not yet determined."); |
b9d9fccad516
(syms_of_coding): eol-mnemonic-* variables are now
Eli Zaretskii <eliz@gnu.org>
parents:
24178
diff
changeset
|
6202 eol_mnemonic_undecided = build_string (":"); |
17052 | 6203 |
22119
592bb8b9bcfd
Change terms unify/unification to
Kenichi Handa <handa@m17n.org>
parents:
22020
diff
changeset
|
6204 DEFVAR_LISP ("enable-character-translation", &Venable_character_translation, |
22186
fc4aaf1b1772
Change term "character translation table" to "translation table".
Kenichi Handa <handa@m17n.org>
parents:
22166
diff
changeset
|
6205 "*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
|
6206 Venable_character_translation = Qt; |
592bb8b9bcfd
Change terms unify/unification to
Kenichi Handa <handa@m17n.org>
parents:
22020
diff
changeset
|
6207 |
22186
fc4aaf1b1772
Change term "character translation table" to "translation table".
Kenichi Handa <handa@m17n.org>
parents:
22166
diff
changeset
|
6208 DEFVAR_LISP ("standard-translation-table-for-decode", |
fc4aaf1b1772
Change term "character translation table" to "translation table".
Kenichi Handa <handa@m17n.org>
parents:
22166
diff
changeset
|
6209 &Vstandard_translation_table_for_decode, |
22119
592bb8b9bcfd
Change terms unify/unification to
Kenichi Handa <handa@m17n.org>
parents:
22020
diff
changeset
|
6210 "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
|
6211 Vstandard_translation_table_for_decode = Qnil; |
fc4aaf1b1772
Change term "character translation table" to "translation table".
Kenichi Handa <handa@m17n.org>
parents:
22166
diff
changeset
|
6212 |
fc4aaf1b1772
Change term "character translation table" to "translation table".
Kenichi Handa <handa@m17n.org>
parents:
22166
diff
changeset
|
6213 DEFVAR_LISP ("standard-translation-table-for-encode", |
fc4aaf1b1772
Change term "character translation table" to "translation table".
Kenichi Handa <handa@m17n.org>
parents:
22166
diff
changeset
|
6214 &Vstandard_translation_table_for_encode, |
22119
592bb8b9bcfd
Change terms unify/unification to
Kenichi Handa <handa@m17n.org>
parents:
22020
diff
changeset
|
6215 "Table for translationg characters while encoding."); |
22186
fc4aaf1b1772
Change term "character translation table" to "translation table".
Kenichi Handa <handa@m17n.org>
parents:
22166
diff
changeset
|
6216 Vstandard_translation_table_for_encode = Qnil; |
17052 | 6217 |
6218 DEFVAR_LISP ("charset-revision-table", &Vcharset_revision_alist, | |
6219 "Alist of charsets vs revision numbers.\n\ | |
6220 While encoding, if a charset (car part of an element) is found,\n\ | |
6221 designate it with the escape sequence identifing revision (cdr part of the element)."); | |
6222 Vcharset_revision_alist = Qnil; | |
18180
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
6223 |
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
6224 DEFVAR_LISP ("default-process-coding-system", |
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
6225 &Vdefault_process_coding_system, |
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
6226 "Cons of coding systems used for process I/O by default.\n\ |
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
6227 The car part is used for decoding a process output,\n\ |
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
6228 the cdr part is used for encoding a text to be sent to a process."); |
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
6229 Vdefault_process_coding_system = Qnil; |
19280
e755044718ee
(ENCODE_ISO_CHARACTER_DIMENSION1): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
19193
diff
changeset
|
6230 |
19365
d9374f5ebd3a
(CODING_FLAG_ISO_LATIN_EXTRA): New macro.
Kenichi Handa <handa@m17n.org>
parents:
19285
diff
changeset
|
6231 DEFVAR_LISP ("latin-extra-code-table", &Vlatin_extra_code_table, |
d9374f5ebd3a
(CODING_FLAG_ISO_LATIN_EXTRA): New macro.
Kenichi Handa <handa@m17n.org>
parents:
19285
diff
changeset
|
6232 "Table of extra Latin codes in the range 128..159 (inclusive).\n\ |
19280
e755044718ee
(ENCODE_ISO_CHARACTER_DIMENSION1): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
19193
diff
changeset
|
6233 This is a vector of length 256.\n\ |
e755044718ee
(ENCODE_ISO_CHARACTER_DIMENSION1): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
19193
diff
changeset
|
6234 If Nth element is non-nil, the existence of code N in a file\n\ |
19750
95e4e1cba6ac
(Qcoding_system_history): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
19747
diff
changeset
|
6235 \(or output of subprocess) doesn't prevent it to be detected as\n\ |
19365
d9374f5ebd3a
(CODING_FLAG_ISO_LATIN_EXTRA): New macro.
Kenichi Handa <handa@m17n.org>
parents:
19285
diff
changeset
|
6236 a coding system of ISO 2022 variant which has a flag\n\ |
d9374f5ebd3a
(CODING_FLAG_ISO_LATIN_EXTRA): New macro.
Kenichi Handa <handa@m17n.org>
parents:
19285
diff
changeset
|
6237 `accept-latin-extra-code' t (e.g. iso-latin-1) on reading a file\n\ |
19280
e755044718ee
(ENCODE_ISO_CHARACTER_DIMENSION1): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
19193
diff
changeset
|
6238 or reading output of a subprocess.\n\ |
e755044718ee
(ENCODE_ISO_CHARACTER_DIMENSION1): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
19193
diff
changeset
|
6239 Only 128th through 159th elements has a meaning."); |
19365
d9374f5ebd3a
(CODING_FLAG_ISO_LATIN_EXTRA): New macro.
Kenichi Handa <handa@m17n.org>
parents:
19285
diff
changeset
|
6240 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
|
6241 |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
6242 DEFVAR_LISP ("select-safe-coding-system-function", |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
6243 &Vselect_safe_coding_system_function, |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
6244 "Function to call to select safe coding system for encoding a text.\n\ |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
6245 \n\ |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
6246 If set, this function is called to force a user to select a proper\n\ |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
6247 coding system which can encode the text in the case that a default\n\ |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
6248 coding system used in each operation can't encode the text.\n\ |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
6249 \n\ |
23089
20486aa49e7d
(file-coding-system-alist, select-safe-coding-system-function): Doc fix.
Andreas Schwab <schwab@suse.de>
parents:
23088
diff
changeset
|
6250 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
|
6251 Vselect_safe_coding_system_function = Qnil; |
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
6252 |
17052 | 6253 } |
6254 | |
26088
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
26067
diff
changeset
|
6255 char * |
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
26067
diff
changeset
|
6256 emacs_strerror (error_number) |
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
26067
diff
changeset
|
6257 int error_number; |
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
26067
diff
changeset
|
6258 { |
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
26067
diff
changeset
|
6259 char *str; |
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
26067
diff
changeset
|
6260 |
26526
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26240
diff
changeset
|
6261 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
|
6262 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
|
6263 |
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
26067
diff
changeset
|
6264 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
|
6265 { |
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
26067
diff
changeset
|
6266 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
|
6267 Vlocale_coding_system, |
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
26067
diff
changeset
|
6268 0); |
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
26067
diff
changeset
|
6269 str = (char *) XSTRING (dec)->data; |
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
26067
diff
changeset
|
6270 } |
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
26067
diff
changeset
|
6271 |
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
26067
diff
changeset
|
6272 return str; |
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
26067
diff
changeset
|
6273 } |
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
26067
diff
changeset
|
6274 |
17052 | 6275 #endif /* emacs */ |
29184 | 6276 |