Mercurial > emacs
annotate src/coding.c @ 94954:81ec00f72dc6
(setup-default-fontset): For kana, han,
hangul, and cjk-misc, move an entry with font-spec at the end.
(generate-fontset-menu): Exclue fontset-auto* from the list.
| author | Kenichi Handa <handa@m17n.org> |
|---|---|
| date | Wed, 14 May 2008 01:55:46 +0000 |
| parents | c16046e21b90 |
| children | 8971ddf55736 |
| rev | line source |
|---|---|
| 88936 | 1 /* Coding system handler (conversion, detection, etc). |
|
68651
3bd95f4f2941
Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
68567
diff
changeset
|
2 Copyright (C) 2001, 2002, 2003, 2004, 2005, |
| 79759 | 3 2006, 2007, 2008 Free Software Foundation, Inc. |
|
74605
6ee41fdd69ff
Update AIST copyright years.
Kenichi Handa <handa@m17n.org>
parents:
73995
diff
changeset
|
4 Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, |
| 79759 | 5 2005, 2006, 2007, 2008 |
| 67658 | 6 National Institute of Advanced Industrial Science and Technology (AIST) |
| 7 Registration Number H14PRO021 | |
| 89483 | 8 Copyright (C) 2003 |
| 88365 | 9 National Institute of Advanced Industrial Science and Technology (AIST) |
| 10 Registration Number H13PRO009 | |
| 17052 | 11 |
| 17071 | 12 This file is part of GNU Emacs. |
| 13 | |
| 14 GNU Emacs is free software; you can redistribute it and/or modify | |
| 15 it under the terms of the GNU General Public License as published by | |
|
78313
2b9404c2f01f
Remove license from trivial file.
Glenn Morris <rgm@gnu.org>
parents:
78152
diff
changeset
|
16 the Free Software Foundation; either version 3, or (at your option) |
| 17071 | 17 any later version. |
| 18 | |
| 19 GNU Emacs is distributed in the hope that it will be useful, | |
| 20 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 21 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 22 GNU General Public License for more details. | |
| 23 | |
| 24 You should have received a copy of the GNU General Public License | |
| 25 along with GNU Emacs; see the file COPYING. If not, write to | |
| 64084 | 26 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
| 27 Boston, MA 02110-1301, USA. */ | |
| 17052 | 28 |
| 29 /*** TABLE OF CONTENTS *** | |
| 30 | |
|
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
31 0. General comments |
| 17052 | 32 1. Preamble |
| 88365 | 33 2. Emacs' internal format (emacs-utf-8) handlers |
| 34 3. UTF-8 handlers | |
| 35 4. UTF-16 handlers | |
| 36 5. Charset-base coding systems handlers | |
| 37 6. emacs-mule (old Emacs' internal format) handlers | |
| 38 7. ISO2022 handlers | |
| 39 8. Shift-JIS and BIG5 handlers | |
| 40 9. CCL handlers | |
| 41 10. C library functions | |
| 42 11. Emacs Lisp library functions | |
| 43 12. Postamble | |
| 17052 | 44 |
| 45 */ | |
| 46 | |
| 88365 | 47 /*** 0. General comments *** |
| 48 | |
| 49 | |
| 50 CODING SYSTEM | |
| 51 | |
| 88485 | 52 A coding system is an object for an encoding mechanism that contains |
| 53 information about how to convert byte sequences to character | |
|
88438
3a34b722dd71
(encode_coding_utf_8): Initialize produced_chars to 0.
Kenichi Handa <handa@m17n.org>
parents:
88430
diff
changeset
|
54 sequences and vice versa. When we say "decode", it means converting |
|
3a34b722dd71
(encode_coding_utf_8): Initialize produced_chars to 0.
Kenichi Handa <handa@m17n.org>
parents:
88430
diff
changeset
|
55 a byte sequence of a specific coding system into a character |
|
3a34b722dd71
(encode_coding_utf_8): Initialize produced_chars to 0.
Kenichi Handa <handa@m17n.org>
parents:
88430
diff
changeset
|
56 sequence that is represented by Emacs' internal coding system |
|
3a34b722dd71
(encode_coding_utf_8): Initialize produced_chars to 0.
Kenichi Handa <handa@m17n.org>
parents:
88430
diff
changeset
|
57 `emacs-utf-8', and when we say "encode", it means converting a |
|
3a34b722dd71
(encode_coding_utf_8): Initialize produced_chars to 0.
Kenichi Handa <handa@m17n.org>
parents:
88430
diff
changeset
|
58 character sequence of emacs-utf-8 to a byte sequence of a specific |
|
17835
f36ffb6f1208
Name change through the code:
Kenichi Handa <handa@m17n.org>
parents:
17725
diff
changeset
|
59 coding system. |
|
f36ffb6f1208
Name change through the code:
Kenichi Handa <handa@m17n.org>
parents:
17725
diff
changeset
|
60 |
|
88438
3a34b722dd71
(encode_coding_utf_8): Initialize produced_chars to 0.
Kenichi Handa <handa@m17n.org>
parents:
88430
diff
changeset
|
61 In Emacs Lisp, a coding system is represented by a Lisp symbol. In |
|
3a34b722dd71
(encode_coding_utf_8): Initialize produced_chars to 0.
Kenichi Handa <handa@m17n.org>
parents:
88430
diff
changeset
|
62 C level, a coding system is represented by a vector of attributes |
| 88485 | 63 stored in the hash table Vcharset_hash_table. The conversion from |
|
88438
3a34b722dd71
(encode_coding_utf_8): Initialize produced_chars to 0.
Kenichi Handa <handa@m17n.org>
parents:
88430
diff
changeset
|
64 coding system symbol to attributes vector is done by looking up |
|
3a34b722dd71
(encode_coding_utf_8): Initialize produced_chars to 0.
Kenichi Handa <handa@m17n.org>
parents:
88430
diff
changeset
|
65 Vcharset_hash_table by the symbol. |
|
3a34b722dd71
(encode_coding_utf_8): Initialize produced_chars to 0.
Kenichi Handa <handa@m17n.org>
parents:
88430
diff
changeset
|
66 |
|
3a34b722dd71
(encode_coding_utf_8): Initialize produced_chars to 0.
Kenichi Handa <handa@m17n.org>
parents:
88430
diff
changeset
|
67 Coding systems are classified into the following types depending on |
| 88485 | 68 the encoding mechanism. Here's a brief description of the types. |
| 88365 | 69 |
| 70 o UTF-8 | |
| 71 | |
| 72 o UTF-16 | |
| 73 | |
| 74 o Charset-base coding system | |
| 75 | |
| 76 A coding system defined by one or more (coded) character sets. | |
| 88485 | 77 Decoding and encoding are done by a code converter defined for each |
| 88365 | 78 character set. |
| 79 | |
| 88485 | 80 o Old Emacs internal format (emacs-mule) |
| 81 | |
| 82 The coding system adopted by old versions of Emacs (20 and 21). | |
| 88365 | 83 |
| 84 o ISO2022-base coding system | |
| 17052 | 85 |
| 86 The most famous coding system for multiple character sets. X's | |
| 88365 | 87 Compound Text, various EUCs (Extended Unix Code), and coding systems |
| 88 used in the Internet communication such as ISO-2022-JP are all | |
| 89 variants of ISO2022. | |
| 90 | |
| 91 o SJIS (or Shift-JIS or MS-Kanji-Code) | |
|
42104
d69c2368e549
(DECODE_COMPOSITION_END): Fixed a typo in the last
Sam Steingold <sds@gnu.org>
parents:
42103
diff
changeset
|
92 |
| 17052 | 93 A coding system to encode character sets: ASCII, JISX0201, and |
| 94 JISX0208. Widely used for PC's in Japan. Details are described in | |
| 88365 | 95 section 8. |
| 96 | |
| 97 o BIG5 | |
| 98 | |
| 99 A coding system to encode character sets: ASCII and Big5. Widely | |
| 35053 | 100 used for Chinese (mainly in Taiwan and Hong Kong). Details are |
| 88365 | 101 described in section 8. In this file, when we write "big5" (all |
| 102 lowercase), we mean the coding system, and when we write "Big5" | |
| 103 (capitalized), we mean the character set. | |
| 104 | |
| 105 o CCL | |
| 106 | |
| 88485 | 107 If a user wants to decode/encode text encoded in a coding system |
| 88365 | 108 not listed above, he can supply a decoder and an encoder for it in |
| 109 CCL (Code Conversion Language) programs. Emacs executes the CCL | |
| 110 program while decoding/encoding. | |
| 111 | |
| 112 o Raw-text | |
| 113 | |
| 88771 | 114 A coding system for text containing raw eight-bit data. Emacs |
| 88485 | 115 treats each byte of source text as a character (except for |
| 88365 | 116 end-of-line conversion). |
| 117 | |
| 118 o No-conversion | |
| 119 | |
| 120 Like raw text, but don't do end-of-line conversion. | |
| 121 | |
| 122 | |
| 123 END-OF-LINE FORMAT | |
| 124 | |
| 88485 | 125 How text end-of-line is encoded depends on operating system. For |
| 88365 | 126 instance, Unix's format is just one byte of LF (line-feed) code, |
| 18766 | 127 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
|
128 `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
|
129 `carriage-return'. |
| 17052 | 130 |
| 35053 | 131 Since text character encoding and end-of-line encoding are |
| 88365 | 132 independent, any coding system described above can take any format |
| 133 of end-of-line (except for no-conversion). | |
| 17052 | 134 |
|
88438
3a34b722dd71
(encode_coding_utf_8): Initialize produced_chars to 0.
Kenichi Handa <handa@m17n.org>
parents:
88430
diff
changeset
|
135 STRUCT CODING_SYSTEM |
|
3a34b722dd71
(encode_coding_utf_8): Initialize produced_chars to 0.
Kenichi Handa <handa@m17n.org>
parents:
88430
diff
changeset
|
136 |
|
3a34b722dd71
(encode_coding_utf_8): Initialize produced_chars to 0.
Kenichi Handa <handa@m17n.org>
parents:
88430
diff
changeset
|
137 Before using a coding system for code conversion (i.e. decoding and |
|
3a34b722dd71
(encode_coding_utf_8): Initialize produced_chars to 0.
Kenichi Handa <handa@m17n.org>
parents:
88430
diff
changeset
|
138 encoding), we setup a structure of type `struct coding_system'. |
|
3a34b722dd71
(encode_coding_utf_8): Initialize produced_chars to 0.
Kenichi Handa <handa@m17n.org>
parents:
88430
diff
changeset
|
139 This structure keeps various information about a specific code |
| 88485 | 140 conversion (e.g. the location of source and destination data). |
| 17052 | 141 |
| 142 */ | |
| 143 | |
| 88365 | 144 /* COMMON MACROS */ |
| 145 | |
| 146 | |
| 17052 | 147 /*** GENERAL NOTES on `detect_coding_XXX ()' functions *** |
| 148 | |
| 88365 | 149 These functions check if a byte sequence specified as a source in |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
150 CODING conforms to the format of XXX, and update the members of |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
151 DETECT_INFO. |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
152 |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
153 Return 1 if the byte sequence conforms to XXX, otherwise return 0. |
| 88365 | 154 |
| 155 Below is the template of these functions. */ | |
| 156 | |
| 17052 | 157 #if 0 |
| 88365 | 158 static int |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
159 detect_coding_XXX (coding, detect_info) |
| 88365 | 160 struct coding_system *coding; |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
161 struct coding_detection_info *detect_info; |
| 17052 | 162 { |
|
90070
95879cc1ed20
Revision: miles@gnu.org--gnu-2004/emacs--unicode--0--patch-81
Miles Bader <miles@gnu.org>
diff
changeset
|
163 const unsigned char *src = coding->source; |
|
95879cc1ed20
Revision: miles@gnu.org--gnu-2004/emacs--unicode--0--patch-81
Miles Bader <miles@gnu.org>
diff
changeset
|
164 const unsigned char *src_end = coding->source + coding->src_bytes; |
| 88365 | 165 int multibytep = coding->src_multibyte; |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
166 int consumed_chars = 0; |
| 88365 | 167 int found = 0; |
| 168 ...; | |
| 169 | |
| 170 while (1) | |
| 171 { | |
| 172 /* Get one byte from the source. If the souce is exausted, jump | |
| 173 to no_more_source:. */ | |
| 174 ONE_MORE_BYTE (c); | |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
175 |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
176 if (! __C_conforms_to_XXX___ (c)) |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
177 break; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
178 if (! __C_strongly_suggests_XXX__ (c)) |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
179 found = CATEGORY_MASK_XXX; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
180 } |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
181 /* The byte sequence is invalid for XXX. */ |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
182 detect_info->rejected |= CATEGORY_MASK_XXX; |
| 88365 | 183 return 0; |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
184 |
| 88365 | 185 no_more_source: |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
186 /* The source exausted successfully. */ |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
187 detect_info->found |= found; |
| 88365 | 188 return 1; |
| 17052 | 189 } |
| 190 #endif | |
| 191 | |
| 192 /*** GENERAL NOTES on `decode_coding_XXX ()' functions *** | |
| 193 | |
| 88365 | 194 These functions decode a byte sequence specified as a source by |
| 195 CODING. The resulting multibyte text goes to a place pointed to by | |
| 196 CODING->charbuf, the length of which should not exceed | |
| 197 CODING->charbuf_size; | |
| 198 | |
| 199 These functions set the information of original and decoded texts in | |
| 200 CODING->consumed, CODING->consumed_char, and CODING->charbuf_used. | |
| 201 They also set CODING->result to one of CODING_RESULT_XXX indicating | |
| 202 how the decoding is finished. | |
| 203 | |
| 204 Below is the template of these functions. */ | |
| 205 | |
| 17052 | 206 #if 0 |
|
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
207 static void |
| 88365 | 208 decode_coding_XXXX (coding) |
| 17052 | 209 struct coding_system *coding; |
| 210 { | |
|
90070
95879cc1ed20
Revision: miles@gnu.org--gnu-2004/emacs--unicode--0--patch-81
Miles Bader <miles@gnu.org>
diff
changeset
|
211 const unsigned char *src = coding->source + coding->consumed; |
|
95879cc1ed20
Revision: miles@gnu.org--gnu-2004/emacs--unicode--0--patch-81
Miles Bader <miles@gnu.org>
diff
changeset
|
212 const unsigned char *src_end = coding->source + coding->src_bytes; |
| 88365 | 213 /* SRC_BASE remembers the start position in source in each loop. |
| 214 The loop will be exited when there's not enough source code, or | |
| 215 when there's no room in CHARBUF for a decoded character. */ | |
|
90070
95879cc1ed20
Revision: miles@gnu.org--gnu-2004/emacs--unicode--0--patch-81
Miles Bader <miles@gnu.org>
diff
changeset
|
216 const unsigned char *src_base; |
| 88365 | 217 /* A buffer to produce decoded characters. */ |
|
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
218 int *charbuf = coding->charbuf + coding->charbuf_used; |
|
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
219 int *charbuf_end = coding->charbuf + coding->charbuf_size; |
| 88365 | 220 int multibytep = coding->src_multibyte; |
| 221 | |
| 222 while (1) | |
| 223 { | |
| 224 src_base = src; | |
| 225 if (charbuf < charbuf_end) | |
| 226 /* No more room to produce a decoded character. */ | |
| 227 break; | |
| 228 ONE_MORE_BYTE (c); | |
| 229 /* Decode it. */ | |
| 230 } | |
| 231 | |
| 232 no_more_source: | |
| 233 if (src_base < src_end | |
| 234 && coding->mode & CODING_MODE_LAST_BLOCK) | |
| 235 /* If the source ends by partial bytes to construct a character, | |
| 236 treat them as eight-bit raw data. */ | |
| 237 while (src_base < src_end && charbuf < charbuf_end) | |
| 238 *charbuf++ = *src_base++; | |
| 239 /* Remember how many bytes and characters we consumed. If the | |
| 240 source is multibyte, the bytes and chars are not identical. */ | |
| 241 coding->consumed = coding->consumed_char = src_base - coding->source; | |
| 242 /* Remember how many characters we produced. */ | |
| 243 coding->charbuf_used = charbuf - coding->charbuf; | |
| 17052 | 244 } |
| 245 #endif | |
| 246 | |
| 247 /*** GENERAL NOTES on `encode_coding_XXX ()' functions *** | |
| 248 | |
| 88365 | 249 These functions encode SRC_BYTES length text at SOURCE of Emacs' |
| 250 internal multibyte format by CODING. The resulting byte sequence | |
|
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
251 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
|
252 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
|
253 |
| 88365 | 254 These functions set the information of original and encoded texts in |
| 255 the members produced, produced_char, consumed, and consumed_char of | |
| 256 the structure *CODING. They also set the member result to one of | |
| 257 CODING_RESULT_XXX indicating how the encoding finished. | |
| 258 | |
| 259 DST_BYTES zero means that source area and destination area are | |
| 260 overlapped, which means that we can produce a encoded text until it | |
| 261 reaches at the head of not-yet-encoded source text. | |
| 262 | |
| 263 Below is a template of these functions. */ | |
| 17052 | 264 #if 0 |
|
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
265 static void |
| 88365 | 266 encode_coding_XXX (coding) |
| 17052 | 267 struct coding_system *coding; |
| 268 { | |
| 88365 | 269 int multibytep = coding->dst_multibyte; |
| 270 int *charbuf = coding->charbuf; | |
| 271 int *charbuf_end = charbuf->charbuf + coding->charbuf_used; | |
| 272 unsigned char *dst = coding->destination + coding->produced; | |
| 273 unsigned char *dst_end = coding->destination + coding->dst_bytes; | |
| 274 unsigned char *adjusted_dst_end = dst_end - _MAX_BYTES_PRODUCED_IN_LOOP_; | |
| 275 int produced_chars = 0; | |
| 276 | |
| 277 for (; charbuf < charbuf_end && dst < adjusted_dst_end; charbuf++) | |
| 278 { | |
| 279 int c = *charbuf; | |
| 280 /* Encode C into DST, and increment DST. */ | |
| 281 } | |
| 282 label_no_more_destination: | |
| 283 /* How many chars and bytes we produced. */ | |
| 284 coding->produced_char += produced_chars; | |
| 285 coding->produced = dst - coding->destination; | |
| 17052 | 286 } |
| 287 #endif | |
| 288 | |
| 289 | |
| 290 /*** 1. Preamble ***/ | |
| 291 | |
|
26088
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
26067
diff
changeset
|
292 #include <config.h> |
| 17052 | 293 #include <stdio.h> |
| 294 | |
| 295 #include "lisp.h" | |
| 296 #include "buffer.h" | |
| 88365 | 297 #include "character.h" |
| 17052 | 298 #include "charset.h" |
| 88365 | 299 #include "ccl.h" |
| 26847 | 300 #include "composite.h" |
| 17052 | 301 #include "coding.h" |
| 302 #include "window.h" | |
|
83127
5182815e0ee1
Make terminal_coding and keyboard_coding display-local.
Karoly Lorentey <lorentey@elte.hu>
parents:
54320
diff
changeset
|
303 #include "frame.h" |
|
5182815e0ee1
Make terminal_coding and keyboard_coding display-local.
Karoly Lorentey <lorentey@elte.hu>
parents:
54320
diff
changeset
|
304 #include "termhooks.h" |
| 17052 | 305 |
| 88365 | 306 Lisp_Object Vcoding_system_hash_table; |
| 307 | |
| 308 Lisp_Object Qcoding_system, Qcoding_aliases, Qeol_type; | |
|
88646
d3b1f30e2267
(Qmac): Remove (duplicated) definition.
Dave Love <fx@gnu.org>
parents:
88645
diff
changeset
|
309 Lisp_Object Qunix, Qdos; |
|
d3b1f30e2267
(Qmac): Remove (duplicated) definition.
Dave Love <fx@gnu.org>
parents:
88645
diff
changeset
|
310 extern Lisp_Object Qmac; /* frame.c */ |
| 17052 | 311 Lisp_Object Qbuffer_file_coding_system; |
| 312 Lisp_Object Qpost_read_conversion, Qpre_write_conversion; | |
| 88365 | 313 Lisp_Object Qdefault_char; |
|
19612
783efd6c7c1e
(Qno_conversion, Qundecided): New variables.
Kenichi Handa <handa@m17n.org>
parents:
19546
diff
changeset
|
314 Lisp_Object Qno_conversion, Qundecided; |
| 88365 | 315 Lisp_Object Qcharset, Qiso_2022, Qutf_8, Qutf_16, Qshift_jis, Qbig5; |
|
89420
c3e67ce6ee0f
(Qsignature, Qendian): Delete these variables.
Kenichi Handa <handa@m17n.org>
parents:
89418
diff
changeset
|
316 Lisp_Object Qbig, Qlittle; |
|
19750
95e4e1cba6ac
(Qcoding_system_history): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
19747
diff
changeset
|
317 Lisp_Object Qcoding_system_history; |
|
22874
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
318 Lisp_Object Qvalid_codes; |
|
89759
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
319 Lisp_Object QCcategory, QCmnemonic, QCdefalut_char; |
|
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
320 Lisp_Object QCdecode_translation_table, QCencode_translation_table; |
|
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
321 Lisp_Object QCpost_read_conversion, QCpre_write_conversion; |
|
90214
460ee00505d5
(QCascii_compatible_p): New variable.
Kenichi Handa <handa@m17n.org>
parents:
90201
diff
changeset
|
322 Lisp_Object QCascii_compatible_p; |
| 17052 | 323 |
| 324 extern Lisp_Object Qinsert_file_contents, Qwrite_region; | |
|
64251
3de1b955c31a
* coding.c (Qprocess_argument):
Kim F. Storm <storm@cua.dk>
parents:
64084
diff
changeset
|
325 Lisp_Object Qcall_process, Qcall_process_region; |
| 17052 | 326 Lisp_Object Qstart_process, Qopen_network_stream; |
| 327 Lisp_Object Qtarget_idx; | |
| 328 | |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
329 Lisp_Object Qinsufficient_source, Qinconsistent_eol, Qinvalid_source; |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
330 Lisp_Object Qinterrupted, Qinsufficient_memory; |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
331 |
|
79107
cce707ee192e
(Qcompletion_ignore_case): New external Lisp_Object.
Glenn Morris <rgm@gnu.org>
parents:
78313
diff
changeset
|
332 extern Lisp_Object Qcompletion_ignore_case; |
|
cce707ee192e
(Qcompletion_ignore_case): New external Lisp_Object.
Glenn Morris <rgm@gnu.org>
parents:
78313
diff
changeset
|
333 |
|
52794
f4d906e31662
(Qcoding_system_define_form): New variable.
Kenichi Handa <handa@m17n.org>
parents:
52401
diff
changeset
|
334 /* If a symbol has this property, evaluate the value to define the |
|
f4d906e31662
(Qcoding_system_define_form): New variable.
Kenichi Handa <handa@m17n.org>
parents:
52401
diff
changeset
|
335 symbol as a coding system. */ |
|
90272
f1df126ec7de
Sync to HEAD for handling autoload-coding-system.
Kenichi Handa <handa@m17n.org>
parents:
90263
diff
changeset
|
336 static Lisp_Object Qcoding_system_define_form; |
|
f1df126ec7de
Sync to HEAD for handling autoload-coding-system.
Kenichi Handa <handa@m17n.org>
parents:
90263
diff
changeset
|
337 |
| 89483 | 338 int coding_system_require_warning; |
|
52794
f4d906e31662
(Qcoding_system_define_form): New variable.
Kenichi Handa <handa@m17n.org>
parents:
52401
diff
changeset
|
339 |
|
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
340 Lisp_Object Vselect_safe_coding_system_function; |
|
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
341 |
|
24200
b9d9fccad516
(syms_of_coding): eol-mnemonic-* variables are now
Eli Zaretskii <eliz@gnu.org>
parents:
24178
diff
changeset
|
342 /* 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
|
343 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
|
344 /* Mnemonic string to indicate format of end-of-line is not yet |
| 17052 | 345 decided. */ |
|
24200
b9d9fccad516
(syms_of_coding): eol-mnemonic-* variables are now
Eli Zaretskii <eliz@gnu.org>
parents:
24178
diff
changeset
|
346 Lisp_Object eol_mnemonic_undecided; |
| 17052 | 347 |
|
90394
263867fe7b55
(system_eol_type): Sync with HEAD.
Kenichi Handa <handa@m17n.org>
parents:
90380
diff
changeset
|
348 /* Format of end-of-line decided by system. This is Qunix on |
|
263867fe7b55
(system_eol_type): Sync with HEAD.
Kenichi Handa <handa@m17n.org>
parents:
90380
diff
changeset
|
349 Unix and Mac, Qdos on DOS/Windows. |
|
70520
b6740a317343
(setup_coding_system): For invalid coding-system, set
Kenichi Handa <handa@m17n.org>
parents:
69995
diff
changeset
|
350 This has an effect only for external encoding (i.e. for output to |
|
b6740a317343
(setup_coding_system): For invalid coding-system, set
Kenichi Handa <handa@m17n.org>
parents:
69995
diff
changeset
|
351 file and process), not for in-buffer or Lisp string encoding. */ |
|
90394
263867fe7b55
(system_eol_type): Sync with HEAD.
Kenichi Handa <handa@m17n.org>
parents:
90380
diff
changeset
|
352 static Lisp_Object system_eol_type; |
|
18650
aa3f2820e2ac
(Qemacs_mule, inhibit_eol_conversion): New variables.
Kenichi Handa <handa@m17n.org>
parents:
18613
diff
changeset
|
353 |
| 17052 | 354 #ifdef emacs |
| 355 | |
|
20105
c017642863c2
(Qcoding_system_spec): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
19824
diff
changeset
|
356 Lisp_Object Vcoding_system_list, Vcoding_system_alist; |
|
c017642863c2
(Qcoding_system_spec): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
19824
diff
changeset
|
357 |
|
c017642863c2
(Qcoding_system_spec): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
19824
diff
changeset
|
358 Lisp_Object Qcoding_system_p, Qcoding_system_error; |
| 17052 | 359 |
|
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
360 /* 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
|
361 end-of-line format. */ |
|
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
362 Lisp_Object Qemacs_mule, Qraw_text; |
| 89483 | 363 Lisp_Object Qutf_8_emacs; |
| 51406 | 364 |
| 17052 | 365 /* Coding-systems are handed between Emacs Lisp programs and C internal |
| 366 routines by the following three variables. */ | |
| 367 /* Coding-system for reading files and receiving data from process. */ | |
| 368 Lisp_Object Vcoding_system_for_read; | |
| 369 /* Coding-system for writing files and sending data to process. */ | |
| 370 Lisp_Object Vcoding_system_for_write; | |
| 371 /* Coding-system actually used in the latest I/O. */ | |
| 372 Lisp_Object Vlast_coding_system_used; | |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
373 /* Set to non-nil when an error is detected while code conversion. */ |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
374 Lisp_Object Vlast_code_conversion_error; |
|
19280
e755044718ee
(ENCODE_ISO_CHARACTER_DIMENSION1): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
19193
diff
changeset
|
375 /* A vector of length 256 which contains information about special |
| 22529 | 376 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
|
377 Lisp_Object Vlatin_extra_code_table; |
|
19280
e755044718ee
(ENCODE_ISO_CHARACTER_DIMENSION1): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
19193
diff
changeset
|
378 |
|
18650
aa3f2820e2ac
(Qemacs_mule, inhibit_eol_conversion): New variables.
Kenichi Handa <handa@m17n.org>
parents:
18613
diff
changeset
|
379 /* 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
|
380 int inhibit_eol_conversion; |
|
aa3f2820e2ac
(Qemacs_mule, inhibit_eol_conversion): New variables.
Kenichi Handa <handa@m17n.org>
parents:
18613
diff
changeset
|
381 |
|
30204
35aec8514228
(inhibit_iso_escape_detection): New variable.
Kenichi Handa <handa@m17n.org>
parents:
29985
diff
changeset
|
382 /* Flag to inhibit ISO2022 escape sequence detection. */ |
|
35aec8514228
(inhibit_iso_escape_detection): New variable.
Kenichi Handa <handa@m17n.org>
parents:
29985
diff
changeset
|
383 int inhibit_iso_escape_detection; |
|
35aec8514228
(inhibit_iso_escape_detection): New variable.
Kenichi Handa <handa@m17n.org>
parents:
29985
diff
changeset
|
384 |
|
21574
30394e3ae7f8
(syms_of_coding): Declare and define inherit-process-coding-system.
Eli Zaretskii <eliz@gnu.org>
parents:
21520
diff
changeset
|
385 /* 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
|
386 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
|
387 |
|
19280
e755044718ee
(ENCODE_ISO_CHARACTER_DIMENSION1): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
19193
diff
changeset
|
388 /* 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
|
389 terminal coding system is nil. */ |
|
e755044718ee
(ENCODE_ISO_CHARACTER_DIMENSION1): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
19193
diff
changeset
|
390 struct coding_system safe_terminal_coding; |
|
e755044718ee
(ENCODE_ISO_CHARACTER_DIMENSION1): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
19193
diff
changeset
|
391 |
|
18180
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
392 Lisp_Object Vfile_coding_system_alist; |
|
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
393 Lisp_Object Vprocess_coding_system_alist; |
|
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
394 Lisp_Object Vnetwork_coding_system_alist; |
| 17052 | 395 |
|
26088
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
26067
diff
changeset
|
396 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
|
397 |
| 17052 | 398 #endif /* emacs */ |
| 399 | |
|
22186
fc4aaf1b1772
Change term "character translation table" to "translation table".
Kenichi Handa <handa@m17n.org>
parents:
22166
diff
changeset
|
400 /* 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
|
401 conversion. */ |
|
22119
592bb8b9bcfd
Change terms unify/unification to
Kenichi Handa <handa@m17n.org>
parents:
22020
diff
changeset
|
402 Lisp_Object Venable_character_translation; |
|
22186
fc4aaf1b1772
Change term "character translation table" to "translation table".
Kenichi Handa <handa@m17n.org>
parents:
22166
diff
changeset
|
403 /* 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
|
404 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
|
405 /* 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
|
406 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
|
407 |
|
fc4aaf1b1772
Change term "character translation table" to "translation table".
Kenichi Handa <handa@m17n.org>
parents:
22166
diff
changeset
|
408 Lisp_Object Qtranslation_table; |
|
fc4aaf1b1772
Change term "character translation table" to "translation table".
Kenichi Handa <handa@m17n.org>
parents:
22166
diff
changeset
|
409 Lisp_Object Qtranslation_table_id; |
|
fc4aaf1b1772
Change term "character translation table" to "translation table".
Kenichi Handa <handa@m17n.org>
parents:
22166
diff
changeset
|
410 Lisp_Object Qtranslation_table_for_decode; |
|
fc4aaf1b1772
Change term "character translation table" to "translation table".
Kenichi Handa <handa@m17n.org>
parents:
22166
diff
changeset
|
411 Lisp_Object Qtranslation_table_for_encode; |
| 17052 | 412 |
| 413 /* Alist of charsets vs revision number. */ | |
| 88365 | 414 static Lisp_Object Vcharset_revision_table; |
| 17052 | 415 |
|
18180
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
416 /* Default coding systems used for process I/O. */ |
|
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
417 Lisp_Object Vdefault_process_coding_system; |
|
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
418 |
|
48182
9474e269efd1
Reformat some DEFUNs so that etags works.
Dave Love <fx@gnu.org>
parents:
48125
diff
changeset
|
419 /* Char table for translating Quail and self-inserting input. */ |
|
9474e269efd1
Reformat some DEFUNs so that etags works.
Dave Love <fx@gnu.org>
parents:
48125
diff
changeset
|
420 Lisp_Object Vtranslation_table_for_input; |
|
9474e269efd1
Reformat some DEFUNs so that etags works.
Dave Love <fx@gnu.org>
parents:
48125
diff
changeset
|
421 |
| 88365 | 422 /* Two special coding systems. */ |
| 423 Lisp_Object Vsjis_coding_system; | |
| 424 Lisp_Object Vbig5_coding_system; | |
| 425 | |
| 426 /* ISO2022 section */ | |
| 427 | |
| 428 #define CODING_ISO_INITIAL(coding, reg) \ | |
| 429 (XINT (AREF (AREF (CODING_ID_ATTRS ((coding)->id), \ | |
| 430 coding_attr_iso_initial), \ | |
| 431 reg))) | |
| 432 | |
| 433 | |
| 434 #define CODING_ISO_REQUEST(coding, charset_id) \ | |
| 435 ((charset_id <= (coding)->max_charset_id \ | |
| 436 ? (coding)->safe_charsets[charset_id] \ | |
| 437 : -1)) | |
| 438 | |
| 439 | |
| 440 #define CODING_ISO_FLAGS(coding) \ | |
| 441 ((coding)->spec.iso_2022.flags) | |
| 442 #define CODING_ISO_DESIGNATION(coding, reg) \ | |
| 443 ((coding)->spec.iso_2022.current_designation[reg]) | |
| 444 #define CODING_ISO_INVOCATION(coding, plane) \ | |
| 445 ((coding)->spec.iso_2022.current_invocation[plane]) | |
| 446 #define CODING_ISO_SINGLE_SHIFTING(coding) \ | |
| 447 ((coding)->spec.iso_2022.single_shifting) | |
| 448 #define CODING_ISO_BOL(coding) \ | |
| 449 ((coding)->spec.iso_2022.bol) | |
| 450 #define CODING_ISO_INVOKED_CHARSET(coding, plane) \ | |
| 451 CODING_ISO_DESIGNATION ((coding), CODING_ISO_INVOCATION ((coding), (plane))) | |
| 452 | |
| 453 /* Control characters of ISO2022. */ | |
| 454 /* code */ /* function */ | |
| 455 #define ISO_CODE_LF 0x0A /* line-feed */ | |
| 456 #define ISO_CODE_CR 0x0D /* carriage-return */ | |
| 457 #define ISO_CODE_SO 0x0E /* shift-out */ | |
| 458 #define ISO_CODE_SI 0x0F /* shift-in */ | |
| 459 #define ISO_CODE_SS2_7 0x19 /* single-shift-2 for 7-bit code */ | |
| 460 #define ISO_CODE_ESC 0x1B /* escape */ | |
| 461 #define ISO_CODE_SS2 0x8E /* single-shift-2 */ | |
| 462 #define ISO_CODE_SS3 0x8F /* single-shift-3 */ | |
| 463 #define ISO_CODE_CSI 0x9B /* control-sequence-introducer */ | |
| 464 | |
| 465 /* All code (1-byte) of ISO2022 is classified into one of the | |
| 466 followings. */ | |
| 467 enum iso_code_class_type | |
| 468 { | |
| 469 ISO_control_0, /* Control codes in the range | |
| 470 0x00..0x1F and 0x7F, except for the | |
| 471 following 5 codes. */ | |
| 472 ISO_shift_out, /* ISO_CODE_SO (0x0E) */ | |
| 473 ISO_shift_in, /* ISO_CODE_SI (0x0F) */ | |
| 474 ISO_single_shift_2_7, /* ISO_CODE_SS2_7 (0x19) */ | |
| 475 ISO_escape, /* ISO_CODE_SO (0x1B) */ | |
| 476 ISO_control_1, /* Control codes in the range | |
| 477 0x80..0x9F, except for the | |
| 478 following 3 codes. */ | |
| 479 ISO_single_shift_2, /* ISO_CODE_SS2 (0x8E) */ | |
| 480 ISO_single_shift_3, /* ISO_CODE_SS3 (0x8F) */ | |
| 481 ISO_control_sequence_introducer, /* ISO_CODE_CSI (0x9B) */ | |
| 482 ISO_0x20_or_0x7F, /* Codes of the values 0x20 or 0x7F. */ | |
| 483 ISO_graphic_plane_0, /* Graphic codes in the range 0x21..0x7E. */ | |
| 484 ISO_0xA0_or_0xFF, /* Codes of the values 0xA0 or 0xFF. */ | |
| 485 ISO_graphic_plane_1 /* Graphic codes in the range 0xA1..0xFE. */ | |
| 486 }; | |
| 487 | |
| 488 /** The macros CODING_ISO_FLAG_XXX defines a flag bit of the | |
| 489 `iso-flags' attribute of an iso2022 coding system. */ | |
| 490 | |
| 491 /* If set, produce long-form designation sequence (e.g. ESC $ ( A) | |
| 492 instead of the correct short-form sequence (e.g. ESC $ A). */ | |
| 493 #define CODING_ISO_FLAG_LONG_FORM 0x0001 | |
| 494 | |
| 495 /* If set, reset graphic planes and registers at end-of-line to the | |
| 496 initial state. */ | |
| 497 #define CODING_ISO_FLAG_RESET_AT_EOL 0x0002 | |
| 498 | |
| 499 /* If set, reset graphic planes and registers before any control | |
| 500 characters to the initial state. */ | |
| 501 #define CODING_ISO_FLAG_RESET_AT_CNTL 0x0004 | |
| 502 | |
| 503 /* If set, encode by 7-bit environment. */ | |
| 504 #define CODING_ISO_FLAG_SEVEN_BITS 0x0008 | |
| 505 | |
| 506 /* If set, use locking-shift function. */ | |
| 507 #define CODING_ISO_FLAG_LOCKING_SHIFT 0x0010 | |
| 508 | |
| 509 /* If set, use single-shift function. Overwrite | |
| 510 CODING_ISO_FLAG_LOCKING_SHIFT. */ | |
| 511 #define CODING_ISO_FLAG_SINGLE_SHIFT 0x0020 | |
| 512 | |
| 513 /* If set, use designation escape sequence. */ | |
| 514 #define CODING_ISO_FLAG_DESIGNATION 0x0040 | |
| 515 | |
| 516 /* If set, produce revision number sequence. */ | |
| 517 #define CODING_ISO_FLAG_REVISION 0x0080 | |
| 518 | |
| 519 /* If set, produce ISO6429's direction specifying sequence. */ | |
| 520 #define CODING_ISO_FLAG_DIRECTION 0x0100 | |
| 521 | |
| 522 /* If set, assume designation states are reset at beginning of line on | |
| 523 output. */ | |
| 524 #define CODING_ISO_FLAG_INIT_AT_BOL 0x0200 | |
| 525 | |
| 526 /* If set, designation sequence should be placed at beginning of line | |
| 527 on output. */ | |
| 528 #define CODING_ISO_FLAG_DESIGNATE_AT_BOL 0x0400 | |
| 529 | |
| 530 /* If set, do not encode unsafe charactes on output. */ | |
| 531 #define CODING_ISO_FLAG_SAFE 0x0800 | |
| 532 | |
| 533 /* If set, extra latin codes (128..159) are accepted as a valid code | |
| 534 on input. */ | |
| 535 #define CODING_ISO_FLAG_LATIN_EXTRA 0x1000 | |
| 536 | |
| 537 #define CODING_ISO_FLAG_COMPOSITION 0x2000 | |
| 538 | |
| 539 #define CODING_ISO_FLAG_EUC_TW_SHIFT 0x4000 | |
| 540 | |
|
88681
2cdfbffa8a0d
(CODING_ISO_FLAG_USE_ROMAN): New macro
Kenichi Handa <handa@m17n.org>
parents:
88669
diff
changeset
|
541 #define CODING_ISO_FLAG_USE_ROMAN 0x8000 |
|
2cdfbffa8a0d
(CODING_ISO_FLAG_USE_ROMAN): New macro
Kenichi Handa <handa@m17n.org>
parents:
88669
diff
changeset
|
542 |
|
2cdfbffa8a0d
(CODING_ISO_FLAG_USE_ROMAN): New macro
Kenichi Handa <handa@m17n.org>
parents:
88669
diff
changeset
|
543 #define CODING_ISO_FLAG_USE_OLDJIS 0x10000 |
|
2cdfbffa8a0d
(CODING_ISO_FLAG_USE_ROMAN): New macro
Kenichi Handa <handa@m17n.org>
parents:
88669
diff
changeset
|
544 |
|
2cdfbffa8a0d
(CODING_ISO_FLAG_USE_ROMAN): New macro
Kenichi Handa <handa@m17n.org>
parents:
88669
diff
changeset
|
545 #define CODING_ISO_FLAG_FULL_SUPPORT 0x100000 |
| 88365 | 546 |
| 547 /* A character to be produced on output if encoding of the original | |
| 548 character is prohibited by CODING_ISO_FLAG_SAFE. */ | |
| 549 #define CODING_INHIBIT_CHARACTER_SUBSTITUTION '?' | |
| 550 | |
| 551 | |
| 552 /* UTF-16 section */ | |
| 553 #define CODING_UTF_16_BOM(coding) \ | |
| 554 ((coding)->spec.utf_16.bom) | |
| 555 | |
| 556 #define CODING_UTF_16_ENDIAN(coding) \ | |
| 557 ((coding)->spec.utf_16.endian) | |
| 558 | |
| 559 #define CODING_UTF_16_SURROGATE(coding) \ | |
| 560 ((coding)->spec.utf_16.surrogate) | |
| 561 | |
| 562 | |
| 563 /* CCL section */ | |
| 564 #define CODING_CCL_DECODER(coding) \ | |
| 565 AREF (CODING_ID_ATTRS ((coding)->id), coding_attr_ccl_decoder) | |
| 566 #define CODING_CCL_ENCODER(coding) \ | |
| 567 AREF (CODING_ID_ATTRS ((coding)->id), coding_attr_ccl_encoder) | |
| 568 #define CODING_CCL_VALIDS(coding) \ | |
| 89483 | 569 (SDATA (AREF (CODING_ID_ATTRS ((coding)->id), coding_attr_ccl_valids))) |
| 88365 | 570 |
| 88771 | 571 /* Index for each coding category in `coding_categories' */ |
| 88365 | 572 |
| 573 enum coding_category | |
| 574 { | |
| 575 coding_category_iso_7, | |
| 576 coding_category_iso_7_tight, | |
| 577 coding_category_iso_8_1, | |
| 578 coding_category_iso_8_2, | |
| 579 coding_category_iso_7_else, | |
| 580 coding_category_iso_8_else, | |
| 581 coding_category_utf_8, | |
| 582 coding_category_utf_16_auto, | |
| 583 coding_category_utf_16_be, | |
| 584 coding_category_utf_16_le, | |
| 585 coding_category_utf_16_be_nosig, | |
| 586 coding_category_utf_16_le_nosig, | |
| 587 coding_category_charset, | |
| 588 coding_category_sjis, | |
| 589 coding_category_big5, | |
| 590 coding_category_ccl, | |
| 591 coding_category_emacs_mule, | |
| 592 /* All above are targets of code detection. */ | |
| 593 coding_category_raw_text, | |
| 594 coding_category_undecided, | |
| 595 coding_category_max | |
| 596 }; | |
| 597 | |
| 598 /* Definitions of flag bits used in detect_coding_XXXX. */ | |
| 599 #define CATEGORY_MASK_ISO_7 (1 << coding_category_iso_7) | |
| 600 #define CATEGORY_MASK_ISO_7_TIGHT (1 << coding_category_iso_7_tight) | |
| 601 #define CATEGORY_MASK_ISO_8_1 (1 << coding_category_iso_8_1) | |
| 602 #define CATEGORY_MASK_ISO_8_2 (1 << coding_category_iso_8_2) | |
| 603 #define CATEGORY_MASK_ISO_7_ELSE (1 << coding_category_iso_7_else) | |
| 604 #define CATEGORY_MASK_ISO_8_ELSE (1 << coding_category_iso_8_else) | |
| 605 #define CATEGORY_MASK_UTF_8 (1 << coding_category_utf_8) | |
|
89420
c3e67ce6ee0f
(Qsignature, Qendian): Delete these variables.
Kenichi Handa <handa@m17n.org>
parents:
89418
diff
changeset
|
606 #define CATEGORY_MASK_UTF_16_AUTO (1 << coding_category_utf_16_auto) |
| 88365 | 607 #define CATEGORY_MASK_UTF_16_BE (1 << coding_category_utf_16_be) |
| 608 #define CATEGORY_MASK_UTF_16_LE (1 << coding_category_utf_16_le) | |
| 609 #define CATEGORY_MASK_UTF_16_BE_NOSIG (1 << coding_category_utf_16_be_nosig) | |
| 610 #define CATEGORY_MASK_UTF_16_LE_NOSIG (1 << coding_category_utf_16_le_nosig) | |
| 611 #define CATEGORY_MASK_CHARSET (1 << coding_category_charset) | |
| 612 #define CATEGORY_MASK_SJIS (1 << coding_category_sjis) | |
| 613 #define CATEGORY_MASK_BIG5 (1 << coding_category_big5) | |
| 614 #define CATEGORY_MASK_CCL (1 << coding_category_ccl) | |
| 615 #define CATEGORY_MASK_EMACS_MULE (1 << coding_category_emacs_mule) | |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
616 #define CATEGORY_MASK_RAW_TEXT (1 << coding_category_raw_text) |
| 88365 | 617 |
| 618 /* This value is returned if detect_coding_mask () find nothing other | |
| 619 than ASCII characters. */ | |
| 620 #define CATEGORY_MASK_ANY \ | |
| 621 (CATEGORY_MASK_ISO_7 \ | |
| 622 | CATEGORY_MASK_ISO_7_TIGHT \ | |
| 623 | CATEGORY_MASK_ISO_8_1 \ | |
| 624 | CATEGORY_MASK_ISO_8_2 \ | |
| 625 | CATEGORY_MASK_ISO_7_ELSE \ | |
| 626 | CATEGORY_MASK_ISO_8_ELSE \ | |
| 627 | CATEGORY_MASK_UTF_8 \ | |
|
93595
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
628 | CATEGORY_MASK_UTF_16_AUTO \ |
| 88365 | 629 | CATEGORY_MASK_UTF_16_BE \ |
| 630 | CATEGORY_MASK_UTF_16_LE \ | |
| 631 | CATEGORY_MASK_UTF_16_BE_NOSIG \ | |
| 632 | CATEGORY_MASK_UTF_16_LE_NOSIG \ | |
| 633 | CATEGORY_MASK_CHARSET \ | |
| 634 | CATEGORY_MASK_SJIS \ | |
| 635 | CATEGORY_MASK_BIG5 \ | |
| 636 | CATEGORY_MASK_CCL \ | |
| 637 | CATEGORY_MASK_EMACS_MULE) | |
| 638 | |
| 639 | |
| 640 #define CATEGORY_MASK_ISO_7BIT \ | |
| 641 (CATEGORY_MASK_ISO_7 | CATEGORY_MASK_ISO_7_TIGHT) | |
| 642 | |
| 643 #define CATEGORY_MASK_ISO_8BIT \ | |
| 644 (CATEGORY_MASK_ISO_8_1 | CATEGORY_MASK_ISO_8_2) | |
| 645 | |
| 646 #define CATEGORY_MASK_ISO_ELSE \ | |
| 647 (CATEGORY_MASK_ISO_7_ELSE | CATEGORY_MASK_ISO_8_ELSE) | |
| 648 | |
| 649 #define CATEGORY_MASK_ISO_ESCAPE \ | |
| 650 (CATEGORY_MASK_ISO_7 \ | |
| 651 | CATEGORY_MASK_ISO_7_TIGHT \ | |
| 652 | CATEGORY_MASK_ISO_7_ELSE \ | |
| 653 | CATEGORY_MASK_ISO_8_ELSE) | |
| 654 | |
| 655 #define CATEGORY_MASK_ISO \ | |
| 656 ( CATEGORY_MASK_ISO_7BIT \ | |
| 657 | CATEGORY_MASK_ISO_8BIT \ | |
| 658 | CATEGORY_MASK_ISO_ELSE) | |
| 659 | |
| 660 #define CATEGORY_MASK_UTF_16 \ | |
|
93595
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
661 (CATEGORY_MASK_UTF_16_AUTO \ |
|
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
662 | CATEGORY_MASK_UTF_16_BE \ |
| 88365 | 663 | CATEGORY_MASK_UTF_16_LE \ |
| 664 | CATEGORY_MASK_UTF_16_BE_NOSIG \ | |
| 665 | CATEGORY_MASK_UTF_16_LE_NOSIG) | |
| 666 | |
| 667 | |
| 668 /* List of symbols `coding-category-xxx' ordered by priority. This | |
| 669 variable is exposed to Emacs Lisp. */ | |
| 670 static Lisp_Object Vcoding_category_list; | |
| 671 | |
| 672 /* Table of coding categories (Lisp symbols). This variable is for | |
| 673 internal use oly. */ | |
| 674 static Lisp_Object Vcoding_category_table; | |
| 675 | |
| 676 /* Table of coding-categories ordered by priority. */ | |
| 677 static enum coding_category coding_priorities[coding_category_max]; | |
| 678 | |
| 679 /* Nth element is a coding context for the coding system bound to the | |
| 680 Nth coding category. */ | |
| 681 static struct coding_system coding_categories[coding_category_max]; | |
| 682 | |
| 683 /*** Commonly used macros and functions ***/ | |
| 684 | |
| 685 #ifndef min | |
| 686 #define min(a, b) ((a) < (b) ? (a) : (b)) | |
| 687 #endif | |
| 688 #ifndef max | |
| 689 #define max(a, b) ((a) > (b) ? (a) : (b)) | |
| 690 #endif | |
| 691 | |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
692 #define CODING_GET_INFO(coding, attrs, charset_list) \ |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
693 do { \ |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
694 (attrs) = CODING_ID_ATTRS ((coding)->id); \ |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
695 (charset_list) = CODING_ATTR_CHARSET_LIST (attrs); \ |
| 88365 | 696 } while (0) |
| 697 | |
| 698 | |
| 699 /* Safely get one byte from the source text pointed by SRC which ends | |
| 700 at SRC_END, and set C to that byte. If there are not enough bytes | |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
701 in the source, it jumps to `no_more_source'. If multibytep is |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
702 nonzero, and a multibyte character is found at SRC, set C to the |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
703 negative value of the character code. The caller should declare |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
704 and set these variables appropriately in advance: |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
705 src, src_end, multibytep */ |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
706 |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
707 #define ONE_MORE_BYTE(c) \ |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
708 do { \ |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
709 if (src == src_end) \ |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
710 { \ |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
711 if (src_base < src) \ |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
712 record_conversion_result \ |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
713 (coding, CODING_RESULT_INSUFFICIENT_SRC); \ |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
714 goto no_more_source; \ |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
715 } \ |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
716 c = *src++; \ |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
717 if (multibytep && (c & 0x80)) \ |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
718 { \ |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
719 if ((c & 0xFE) == 0xC0) \ |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
720 c = ((c & 1) << 6) | *src++; \ |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
721 else \ |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
722 { \ |
|
90214
460ee00505d5
(QCascii_compatible_p): New variable.
Kenichi Handa <handa@m17n.org>
parents:
90201
diff
changeset
|
723 src--; \ |
|
460ee00505d5
(QCascii_compatible_p): New variable.
Kenichi Handa <handa@m17n.org>
parents:
90201
diff
changeset
|
724 c = - string_char (src, &src, NULL); \ |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
725 record_conversion_result \ |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
726 (coding, CODING_RESULT_INVALID_SRC); \ |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
727 } \ |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
728 } \ |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
729 consumed_chars++; \ |
| 88365 | 730 } while (0) |
| 731 | |
| 732 | |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
733 #define ONE_MORE_BYTE_NO_CHECK(c) \ |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
734 do { \ |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
735 c = *src++; \ |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
736 if (multibytep && (c & 0x80)) \ |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
737 { \ |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
738 if ((c & 0xFE) == 0xC0) \ |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
739 c = ((c & 1) << 6) | *src++; \ |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
740 else \ |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
741 { \ |
|
90214
460ee00505d5
(QCascii_compatible_p): New variable.
Kenichi Handa <handa@m17n.org>
parents:
90201
diff
changeset
|
742 src--; \ |
|
460ee00505d5
(QCascii_compatible_p): New variable.
Kenichi Handa <handa@m17n.org>
parents:
90201
diff
changeset
|
743 c = - string_char (src, &src, NULL); \ |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
744 record_conversion_result \ |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
745 (coding, CODING_RESULT_INVALID_SRC); \ |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
746 } \ |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
747 } \ |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
748 consumed_chars++; \ |
| 88365 | 749 } while (0) |
| 750 | |
| 751 | |
| 752 /* Store a byte C in the place pointed by DST and increment DST to the | |
| 753 next free point, and increment PRODUCED_CHARS. The caller should | |
| 754 assure that C is 0..127, and declare and set the variable `dst' | |
| 755 appropriately in advance. | |
| 756 */ | |
| 757 | |
| 758 | |
| 759 #define EMIT_ONE_ASCII_BYTE(c) \ | |
| 760 do { \ | |
| 761 produced_chars++; \ | |
| 762 *dst++ = (c); \ | |
| 763 } while (0) | |
| 764 | |
| 765 | |
| 766 /* Like EMIT_ONE_ASCII_BYTE byt store two bytes; C1 and C2. */ | |
| 767 | |
| 768 #define EMIT_TWO_ASCII_BYTES(c1, c2) \ | |
| 769 do { \ | |
| 770 produced_chars += 2; \ | |
| 771 *dst++ = (c1), *dst++ = (c2); \ | |
| 772 } while (0) | |
| 773 | |
| 774 | |
| 775 /* Store a byte C in the place pointed by DST and increment DST to the | |
| 776 next free point, and increment PRODUCED_CHARS. If MULTIBYTEP is | |
| 777 nonzero, store in an appropriate multibyte from. The caller should | |
| 778 declare and set the variables `dst' and `multibytep' appropriately | |
| 779 in advance. */ | |
| 780 | |
| 781 #define EMIT_ONE_BYTE(c) \ | |
| 782 do { \ | |
| 783 produced_chars++; \ | |
| 784 if (multibytep) \ | |
| 785 { \ | |
| 786 int ch = (c); \ | |
| 787 if (ch >= 0x80) \ | |
| 788 ch = BYTE8_TO_CHAR (ch); \ | |
| 789 CHAR_STRING_ADVANCE (ch, dst); \ | |
| 790 } \ | |
| 791 else \ | |
| 792 *dst++ = (c); \ | |
| 793 } while (0) | |
| 794 | |
| 795 | |
| 796 /* Like EMIT_ONE_BYTE, but emit two bytes; C1 and C2. */ | |
| 797 | |
|
88438
3a34b722dd71
(encode_coding_utf_8): Initialize produced_chars to 0.
Kenichi Handa <handa@m17n.org>
parents:
88430
diff
changeset
|
798 #define EMIT_TWO_BYTES(c1, c2) \ |
|
3a34b722dd71
(encode_coding_utf_8): Initialize produced_chars to 0.
Kenichi Handa <handa@m17n.org>
parents:
88430
diff
changeset
|
799 do { \ |
|
3a34b722dd71
(encode_coding_utf_8): Initialize produced_chars to 0.
Kenichi Handa <handa@m17n.org>
parents:
88430
diff
changeset
|
800 produced_chars += 2; \ |
|
3a34b722dd71
(encode_coding_utf_8): Initialize produced_chars to 0.
Kenichi Handa <handa@m17n.org>
parents:
88430
diff
changeset
|
801 if (multibytep) \ |
|
3a34b722dd71
(encode_coding_utf_8): Initialize produced_chars to 0.
Kenichi Handa <handa@m17n.org>
parents:
88430
diff
changeset
|
802 { \ |
|
3a34b722dd71
(encode_coding_utf_8): Initialize produced_chars to 0.
Kenichi Handa <handa@m17n.org>
parents:
88430
diff
changeset
|
803 int ch; \ |
|
3a34b722dd71
(encode_coding_utf_8): Initialize produced_chars to 0.
Kenichi Handa <handa@m17n.org>
parents:
88430
diff
changeset
|
804 \ |
|
3a34b722dd71
(encode_coding_utf_8): Initialize produced_chars to 0.
Kenichi Handa <handa@m17n.org>
parents:
88430
diff
changeset
|
805 ch = (c1); \ |
|
3a34b722dd71
(encode_coding_utf_8): Initialize produced_chars to 0.
Kenichi Handa <handa@m17n.org>
parents:
88430
diff
changeset
|
806 if (ch >= 0x80) \ |
|
3a34b722dd71
(encode_coding_utf_8): Initialize produced_chars to 0.
Kenichi Handa <handa@m17n.org>
parents:
88430
diff
changeset
|
807 ch = BYTE8_TO_CHAR (ch); \ |
|
3a34b722dd71
(encode_coding_utf_8): Initialize produced_chars to 0.
Kenichi Handa <handa@m17n.org>
parents:
88430
diff
changeset
|
808 CHAR_STRING_ADVANCE (ch, dst); \ |
|
3a34b722dd71
(encode_coding_utf_8): Initialize produced_chars to 0.
Kenichi Handa <handa@m17n.org>
parents:
88430
diff
changeset
|
809 ch = (c2); \ |
|
3a34b722dd71
(encode_coding_utf_8): Initialize produced_chars to 0.
Kenichi Handa <handa@m17n.org>
parents:
88430
diff
changeset
|
810 if (ch >= 0x80) \ |
|
3a34b722dd71
(encode_coding_utf_8): Initialize produced_chars to 0.
Kenichi Handa <handa@m17n.org>
parents:
88430
diff
changeset
|
811 ch = BYTE8_TO_CHAR (ch); \ |
|
3a34b722dd71
(encode_coding_utf_8): Initialize produced_chars to 0.
Kenichi Handa <handa@m17n.org>
parents:
88430
diff
changeset
|
812 CHAR_STRING_ADVANCE (ch, dst); \ |
|
3a34b722dd71
(encode_coding_utf_8): Initialize produced_chars to 0.
Kenichi Handa <handa@m17n.org>
parents:
88430
diff
changeset
|
813 } \ |
|
3a34b722dd71
(encode_coding_utf_8): Initialize produced_chars to 0.
Kenichi Handa <handa@m17n.org>
parents:
88430
diff
changeset
|
814 else \ |
|
3a34b722dd71
(encode_coding_utf_8): Initialize produced_chars to 0.
Kenichi Handa <handa@m17n.org>
parents:
88430
diff
changeset
|
815 { \ |
|
3a34b722dd71
(encode_coding_utf_8): Initialize produced_chars to 0.
Kenichi Handa <handa@m17n.org>
parents:
88430
diff
changeset
|
816 *dst++ = (c1); \ |
|
3a34b722dd71
(encode_coding_utf_8): Initialize produced_chars to 0.
Kenichi Handa <handa@m17n.org>
parents:
88430
diff
changeset
|
817 *dst++ = (c2); \ |
|
3a34b722dd71
(encode_coding_utf_8): Initialize produced_chars to 0.
Kenichi Handa <handa@m17n.org>
parents:
88430
diff
changeset
|
818 } \ |
| 88365 | 819 } while (0) |
| 820 | |
| 821 | |
| 822 #define EMIT_THREE_BYTES(c1, c2, c3) \ | |
| 823 do { \ | |
| 824 EMIT_ONE_BYTE (c1); \ | |
| 825 EMIT_TWO_BYTES (c2, c3); \ | |
| 826 } while (0) | |
| 827 | |
| 828 | |
| 829 #define EMIT_FOUR_BYTES(c1, c2, c3, c4) \ | |
| 830 do { \ | |
| 831 EMIT_TWO_BYTES (c1, c2); \ | |
| 832 EMIT_TWO_BYTES (c3, c4); \ | |
| 833 } while (0) | |
| 834 | |
| 835 | |
|
89863
428fc37b2ae6
Add many prototypes for static functions.
Kenichi Handa <handa@m17n.org>
parents:
89861
diff
changeset
|
836 /* Prototypes for static functions. */ |
|
428fc37b2ae6
Add many prototypes for static functions.
Kenichi Handa <handa@m17n.org>
parents:
89861
diff
changeset
|
837 static void record_conversion_result P_ ((struct coding_system *coding, |
|
428fc37b2ae6
Add many prototypes for static functions.
Kenichi Handa <handa@m17n.org>
parents:
89861
diff
changeset
|
838 enum coding_result_code result)); |
|
428fc37b2ae6
Add many prototypes for static functions.
Kenichi Handa <handa@m17n.org>
parents:
89861
diff
changeset
|
839 static int detect_coding_utf_8 P_ ((struct coding_system *, |
|
428fc37b2ae6
Add many prototypes for static functions.
Kenichi Handa <handa@m17n.org>
parents:
89861
diff
changeset
|
840 struct coding_detection_info *info)); |
|
428fc37b2ae6
Add many prototypes for static functions.
Kenichi Handa <handa@m17n.org>
parents:
89861
diff
changeset
|
841 static void decode_coding_utf_8 P_ ((struct coding_system *)); |
|
428fc37b2ae6
Add many prototypes for static functions.
Kenichi Handa <handa@m17n.org>
parents:
89861
diff
changeset
|
842 static int encode_coding_utf_8 P_ ((struct coding_system *)); |
|
428fc37b2ae6
Add many prototypes for static functions.
Kenichi Handa <handa@m17n.org>
parents:
89861
diff
changeset
|
843 |
|
428fc37b2ae6
Add many prototypes for static functions.
Kenichi Handa <handa@m17n.org>
parents:
89861
diff
changeset
|
844 static int detect_coding_utf_16 P_ ((struct coding_system *, |
|
428fc37b2ae6
Add many prototypes for static functions.
Kenichi Handa <handa@m17n.org>
parents:
89861
diff
changeset
|
845 struct coding_detection_info *info)); |
|
428fc37b2ae6
Add many prototypes for static functions.
Kenichi Handa <handa@m17n.org>
parents:
89861
diff
changeset
|
846 static void decode_coding_utf_16 P_ ((struct coding_system *)); |
|
428fc37b2ae6
Add many prototypes for static functions.
Kenichi Handa <handa@m17n.org>
parents:
89861
diff
changeset
|
847 static int encode_coding_utf_16 P_ ((struct coding_system *)); |
|
428fc37b2ae6
Add many prototypes for static functions.
Kenichi Handa <handa@m17n.org>
parents:
89861
diff
changeset
|
848 |
|
428fc37b2ae6
Add many prototypes for static functions.
Kenichi Handa <handa@m17n.org>
parents:
89861
diff
changeset
|
849 static int detect_coding_iso_2022 P_ ((struct coding_system *, |
|
428fc37b2ae6
Add many prototypes for static functions.
Kenichi Handa <handa@m17n.org>
parents:
89861
diff
changeset
|
850 struct coding_detection_info *info)); |
|
428fc37b2ae6
Add many prototypes for static functions.
Kenichi Handa <handa@m17n.org>
parents:
89861
diff
changeset
|
851 static void decode_coding_iso_2022 P_ ((struct coding_system *)); |
|
428fc37b2ae6
Add many prototypes for static functions.
Kenichi Handa <handa@m17n.org>
parents:
89861
diff
changeset
|
852 static int encode_coding_iso_2022 P_ ((struct coding_system *)); |
|
428fc37b2ae6
Add many prototypes for static functions.
Kenichi Handa <handa@m17n.org>
parents:
89861
diff
changeset
|
853 |
|
428fc37b2ae6
Add many prototypes for static functions.
Kenichi Handa <handa@m17n.org>
parents:
89861
diff
changeset
|
854 static int detect_coding_emacs_mule P_ ((struct coding_system *, |
|
428fc37b2ae6
Add many prototypes for static functions.
Kenichi Handa <handa@m17n.org>
parents:
89861
diff
changeset
|
855 struct coding_detection_info *info)); |
|
428fc37b2ae6
Add many prototypes for static functions.
Kenichi Handa <handa@m17n.org>
parents:
89861
diff
changeset
|
856 static void decode_coding_emacs_mule P_ ((struct coding_system *)); |
|
428fc37b2ae6
Add many prototypes for static functions.
Kenichi Handa <handa@m17n.org>
parents:
89861
diff
changeset
|
857 static int encode_coding_emacs_mule P_ ((struct coding_system *)); |
|
428fc37b2ae6
Add many prototypes for static functions.
Kenichi Handa <handa@m17n.org>
parents:
89861
diff
changeset
|
858 |
|
428fc37b2ae6
Add many prototypes for static functions.
Kenichi Handa <handa@m17n.org>
parents:
89861
diff
changeset
|
859 static int detect_coding_sjis P_ ((struct coding_system *, |
|
428fc37b2ae6
Add many prototypes for static functions.
Kenichi Handa <handa@m17n.org>
parents:
89861
diff
changeset
|
860 struct coding_detection_info *info)); |
|
428fc37b2ae6
Add many prototypes for static functions.
Kenichi Handa <handa@m17n.org>
parents:
89861
diff
changeset
|
861 static void decode_coding_sjis P_ ((struct coding_system *)); |
|
428fc37b2ae6
Add many prototypes for static functions.
Kenichi Handa <handa@m17n.org>
parents:
89861
diff
changeset
|
862 static int encode_coding_sjis P_ ((struct coding_system *)); |
|
428fc37b2ae6
Add many prototypes for static functions.
Kenichi Handa <handa@m17n.org>
parents:
89861
diff
changeset
|
863 |
|
428fc37b2ae6
Add many prototypes for static functions.
Kenichi Handa <handa@m17n.org>
parents:
89861
diff
changeset
|
864 static int detect_coding_big5 P_ ((struct coding_system *, |
|
428fc37b2ae6
Add many prototypes for static functions.
Kenichi Handa <handa@m17n.org>
parents:
89861
diff
changeset
|
865 struct coding_detection_info *info)); |
|
428fc37b2ae6
Add many prototypes for static functions.
Kenichi Handa <handa@m17n.org>
parents:
89861
diff
changeset
|
866 static void decode_coding_big5 P_ ((struct coding_system *)); |
|
428fc37b2ae6
Add many prototypes for static functions.
Kenichi Handa <handa@m17n.org>
parents:
89861
diff
changeset
|
867 static int encode_coding_big5 P_ ((struct coding_system *)); |
|
428fc37b2ae6
Add many prototypes for static functions.
Kenichi Handa <handa@m17n.org>
parents:
89861
diff
changeset
|
868 |
|
428fc37b2ae6
Add many prototypes for static functions.
Kenichi Handa <handa@m17n.org>
parents:
89861
diff
changeset
|
869 static int detect_coding_ccl P_ ((struct coding_system *, |
|
428fc37b2ae6
Add many prototypes for static functions.
Kenichi Handa <handa@m17n.org>
parents:
89861
diff
changeset
|
870 struct coding_detection_info *info)); |
|
428fc37b2ae6
Add many prototypes for static functions.
Kenichi Handa <handa@m17n.org>
parents:
89861
diff
changeset
|
871 static void decode_coding_ccl P_ ((struct coding_system *)); |
|
428fc37b2ae6
Add many prototypes for static functions.
Kenichi Handa <handa@m17n.org>
parents:
89861
diff
changeset
|
872 static int encode_coding_ccl P_ ((struct coding_system *)); |
|
428fc37b2ae6
Add many prototypes for static functions.
Kenichi Handa <handa@m17n.org>
parents:
89861
diff
changeset
|
873 |
|
428fc37b2ae6
Add many prototypes for static functions.
Kenichi Handa <handa@m17n.org>
parents:
89861
diff
changeset
|
874 static void decode_coding_raw_text P_ ((struct coding_system *)); |
|
428fc37b2ae6
Add many prototypes for static functions.
Kenichi Handa <handa@m17n.org>
parents:
89861
diff
changeset
|
875 static int encode_coding_raw_text P_ ((struct coding_system *)); |
|
428fc37b2ae6
Add many prototypes for static functions.
Kenichi Handa <handa@m17n.org>
parents:
89861
diff
changeset
|
876 |
|
428fc37b2ae6
Add many prototypes for static functions.
Kenichi Handa <handa@m17n.org>
parents:
89861
diff
changeset
|
877 static void coding_set_source P_ ((struct coding_system *)); |
|
428fc37b2ae6
Add many prototypes for static functions.
Kenichi Handa <handa@m17n.org>
parents:
89861
diff
changeset
|
878 static void coding_set_destination P_ ((struct coding_system *)); |
|
428fc37b2ae6
Add many prototypes for static functions.
Kenichi Handa <handa@m17n.org>
parents:
89861
diff
changeset
|
879 static void coding_alloc_by_realloc P_ ((struct coding_system *, EMACS_INT)); |
|
428fc37b2ae6
Add many prototypes for static functions.
Kenichi Handa <handa@m17n.org>
parents:
89861
diff
changeset
|
880 static void coding_alloc_by_making_gap P_ ((struct coding_system *, |
|
90772
b15334b4a9c3
(coding_alloc_by_making_gap): New arg offset.
Kenichi Handa <handa@m17n.org>
parents:
90737
diff
changeset
|
881 EMACS_INT, EMACS_INT)); |
|
89863
428fc37b2ae6
Add many prototypes for static functions.
Kenichi Handa <handa@m17n.org>
parents:
89861
diff
changeset
|
882 static unsigned char *alloc_destination P_ ((struct coding_system *, |
|
428fc37b2ae6
Add many prototypes for static functions.
Kenichi Handa <handa@m17n.org>
parents:
89861
diff
changeset
|
883 EMACS_INT, unsigned char *)); |
|
428fc37b2ae6
Add many prototypes for static functions.
Kenichi Handa <handa@m17n.org>
parents:
89861
diff
changeset
|
884 static void setup_iso_safe_charsets P_ ((Lisp_Object)); |
|
428fc37b2ae6
Add many prototypes for static functions.
Kenichi Handa <handa@m17n.org>
parents:
89861
diff
changeset
|
885 static unsigned char *encode_designation_at_bol P_ ((struct coding_system *, |
|
428fc37b2ae6
Add many prototypes for static functions.
Kenichi Handa <handa@m17n.org>
parents:
89861
diff
changeset
|
886 int *, int *, |
|
428fc37b2ae6
Add many prototypes for static functions.
Kenichi Handa <handa@m17n.org>
parents:
89861
diff
changeset
|
887 unsigned char *)); |
|
428fc37b2ae6
Add many prototypes for static functions.
Kenichi Handa <handa@m17n.org>
parents:
89861
diff
changeset
|
888 static int detect_eol P_ ((const unsigned char *, |
|
428fc37b2ae6
Add many prototypes for static functions.
Kenichi Handa <handa@m17n.org>
parents:
89861
diff
changeset
|
889 EMACS_INT, enum coding_category)); |
|
428fc37b2ae6
Add many prototypes for static functions.
Kenichi Handa <handa@m17n.org>
parents:
89861
diff
changeset
|
890 static Lisp_Object adjust_coding_eol_type P_ ((struct coding_system *, int)); |
|
428fc37b2ae6
Add many prototypes for static functions.
Kenichi Handa <handa@m17n.org>
parents:
89861
diff
changeset
|
891 static void decode_eol P_ ((struct coding_system *)); |
|
428fc37b2ae6
Add many prototypes for static functions.
Kenichi Handa <handa@m17n.org>
parents:
89861
diff
changeset
|
892 static Lisp_Object get_translation_table P_ ((Lisp_Object, int, int *)); |
|
428fc37b2ae6
Add many prototypes for static functions.
Kenichi Handa <handa@m17n.org>
parents:
89861
diff
changeset
|
893 static Lisp_Object get_translation P_ ((Lisp_Object, int *, int *, |
|
428fc37b2ae6
Add many prototypes for static functions.
Kenichi Handa <handa@m17n.org>
parents:
89861
diff
changeset
|
894 int, int *, int *)); |
|
428fc37b2ae6
Add many prototypes for static functions.
Kenichi Handa <handa@m17n.org>
parents:
89861
diff
changeset
|
895 static int produce_chars P_ ((struct coding_system *, Lisp_Object, int)); |
|
428fc37b2ae6
Add many prototypes for static functions.
Kenichi Handa <handa@m17n.org>
parents:
89861
diff
changeset
|
896 static INLINE void produce_composition P_ ((struct coding_system *, int *, |
|
428fc37b2ae6
Add many prototypes for static functions.
Kenichi Handa <handa@m17n.org>
parents:
89861
diff
changeset
|
897 EMACS_INT)); |
|
428fc37b2ae6
Add many prototypes for static functions.
Kenichi Handa <handa@m17n.org>
parents:
89861
diff
changeset
|
898 static INLINE void produce_charset P_ ((struct coding_system *, int *, |
|
428fc37b2ae6
Add many prototypes for static functions.
Kenichi Handa <handa@m17n.org>
parents:
89861
diff
changeset
|
899 EMACS_INT)); |
|
428fc37b2ae6
Add many prototypes for static functions.
Kenichi Handa <handa@m17n.org>
parents:
89861
diff
changeset
|
900 static void produce_annotation P_ ((struct coding_system *, EMACS_INT)); |
|
428fc37b2ae6
Add many prototypes for static functions.
Kenichi Handa <handa@m17n.org>
parents:
89861
diff
changeset
|
901 static int decode_coding P_ ((struct coding_system *)); |
|
428fc37b2ae6
Add many prototypes for static functions.
Kenichi Handa <handa@m17n.org>
parents:
89861
diff
changeset
|
902 static INLINE int *handle_composition_annotation P_ ((EMACS_INT, EMACS_INT, |
|
93877
62d97ebb13a9
* coding.c (detect_coding_emacs_mule)
Michael Albinus <michael.albinus@gmx.de>
parents:
93595
diff
changeset
|
903 struct coding_system *, |
|
89863
428fc37b2ae6
Add many prototypes for static functions.
Kenichi Handa <handa@m17n.org>
parents:
89861
diff
changeset
|
904 int *, EMACS_INT *)); |
|
428fc37b2ae6
Add many prototypes for static functions.
Kenichi Handa <handa@m17n.org>
parents:
89861
diff
changeset
|
905 static INLINE int *handle_charset_annotation P_ ((EMACS_INT, EMACS_INT, |
|
428fc37b2ae6
Add many prototypes for static functions.
Kenichi Handa <handa@m17n.org>
parents:
89861
diff
changeset
|
906 struct coding_system *, |
|
428fc37b2ae6
Add many prototypes for static functions.
Kenichi Handa <handa@m17n.org>
parents:
89861
diff
changeset
|
907 int *, EMACS_INT *)); |
|
428fc37b2ae6
Add many prototypes for static functions.
Kenichi Handa <handa@m17n.org>
parents:
89861
diff
changeset
|
908 static void consume_chars P_ ((struct coding_system *, Lisp_Object, int)); |
|
428fc37b2ae6
Add many prototypes for static functions.
Kenichi Handa <handa@m17n.org>
parents:
89861
diff
changeset
|
909 static int encode_coding P_ ((struct coding_system *)); |
|
428fc37b2ae6
Add many prototypes for static functions.
Kenichi Handa <handa@m17n.org>
parents:
89861
diff
changeset
|
910 static Lisp_Object make_conversion_work_buffer P_ ((int)); |
|
428fc37b2ae6
Add many prototypes for static functions.
Kenichi Handa <handa@m17n.org>
parents:
89861
diff
changeset
|
911 static Lisp_Object code_conversion_restore P_ ((Lisp_Object)); |
|
428fc37b2ae6
Add many prototypes for static functions.
Kenichi Handa <handa@m17n.org>
parents:
89861
diff
changeset
|
912 static INLINE int char_encodable_p P_ ((int, Lisp_Object)); |
|
428fc37b2ae6
Add many prototypes for static functions.
Kenichi Handa <handa@m17n.org>
parents:
89861
diff
changeset
|
913 static Lisp_Object make_subsidiaries P_ ((Lisp_Object)); |
|
428fc37b2ae6
Add many prototypes for static functions.
Kenichi Handa <handa@m17n.org>
parents:
89861
diff
changeset
|
914 |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
915 static void |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
916 record_conversion_result (struct coding_system *coding, |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
917 enum coding_result_code result) |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
918 { |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
919 coding->result = result; |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
920 switch (result) |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
921 { |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
922 case CODING_RESULT_INSUFFICIENT_SRC: |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
923 Vlast_code_conversion_error = Qinsufficient_source; |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
924 break; |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
925 case CODING_RESULT_INCONSISTENT_EOL: |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
926 Vlast_code_conversion_error = Qinconsistent_eol; |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
927 break; |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
928 case CODING_RESULT_INVALID_SRC: |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
929 Vlast_code_conversion_error = Qinvalid_source; |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
930 break; |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
931 case CODING_RESULT_INTERRUPT: |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
932 Vlast_code_conversion_error = Qinterrupted; |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
933 break; |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
934 case CODING_RESULT_INSUFFICIENT_MEM: |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
935 Vlast_code_conversion_error = Qinsufficient_memory; |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
936 break; |
|
90214
460ee00505d5
(QCascii_compatible_p): New variable.
Kenichi Handa <handa@m17n.org>
parents:
90201
diff
changeset
|
937 default: |
|
460ee00505d5
(QCascii_compatible_p): New variable.
Kenichi Handa <handa@m17n.org>
parents:
90201
diff
changeset
|
938 Vlast_code_conversion_error = intern ("Unknown error"); |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
939 } |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
940 } |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
941 |
| 88365 | 942 #define CODING_DECODE_CHAR(coding, src, src_base, src_end, charset, code, c) \ |
| 943 do { \ | |
| 944 charset_map_loaded = 0; \ | |
| 945 c = DECODE_CHAR (charset, code); \ | |
| 946 if (charset_map_loaded) \ | |
| 947 { \ | |
| 89483 | 948 const unsigned char *orig = coding->source; \ |
| 88365 | 949 EMACS_INT offset; \ |
| 950 \ | |
| 951 coding_set_source (coding); \ | |
| 952 offset = coding->source - orig; \ | |
| 953 src += offset; \ | |
| 954 src_base += offset; \ | |
| 955 src_end += offset; \ | |
| 956 } \ | |
| 957 } while (0) | |
| 958 | |
| 959 | |
|
92399
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
960 /* If there are at least BYTES length of room at dst, allocate memory |
|
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
961 for coding->destination and update dst and dst_end. We don't have |
|
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
962 to take care of coding->source which will be relocated. It is |
|
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
963 handled by calling coding_set_source in encode_coding. */ |
|
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
964 |
| 88365 | 965 #define ASSURE_DESTINATION(bytes) \ |
| 966 do { \ | |
| 967 if (dst + (bytes) >= dst_end) \ | |
| 968 { \ | |
| 969 int more_bytes = charbuf_end - charbuf + (bytes); \ | |
| 970 \ | |
| 971 dst = alloc_destination (coding, more_bytes, dst); \ | |
| 972 dst_end = coding->destination + coding->dst_bytes; \ | |
| 973 } \ | |
| 974 } while (0) | |
| 975 | |
| 976 | |
|
92992
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
977 /* Store multibyte form of the character C in P, and advance P to the |
|
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
978 end of the multibyte form. This is like CHAR_STRING_ADVANCE but it |
|
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
979 never calls MAYBE_UNIFY_CHAR. */ |
|
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
980 |
|
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
981 #define CHAR_STRING_ADVANCE_NO_UNIFY(c, p) \ |
|
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
982 do { \ |
|
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
983 if ((c) <= MAX_1_BYTE_CHAR) \ |
|
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
984 *(p)++ = (c); \ |
|
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
985 else if ((c) <= MAX_2_BYTE_CHAR) \ |
|
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
986 *(p)++ = (0xC0 | ((c) >> 6)), \ |
|
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
987 *(p)++ = (0x80 | ((c) & 0x3F)); \ |
|
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
988 else if ((c) <= MAX_3_BYTE_CHAR) \ |
|
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
989 *(p)++ = (0xE0 | ((c) >> 12)), \ |
|
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
990 *(p)++ = (0x80 | (((c) >> 6) & 0x3F)), \ |
|
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
991 *(p)++ = (0x80 | ((c) & 0x3F)); \ |
|
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
992 else if ((c) <= MAX_4_BYTE_CHAR) \ |
|
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
993 *(p)++ = (0xF0 | (c >> 18)), \ |
|
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
994 *(p)++ = (0x80 | ((c >> 12) & 0x3F)), \ |
|
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
995 *(p)++ = (0x80 | ((c >> 6) & 0x3F)), \ |
|
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
996 *(p)++ = (0x80 | (c & 0x3F)); \ |
|
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
997 else if ((c) <= MAX_5_BYTE_CHAR) \ |
|
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
998 *(p)++ = 0xF8, \ |
|
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
999 *(p)++ = (0x80 | ((c >> 18) & 0x0F)), \ |
|
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
1000 *(p)++ = (0x80 | ((c >> 12) & 0x3F)), \ |
|
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
1001 *(p)++ = (0x80 | ((c >> 6) & 0x3F)), \ |
|
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
1002 *(p)++ = (0x80 | (c & 0x3F)); \ |
|
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
1003 else \ |
|
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
1004 (p) += BYTE8_STRING ((c) - 0x3FFF80, p); \ |
|
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
1005 } while (0) |
|
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
1006 |
|
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
1007 |
|
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
1008 /* Return the character code of character whose multibyte form is at |
|
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
1009 P, and advance P to the end of the multibyte form. This is like |
|
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
1010 STRING_CHAR_ADVANCE, but it never calls MAYBE_UNIFY_CHAR. */ |
|
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
1011 |
|
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
1012 #define STRING_CHAR_ADVANCE_NO_UNIFY(p) \ |
|
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
1013 (!((p)[0] & 0x80) \ |
|
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
1014 ? *(p)++ \ |
|
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
1015 : ! ((p)[0] & 0x20) \ |
|
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
1016 ? ((p) += 2, \ |
|
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
1017 ((((p)[-2] & 0x1F) << 6) \ |
|
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
1018 | ((p)[-1] & 0x3F) \ |
|
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
1019 | ((unsigned char) ((p)[-2]) < 0xC2 ? 0x3FFF80 : 0))) \ |
|
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
1020 : ! ((p)[0] & 0x10) \ |
|
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
1021 ? ((p) += 3, \ |
|
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
1022 ((((p)[-3] & 0x0F) << 12) \ |
|
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
1023 | (((p)[-2] & 0x3F) << 6) \ |
|
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
1024 | ((p)[-1] & 0x3F))) \ |
|
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
1025 : ! ((p)[0] & 0x08) \ |
|
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
1026 ? ((p) += 4, \ |
|
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
1027 ((((p)[-4] & 0xF) << 18) \ |
|
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
1028 | (((p)[-3] & 0x3F) << 12) \ |
|
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
1029 | (((p)[-2] & 0x3F) << 6) \ |
|
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
1030 | ((p)[-1] & 0x3F))) \ |
|
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
1031 : ((p) += 5, \ |
|
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
1032 ((((p)[-4] & 0x3F) << 18) \ |
|
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
1033 | (((p)[-3] & 0x3F) << 12) \ |
|
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
1034 | (((p)[-2] & 0x3F) << 6) \ |
|
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
1035 | ((p)[-1] & 0x3F)))) |
|
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
1036 |
| 88365 | 1037 |
| 1038 static void | |
| 1039 coding_set_source (coding) | |
| 1040 struct coding_system *coding; | |
| 1041 { | |
| 1042 if (BUFFERP (coding->src_object)) | |
| 1043 { | |
|
89418
a9c2b3712863
(coding_set_source): Fix for the case that the current
Kenichi Handa <handa@m17n.org>
parents:
89404
diff
changeset
|
1044 struct buffer *buf = XBUFFER (coding->src_object); |
|
a9c2b3712863
(coding_set_source): Fix for the case that the current
Kenichi Handa <handa@m17n.org>
parents:
89404
diff
changeset
|
1045 |
| 88365 | 1046 if (coding->src_pos < 0) |
|
89418
a9c2b3712863
(coding_set_source): Fix for the case that the current
Kenichi Handa <handa@m17n.org>
parents:
89404
diff
changeset
|
1047 coding->source = BUF_GAP_END_ADDR (buf) + coding->src_pos_byte; |
| 88365 | 1048 else |
|
89418
a9c2b3712863
(coding_set_source): Fix for the case that the current
Kenichi Handa <handa@m17n.org>
parents:
89404
diff
changeset
|
1049 coding->source = BUF_BYTE_ADDRESS (buf, coding->src_pos_byte); |
| 88365 | 1050 } |
| 1051 else if (STRINGP (coding->src_object)) | |
| 1052 { | |
| 89483 | 1053 coding->source = SDATA (coding->src_object) + coding->src_pos_byte; |
| 88365 | 1054 } |
| 1055 else | |
| 1056 /* Otherwise, the source is C string and is never relocated | |
| 1057 automatically. Thus we don't have to update anything. */ | |
| 1058 ; | |
| 1059 } | |
| 1060 | |
| 1061 static void | |
| 1062 coding_set_destination (coding) | |
|
30487
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
1063 struct coding_system *coding; |
|
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
1064 { |
| 88365 | 1065 if (BUFFERP (coding->dst_object)) |
| 1066 { | |
| 1067 if (coding->src_pos < 0) | |
|
89042
2b9f8973f240
(coding_set_destination): Fix coding->destination for
Kenichi Handa <handa@m17n.org>
parents:
88977
diff
changeset
|
1068 { |
|
91807
507bcfb4342c
* coding.c (coding_set_destination): Use BEG_BYTE rather than hardcoding 1.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91622
diff
changeset
|
1069 coding->destination = BEG_ADDR + coding->dst_pos_byte - BEG_BYTE; |
|
89042
2b9f8973f240
(coding_set_destination): Fix coding->destination for
Kenichi Handa <handa@m17n.org>
parents:
88977
diff
changeset
|
1070 coding->dst_bytes = (GAP_END_ADDR |
|
2b9f8973f240
(coding_set_destination): Fix coding->destination for
Kenichi Handa <handa@m17n.org>
parents:
88977
diff
changeset
|
1071 - (coding->src_bytes - coding->consumed) |
|
2b9f8973f240
(coding_set_destination): Fix coding->destination for
Kenichi Handa <handa@m17n.org>
parents:
88977
diff
changeset
|
1072 - coding->destination); |
|
2b9f8973f240
(coding_set_destination): Fix coding->destination for
Kenichi Handa <handa@m17n.org>
parents:
88977
diff
changeset
|
1073 } |
| 88365 | 1074 else |
|
89042
2b9f8973f240
(coding_set_destination): Fix coding->destination for
Kenichi Handa <handa@m17n.org>
parents:
88977
diff
changeset
|
1075 { |
|
2b9f8973f240
(coding_set_destination): Fix coding->destination for
Kenichi Handa <handa@m17n.org>
parents:
88977
diff
changeset
|
1076 /* We are sure that coding->dst_pos_byte is before the gap |
|
2b9f8973f240
(coding_set_destination): Fix coding->destination for
Kenichi Handa <handa@m17n.org>
parents:
88977
diff
changeset
|
1077 of the buffer. */ |
|
2b9f8973f240
(coding_set_destination): Fix coding->destination for
Kenichi Handa <handa@m17n.org>
parents:
88977
diff
changeset
|
1078 coding->destination = (BUF_BEG_ADDR (XBUFFER (coding->dst_object)) |
|
91807
507bcfb4342c
* coding.c (coding_set_destination): Use BEG_BYTE rather than hardcoding 1.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91622
diff
changeset
|
1079 + coding->dst_pos_byte - BEG_BYTE); |
|
89042
2b9f8973f240
(coding_set_destination): Fix coding->destination for
Kenichi Handa <handa@m17n.org>
parents:
88977
diff
changeset
|
1080 coding->dst_bytes = (BUF_GAP_END_ADDR (XBUFFER (coding->dst_object)) |
|
2b9f8973f240
(coding_set_destination): Fix coding->destination for
Kenichi Handa <handa@m17n.org>
parents:
88977
diff
changeset
|
1081 - coding->destination); |
|
2b9f8973f240
(coding_set_destination): Fix coding->destination for
Kenichi Handa <handa@m17n.org>
parents:
88977
diff
changeset
|
1082 } |
| 88365 | 1083 } |
| 1084 else | |
| 1085 /* Otherwise, the destination is C string and is never relocated | |
| 1086 automatically. Thus we don't have to update anything. */ | |
| 1087 ; | |
| 1088 } | |
| 1089 | |
| 1090 | |
| 1091 static void | |
| 1092 coding_alloc_by_realloc (coding, bytes) | |
| 1093 struct coding_system *coding; | |
| 1094 EMACS_INT bytes; | |
| 1095 { | |
| 1096 coding->destination = (unsigned char *) xrealloc (coding->destination, | |
| 1097 coding->dst_bytes + bytes); | |
| 1098 coding->dst_bytes += bytes; | |
|
30487
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
1099 } |
|
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
1100 |
| 88365 | 1101 static void |
|
92992
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
1102 coding_alloc_by_making_gap (coding, gap_head_used, bytes) |
| 88365 | 1103 struct coding_system *coding; |
|
92992
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
1104 EMACS_INT gap_head_used, bytes; |
|
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
1105 { |
|
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
1106 if (EQ (coding->src_object, coding->dst_object)) |
|
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
1107 { |
|
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
1108 /* The gap may contain the produced data at the head and not-yet |
|
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
1109 consumed data at the tail. To preserve those data, we at |
|
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
1110 first make the gap size to zero, then increase the gap |
|
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
1111 size. */ |
|
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
1112 EMACS_INT add = GAP_SIZE; |
|
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
1113 |
|
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
1114 GPT += gap_head_used, GPT_BYTE += gap_head_used; |
|
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
1115 GAP_SIZE = 0; ZV += add; Z += add; ZV_BYTE += add; Z_BYTE += add; |
| 88365 | 1116 make_gap (bytes); |
| 1117 GAP_SIZE += add; ZV -= add; Z -= add; ZV_BYTE -= add; Z_BYTE -= add; | |
|
92992
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
1118 GPT -= gap_head_used, GPT_BYTE -= gap_head_used; |
| 88365 | 1119 } |
|
90292
697c08d95af7
Cancel incorrect synching with HEAD.
Kenichi Handa <handa@m17n.org>
parents:
90291
diff
changeset
|
1120 else |
| 88365 | 1121 { |
|
88456
a7b309f72920
(coding_alloc_by_making_gap): Check the case that the
Kenichi Handa <handa@m17n.org>
parents:
88443
diff
changeset
|
1122 Lisp_Object this_buffer; |
|
a7b309f72920
(coding_alloc_by_making_gap): Check the case that the
Kenichi Handa <handa@m17n.org>
parents:
88443
diff
changeset
|
1123 |
|
a7b309f72920
(coding_alloc_by_making_gap): Check the case that the
Kenichi Handa <handa@m17n.org>
parents:
88443
diff
changeset
|
1124 this_buffer = Fcurrent_buffer (); |
| 88365 | 1125 set_buffer_internal (XBUFFER (coding->dst_object)); |
| 1126 make_gap (bytes); | |
| 1127 set_buffer_internal (XBUFFER (this_buffer)); | |
| 1128 } | |
| 1129 } | |
| 89483 | 1130 |
| 88365 | 1131 |
| 1132 static unsigned char * | |
| 1133 alloc_destination (coding, nbytes, dst) | |
| 1134 struct coding_system *coding; | |
|
89545
4f394eed6ff2
(inhibit_pre_post_conversion): Removed (unused).
Dave Love <fx@gnu.org>
parents:
89519
diff
changeset
|
1135 EMACS_INT nbytes; |
| 88365 | 1136 unsigned char *dst; |
| 1137 { | |
| 1138 EMACS_INT offset = dst - coding->destination; | |
| 1139 | |
| 1140 if (BUFFERP (coding->dst_object)) | |
|
92992
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
1141 { |
|
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
1142 struct buffer *buf = XBUFFER (coding->dst_object); |
|
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
1143 |
|
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
1144 coding_alloc_by_making_gap (coding, dst - BUF_GPT_ADDR (buf), nbytes); |
|
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
1145 } |
| 88365 | 1146 else |
| 1147 coding_alloc_by_realloc (coding, nbytes); | |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1148 record_conversion_result (coding, CODING_RESULT_SUCCESS); |
| 88365 | 1149 coding_set_destination (coding); |
| 1150 dst = coding->destination + offset; | |
| 1151 return dst; | |
| 1152 } | |
| 1153 | |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1154 /** Macros for annotations. */ |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1155 |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1156 /* Maximum length of annotation data (sum of annotations for |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1157 composition and charset). */ |
|
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
1158 #define MAX_ANNOTATION_LENGTH (4 + (MAX_COMPOSITION_COMPONENTS * 2) - 1 + 4) |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1159 |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1160 /* An annotation data is stored in the array coding->charbuf in this |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1161 format: |
|
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
1162 [ -LENGTH ANNOTATION_MASK NCHARS ... ] |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1163 LENGTH is the number of elements in the annotation. |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1164 ANNOTATION_MASK is one of CODING_ANNOTATE_XXX_MASK. |
|
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
1165 NCHARS is the number of characters in the text annotated. |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1166 |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1167 The format of the following elements depend on ANNOTATION_MASK. |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1168 |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1169 In the case of CODING_ANNOTATE_COMPOSITION_MASK, these elements |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1170 follows: |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1171 ... METHOD [ COMPOSITION-COMPONENTS ... ] |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1172 METHOD is one of enum composition_method. |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1173 Optionnal COMPOSITION-COMPONENTS are characters and composition |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1174 rules. |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1175 |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1176 In the case of CODING_ANNOTATE_CHARSET_MASK, one element CHARSET-ID |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1177 follows. */ |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1178 |
|
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
1179 #define ADD_ANNOTATION_DATA(buf, len, mask, nchars) \ |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1180 do { \ |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1181 *(buf)++ = -(len); \ |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1182 *(buf)++ = (mask); \ |
|
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
1183 *(buf)++ = (nchars); \ |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1184 coding->annotated = 1; \ |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1185 } while (0); |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1186 |
|
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
1187 #define ADD_COMPOSITION_DATA(buf, nchars, method) \ |
|
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
1188 do { \ |
|
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
1189 ADD_ANNOTATION_DATA (buf, 4, CODING_ANNOTATE_COMPOSITION_MASK, nchars); \ |
|
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
1190 *buf++ = method; \ |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1191 } while (0) |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1192 |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1193 |
|
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
1194 #define ADD_CHARSET_DATA(buf, nchars, id) \ |
|
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
1195 do { \ |
|
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
1196 ADD_ANNOTATION_DATA (buf, 4, CODING_ANNOTATE_CHARSET_MASK, nchars); \ |
|
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
1197 *buf++ = id; \ |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1198 } while (0) |
|
30487
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
1199 |
| 17052 | 1200 |
| 88365 | 1201 /*** 2. Emacs' internal format (emacs-utf-8) ***/ |
| 1202 | |
| 1203 | |
|
30487
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
1204 |
| 17052 | 1205 |
| 88365 | 1206 /*** 3. UTF-8 ***/ |
| 1207 | |
| 1208 /* See the above "GENERAL NOTES on `detect_coding_XXX ()' functions". | |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1209 Check if a text is encoded in UTF-8. If it is, return 1, else |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1210 return 0. */ |
| 88365 | 1211 |
| 1212 #define UTF_8_1_OCTET_P(c) ((c) < 0x80) | |
| 1213 #define UTF_8_EXTRA_OCTET_P(c) (((c) & 0xC0) == 0x80) | |
| 1214 #define UTF_8_2_OCTET_LEADING_P(c) (((c) & 0xE0) == 0xC0) | |
| 1215 #define UTF_8_3_OCTET_LEADING_P(c) (((c) & 0xF0) == 0xE0) | |
| 1216 #define UTF_8_4_OCTET_LEADING_P(c) (((c) & 0xF8) == 0xF0) | |
| 1217 #define UTF_8_5_OCTET_LEADING_P(c) (((c) & 0xFC) == 0xF8) | |
| 1218 | |
| 1219 static int | |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1220 detect_coding_utf_8 (coding, detect_info) |
| 88365 | 1221 struct coding_system *coding; |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1222 struct coding_detection_info *detect_info; |
| 88365 | 1223 { |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1224 const unsigned char *src = coding->source, *src_base; |
| 89483 | 1225 const unsigned char *src_end = coding->source + coding->src_bytes; |
| 88365 | 1226 int multibytep = coding->src_multibyte; |
| 1227 int consumed_chars = 0; | |
| 1228 int found = 0; | |
| 1229 | |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1230 detect_info->checked |= CATEGORY_MASK_UTF_8; |
| 88365 | 1231 /* A coding system of this category is always ASCII compatible. */ |
| 1232 src += coding->head_ascii; | |
| 1233 | |
| 1234 while (1) | |
| 1235 { | |
| 1236 int c, c1, c2, c3, c4; | |
| 1237 | |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1238 src_base = src; |
| 88365 | 1239 ONE_MORE_BYTE (c); |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1240 if (c < 0 || UTF_8_1_OCTET_P (c)) |
| 88365 | 1241 continue; |
| 1242 ONE_MORE_BYTE (c1); | |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1243 if (c1 < 0 || ! UTF_8_EXTRA_OCTET_P (c1)) |
| 88365 | 1244 break; |
| 1245 if (UTF_8_2_OCTET_LEADING_P (c)) | |
| 1246 { | |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1247 found = CATEGORY_MASK_UTF_8; |
| 88365 | 1248 continue; |
| 1249 } | |
| 1250 ONE_MORE_BYTE (c2); | |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1251 if (c2 < 0 || ! UTF_8_EXTRA_OCTET_P (c2)) |
| 88365 | 1252 break; |
| 1253 if (UTF_8_3_OCTET_LEADING_P (c)) | |
| 1254 { | |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1255 found = CATEGORY_MASK_UTF_8; |
| 88365 | 1256 continue; |
| 1257 } | |
| 1258 ONE_MORE_BYTE (c3); | |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1259 if (c3 < 0 || ! UTF_8_EXTRA_OCTET_P (c3)) |
| 88365 | 1260 break; |
| 1261 if (UTF_8_4_OCTET_LEADING_P (c)) | |
| 1262 { | |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1263 found = CATEGORY_MASK_UTF_8; |
| 88365 | 1264 continue; |
| 1265 } | |
| 1266 ONE_MORE_BYTE (c4); | |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1267 if (c4 < 0 || ! UTF_8_EXTRA_OCTET_P (c4)) |
| 88365 | 1268 break; |
| 1269 if (UTF_8_5_OCTET_LEADING_P (c)) | |
| 1270 { | |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1271 found = CATEGORY_MASK_UTF_8; |
| 88365 | 1272 continue; |
| 1273 } | |
| 1274 break; | |
| 1275 } | |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1276 detect_info->rejected |= CATEGORY_MASK_UTF_8; |
| 88365 | 1277 return 0; |
| 1278 | |
| 1279 no_more_source: | |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1280 if (src_base < src && coding->mode & CODING_MODE_LAST_BLOCK) |
|
89193
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
1281 { |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1282 detect_info->rejected |= CATEGORY_MASK_UTF_8; |
|
89193
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
1283 return 0; |
|
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
1284 } |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1285 detect_info->found |= found; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1286 return 1; |
| 88365 | 1287 } |
| 1288 | |
| 1289 | |
| 1290 static void | |
| 1291 decode_coding_utf_8 (coding) | |
| 1292 struct coding_system *coding; | |
| 1293 { | |
| 89483 | 1294 const unsigned char *src = coding->source + coding->consumed; |
| 1295 const unsigned char *src_end = coding->source + coding->src_bytes; | |
| 1296 const unsigned char *src_base; | |
|
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
1297 int *charbuf = coding->charbuf + coding->charbuf_used; |
|
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
1298 int *charbuf_end = coding->charbuf + coding->charbuf_size; |
| 88365 | 1299 int consumed_chars = 0, consumed_chars_base; |
| 1300 int multibytep = coding->src_multibyte; | |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
1301 Lisp_Object attr, charset_list; |
|
92399
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
1302 int eol_crlf = EQ (CODING_ID_EOL_TYPE (coding->id), Qdos); |
|
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
1303 int byte_after_cr = -1; |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
1304 |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
1305 CODING_GET_INFO (coding, attr, charset_list); |
| 88365 | 1306 |
| 1307 while (1) | |
| 1308 { | |
| 1309 int c, c1, c2, c3, c4, c5; | |
| 1310 | |
| 1311 src_base = src; | |
| 1312 consumed_chars_base = consumed_chars; | |
| 1313 | |
| 1314 if (charbuf >= charbuf_end) | |
| 1315 break; | |
| 1316 | |
|
92399
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
1317 if (byte_after_cr >= 0) |
|
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
1318 c1 = byte_after_cr, byte_after_cr = -1; |
|
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
1319 else |
|
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
1320 ONE_MORE_BYTE (c1); |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1321 if (c1 < 0) |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1322 { |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1323 c = - c1; |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1324 } |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1325 else if (UTF_8_1_OCTET_P(c1)) |
| 88365 | 1326 { |
|
92399
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
1327 if (eol_crlf && c1 == '\r') |
|
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
1328 ONE_MORE_BYTE (byte_after_cr); |
| 88365 | 1329 c = c1; |
| 1330 } | |
| 1331 else | |
| 1332 { | |
| 1333 ONE_MORE_BYTE (c2); | |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1334 if (c2 < 0 || ! UTF_8_EXTRA_OCTET_P (c2)) |
| 88365 | 1335 goto invalid_code; |
| 1336 if (UTF_8_2_OCTET_LEADING_P (c1)) | |
|
88669
0bc5868f9f61
(decode_coding_utf_8): Reject overlong sequences.
Dave Love <fx@gnu.org>
parents:
88646
diff
changeset
|
1337 { |
|
0bc5868f9f61
(decode_coding_utf_8): Reject overlong sequences.
Dave Love <fx@gnu.org>
parents:
88646
diff
changeset
|
1338 c = ((c1 & 0x1F) << 6) | (c2 & 0x3F); |
|
0bc5868f9f61
(decode_coding_utf_8): Reject overlong sequences.
Dave Love <fx@gnu.org>
parents:
88646
diff
changeset
|
1339 /* Reject overlong sequences here and below. Encoders |
|
0bc5868f9f61
(decode_coding_utf_8): Reject overlong sequences.
Dave Love <fx@gnu.org>
parents:
88646
diff
changeset
|
1340 producing them are incorrect, they can be misleading, |
|
0bc5868f9f61
(decode_coding_utf_8): Reject overlong sequences.
Dave Love <fx@gnu.org>
parents:
88646
diff
changeset
|
1341 and they mess up read/write invariance. */ |
|
0bc5868f9f61
(decode_coding_utf_8): Reject overlong sequences.
Dave Love <fx@gnu.org>
parents:
88646
diff
changeset
|
1342 if (c < 128) |
|
0bc5868f9f61
(decode_coding_utf_8): Reject overlong sequences.
Dave Love <fx@gnu.org>
parents:
88646
diff
changeset
|
1343 goto invalid_code; |
|
0bc5868f9f61
(decode_coding_utf_8): Reject overlong sequences.
Dave Love <fx@gnu.org>
parents:
88646
diff
changeset
|
1344 } |
| 88365 | 1345 else |
| 1346 { | |
| 1347 ONE_MORE_BYTE (c3); | |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1348 if (c3 < 0 || ! UTF_8_EXTRA_OCTET_P (c3)) |
| 88365 | 1349 goto invalid_code; |
| 1350 if (UTF_8_3_OCTET_LEADING_P (c1)) | |
|
88669
0bc5868f9f61
(decode_coding_utf_8): Reject overlong sequences.
Dave Love <fx@gnu.org>
parents:
88646
diff
changeset
|
1351 { |
|
0bc5868f9f61
(decode_coding_utf_8): Reject overlong sequences.
Dave Love <fx@gnu.org>
parents:
88646
diff
changeset
|
1352 c = (((c1 & 0xF) << 12) |
|
0bc5868f9f61
(decode_coding_utf_8): Reject overlong sequences.
Dave Love <fx@gnu.org>
parents:
88646
diff
changeset
|
1353 | ((c2 & 0x3F) << 6) | (c3 & 0x3F)); |
|
89184
88a9e962e183
(decode_coding_utf_8): Treat surrogates as invalid.
Dave Love <fx@gnu.org>
parents:
89042
diff
changeset
|
1354 if (c < 0x800 |
|
88a9e962e183
(decode_coding_utf_8): Treat surrogates as invalid.
Dave Love <fx@gnu.org>
parents:
89042
diff
changeset
|
1355 || (c >= 0xd800 && c < 0xe000)) /* surrogates (invalid) */ |
|
88669
0bc5868f9f61
(decode_coding_utf_8): Reject overlong sequences.
Dave Love <fx@gnu.org>
parents:
88646
diff
changeset
|
1356 goto invalid_code; |
|
0bc5868f9f61
(decode_coding_utf_8): Reject overlong sequences.
Dave Love <fx@gnu.org>
parents:
88646
diff
changeset
|
1357 } |
| 88365 | 1358 else |
| 1359 { | |
| 1360 ONE_MORE_BYTE (c4); | |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1361 if (c4 < 0 || ! UTF_8_EXTRA_OCTET_P (c4)) |
| 88365 | 1362 goto invalid_code; |
| 1363 if (UTF_8_4_OCTET_LEADING_P (c1)) | |
|
88669
0bc5868f9f61
(decode_coding_utf_8): Reject overlong sequences.
Dave Love <fx@gnu.org>
parents:
88646
diff
changeset
|
1364 { |
| 88365 | 1365 c = (((c1 & 0x7) << 18) | ((c2 & 0x3F) << 12) |
| 1366 | ((c3 & 0x3F) << 6) | (c4 & 0x3F)); | |
|
88669
0bc5868f9f61
(decode_coding_utf_8): Reject overlong sequences.
Dave Love <fx@gnu.org>
parents:
88646
diff
changeset
|
1367 if (c < 0x10000) |
|
0bc5868f9f61
(decode_coding_utf_8): Reject overlong sequences.
Dave Love <fx@gnu.org>
parents:
88646
diff
changeset
|
1368 goto invalid_code; |
|
0bc5868f9f61
(decode_coding_utf_8): Reject overlong sequences.
Dave Love <fx@gnu.org>
parents:
88646
diff
changeset
|
1369 } |
| 88365 | 1370 else |
| 1371 { | |
| 1372 ONE_MORE_BYTE (c5); | |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1373 if (c5 < 0 || ! UTF_8_EXTRA_OCTET_P (c5)) |
| 88365 | 1374 goto invalid_code; |
| 1375 if (UTF_8_5_OCTET_LEADING_P (c1)) | |
| 1376 { | |
| 1377 c = (((c1 & 0x3) << 24) | ((c2 & 0x3F) << 18) | |
| 1378 | ((c3 & 0x3F) << 12) | ((c4 & 0x3F) << 6) | |
| 1379 | (c5 & 0x3F)); | |
|
88669
0bc5868f9f61
(decode_coding_utf_8): Reject overlong sequences.
Dave Love <fx@gnu.org>
parents:
88646
diff
changeset
|
1380 if ((c > MAX_CHAR) || (c < 0x200000)) |
| 88365 | 1381 goto invalid_code; |
| 1382 } | |
| 1383 else | |
| 1384 goto invalid_code; | |
| 1385 } | |
| 1386 } | |
| 1387 } | |
| 1388 } | |
| 1389 | |
| 1390 *charbuf++ = c; | |
| 1391 continue; | |
| 1392 | |
| 1393 invalid_code: | |
| 1394 src = src_base; | |
| 1395 consumed_chars = consumed_chars_base; | |
| 1396 ONE_MORE_BYTE (c); | |
| 1397 *charbuf++ = ASCII_BYTE_P (c) ? c : BYTE8_TO_CHAR (c); | |
| 1398 coding->errors++; | |
| 1399 } | |
| 1400 | |
| 1401 no_more_source: | |
| 1402 coding->consumed_char += consumed_chars_base; | |
| 1403 coding->consumed = src_base - coding->source; | |
| 1404 coding->charbuf_used = charbuf - coding->charbuf; | |
| 1405 } | |
| 1406 | |
| 1407 | |
| 1408 static int | |
| 1409 encode_coding_utf_8 (coding) | |
| 1410 struct coding_system *coding; | |
| 1411 { | |
| 1412 int multibytep = coding->dst_multibyte; | |
| 1413 int *charbuf = coding->charbuf; | |
| 1414 int *charbuf_end = charbuf + coding->charbuf_used; | |
| 1415 unsigned char *dst = coding->destination + coding->produced; | |
| 1416 unsigned char *dst_end = coding->destination + coding->dst_bytes; | |
|
88438
3a34b722dd71
(encode_coding_utf_8): Initialize produced_chars to 0.
Kenichi Handa <handa@m17n.org>
parents:
88430
diff
changeset
|
1417 int produced_chars = 0; |
| 88365 | 1418 int c; |
| 1419 | |
| 1420 if (multibytep) | |
| 1421 { | |
| 1422 int safe_room = MAX_MULTIBYTE_LENGTH * 2; | |
| 1423 | |
| 1424 while (charbuf < charbuf_end) | |
| 1425 { | |
| 1426 unsigned char str[MAX_MULTIBYTE_LENGTH], *p, *pend = str; | |
| 89483 | 1427 |
| 88365 | 1428 ASSURE_DESTINATION (safe_room); |
| 1429 c = *charbuf++; | |
|
89042
2b9f8973f240
(coding_set_destination): Fix coding->destination for
Kenichi Handa <handa@m17n.org>
parents:
88977
diff
changeset
|
1430 if (CHAR_BYTE8_P (c)) |
|
2b9f8973f240
(coding_set_destination): Fix coding->destination for
Kenichi Handa <handa@m17n.org>
parents:
88977
diff
changeset
|
1431 { |
|
2b9f8973f240
(coding_set_destination): Fix coding->destination for
Kenichi Handa <handa@m17n.org>
parents:
88977
diff
changeset
|
1432 c = CHAR_TO_BYTE8 (c); |
|
2b9f8973f240
(coding_set_destination): Fix coding->destination for
Kenichi Handa <handa@m17n.org>
parents:
88977
diff
changeset
|
1433 EMIT_ONE_BYTE (c); |
|
2b9f8973f240
(coding_set_destination): Fix coding->destination for
Kenichi Handa <handa@m17n.org>
parents:
88977
diff
changeset
|
1434 } |
|
2b9f8973f240
(coding_set_destination): Fix coding->destination for
Kenichi Handa <handa@m17n.org>
parents:
88977
diff
changeset
|
1435 else |
|
2b9f8973f240
(coding_set_destination): Fix coding->destination for
Kenichi Handa <handa@m17n.org>
parents:
88977
diff
changeset
|
1436 { |
|
92992
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
1437 CHAR_STRING_ADVANCE_NO_UNIFY (c, pend); |
|
89042
2b9f8973f240
(coding_set_destination): Fix coding->destination for
Kenichi Handa <handa@m17n.org>
parents:
88977
diff
changeset
|
1438 for (p = str; p < pend; p++) |
|
2b9f8973f240
(coding_set_destination): Fix coding->destination for
Kenichi Handa <handa@m17n.org>
parents:
88977
diff
changeset
|
1439 EMIT_ONE_BYTE (*p); |
|
2b9f8973f240
(coding_set_destination): Fix coding->destination for
Kenichi Handa <handa@m17n.org>
parents:
88977
diff
changeset
|
1440 } |
| 88365 | 1441 } |
| 1442 } | |
| 1443 else | |
| 1444 { | |
| 1445 int safe_room = MAX_MULTIBYTE_LENGTH; | |
| 1446 | |
| 1447 while (charbuf < charbuf_end) | |
| 1448 { | |
| 1449 ASSURE_DESTINATION (safe_room); | |
| 1450 c = *charbuf++; | |
|
89917
1763eef5ad02
(encode_coding_utf_8): Fix handling of raw-byte char.
Kenichi Handa <handa@m17n.org>
parents:
89905
diff
changeset
|
1451 if (CHAR_BYTE8_P (c)) |
|
1763eef5ad02
(encode_coding_utf_8): Fix handling of raw-byte char.
Kenichi Handa <handa@m17n.org>
parents:
89905
diff
changeset
|
1452 *dst++ = CHAR_TO_BYTE8 (c); |
|
1763eef5ad02
(encode_coding_utf_8): Fix handling of raw-byte char.
Kenichi Handa <handa@m17n.org>
parents:
89905
diff
changeset
|
1453 else |
|
92992
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
1454 CHAR_STRING_ADVANCE_NO_UNIFY (c, dst); |
| 88365 | 1455 produced_chars++; |
| 1456 } | |
| 1457 } | |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1458 record_conversion_result (coding, CODING_RESULT_SUCCESS); |
| 88365 | 1459 coding->produced_char += produced_chars; |
| 1460 coding->produced = dst - coding->destination; | |
| 1461 return 0; | |
| 1462 } | |
| 1463 | |
| 1464 | |
| 1465 /* See the above "GENERAL NOTES on `detect_coding_XXX ()' functions". | |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1466 Check if a text is encoded in one of UTF-16 based coding systems. |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1467 If it is, return 1, else return 0. */ |
| 88365 | 1468 |
| 1469 #define UTF_16_HIGH_SURROGATE_P(val) \ | |
| 1470 (((val) & 0xFC00) == 0xD800) | |
| 1471 | |
| 1472 #define UTF_16_LOW_SURROGATE_P(val) \ | |
| 1473 (((val) & 0xFC00) == 0xDC00) | |
| 1474 | |
| 1475 #define UTF_16_INVALID_P(val) \ | |
| 1476 (((val) == 0xFFFE) \ | |
| 1477 || ((val) == 0xFFFF) \ | |
| 1478 || UTF_16_LOW_SURROGATE_P (val)) | |
| 1479 | |
| 1480 | |
| 1481 static int | |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1482 detect_coding_utf_16 (coding, detect_info) |
| 88365 | 1483 struct coding_system *coding; |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1484 struct coding_detection_info *detect_info; |
| 88365 | 1485 { |
| 89483 | 1486 const unsigned char *src = coding->source, *src_base = src; |
| 1487 const unsigned char *src_end = coding->source + coding->src_bytes; | |
| 88365 | 1488 int multibytep = coding->src_multibyte; |
| 1489 int consumed_chars = 0; | |
| 1490 int c1, c2; | |
| 1491 | |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1492 detect_info->checked |= CATEGORY_MASK_UTF_16; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1493 if (coding->mode & CODING_MODE_LAST_BLOCK |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
1494 && (coding->src_chars & 1)) |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1495 { |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1496 detect_info->rejected |= CATEGORY_MASK_UTF_16; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1497 return 0; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1498 } |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
1499 |
| 88365 | 1500 ONE_MORE_BYTE (c1); |
| 1501 ONE_MORE_BYTE (c2); | |
| 1502 if ((c1 == 0xFF) && (c2 == 0xFE)) | |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1503 { |
|
89420
c3e67ce6ee0f
(Qsignature, Qendian): Delete these variables.
Kenichi Handa <handa@m17n.org>
parents:
89418
diff
changeset
|
1504 detect_info->found |= (CATEGORY_MASK_UTF_16_LE |
|
c3e67ce6ee0f
(Qsignature, Qendian): Delete these variables.
Kenichi Handa <handa@m17n.org>
parents:
89418
diff
changeset
|
1505 | CATEGORY_MASK_UTF_16_AUTO); |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
1506 detect_info->rejected |= (CATEGORY_MASK_UTF_16_BE |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
1507 | CATEGORY_MASK_UTF_16_BE_NOSIG |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
1508 | CATEGORY_MASK_UTF_16_LE_NOSIG); |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1509 } |
| 88365 | 1510 else if ((c1 == 0xFE) && (c2 == 0xFF)) |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1511 { |
|
89420
c3e67ce6ee0f
(Qsignature, Qendian): Delete these variables.
Kenichi Handa <handa@m17n.org>
parents:
89418
diff
changeset
|
1512 detect_info->found |= (CATEGORY_MASK_UTF_16_BE |
|
c3e67ce6ee0f
(Qsignature, Qendian): Delete these variables.
Kenichi Handa <handa@m17n.org>
parents:
89418
diff
changeset
|
1513 | CATEGORY_MASK_UTF_16_AUTO); |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
1514 detect_info->rejected |= (CATEGORY_MASK_UTF_16_LE |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
1515 | CATEGORY_MASK_UTF_16_BE_NOSIG |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
1516 | CATEGORY_MASK_UTF_16_LE_NOSIG); |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
1517 } |
|
93595
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
1518 else |
|
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
1519 { |
|
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
1520 /* We check the dispersion of Eth and Oth bytes where E is even and |
|
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
1521 O is odd. If both are high, we assume binary data.*/ |
|
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
1522 unsigned char e[256], o[256]; |
|
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
1523 unsigned e_num = 1, o_num = 1; |
|
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
1524 |
|
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
1525 memset (e, 0, 256); |
|
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
1526 memset (o, 0, 256); |
|
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
1527 e[c1] = 1; |
|
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
1528 o[c2] = 1; |
|
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
1529 |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
1530 detect_info->rejected |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
1531 |= (CATEGORY_MASK_UTF_16_BE | CATEGORY_MASK_UTF_16_LE); |
|
93595
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
1532 |
|
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
1533 while (1) |
|
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
1534 { |
|
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
1535 ONE_MORE_BYTE (c1); |
|
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
1536 ONE_MORE_BYTE (c2); |
|
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
1537 if (! e[c1]) |
|
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
1538 { |
|
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
1539 e[c1] = 1; |
|
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
1540 e_num++; |
|
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
1541 if (e_num >= 128) |
|
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
1542 break; |
|
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
1543 } |
|
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
1544 if (! o[c2]) |
|
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
1545 { |
|
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
1546 o[c1] = 1; |
|
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
1547 o_num++; |
|
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
1548 if (o_num >= 128) |
|
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
1549 break; |
|
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
1550 } |
|
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
1551 } |
|
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
1552 detect_info->rejected |= CATEGORY_MASK_UTF_16; |
|
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
1553 return 0; |
|
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
1554 } |
|
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
1555 |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1556 no_more_source: |
|
89193
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
1557 return 1; |
| 88365 | 1558 } |
| 1559 | |
| 1560 static void | |
| 1561 decode_coding_utf_16 (coding) | |
| 1562 struct coding_system *coding; | |
| 1563 { | |
| 89483 | 1564 const unsigned char *src = coding->source + coding->consumed; |
| 1565 const unsigned char *src_end = coding->source + coding->src_bytes; | |
| 1566 const unsigned char *src_base; | |
|
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
1567 int *charbuf = coding->charbuf + coding->charbuf_used; |
|
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
1568 int *charbuf_end = coding->charbuf + coding->charbuf_size; |
| 88365 | 1569 int consumed_chars = 0, consumed_chars_base; |
| 1570 int multibytep = coding->src_multibyte; | |
| 1571 enum utf_16_bom_type bom = CODING_UTF_16_BOM (coding); | |
| 1572 enum utf_16_endian_type endian = CODING_UTF_16_ENDIAN (coding); | |
| 1573 int surrogate = CODING_UTF_16_SURROGATE (coding); | |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
1574 Lisp_Object attr, charset_list; |
|
92399
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
1575 int eol_crlf = EQ (CODING_ID_EOL_TYPE (coding->id), Qdos); |
|
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
1576 int byte_after_cr1 = -1, byte_after_cr2 = -1; |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
1577 |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
1578 CODING_GET_INFO (coding, attr, charset_list); |
| 88365 | 1579 |
|
89420
c3e67ce6ee0f
(Qsignature, Qendian): Delete these variables.
Kenichi Handa <handa@m17n.org>
parents:
89418
diff
changeset
|
1580 if (bom == utf_16_with_bom) |
| 88365 | 1581 { |
| 1582 int c, c1, c2; | |
| 1583 | |
| 1584 src_base = src; | |
| 1585 ONE_MORE_BYTE (c1); | |
| 1586 ONE_MORE_BYTE (c2); | |
|
88438
3a34b722dd71
(encode_coding_utf_8): Initialize produced_chars to 0.
Kenichi Handa <handa@m17n.org>
parents:
88430
diff
changeset
|
1587 c = (c1 << 8) | c2; |
|
89420
c3e67ce6ee0f
(Qsignature, Qendian): Delete these variables.
Kenichi Handa <handa@m17n.org>
parents:
89418
diff
changeset
|
1588 |
|
c3e67ce6ee0f
(Qsignature, Qendian): Delete these variables.
Kenichi Handa <handa@m17n.org>
parents:
89418
diff
changeset
|
1589 if (endian == utf_16_big_endian |
|
c3e67ce6ee0f
(Qsignature, Qendian): Delete these variables.
Kenichi Handa <handa@m17n.org>
parents:
89418
diff
changeset
|
1590 ? c != 0xFEFF : c != 0xFFFE) |
| 88365 | 1591 { |
|
89420
c3e67ce6ee0f
(Qsignature, Qendian): Delete these variables.
Kenichi Handa <handa@m17n.org>
parents:
89418
diff
changeset
|
1592 /* The first two bytes are not BOM. Treat them as bytes |
|
c3e67ce6ee0f
(Qsignature, Qendian): Delete these variables.
Kenichi Handa <handa@m17n.org>
parents:
89418
diff
changeset
|
1593 for a normal character. */ |
|
c3e67ce6ee0f
(Qsignature, Qendian): Delete these variables.
Kenichi Handa <handa@m17n.org>
parents:
89418
diff
changeset
|
1594 src = src_base; |
|
c3e67ce6ee0f
(Qsignature, Qendian): Delete these variables.
Kenichi Handa <handa@m17n.org>
parents:
89418
diff
changeset
|
1595 coding->errors++; |
| 88365 | 1596 } |
|
89420
c3e67ce6ee0f
(Qsignature, Qendian): Delete these variables.
Kenichi Handa <handa@m17n.org>
parents:
89418
diff
changeset
|
1597 CODING_UTF_16_BOM (coding) = utf_16_without_bom; |
|
c3e67ce6ee0f
(Qsignature, Qendian): Delete these variables.
Kenichi Handa <handa@m17n.org>
parents:
89418
diff
changeset
|
1598 } |
|
c3e67ce6ee0f
(Qsignature, Qendian): Delete these variables.
Kenichi Handa <handa@m17n.org>
parents:
89418
diff
changeset
|
1599 else if (bom == utf_16_detect_bom) |
|
c3e67ce6ee0f
(Qsignature, Qendian): Delete these variables.
Kenichi Handa <handa@m17n.org>
parents:
89418
diff
changeset
|
1600 { |
|
c3e67ce6ee0f
(Qsignature, Qendian): Delete these variables.
Kenichi Handa <handa@m17n.org>
parents:
89418
diff
changeset
|
1601 /* We have already tried to detect BOM and failed in |
|
c3e67ce6ee0f
(Qsignature, Qendian): Delete these variables.
Kenichi Handa <handa@m17n.org>
parents:
89418
diff
changeset
|
1602 detect_coding. */ |
|
c3e67ce6ee0f
(Qsignature, Qendian): Delete these variables.
Kenichi Handa <handa@m17n.org>
parents:
89418
diff
changeset
|
1603 CODING_UTF_16_BOM (coding) = utf_16_without_bom; |
| 88365 | 1604 } |
| 1605 | |
| 1606 while (1) | |
| 1607 { | |
| 1608 int c, c1, c2; | |
| 1609 | |
| 1610 src_base = src; | |
| 1611 consumed_chars_base = consumed_chars; | |
| 1612 | |
| 1613 if (charbuf + 2 >= charbuf_end) | |
| 1614 break; | |
| 1615 | |
|
92399
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
1616 if (byte_after_cr1 >= 0) |
|
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
1617 c1 = byte_after_cr1, byte_after_cr1 = -1; |
|
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
1618 else |
|
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
1619 ONE_MORE_BYTE (c1); |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1620 if (c1 < 0) |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1621 { |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1622 *charbuf++ = -c1; |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1623 continue; |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1624 } |
|
92399
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
1625 if (byte_after_cr2 >= 0) |
|
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
1626 c2 = byte_after_cr2, byte_after_cr2 = -1; |
|
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
1627 else |
|
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
1628 ONE_MORE_BYTE (c2); |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1629 if (c2 < 0) |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1630 { |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1631 *charbuf++ = ASCII_BYTE_P (c1) ? c1 : BYTE8_TO_CHAR (c1); |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1632 *charbuf++ = -c2; |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1633 continue; |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1634 } |
| 88365 | 1635 c = (endian == utf_16_big_endian |
|
88438
3a34b722dd71
(encode_coding_utf_8): Initialize produced_chars to 0.
Kenichi Handa <handa@m17n.org>
parents:
88430
diff
changeset
|
1636 ? ((c1 << 8) | c2) : ((c2 << 8) | c1)); |
|
92399
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
1637 |
| 88365 | 1638 if (surrogate) |
| 1639 { | |
| 1640 if (! UTF_16_LOW_SURROGATE_P (c)) | |
| 1641 { | |
| 1642 if (endian == utf_16_big_endian) | |
| 1643 c1 = surrogate >> 8, c2 = surrogate & 0xFF; | |
| 1644 else | |
| 1645 c1 = surrogate & 0xFF, c2 = surrogate >> 8; | |
| 1646 *charbuf++ = c1; | |
| 1647 *charbuf++ = c2; | |
| 1648 coding->errors++; | |
| 1649 if (UTF_16_HIGH_SURROGATE_P (c)) | |
| 1650 CODING_UTF_16_SURROGATE (coding) = surrogate = c; | |
| 1651 else | |
| 1652 *charbuf++ = c; | |
| 1653 } | |
| 1654 else | |
| 1655 { | |
| 1656 c = ((surrogate - 0xD800) << 10) | (c - 0xDC00); | |
| 1657 CODING_UTF_16_SURROGATE (coding) = surrogate = 0; | |
|
89842
b5f22f538c1f
(decode_coding_utf_16): Fix handling of surrogate pare.
Kenichi Handa <handa@m17n.org>
parents:
89780
diff
changeset
|
1658 *charbuf++ = 0x10000 + c; |
| 88365 | 1659 } |
| 1660 } | |
| 1661 else | |
| 1662 { | |
| 1663 if (UTF_16_HIGH_SURROGATE_P (c)) | |
| 1664 CODING_UTF_16_SURROGATE (coding) = surrogate = c; | |
| 1665 else | |
|
92399
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
1666 { |
|
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
1667 if (eol_crlf && c == '\r') |
|
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
1668 { |
|
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
1669 ONE_MORE_BYTE (byte_after_cr1); |
|
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
1670 ONE_MORE_BYTE (byte_after_cr2); |
|
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
1671 } |
|
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
1672 *charbuf++ = c; |
|
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
1673 } |
| 89483 | 1674 } |
| 88365 | 1675 } |
| 1676 | |
| 1677 no_more_source: | |
| 1678 coding->consumed_char += consumed_chars_base; | |
| 1679 coding->consumed = src_base - coding->source; | |
| 1680 coding->charbuf_used = charbuf - coding->charbuf; | |
| 1681 } | |
| 1682 | |
| 1683 static int | |
| 1684 encode_coding_utf_16 (coding) | |
| 1685 struct coding_system *coding; | |
| 1686 { | |
| 1687 int multibytep = coding->dst_multibyte; | |
| 1688 int *charbuf = coding->charbuf; | |
| 1689 int *charbuf_end = charbuf + coding->charbuf_used; | |
| 1690 unsigned char *dst = coding->destination + coding->produced; | |
| 1691 unsigned char *dst_end = coding->destination + coding->dst_bytes; | |
| 1692 int safe_room = 8; | |
| 1693 enum utf_16_bom_type bom = CODING_UTF_16_BOM (coding); | |
| 1694 int big_endian = CODING_UTF_16_ENDIAN (coding) == utf_16_big_endian; | |
| 1695 int produced_chars = 0; | |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
1696 Lisp_Object attrs, charset_list; |
| 88365 | 1697 int c; |
| 1698 | |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
1699 CODING_GET_INFO (coding, attrs, charset_list); |
| 88365 | 1700 |
|
89420
c3e67ce6ee0f
(Qsignature, Qendian): Delete these variables.
Kenichi Handa <handa@m17n.org>
parents:
89418
diff
changeset
|
1701 if (bom != utf_16_without_bom) |
| 88365 | 1702 { |
| 1703 ASSURE_DESTINATION (safe_room); | |
| 1704 if (big_endian) | |
|
89404
3e1d187b52c3
(Qutf_16_be_nosig, Qutf_16_be, Qutf_16_le_nosig)
Kenichi Handa <handa@m17n.org>
parents:
89394
diff
changeset
|
1705 EMIT_TWO_BYTES (0xFE, 0xFF); |
| 88365 | 1706 else |
|
89404
3e1d187b52c3
(Qutf_16_be_nosig, Qutf_16_be, Qutf_16_le_nosig)
Kenichi Handa <handa@m17n.org>
parents:
89394
diff
changeset
|
1707 EMIT_TWO_BYTES (0xFF, 0xFE); |
| 88365 | 1708 CODING_UTF_16_BOM (coding) = utf_16_without_bom; |
| 1709 } | |
| 1710 | |
| 1711 while (charbuf < charbuf_end) | |
| 1712 { | |
| 1713 ASSURE_DESTINATION (safe_room); | |
| 1714 c = *charbuf++; | |
|
88438
3a34b722dd71
(encode_coding_utf_8): Initialize produced_chars to 0.
Kenichi Handa <handa@m17n.org>
parents:
88430
diff
changeset
|
1715 if (c >= MAX_UNICODE_CHAR) |
|
3a34b722dd71
(encode_coding_utf_8): Initialize produced_chars to 0.
Kenichi Handa <handa@m17n.org>
parents:
88430
diff
changeset
|
1716 c = coding->default_char; |
| 88365 | 1717 |
| 1718 if (c < 0x10000) | |
| 1719 { | |
| 1720 if (big_endian) | |
| 1721 EMIT_TWO_BYTES (c >> 8, c & 0xFF); | |
| 1722 else | |
| 1723 EMIT_TWO_BYTES (c & 0xFF, c >> 8); | |
| 1724 } | |
| 1725 else | |
| 1726 { | |
| 1727 int c1, c2; | |
| 1728 | |
| 1729 c -= 0x10000; | |
| 1730 c1 = (c >> 10) + 0xD800; | |
| 1731 c2 = (c & 0x3FF) + 0xDC00; | |
| 1732 if (big_endian) | |
| 1733 EMIT_FOUR_BYTES (c1 >> 8, c1 & 0xFF, c2 >> 8, c2 & 0xFF); | |
| 1734 else | |
| 1735 EMIT_FOUR_BYTES (c1 & 0xFF, c1 >> 8, c2 & 0xFF, c2 >> 8); | |
| 1736 } | |
| 1737 } | |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1738 record_conversion_result (coding, CODING_RESULT_SUCCESS); |
| 88365 | 1739 coding->produced = dst - coding->destination; |
| 1740 coding->produced_char += produced_chars; | |
| 1741 return 0; | |
| 1742 } | |
| 1743 | |
| 1744 | |
| 1745 /*** 6. Old Emacs' internal format (emacs-mule) ***/ | |
| 17052 | 1746 |
|
34888
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1747 /* Emacs' internal format for representation of multiple character |
|
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1748 sets is a kind of multi-byte encoding, i.e. characters are |
|
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1749 represented by variable-length sequences of one-byte codes. |
|
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1750 |
|
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1751 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
|
1752 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
|
1753 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
|
1754 |
|
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1755 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
|
1756 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
|
1757 code + 0x20). |
|
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1758 |
|
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1759 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
|
1760 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
|
1761 |
|
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1762 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
|
1763 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
|
1764 `position-code's. The length of the sequence is determined by the |
|
34888
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1765 base leading-code. Leading-code takes the range 0x81 through 0x9D, |
|
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1766 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
|
1767 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
|
1768 and position-code. |
| 18766 | 1769 |
| 17052 | 1770 --- 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
|
1771 character set range |
|
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1772 ------------- ----- |
|
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1773 ascii 0x00..0x7F |
|
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1774 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
|
1775 eight-bit-graphic 0xA0..0xBF |
|
34888
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1776 ELSE 0x81..0x9D + [0xA0..0xFF]+ |
| 17052 | 1777 --------------------------------------------- |
| 1778 | |
|
34888
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1779 As this is the internal character representation, the format is |
|
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1780 usually not used externally (i.e. in a file or in a data sent to a |
|
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1781 process). But, it is possible to have a text externally in this |
|
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1782 format (i.e. by encoding by the coding system `emacs-mule'). |
|
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1783 |
|
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1784 In that case, a sequence of one-byte codes has a slightly different |
|
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1785 form. |
|
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1786 |
| 88365 | 1787 At first, all characters in eight-bit-control are represented by |
|
34888
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1788 one-byte sequences which are their 8-bit code. |
|
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1789 |
|
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1790 Next, character composition data are represented by the byte |
|
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1791 sequence of the form: 0x80 METHOD BYTES CHARS COMPONENT ..., |
|
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1792 where, |
|
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1793 METHOD is 0xF0 plus one of composition method (enum |
|
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1794 composition_method), |
|
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1795 |
| 88365 | 1796 BYTES is 0xA0 plus a byte length of this composition data, |
| 1797 | |
| 1798 CHARS is 0x20 plus a number of characters composed by this | |
|
34888
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1799 data, |
|
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1800 |
| 88365 | 1801 COMPONENTs are characters of multibye form or composition |
|
34888
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1802 rules encoded by two-byte of ASCII codes. |
|
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1803 |
|
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1804 In addition, for backward compatibility, the following formats are |
|
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1805 also recognized as composition data on decoding. |
|
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1806 |
|
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1807 0x80 MSEQ ... |
|
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1808 0x80 0xFF MSEQ RULE MSEQ RULE ... MSEQ |
|
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1809 |
|
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1810 Here, |
|
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1811 MSEQ is a multibyte form but in these special format: |
|
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1812 ASCII: 0xA0 ASCII_CODE+0x80, |
|
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1813 other: LEADING_CODE+0x20 FOLLOWING-BYTE ..., |
|
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1814 RULE is a one byte code of the range 0xA0..0xF0 that |
|
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1815 represents a composition rule. |
| 17052 | 1816 */ |
| 1817 | |
| 88365 | 1818 char emacs_mule_bytes[256]; |
| 1819 | |
| 1820 int | |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1821 emacs_mule_char (coding, src, nbytes, nchars, id) |
| 88365 | 1822 struct coding_system *coding; |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1823 const unsigned char *src; |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1824 int *nbytes, *nchars, *id; |
| 88365 | 1825 { |
| 89483 | 1826 const unsigned char *src_end = coding->source + coding->src_bytes; |
| 1827 const unsigned char *src_base = src; | |
| 88365 | 1828 int multibytep = coding->src_multibyte; |
| 1829 struct charset *charset; | |
| 1830 unsigned code; | |
| 1831 int c; | |
| 1832 int consumed_chars = 0; | |
| 1833 | |
| 1834 ONE_MORE_BYTE (c); | |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1835 if (c < 0) |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1836 { |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1837 c = -c; |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1838 charset = emacs_mule_charset[0]; |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1839 } |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1840 else |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1841 { |
|
90354
450fb16a4bf4
(DECODE_COMPOSITION_START): If the source is short, set
Kenichi Handa <handa@m17n.org>
parents:
90350
diff
changeset
|
1842 if (c >= 0xA0) |
|
450fb16a4bf4
(DECODE_COMPOSITION_START): If the source is short, set
Kenichi Handa <handa@m17n.org>
parents:
90350
diff
changeset
|
1843 { |
| 92030 | 1844 /* Old style component character of a composition. */ |
|
90354
450fb16a4bf4
(DECODE_COMPOSITION_START): If the source is short, set
Kenichi Handa <handa@m17n.org>
parents:
90350
diff
changeset
|
1845 if (c == 0xA0) |
|
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1846 { |
|
90354
450fb16a4bf4
(DECODE_COMPOSITION_START): If the source is short, set
Kenichi Handa <handa@m17n.org>
parents:
90350
diff
changeset
|
1847 ONE_MORE_BYTE (c); |
|
450fb16a4bf4
(DECODE_COMPOSITION_START): If the source is short, set
Kenichi Handa <handa@m17n.org>
parents:
90350
diff
changeset
|
1848 c -= 0x80; |
|
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1849 } |
| 17052 | 1850 else |
| 1851 c -= 0x20; | |
| 1852 } | |
| 1853 | |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1854 switch (emacs_mule_bytes[c]) |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1855 { |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1856 case 2: |
| 88365 | 1857 if (! (charset = emacs_mule_charset[c])) |
| 1858 goto invalid_code; | |
| 1859 ONE_MORE_BYTE (c); | |
| 17052 | 1860 if (c < 0xA0) |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1861 goto invalid_code; |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1862 code = c & 0x7F; |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1863 break; |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1864 |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1865 case 3: |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1866 if (c == EMACS_MULE_LEADING_CODE_PRIVATE_11 |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1867 || c == EMACS_MULE_LEADING_CODE_PRIVATE_12) |
|
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1868 { |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1869 ONE_MORE_BYTE (c); |
| 89892 | 1870 if (c < 0xA0 || ! (charset = emacs_mule_charset[c])) |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1871 goto invalid_code; |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1872 ONE_MORE_BYTE (c); |
| 89892 | 1873 if (c < 0xA0) |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1874 goto invalid_code; |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1875 code = c & 0x7F; |
|
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1876 } |
| 26847 | 1877 else |
|
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1878 { |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1879 if (! (charset = emacs_mule_charset[c])) |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1880 goto invalid_code; |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1881 ONE_MORE_BYTE (c); |
| 89892 | 1882 if (c < 0xA0) |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1883 goto invalid_code; |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1884 code = (c & 0x7F) << 8; |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1885 ONE_MORE_BYTE (c); |
| 89892 | 1886 if (c < 0xA0) |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1887 goto invalid_code; |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1888 code |= c & 0x7F; |
|
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1889 } |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1890 break; |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1891 |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1892 case 4: |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1893 ONE_MORE_BYTE (c); |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1894 if (c < 0 || ! (charset = emacs_mule_charset[c])) |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1895 goto invalid_code; |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1896 ONE_MORE_BYTE (c); |
| 89892 | 1897 if (c < 0xA0) |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1898 goto invalid_code; |
|
88585
c7772f702227
(ONE_MORE_BYTE_NO_CHECK): Increment consumed_chars.
Kenichi Handa <handa@m17n.org>
parents:
88573
diff
changeset
|
1899 code = (c & 0x7F) << 8; |
| 88365 | 1900 ONE_MORE_BYTE (c); |
| 89892 | 1901 if (c < 0xA0) |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1902 goto invalid_code; |
| 88365 | 1903 code |= c & 0x7F; |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1904 break; |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1905 |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1906 case 1: |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1907 code = c; |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1908 charset = CHARSET_FROM_ID (ASCII_BYTE_P (code) |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1909 ? charset_ascii : charset_eight_bit); |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1910 break; |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1911 |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1912 default: |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1913 abort (); |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1914 } |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1915 c = DECODE_CHAR (charset, code); |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1916 if (c < 0) |
| 88365 | 1917 goto invalid_code; |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1918 } |
| 88365 | 1919 *nbytes = src - src_base; |
| 1920 *nchars = consumed_chars; | |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1921 if (id) |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1922 *id = charset->id; |
| 88365 | 1923 return c; |
| 1924 | |
| 1925 no_more_source: | |
| 1926 return -2; | |
| 1927 | |
| 1928 invalid_code: | |
| 1929 return -1; | |
| 1930 } | |
| 1931 | |
| 17052 | 1932 |
| 1933 /* See the above "GENERAL NOTES on `detect_coding_XXX ()' functions". | |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1934 Check if a text is encoded in `emacs-mule'. If it is, return 1, |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1935 else return 0. */ |
| 17052 | 1936 |
|
34531
37f85e931855
(ONE_MORE_BYTE_CHECK_MULTIBYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34197
diff
changeset
|
1937 static int |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1938 detect_coding_emacs_mule (coding, detect_info) |
| 88365 | 1939 struct coding_system *coding; |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1940 struct coding_detection_info *detect_info; |
| 17052 | 1941 { |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1942 const unsigned char *src = coding->source, *src_base; |
| 89483 | 1943 const unsigned char *src_end = coding->source + coding->src_bytes; |
| 88365 | 1944 int multibytep = coding->src_multibyte; |
| 1945 int consumed_chars = 0; | |
| 1946 int c; | |
| 1947 int found = 0; | |
| 1948 | |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1949 detect_info->checked |= CATEGORY_MASK_EMACS_MULE; |
| 88365 | 1950 /* A coding system of this category is always ASCII compatible. */ |
| 1951 src += coding->head_ascii; | |
|
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1952 |
|
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1953 while (1) |
| 17052 | 1954 { |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1955 src_base = src; |
| 88365 | 1956 ONE_MORE_BYTE (c); |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1957 if (c < 0) |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1958 continue; |
| 88365 | 1959 if (c == 0x80) |
| 17052 | 1960 { |
| 88365 | 1961 /* Perhaps the start of composite character. We simple skip |
| 1962 it because analyzing it is too heavy for detecting. But, | |
| 1963 at least, we check that the composite character | |
|
93877
62d97ebb13a9
* coding.c (detect_coding_emacs_mule)
Michael Albinus <michael.albinus@gmx.de>
parents:
93595
diff
changeset
|
1964 constitutes of more than 4 bytes. */ |
| 89483 | 1965 const unsigned char *src_base; |
| 88365 | 1966 |
| 1967 repeat: | |
| 1968 src_base = src; | |
| 1969 do | |
| 1970 { | |
| 1971 ONE_MORE_BYTE (c); | |
| 1972 } | |
| 1973 while (c >= 0xA0); | |
| 1974 | |
| 1975 if (src - src_base <= 4) | |
| 1976 break; | |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1977 found = CATEGORY_MASK_EMACS_MULE; |
|
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1978 if (c == 0x80) |
| 88365 | 1979 goto repeat; |
|
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1980 } |
| 88365 | 1981 |
| 1982 if (c < 0x80) | |
| 1983 { | |
| 1984 if (c < 0x20 | |
| 1985 && (c == ISO_CODE_ESC || c == ISO_CODE_SI || c == ISO_CODE_SO)) | |
| 1986 break; | |
| 1987 } | |
| 1988 else | |
| 1989 { | |
|
89848
3edfa038a435
(detect_coding_emacs_mule): Fix counting of encoded
Kenichi Handa <handa@m17n.org>
parents:
89842
diff
changeset
|
1990 int more_bytes = emacs_mule_bytes[*src_base] - 1; |
|
3edfa038a435
(detect_coding_emacs_mule): Fix counting of encoded
Kenichi Handa <handa@m17n.org>
parents:
89842
diff
changeset
|
1991 |
|
3edfa038a435
(detect_coding_emacs_mule): Fix counting of encoded
Kenichi Handa <handa@m17n.org>
parents:
89842
diff
changeset
|
1992 while (more_bytes > 0) |
| 88365 | 1993 { |
| 1994 ONE_MORE_BYTE (c); | |
|
89848
3edfa038a435
(detect_coding_emacs_mule): Fix counting of encoded
Kenichi Handa <handa@m17n.org>
parents:
89842
diff
changeset
|
1995 if (c < 0xA0) |
|
3edfa038a435
(detect_coding_emacs_mule): Fix counting of encoded
Kenichi Handa <handa@m17n.org>
parents:
89842
diff
changeset
|
1996 { |
|
3edfa038a435
(detect_coding_emacs_mule): Fix counting of encoded
Kenichi Handa <handa@m17n.org>
parents:
89842
diff
changeset
|
1997 src--; /* Unread the last byte. */ |
|
3edfa038a435
(detect_coding_emacs_mule): Fix counting of encoded
Kenichi Handa <handa@m17n.org>
parents:
89842
diff
changeset
|
1998 break; |
|
3edfa038a435
(detect_coding_emacs_mule): Fix counting of encoded
Kenichi Handa <handa@m17n.org>
parents:
89842
diff
changeset
|
1999 } |
|
3edfa038a435
(detect_coding_emacs_mule): Fix counting of encoded
Kenichi Handa <handa@m17n.org>
parents:
89842
diff
changeset
|
2000 more_bytes--; |
| 88365 | 2001 } |
|
89848
3edfa038a435
(detect_coding_emacs_mule): Fix counting of encoded
Kenichi Handa <handa@m17n.org>
parents:
89842
diff
changeset
|
2002 if (more_bytes != 0) |
| 88365 | 2003 break; |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2004 found = CATEGORY_MASK_EMACS_MULE; |
| 88365 | 2005 } |
| 2006 } | |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2007 detect_info->rejected |= CATEGORY_MASK_EMACS_MULE; |
| 88365 | 2008 return 0; |
| 2009 | |
| 2010 no_more_source: | |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
2011 if (src_base < src && coding->mode & CODING_MODE_LAST_BLOCK) |
|
89193
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
2012 { |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2013 detect_info->rejected |= CATEGORY_MASK_EMACS_MULE; |
|
89193
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
2014 return 0; |
|
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
2015 } |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2016 detect_info->found |= found; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2017 return 1; |
|
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2018 } |
|
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2019 |
|
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2020 |
| 88365 | 2021 /* See the above "GENERAL NOTES on `decode_coding_XXX ()' functions". */ |
|
34888
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
2022 |
|
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
2023 /* Decode a character represented as a component of composition |
| 88365 | 2024 sequence of Emacs 20/21 style at SRC. Set C to that character and |
| 2025 update SRC to the head of next character (or an encoded composition | |
| 2026 rule). If SRC doesn't points a composition component, set C to -1. | |
| 2027 If SRC points an invalid byte sequence, global exit by a return | |
| 2028 value 0. */ | |
| 2029 | |
| 2030 #define DECODE_EMACS_MULE_COMPOSITION_CHAR(buf) \ | |
|
91622
0a283ea23533
(DECODE_EMACS_MULE_COMPOSITION_CHAR): Use "do...while (0)".
Jan Dj?rv <jan.h.d@swipnet.se>
parents:
91535
diff
changeset
|
2031 do \ |
| 88365 | 2032 { \ |
| 2033 int c; \ | |
| 2034 int nbytes, nchars; \ | |
|
51356
8da3b8a0ca4f
(DECODE_EMACS_MULE_COMPOSITION_CHAR): If coding->flags
Kenichi Handa <handa@m17n.org>
parents:
51327
diff
changeset
|
2035 \ |
| 88365 | 2036 if (src == src_end) \ |
| 2037 break; \ | |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2038 c = emacs_mule_char (coding, src, &nbytes, &nchars, NULL);\ |
| 88365 | 2039 if (c < 0) \ |
| 2040 { \ | |
| 2041 if (c == -2) \ | |
| 2042 break; \ | |
| 2043 goto invalid_code; \ | |
| 2044 } \ | |
| 2045 *buf++ = c; \ | |
| 2046 src += nbytes; \ | |
| 2047 consumed_chars += nchars; \ | |
| 2048 } \ | |
|
91622
0a283ea23533
(DECODE_EMACS_MULE_COMPOSITION_CHAR): Use "do...while (0)".
Jan Dj?rv <jan.h.d@swipnet.se>
parents:
91535
diff
changeset
|
2049 while (0) |
|
34888
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
2050 |
|
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
2051 |
|
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
2052 /* Decode a composition rule represented as a component of composition |
|
88585
c7772f702227
(ONE_MORE_BYTE_NO_CHECK): Increment consumed_chars.
Kenichi Handa <handa@m17n.org>
parents:
88573
diff
changeset
|
2053 sequence of Emacs 20 style at SRC. Store the decoded rule in *BUF, |
|
c7772f702227
(ONE_MORE_BYTE_NO_CHECK): Increment consumed_chars.
Kenichi Handa <handa@m17n.org>
parents:
88573
diff
changeset
|
2054 and increment BUF. If SRC points an invalid byte sequence, set C |
|
c7772f702227
(ONE_MORE_BYTE_NO_CHECK): Increment consumed_chars.
Kenichi Handa <handa@m17n.org>
parents:
88573
diff
changeset
|
2055 to -1. */ |
|
c7772f702227
(ONE_MORE_BYTE_NO_CHECK): Increment consumed_chars.
Kenichi Handa <handa@m17n.org>
parents:
88573
diff
changeset
|
2056 |
|
c7772f702227
(ONE_MORE_BYTE_NO_CHECK): Increment consumed_chars.
Kenichi Handa <handa@m17n.org>
parents:
88573
diff
changeset
|
2057 #define DECODE_EMACS_MULE_COMPOSITION_RULE_20(buf) \ |
|
34888
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
2058 do { \ |
| 88365 | 2059 int c, gref, nref; \ |
| 2060 \ | |
|
88585
c7772f702227
(ONE_MORE_BYTE_NO_CHECK): Increment consumed_chars.
Kenichi Handa <handa@m17n.org>
parents:
88573
diff
changeset
|
2061 if (src >= src_end) \ |
| 88365 | 2062 goto invalid_code; \ |
| 2063 ONE_MORE_BYTE_NO_CHECK (c); \ | |
|
90354
450fb16a4bf4
(DECODE_COMPOSITION_START): If the source is short, set
Kenichi Handa <handa@m17n.org>
parents:
90350
diff
changeset
|
2064 c -= 0xA0; \ |
|
34888
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
2065 if (c < 0 || c >= 81) \ |
| 88365 | 2066 goto invalid_code; \ |
| 2067 \ | |
| 2068 gref = c / 9, nref = c % 9; \ | |
| 2069 *buf++ = COMPOSITION_ENCODE_RULE (gref, nref); \ | |
|
34888
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
2070 } while (0) |
|
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
2071 |
|
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
2072 |
|
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
2073 /* Decode a composition rule represented as a component of composition |
|
88585
c7772f702227
(ONE_MORE_BYTE_NO_CHECK): Increment consumed_chars.
Kenichi Handa <handa@m17n.org>
parents:
88573
diff
changeset
|
2074 sequence of Emacs 21 style at SRC. Store the decoded rule in *BUF, |
|
c7772f702227
(ONE_MORE_BYTE_NO_CHECK): Increment consumed_chars.
Kenichi Handa <handa@m17n.org>
parents:
88573
diff
changeset
|
2075 and increment BUF. If SRC points an invalid byte sequence, set C |
|
c7772f702227
(ONE_MORE_BYTE_NO_CHECK): Increment consumed_chars.
Kenichi Handa <handa@m17n.org>
parents:
88573
diff
changeset
|
2076 to -1. */ |
|
c7772f702227
(ONE_MORE_BYTE_NO_CHECK): Increment consumed_chars.
Kenichi Handa <handa@m17n.org>
parents:
88573
diff
changeset
|
2077 |
|
c7772f702227
(ONE_MORE_BYTE_NO_CHECK): Increment consumed_chars.
Kenichi Handa <handa@m17n.org>
parents:
88573
diff
changeset
|
2078 #define DECODE_EMACS_MULE_COMPOSITION_RULE_21(buf) \ |
|
34888
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
2079 do { \ |
|
88585
c7772f702227
(ONE_MORE_BYTE_NO_CHECK): Increment consumed_chars.
Kenichi Handa <handa@m17n.org>
parents:
88573
diff
changeset
|
2080 int gref, nref; \ |
|
c7772f702227
(ONE_MORE_BYTE_NO_CHECK): Increment consumed_chars.
Kenichi Handa <handa@m17n.org>
parents:
88573
diff
changeset
|
2081 \ |
|
c7772f702227
(ONE_MORE_BYTE_NO_CHECK): Increment consumed_chars.
Kenichi Handa <handa@m17n.org>
parents:
88573
diff
changeset
|
2082 if (src + 1>= src_end) \ |
|
c7772f702227
(ONE_MORE_BYTE_NO_CHECK): Increment consumed_chars.
Kenichi Handa <handa@m17n.org>
parents:
88573
diff
changeset
|
2083 goto invalid_code; \ |
|
c7772f702227
(ONE_MORE_BYTE_NO_CHECK): Increment consumed_chars.
Kenichi Handa <handa@m17n.org>
parents:
88573
diff
changeset
|
2084 ONE_MORE_BYTE_NO_CHECK (gref); \ |
|
c7772f702227
(ONE_MORE_BYTE_NO_CHECK): Increment consumed_chars.
Kenichi Handa <handa@m17n.org>
parents:
88573
diff
changeset
|
2085 gref -= 0x20; \ |
|
c7772f702227
(ONE_MORE_BYTE_NO_CHECK): Increment consumed_chars.
Kenichi Handa <handa@m17n.org>
parents:
88573
diff
changeset
|
2086 ONE_MORE_BYTE_NO_CHECK (nref); \ |
|
c7772f702227
(ONE_MORE_BYTE_NO_CHECK): Increment consumed_chars.
Kenichi Handa <handa@m17n.org>
parents:
88573
diff
changeset
|
2087 nref -= 0x20; \ |
|
c7772f702227
(ONE_MORE_BYTE_NO_CHECK): Increment consumed_chars.
Kenichi Handa <handa@m17n.org>
parents:
88573
diff
changeset
|
2088 if (gref < 0 || gref >= 81 \ |
|
c7772f702227
(ONE_MORE_BYTE_NO_CHECK): Increment consumed_chars.
Kenichi Handa <handa@m17n.org>
parents:
88573
diff
changeset
|
2089 || nref < 0 || nref >= 81) \ |
|
c7772f702227
(ONE_MORE_BYTE_NO_CHECK): Increment consumed_chars.
Kenichi Handa <handa@m17n.org>
parents:
88573
diff
changeset
|
2090 goto invalid_code; \ |
|
c7772f702227
(ONE_MORE_BYTE_NO_CHECK): Increment consumed_chars.
Kenichi Handa <handa@m17n.org>
parents:
88573
diff
changeset
|
2091 *buf++ = COMPOSITION_ENCODE_RULE (gref, nref); \ |
|
34888
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
2092 } while (0) |
|
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
2093 |
|
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
2094 |
| 88365 | 2095 #define DECODE_EMACS_MULE_21_COMPOSITION(c) \ |
| 2096 do { \ | |
| 2097 /* Emacs 21 style format. The first three bytes at SRC are \ | |
|
88585
c7772f702227
(ONE_MORE_BYTE_NO_CHECK): Increment consumed_chars.
Kenichi Handa <handa@m17n.org>
parents:
88573
diff
changeset
|
2098 (METHOD - 0xF2), (BYTES - 0xA0), (CHARS - 0xA0), where BYTES is \ |
| 88365 | 2099 the byte length of this composition information, CHARS is the \ |
| 2100 number of characters composed by this composition. */ \ | |
|
88585
c7772f702227
(ONE_MORE_BYTE_NO_CHECK): Increment consumed_chars.
Kenichi Handa <handa@m17n.org>
parents:
88573
diff
changeset
|
2101 enum composition_method method = c - 0xF2; \ |
|
c7772f702227
(ONE_MORE_BYTE_NO_CHECK): Increment consumed_chars.
Kenichi Handa <handa@m17n.org>
parents:
88573
diff
changeset
|
2102 int *charbuf_base = charbuf; \ |
| 88365 | 2103 int consumed_chars_limit; \ |
| 2104 int nbytes, nchars; \ | |
| 2105 \ | |
| 2106 ONE_MORE_BYTE (c); \ | |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
2107 if (c < 0) \ |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
2108 goto invalid_code; \ |
| 88365 | 2109 nbytes = c - 0xA0; \ |
| 2110 if (nbytes < 3) \ | |
| 2111 goto invalid_code; \ | |
| 2112 ONE_MORE_BYTE (c); \ | |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
2113 if (c < 0) \ |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
2114 goto invalid_code; \ |
| 88365 | 2115 nchars = c - 0xA0; \ |
|
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
2116 ADD_COMPOSITION_DATA (charbuf, nchars, method); \ |
| 88365 | 2117 consumed_chars_limit = consumed_chars_base + nbytes; \ |
| 2118 if (method != COMPOSITION_RELATIVE) \ | |
| 2119 { \ | |
| 2120 int i = 0; \ | |
| 2121 while (consumed_chars < consumed_chars_limit) \ | |
| 2122 { \ | |
| 2123 if (i % 2 && method != COMPOSITION_WITH_ALTCHARS) \ | |
|
88585
c7772f702227
(ONE_MORE_BYTE_NO_CHECK): Increment consumed_chars.
Kenichi Handa <handa@m17n.org>
parents:
88573
diff
changeset
|
2124 DECODE_EMACS_MULE_COMPOSITION_RULE_21 (charbuf); \ |
| 88365 | 2125 else \ |
| 2126 DECODE_EMACS_MULE_COMPOSITION_CHAR (charbuf); \ | |
|
88585
c7772f702227
(ONE_MORE_BYTE_NO_CHECK): Increment consumed_chars.
Kenichi Handa <handa@m17n.org>
parents:
88573
diff
changeset
|
2127 i++; \ |
| 88365 | 2128 } \ |
| 2129 if (consumed_chars < consumed_chars_limit) \ | |
| 2130 goto invalid_code; \ | |
|
88585
c7772f702227
(ONE_MORE_BYTE_NO_CHECK): Increment consumed_chars.
Kenichi Handa <handa@m17n.org>
parents:
88573
diff
changeset
|
2131 charbuf_base[0] -= i; \ |
| 88365 | 2132 } \ |
| 2133 } while (0) | |
| 2134 | |
| 2135 | |
|
90363
ec0a46fadd7e
(DECODE_EMACS_MULE_20_RELATIVE_COMPOSITION): Fix
Kenichi Handa <handa@m17n.org>
parents:
90359
diff
changeset
|
2136 #define DECODE_EMACS_MULE_20_RELATIVE_COMPOSITION(c) \ |
|
ec0a46fadd7e
(DECODE_EMACS_MULE_20_RELATIVE_COMPOSITION): Fix
Kenichi Handa <handa@m17n.org>
parents:
90359
diff
changeset
|
2137 do { \ |
|
ec0a46fadd7e
(DECODE_EMACS_MULE_20_RELATIVE_COMPOSITION): Fix
Kenichi Handa <handa@m17n.org>
parents:
90359
diff
changeset
|
2138 /* Emacs 20 style format for relative composition. */ \ |
|
ec0a46fadd7e
(DECODE_EMACS_MULE_20_RELATIVE_COMPOSITION): Fix
Kenichi Handa <handa@m17n.org>
parents:
90359
diff
changeset
|
2139 /* Store multibyte form of characters to be composed. */ \ |
|
ec0a46fadd7e
(DECODE_EMACS_MULE_20_RELATIVE_COMPOSITION): Fix
Kenichi Handa <handa@m17n.org>
parents:
90359
diff
changeset
|
2140 enum composition_method method = COMPOSITION_RELATIVE; \ |
|
ec0a46fadd7e
(DECODE_EMACS_MULE_20_RELATIVE_COMPOSITION): Fix
Kenichi Handa <handa@m17n.org>
parents:
90359
diff
changeset
|
2141 int components[MAX_COMPOSITION_COMPONENTS * 2 - 1]; \ |
|
ec0a46fadd7e
(DECODE_EMACS_MULE_20_RELATIVE_COMPOSITION): Fix
Kenichi Handa <handa@m17n.org>
parents:
90359
diff
changeset
|
2142 int *buf = components; \ |
|
ec0a46fadd7e
(DECODE_EMACS_MULE_20_RELATIVE_COMPOSITION): Fix
Kenichi Handa <handa@m17n.org>
parents:
90359
diff
changeset
|
2143 int i, j; \ |
|
ec0a46fadd7e
(DECODE_EMACS_MULE_20_RELATIVE_COMPOSITION): Fix
Kenichi Handa <handa@m17n.org>
parents:
90359
diff
changeset
|
2144 \ |
|
ec0a46fadd7e
(DECODE_EMACS_MULE_20_RELATIVE_COMPOSITION): Fix
Kenichi Handa <handa@m17n.org>
parents:
90359
diff
changeset
|
2145 src = src_base; \ |
|
ec0a46fadd7e
(DECODE_EMACS_MULE_20_RELATIVE_COMPOSITION): Fix
Kenichi Handa <handa@m17n.org>
parents:
90359
diff
changeset
|
2146 ONE_MORE_BYTE (c); /* skip 0x80 */ \ |
|
ec0a46fadd7e
(DECODE_EMACS_MULE_20_RELATIVE_COMPOSITION): Fix
Kenichi Handa <handa@m17n.org>
parents:
90359
diff
changeset
|
2147 for (i = 0; *src >= 0xA0 && i < MAX_COMPOSITION_COMPONENTS; i++) \ |
|
ec0a46fadd7e
(DECODE_EMACS_MULE_20_RELATIVE_COMPOSITION): Fix
Kenichi Handa <handa@m17n.org>
parents:
90359
diff
changeset
|
2148 DECODE_EMACS_MULE_COMPOSITION_CHAR (buf); \ |
|
ec0a46fadd7e
(DECODE_EMACS_MULE_20_RELATIVE_COMPOSITION): Fix
Kenichi Handa <handa@m17n.org>
parents:
90359
diff
changeset
|
2149 if (i < 2) \ |
|
ec0a46fadd7e
(DECODE_EMACS_MULE_20_RELATIVE_COMPOSITION): Fix
Kenichi Handa <handa@m17n.org>
parents:
90359
diff
changeset
|
2150 goto invalid_code; \ |
|
ec0a46fadd7e
(DECODE_EMACS_MULE_20_RELATIVE_COMPOSITION): Fix
Kenichi Handa <handa@m17n.org>
parents:
90359
diff
changeset
|
2151 ADD_COMPOSITION_DATA (charbuf, i, method); \ |
|
ec0a46fadd7e
(DECODE_EMACS_MULE_20_RELATIVE_COMPOSITION): Fix
Kenichi Handa <handa@m17n.org>
parents:
90359
diff
changeset
|
2152 for (j = 0; j < i; j++) \ |
|
ec0a46fadd7e
(DECODE_EMACS_MULE_20_RELATIVE_COMPOSITION): Fix
Kenichi Handa <handa@m17n.org>
parents:
90359
diff
changeset
|
2153 *charbuf++ = components[j]; \ |
| 88365 | 2154 } while (0) |
| 2155 | |
| 2156 | |
| 2157 #define DECODE_EMACS_MULE_20_RULEBASE_COMPOSITION(c) \ | |
| 2158 do { \ | |
| 2159 /* Emacs 20 style format for rule-base composition. */ \ | |
| 2160 /* Store multibyte form of characters to be composed. */ \ | |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2161 enum composition_method method = COMPOSITION_WITH_RULE; \ |
|
90354
450fb16a4bf4
(DECODE_COMPOSITION_START): If the source is short, set
Kenichi Handa <handa@m17n.org>
parents:
90350
diff
changeset
|
2162 int *charbuf_base = charbuf; \ |
| 88365 | 2163 int components[MAX_COMPOSITION_COMPONENTS * 2 - 1]; \ |
| 2164 int *buf = components; \ | |
| 2165 int i, j; \ | |
|
90354
450fb16a4bf4
(DECODE_COMPOSITION_START): If the source is short, set
Kenichi Handa <handa@m17n.org>
parents:
90350
diff
changeset
|
2166 \ |
| 88365 | 2167 DECODE_EMACS_MULE_COMPOSITION_CHAR (buf); \ |
|
90354
450fb16a4bf4
(DECODE_COMPOSITION_START): If the source is short, set
Kenichi Handa <handa@m17n.org>
parents:
90350
diff
changeset
|
2168 for (i = 1; i < MAX_COMPOSITION_COMPONENTS; i++) \ |
| 88365 | 2169 { \ |
|
90354
450fb16a4bf4
(DECODE_COMPOSITION_START): If the source is short, set
Kenichi Handa <handa@m17n.org>
parents:
90350
diff
changeset
|
2170 if (*src < 0xA0) \ |
|
450fb16a4bf4
(DECODE_COMPOSITION_START): If the source is short, set
Kenichi Handa <handa@m17n.org>
parents:
90350
diff
changeset
|
2171 break; \ |
|
88585
c7772f702227
(ONE_MORE_BYTE_NO_CHECK): Increment consumed_chars.
Kenichi Handa <handa@m17n.org>
parents:
88573
diff
changeset
|
2172 DECODE_EMACS_MULE_COMPOSITION_RULE_20 (buf); \ |
| 88365 | 2173 DECODE_EMACS_MULE_COMPOSITION_CHAR (buf); \ |
| 2174 } \ | |
|
90354
450fb16a4bf4
(DECODE_COMPOSITION_START): If the source is short, set
Kenichi Handa <handa@m17n.org>
parents:
90350
diff
changeset
|
2175 if (i <= 1 || (buf - components) % 2 == 0) \ |
| 88365 | 2176 goto invalid_code; \ |
|
90354
450fb16a4bf4
(DECODE_COMPOSITION_START): If the source is short, set
Kenichi Handa <handa@m17n.org>
parents:
90350
diff
changeset
|
2177 if (charbuf + i + (i / 2) + 1 >= charbuf_end) \ |
| 88365 | 2178 goto no_more_source; \ |
|
90354
450fb16a4bf4
(DECODE_COMPOSITION_START): If the source is short, set
Kenichi Handa <handa@m17n.org>
parents:
90350
diff
changeset
|
2179 ADD_COMPOSITION_DATA (charbuf, i, method); \ |
|
450fb16a4bf4
(DECODE_COMPOSITION_START): If the source is short, set
Kenichi Handa <handa@m17n.org>
parents:
90350
diff
changeset
|
2180 i = i * 2 - 1; \ |
| 88365 | 2181 for (j = 0; j < i; j++) \ |
| 2182 *charbuf++ = components[j]; \ | |
|
90354
450fb16a4bf4
(DECODE_COMPOSITION_START): If the source is short, set
Kenichi Handa <handa@m17n.org>
parents:
90350
diff
changeset
|
2183 charbuf_base[0] -= i; \ |
| 88365 | 2184 for (j = 0; j < i; j += 2) \ |
| 2185 *charbuf++ = components[j]; \ | |
| 2186 } while (0) | |
| 2187 | |
|
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2188 |
|
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2189 static void |
| 88365 | 2190 decode_coding_emacs_mule (coding) |
|
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2191 struct coding_system *coding; |
|
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2192 { |
| 89483 | 2193 const unsigned char *src = coding->source + coding->consumed; |
| 2194 const unsigned char *src_end = coding->source + coding->src_bytes; | |
|
59168
0345f2b10f1d
(decode_coding_XXX, decode_composition_emacs_mule)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
59095
diff
changeset
|
2195 const unsigned char *src_base; |
|
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
2196 int *charbuf = coding->charbuf + coding->charbuf_used; |
|
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
2197 int *charbuf_end |
|
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
2198 = coding->charbuf + coding->charbuf_size - MAX_ANNOTATION_LENGTH; |
| 88365 | 2199 int consumed_chars = 0, consumed_chars_base; |
| 2200 int multibytep = coding->src_multibyte; | |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
2201 Lisp_Object attrs, charset_list; |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2202 int char_offset = coding->produced_char; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2203 int last_offset = char_offset; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2204 int last_id = charset_ascii; |
|
92399
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
2205 int eol_crlf = EQ (CODING_ID_EOL_TYPE (coding->id), Qdos); |
|
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
2206 int byte_after_cr = -1; |
| 88365 | 2207 |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
2208 CODING_GET_INFO (coding, attrs, charset_list); |
| 88365 | 2209 |
| 2210 while (1) | |
| 2211 { | |
| 2212 int c; | |
| 2213 | |
| 2214 src_base = src; | |
| 2215 consumed_chars_base = consumed_chars; | |
| 2216 | |
| 2217 if (charbuf >= charbuf_end) | |
| 2218 break; | |
| 2219 | |
|
92399
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
2220 if (byte_after_cr >= 0) |
|
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
2221 c = byte_after_cr, byte_after_cr = -1; |
|
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
2222 else |
|
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
2223 ONE_MORE_BYTE (c); |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
2224 if (c < 0) |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
2225 { |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
2226 *charbuf++ = -c; |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
2227 char_offset++; |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
2228 } |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
2229 else if (c < 0x80) |
|
32806
9502d0a5b2ad
(decode_coding_emacs_mule): If coding->eol_type is CR
Eli Zaretskii <eliz@gnu.org>
parents:
32745
diff
changeset
|
2230 { |
|
92399
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
2231 if (eol_crlf && c == '\r') |
|
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
2232 ONE_MORE_BYTE (byte_after_cr); |
| 88365 | 2233 *charbuf++ = c; |
| 2234 char_offset++; | |
|
32806
9502d0a5b2ad
(decode_coding_emacs_mule): If coding->eol_type is CR
Eli Zaretskii <eliz@gnu.org>
parents:
32745
diff
changeset
|
2235 } |
| 88365 | 2236 else if (c == 0x80) |
|
32806
9502d0a5b2ad
(decode_coding_emacs_mule): If coding->eol_type is CR
Eli Zaretskii <eliz@gnu.org>
parents:
32745
diff
changeset
|
2237 { |
| 88365 | 2238 ONE_MORE_BYTE (c); |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
2239 if (c < 0) |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
2240 goto invalid_code; |
|
88585
c7772f702227
(ONE_MORE_BYTE_NO_CHECK): Increment consumed_chars.
Kenichi Handa <handa@m17n.org>
parents:
88573
diff
changeset
|
2241 if (c - 0xF2 >= COMPOSITION_RELATIVE |
|
c7772f702227
(ONE_MORE_BYTE_NO_CHECK): Increment consumed_chars.
Kenichi Handa <handa@m17n.org>
parents:
88573
diff
changeset
|
2242 && c - 0xF2 <= COMPOSITION_WITH_RULE_ALTCHARS) |
| 88365 | 2243 DECODE_EMACS_MULE_21_COMPOSITION (c); |
| 2244 else if (c < 0xC0) | |
| 2245 DECODE_EMACS_MULE_20_RELATIVE_COMPOSITION (c); | |
| 2246 else if (c == 0xFF) | |
| 2247 DECODE_EMACS_MULE_20_RULEBASE_COMPOSITION (c); | |
| 2248 else | |
| 2249 goto invalid_code; | |
|
32806
9502d0a5b2ad
(decode_coding_emacs_mule): If coding->eol_type is CR
Eli Zaretskii <eliz@gnu.org>
parents:
32745
diff
changeset
|
2250 } |
| 88365 | 2251 else if (c < 0xA0 && emacs_mule_bytes[c] > 1) |
|
34888
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
2252 { |
| 88365 | 2253 int nbytes, nchars; |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2254 int id; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2255 |
|
88585
c7772f702227
(ONE_MORE_BYTE_NO_CHECK): Increment consumed_chars.
Kenichi Handa <handa@m17n.org>
parents:
88573
diff
changeset
|
2256 src = src_base; |
|
c7772f702227
(ONE_MORE_BYTE_NO_CHECK): Increment consumed_chars.
Kenichi Handa <handa@m17n.org>
parents:
88573
diff
changeset
|
2257 consumed_chars = consumed_chars_base; |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2258 c = emacs_mule_char (coding, src, &nbytes, &nchars, &id); |
| 88365 | 2259 if (c < 0) |
|
32806
9502d0a5b2ad
(decode_coding_emacs_mule): If coding->eol_type is CR
Eli Zaretskii <eliz@gnu.org>
parents:
32745
diff
changeset
|
2260 { |
| 88365 | 2261 if (c == -2) |
| 2262 break; | |
| 2263 goto invalid_code; | |
|
32806
9502d0a5b2ad
(decode_coding_emacs_mule): If coding->eol_type is CR
Eli Zaretskii <eliz@gnu.org>
parents:
32745
diff
changeset
|
2264 } |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2265 if (last_id != id) |
|
32806
9502d0a5b2ad
(decode_coding_emacs_mule): If coding->eol_type is CR
Eli Zaretskii <eliz@gnu.org>
parents:
32745
diff
changeset
|
2266 { |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2267 if (last_id != charset_ascii) |
|
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
2268 ADD_CHARSET_DATA (charbuf, char_offset - last_offset, last_id); |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2269 last_id = id; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2270 last_offset = char_offset; |
|
32806
9502d0a5b2ad
(decode_coding_emacs_mule): If coding->eol_type is CR
Eli Zaretskii <eliz@gnu.org>
parents:
32745
diff
changeset
|
2271 } |
| 88365 | 2272 *charbuf++ = c; |
|
88585
c7772f702227
(ONE_MORE_BYTE_NO_CHECK): Increment consumed_chars.
Kenichi Handa <handa@m17n.org>
parents:
88573
diff
changeset
|
2273 src += nbytes; |
|
c7772f702227
(ONE_MORE_BYTE_NO_CHECK): Increment consumed_chars.
Kenichi Handa <handa@m17n.org>
parents:
88573
diff
changeset
|
2274 consumed_chars += nchars; |
| 88365 | 2275 char_offset++; |
|
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2276 } |
|
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2277 else |
|
90354
450fb16a4bf4
(DECODE_COMPOSITION_START): If the source is short, set
Kenichi Handa <handa@m17n.org>
parents:
90350
diff
changeset
|
2278 goto invalid_code; |
| 88365 | 2279 continue; |
| 2280 | |
| 2281 invalid_code: | |
| 2282 src = src_base; | |
| 2283 consumed_chars = consumed_chars_base; | |
| 2284 ONE_MORE_BYTE (c); | |
| 2285 *charbuf++ = ASCII_BYTE_P (c) ? c : BYTE8_TO_CHAR (c); | |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2286 char_offset++; |
| 88365 | 2287 coding->errors++; |
| 2288 } | |
| 2289 | |
| 2290 no_more_source: | |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2291 if (last_id != charset_ascii) |
|
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
2292 ADD_CHARSET_DATA (charbuf, char_offset - last_offset, last_id); |
| 88365 | 2293 coding->consumed_char += consumed_chars_base; |
| 2294 coding->consumed = src_base - coding->source; | |
| 2295 coding->charbuf_used = charbuf - coding->charbuf; | |
| 2296 } | |
| 2297 | |
| 2298 | |
| 2299 #define EMACS_MULE_LEADING_CODES(id, codes) \ | |
| 2300 do { \ | |
| 2301 if (id < 0xA0) \ | |
| 2302 codes[0] = id, codes[1] = 0; \ | |
| 2303 else if (id < 0xE0) \ | |
| 2304 codes[0] = 0x9A, codes[1] = id; \ | |
| 2305 else if (id < 0xF0) \ | |
| 2306 codes[0] = 0x9B, codes[1] = id; \ | |
| 2307 else if (id < 0xF5) \ | |
| 2308 codes[0] = 0x9C, codes[1] = id; \ | |
| 2309 else \ | |
| 2310 codes[0] = 0x9D, codes[1] = id; \ | |
| 2311 } while (0); | |
| 2312 | |
| 2313 | |
| 2314 static int | |
| 2315 encode_coding_emacs_mule (coding) | |
| 2316 struct coding_system *coding; | |
| 2317 { | |
| 2318 int multibytep = coding->dst_multibyte; | |
| 2319 int *charbuf = coding->charbuf; | |
| 2320 int *charbuf_end = charbuf + coding->charbuf_used; | |
| 2321 unsigned char *dst = coding->destination + coding->produced; | |
| 2322 unsigned char *dst_end = coding->destination + coding->dst_bytes; | |
| 2323 int safe_room = 8; | |
| 2324 int produced_chars = 0; | |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
2325 Lisp_Object attrs, charset_list; |
| 88365 | 2326 int c; |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2327 int preferred_charset_id = -1; |
| 88365 | 2328 |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
2329 CODING_GET_INFO (coding, attrs, charset_list); |
|
89644
fc9cda144ffc
(encode_coding_emacs_mule): Resync charset_list to
Kenichi Handa <handa@m17n.org>
parents:
89642
diff
changeset
|
2330 if (! EQ (charset_list, Vemacs_mule_charset_list)) |
|
fc9cda144ffc
(encode_coding_emacs_mule): Resync charset_list to
Kenichi Handa <handa@m17n.org>
parents:
89642
diff
changeset
|
2331 { |
|
fc9cda144ffc
(encode_coding_emacs_mule): Resync charset_list to
Kenichi Handa <handa@m17n.org>
parents:
89642
diff
changeset
|
2332 CODING_ATTR_CHARSET_LIST (attrs) |
|
fc9cda144ffc
(encode_coding_emacs_mule): Resync charset_list to
Kenichi Handa <handa@m17n.org>
parents:
89642
diff
changeset
|
2333 = charset_list = Vemacs_mule_charset_list; |
|
fc9cda144ffc
(encode_coding_emacs_mule): Resync charset_list to
Kenichi Handa <handa@m17n.org>
parents:
89642
diff
changeset
|
2334 } |
| 88365 | 2335 |
| 2336 while (charbuf < charbuf_end) | |
| 2337 { | |
| 2338 ASSURE_DESTINATION (safe_room); | |
| 2339 c = *charbuf++; | |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2340 |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2341 if (c < 0) |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2342 { |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2343 /* Handle an annotation. */ |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2344 switch (*charbuf) |
|
54320
a7e59b39de35
(decode_coding_emacs_mule): Handle insufficent source correctly.
Kenichi Handa <handa@m17n.org>
parents:
54303
diff
changeset
|
2345 { |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2346 case CODING_ANNOTATE_COMPOSITION_MASK: |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2347 /* Not yet implemented. */ |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2348 break; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2349 case CODING_ANNOTATE_CHARSET_MASK: |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2350 preferred_charset_id = charbuf[3]; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2351 if (preferred_charset_id >= 0 |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2352 && NILP (Fmemq (make_number (preferred_charset_id), |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2353 charset_list))) |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2354 preferred_charset_id = -1; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2355 break; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2356 default: |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2357 abort (); |
|
54320
a7e59b39de35
(decode_coding_emacs_mule): Handle insufficent source correctly.
Kenichi Handa <handa@m17n.org>
parents:
54303
diff
changeset
|
2358 } |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2359 charbuf += -c - 1; |
|
32806
9502d0a5b2ad
(decode_coding_emacs_mule): If coding->eol_type is CR
Eli Zaretskii <eliz@gnu.org>
parents:
32745
diff
changeset
|
2360 continue; |
|
9502d0a5b2ad
(decode_coding_emacs_mule): If coding->eol_type is CR
Eli Zaretskii <eliz@gnu.org>
parents:
32745
diff
changeset
|
2361 } |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2362 |
| 88365 | 2363 if (ASCII_CHAR_P (c)) |
| 2364 EMIT_ONE_ASCII_BYTE (c); | |
|
88690
7f284ac55b07
(encode_coding_emacs_mule): Pay attention to raw-8-bit chars.
Kenichi Handa <handa@m17n.org>
parents:
88681
diff
changeset
|
2365 else if (CHAR_BYTE8_P (c)) |
|
7f284ac55b07
(encode_coding_emacs_mule): Pay attention to raw-8-bit chars.
Kenichi Handa <handa@m17n.org>
parents:
88681
diff
changeset
|
2366 { |
|
7f284ac55b07
(encode_coding_emacs_mule): Pay attention to raw-8-bit chars.
Kenichi Handa <handa@m17n.org>
parents:
88681
diff
changeset
|
2367 c = CHAR_TO_BYTE8 (c); |
|
7f284ac55b07
(encode_coding_emacs_mule): Pay attention to raw-8-bit chars.
Kenichi Handa <handa@m17n.org>
parents:
88681
diff
changeset
|
2368 EMIT_ONE_BYTE (c); |
|
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2369 } |
|
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2370 else |
|
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2371 { |
| 88365 | 2372 struct charset *charset; |
| 2373 unsigned code; | |
| 2374 int dimension; | |
| 2375 int emacs_mule_id; | |
| 2376 unsigned char leading_codes[2]; | |
| 2377 | |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2378 if (preferred_charset_id >= 0) |
|
54320
a7e59b39de35
(decode_coding_emacs_mule): Handle insufficent source correctly.
Kenichi Handa <handa@m17n.org>
parents:
54303
diff
changeset
|
2379 { |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2380 charset = CHARSET_FROM_ID (preferred_charset_id); |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2381 if (! CHAR_CHARSET_P (c, charset)) |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2382 charset = char_charset (c, charset_list, NULL); |
|
54320
a7e59b39de35
(decode_coding_emacs_mule): Handle insufficent source correctly.
Kenichi Handa <handa@m17n.org>
parents:
54303
diff
changeset
|
2383 } |
|
a7e59b39de35
(decode_coding_emacs_mule): Handle insufficent source correctly.
Kenichi Handa <handa@m17n.org>
parents:
54303
diff
changeset
|
2384 else |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2385 charset = char_charset (c, charset_list, &code); |
| 88365 | 2386 if (! charset) |
|
54320
a7e59b39de35
(decode_coding_emacs_mule): Handle insufficent source correctly.
Kenichi Handa <handa@m17n.org>
parents:
54303
diff
changeset
|
2387 { |
| 88365 | 2388 c = coding->default_char; |
| 2389 if (ASCII_CHAR_P (c)) | |
| 2390 { | |
| 2391 EMIT_ONE_ASCII_BYTE (c); | |
| 2392 continue; | |
| 2393 } | |
| 2394 charset = char_charset (c, charset_list, &code); | |
|
54320
a7e59b39de35
(decode_coding_emacs_mule): Handle insufficent source correctly.
Kenichi Handa <handa@m17n.org>
parents:
54303
diff
changeset
|
2395 } |
| 88365 | 2396 dimension = CHARSET_DIMENSION (charset); |
| 2397 emacs_mule_id = CHARSET_EMACS_MULE_ID (charset); | |
| 2398 EMACS_MULE_LEADING_CODES (emacs_mule_id, leading_codes); | |
| 2399 EMIT_ONE_BYTE (leading_codes[0]); | |
| 2400 if (leading_codes[1]) | |
| 2401 EMIT_ONE_BYTE (leading_codes[1]); | |
| 2402 if (dimension == 1) | |
|
89642
e97441b6244b
(encode_coding_emacs_mule): Emit bytes with MSB.
Kenichi Handa <handa@m17n.org>
parents:
89575
diff
changeset
|
2403 EMIT_ONE_BYTE (code | 0x80); |
|
54320
a7e59b39de35
(decode_coding_emacs_mule): Handle insufficent source correctly.
Kenichi Handa <handa@m17n.org>
parents:
54303
diff
changeset
|
2404 else |
|
a7e59b39de35
(decode_coding_emacs_mule): Handle insufficent source correctly.
Kenichi Handa <handa@m17n.org>
parents:
54303
diff
changeset
|
2405 { |
|
89642
e97441b6244b
(encode_coding_emacs_mule): Emit bytes with MSB.
Kenichi Handa <handa@m17n.org>
parents:
89575
diff
changeset
|
2406 code |= 0x8080; |
| 88365 | 2407 EMIT_ONE_BYTE (code >> 8); |
| 2408 EMIT_ONE_BYTE (code & 0xFF); | |
|
54320
a7e59b39de35
(decode_coding_emacs_mule): Handle insufficent source correctly.
Kenichi Handa <handa@m17n.org>
parents:
54303
diff
changeset
|
2409 } |
|
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2410 } |
| 88365 | 2411 } |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
2412 record_conversion_result (coding, CODING_RESULT_SUCCESS); |
| 88365 | 2413 coding->produced_char += produced_chars; |
| 2414 coding->produced = dst - coding->destination; | |
| 2415 return 0; | |
|
34888
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
2416 } |
|
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2417 |
| 17052 | 2418 |
| 88365 | 2419 /*** 7. ISO2022 handlers ***/ |
| 17052 | 2420 |
| 2421 /* 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
|
2422 Since the intention of this note is to help understand the |
| 35053 | 2423 functions in this file, some parts are NOT ACCURATE or are OVERLY |
|
24425
61c6b3be1d51
Comment for ISO 2022 encoding mechanism modified.
Kenichi Handa <handa@m17n.org>
parents:
24344
diff
changeset
|
2424 SIMPLIFIED. For thorough understanding, please refer to the |
| 35053 | 2425 original document of ISO2022. This is equivalent to the standard |
| 2426 ECMA-35, obtainable from <URL:http://www.ecma.ch/> (*). | |
| 17052 | 2427 |
| 2428 ISO2022 provides many mechanisms to encode several character sets | |
| 35053 | 2429 in 7-bit and 8-bit environments. For 7-bit environments, all text |
|
24425
61c6b3be1d51
Comment for ISO 2022 encoding mechanism modified.
Kenichi Handa <handa@m17n.org>
parents:
24344
diff
changeset
|
2430 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
|
2431 text a little bit longer, but the text passes more easily through |
| 35053 | 2432 several types of gateway, some of which strip off the MSB (Most |
| 36087 | 2433 Significant Bit). |
| 35053 | 2434 |
| 2435 There are two kinds of character sets: control character sets and | |
| 2436 graphic character sets. The former contain control characters such | |
| 17052 | 2437 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
|
2438 functions are also provided by escape sequences). The latter |
| 35053 | 2439 contain graphic characters such as 'A' and '-'. Emacs recognizes |
| 17052 | 2440 two control character sets and many graphic character sets. |
| 2441 | |
| 2442 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
|
2443 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
|
2444 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
|
2445 - DIMENSION1_CHARS94 |
|
61c6b3be1d51
Comment for ISO 2022 encoding mechanism modified.
Kenichi Handa <handa@m17n.org>
parents:
24344
diff
changeset
|
2446 - DIMENSION1_CHARS96 |
|
61c6b3be1d51
Comment for ISO 2022 encoding mechanism modified.
Kenichi Handa <handa@m17n.org>
parents:
24344
diff
changeset
|
2447 - DIMENSION2_CHARS94 |
|
61c6b3be1d51
Comment for ISO 2022 encoding mechanism modified.
Kenichi Handa <handa@m17n.org>
parents:
24344
diff
changeset
|
2448 - DIMENSION2_CHARS96 |
|
61c6b3be1d51
Comment for ISO 2022 encoding mechanism modified.
Kenichi Handa <handa@m17n.org>
parents:
24344
diff
changeset
|
2449 |
|
61c6b3be1d51
Comment for ISO 2022 encoding mechanism modified.
Kenichi Handa <handa@m17n.org>
parents:
24344
diff
changeset
|
2450 In addition, each character set is assigned an identification tag, |
| 35053 | 2451 unique for each set, called the "final character" (denoted as <F> |
|
24425
61c6b3be1d51
Comment for ISO 2022 encoding mechanism modified.
Kenichi Handa <handa@m17n.org>
parents:
24344
diff
changeset
|
2452 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
|
2453 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
|
2454 (0x30..0x3F are for private use only). |
| 17052 | 2455 |
| 2456 Note (*): ECMA = European Computer Manufacturers Association | |
| 2457 | |
| 35053 | 2458 Here are examples of graphic character sets [NAME(<F>)]: |
| 17052 | 2459 o DIMENSION1_CHARS94 -- ASCII('B'), right-half-of-JISX0201('I'), ... |
| 2460 o DIMENSION1_CHARS96 -- right-half-of-ISO8859-1('A'), ... | |
| 2461 o DIMENSION2_CHARS94 -- GB2312('A'), JISX0208('B'), ... | |
| 2462 o DIMENSION2_CHARS96 -- none for the moment | |
| 2463 | |
|
24425
61c6b3be1d51
Comment for ISO 2022 encoding mechanism modified.
Kenichi Handa <handa@m17n.org>
parents:
24344
diff
changeset
|
2464 A code area (1 byte=8 bits) is divided into 4 areas, C0, GL, C1, and GR. |
| 17052 | 2465 C0 [0x00..0x1F] -- control character plane 0 |
| 2466 GL [0x20..0x7F] -- graphic character plane 0 | |
| 2467 C1 [0x80..0x9F] -- control character plane 1 | |
| 2468 GR [0xA0..0xFF] -- graphic character plane 1 | |
| 2469 | |
| 2470 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
|
2471 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
|
2472 - 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
|
2473 - 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
|
2474 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
|
2475 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
|
2476 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
|
2477 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
|
2478 defined to have corresponding escape sequences. |
| 17052 | 2479 |
| 2480 A graphic character set is at first designated to one of four | |
| 2481 graphic registers (G0 through G3), then these graphic registers are | |
| 2482 invoked to GL or GR. These designations and invocations can be | |
| 2483 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
|
2484 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
|
2485 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
|
2486 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
|
2487 |
|
61c6b3be1d51
Comment for ISO 2022 encoding mechanism modified.
Kenichi Handa <handa@m17n.org>
parents:
24344
diff
changeset
|
2488 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
|
2489 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
|
2490 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
|
2491 be used. |
| 17052 | 2492 |
| 2493 There are two ways of invocation: locking-shift and single-shift. | |
| 2494 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
|
2495 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
|
2496 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
|
2497 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
|
2498 escape sequences: |
| 17052 | 2499 |
| 2500 ---------------------------------------------------------------------- | |
|
24425
61c6b3be1d51
Comment for ISO 2022 encoding mechanism modified.
Kenichi Handa <handa@m17n.org>
parents:
24344
diff
changeset
|
2501 abbrev function cntrl escape seq description |
| 17052 | 2502 ---------------------------------------------------------------------- |
|
24425
61c6b3be1d51
Comment for ISO 2022 encoding mechanism modified.
Kenichi Handa <handa@m17n.org>
parents:
24344
diff
changeset
|
2503 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
|
2504 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
|
2505 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
|
2506 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
|
2507 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
|
2508 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
|
2509 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
|
2510 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
|
2511 SS3 (single-shift-3) 0x8F ESC 'O' invoke G3 for one char |
| 17052 | 2512 ---------------------------------------------------------------------- |
|
24425
61c6b3be1d51
Comment for ISO 2022 encoding mechanism modified.
Kenichi Handa <handa@m17n.org>
parents:
24344
diff
changeset
|
2513 (*) 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
|
2514 |
|
61c6b3be1d51
Comment for ISO 2022 encoding mechanism modified.
Kenichi Handa <handa@m17n.org>
parents:
24344
diff
changeset
|
2515 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
|
2516 ISO_CODE_XXX in `coding.h'. |
|
61c6b3be1d51
Comment for ISO 2022 encoding mechanism modified.
Kenichi Handa <handa@m17n.org>
parents:
24344
diff
changeset
|
2517 |
|
61c6b3be1d51
Comment for ISO 2022 encoding mechanism modified.
Kenichi Handa <handa@m17n.org>
parents:
24344
diff
changeset
|
2518 Designations are done by the following escape sequences: |
| 17052 | 2519 ---------------------------------------------------------------------- |
| 2520 escape sequence description | |
| 2521 ---------------------------------------------------------------------- | |
| 2522 ESC '(' <F> designate DIMENSION1_CHARS94<F> to G0 | |
| 2523 ESC ')' <F> designate DIMENSION1_CHARS94<F> to G1 | |
| 2524 ESC '*' <F> designate DIMENSION1_CHARS94<F> to G2 | |
| 2525 ESC '+' <F> designate DIMENSION1_CHARS94<F> to G3 | |
| 2526 ESC ',' <F> designate DIMENSION1_CHARS96<F> to G0 (*) | |
| 2527 ESC '-' <F> designate DIMENSION1_CHARS96<F> to G1 | |
| 2528 ESC '.' <F> designate DIMENSION1_CHARS96<F> to G2 | |
| 2529 ESC '/' <F> designate DIMENSION1_CHARS96<F> to G3 | |
| 2530 ESC '$' '(' <F> designate DIMENSION2_CHARS94<F> to G0 (**) | |
| 2531 ESC '$' ')' <F> designate DIMENSION2_CHARS94<F> to G1 | |
| 2532 ESC '$' '*' <F> designate DIMENSION2_CHARS94<F> to G2 | |
| 2533 ESC '$' '+' <F> designate DIMENSION2_CHARS94<F> to G3 | |
| 2534 ESC '$' ',' <F> designate DIMENSION2_CHARS96<F> to G0 (*) | |
| 2535 ESC '$' '-' <F> designate DIMENSION2_CHARS96<F> to G1 | |
| 2536 ESC '$' '.' <F> designate DIMENSION2_CHARS96<F> to G2 | |
| 2537 ESC '$' '/' <F> designate DIMENSION2_CHARS96<F> to G3 | |
| 2538 ---------------------------------------------------------------------- | |
| 2539 | |
| 2540 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
|
2541 of dimension 1, chars 94, and final character <F>, etc... |
| 17052 | 2542 |
| 2543 Note (*): Although these designations are not allowed in ISO2022, | |
| 2544 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
|
2545 CHARS96 character sets in a coding system which is characterized as |
| 17052 | 2546 7-bit environment, non-locking-shift, and non-single-shift. |
| 2547 | |
| 2548 Note (**): If <F> is '@', 'A', or 'B', the intermediate character | |
| 88365 | 2549 '(' must be omitted. We refer to this as "short-form" hereafter. |
| 17052 | 2550 |
| 35053 | 2551 Now you may notice that there are a lot of ways of encoding the |
|
24425
61c6b3be1d51
Comment for ISO 2022 encoding mechanism modified.
Kenichi Handa <handa@m17n.org>
parents:
24344
diff
changeset
|
2552 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
|
2553 coding systems such as Compound Text (used in X11's inter client |
| 36087 | 2554 communication, ISO-2022-JP (used in Japanese Internet), ISO-2022-KR |
| 2555 (used in Korean Internet), EUC (Extended UNIX Code, used in Asian | |
| 17052 | 2556 localized platforms), and all of these are variants of ISO2022. |
| 2557 | |
| 2558 In addition to the above, Emacs handles two more kinds of escape | |
| 2559 sequences: ISO6429's direction specification and Emacs' private | |
| 2560 sequence for specifying character composition. | |
| 2561 | |
|
24425
61c6b3be1d51
Comment for ISO 2022 encoding mechanism modified.
Kenichi Handa <handa@m17n.org>
parents:
24344
diff
changeset
|
2562 ISO6429's direction specification takes the following form: |
| 17052 | 2563 o CSI ']' -- end of the current direction |
| 2564 o CSI '0' ']' -- end of the current direction | |
| 2565 o CSI '1' ']' -- start of left-to-right text | |
| 2566 o CSI '2' ']' -- start of right-to-left text | |
| 2567 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
|
2568 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
|
2569 |
|
61c6b3be1d51
Comment for ISO 2022 encoding mechanism modified.
Kenichi Handa <handa@m17n.org>
parents:
24344
diff
changeset
|
2570 Character composition specification takes the following form: |
| 26847 | 2571 o ESC '0' -- start relative composition |
| 2572 o ESC '1' -- end composition | |
| 2573 o ESC '2' -- start rule-base composition (*) | |
| 2574 o ESC '3' -- start relative composition with alternate chars (**) | |
| 2575 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
|
2576 Since these are not standard escape sequences of any ISO standard, |
| 35053 | 2577 the use of them with these meanings is restricted to Emacs only. |
| 2578 | |
| 88771 | 2579 (*) This form is used only in Emacs 20.7 and older versions, |
| 2580 but newer versions can safely decode it. | |
| 35053 | 2581 (**) This form is used only in Emacs 21.1 and newer versions, |
| 88771 | 2582 and older versions can't decode it. |
|
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2583 |
| 35053 | 2584 Here's a list of example usages of these composition escape |
|
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2585 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
|
2586 |
|
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2587 COMPOSITION_RELATIVE: |
| 26847 | 2588 ESC 0 CHAR [ CHAR ] ESC 1 |
| 36087 | 2589 COMPOSITION_WITH_RULE: |
| 26847 | 2590 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
|
2591 COMPOSITION_WITH_ALTCHARS: |
| 26847 | 2592 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
|
2593 COMPOSITION_WITH_RULE_ALTCHARS: |
| 26847 | 2594 ESC 4 ALTCHAR [ RULE ALTCHAR ] ESC 0 CHAR [ CHAR ] ESC 1 */ |
| 17052 | 2595 |
| 2596 enum iso_code_class_type iso_code_class[256]; | |
| 2597 | |
| 88365 | 2598 #define SAFE_CHARSET_P(coding, id) \ |
| 2599 ((id) <= (coding)->max_charset_id \ | |
| 2600 && (coding)->safe_charsets[id] >= 0) | |
| 2601 | |
| 2602 | |
| 2603 #define SHIFT_OUT_OK(category) \ | |
| 2604 (CODING_ISO_INITIAL (&coding_categories[category], 1) >= 0) | |
| 2605 | |
| 2606 static void | |
|
88631
780b91d4a7e5
(setup_iso_safe_charsets): Fix arg decl for K&R.
Dave Love <fx@gnu.org>
parents:
88607
diff
changeset
|
2607 setup_iso_safe_charsets (attrs) |
|
780b91d4a7e5
(setup_iso_safe_charsets): Fix arg decl for K&R.
Dave Love <fx@gnu.org>
parents:
88607
diff
changeset
|
2608 Lisp_Object attrs; |
| 88365 | 2609 { |
| 2610 Lisp_Object charset_list, safe_charsets; | |
| 2611 Lisp_Object request; | |
| 2612 Lisp_Object reg_usage; | |
| 2613 Lisp_Object tail; | |
| 2614 int reg94, reg96; | |
| 2615 int flags = XINT (AREF (attrs, coding_attr_iso_flags)); | |
| 2616 int max_charset_id; | |
| 2617 | |
| 2618 charset_list = CODING_ATTR_CHARSET_LIST (attrs); | |
| 2619 if ((flags & CODING_ISO_FLAG_FULL_SUPPORT) | |
| 2620 && ! EQ (charset_list, Viso_2022_charset_list)) | |
| 2621 { | |
| 2622 CODING_ATTR_CHARSET_LIST (attrs) | |
| 2623 = charset_list = Viso_2022_charset_list; | |
| 2624 ASET (attrs, coding_attr_safe_charsets, Qnil); | |
| 2625 } | |
| 2626 | |
| 2627 if (STRINGP (AREF (attrs, coding_attr_safe_charsets))) | |
| 2628 return; | |
| 2629 | |
| 2630 max_charset_id = 0; | |
| 2631 for (tail = charset_list; CONSP (tail); tail = XCDR (tail)) | |
| 2632 { | |
| 2633 int id = XINT (XCAR (tail)); | |
| 2634 if (max_charset_id < id) | |
| 2635 max_charset_id = id; | |
| 2636 } | |
| 2637 | |
| 2638 safe_charsets = Fmake_string (make_number (max_charset_id + 1), | |
| 2639 make_number (255)); | |
| 2640 request = AREF (attrs, coding_attr_iso_request); | |
| 2641 reg_usage = AREF (attrs, coding_attr_iso_usage); | |
| 2642 reg94 = XINT (XCAR (reg_usage)); | |
| 2643 reg96 = XINT (XCDR (reg_usage)); | |
| 2644 | |
| 2645 for (tail = charset_list; CONSP (tail); tail = XCDR (tail)) | |
| 2646 { | |
| 2647 Lisp_Object id; | |
| 2648 Lisp_Object reg; | |
| 2649 struct charset *charset; | |
| 2650 | |
| 2651 id = XCAR (tail); | |
| 2652 charset = CHARSET_FROM_ID (XINT (id)); | |
|
88681
2cdfbffa8a0d
(CODING_ISO_FLAG_USE_ROMAN): New macro
Kenichi Handa <handa@m17n.org>
parents:
88669
diff
changeset
|
2653 reg = Fcdr (Fassq (id, request)); |
| 88365 | 2654 if (! NILP (reg)) |
| 89483 | 2655 SSET (safe_charsets, XINT (id), XINT (reg)); |
| 88365 | 2656 else if (charset->iso_chars_96) |
| 2657 { | |
| 2658 if (reg96 < 4) | |
| 89483 | 2659 SSET (safe_charsets, XINT (id), reg96); |
| 88365 | 2660 } |
| 2661 else | |
| 2662 { | |
| 2663 if (reg94 < 4) | |
| 89483 | 2664 SSET (safe_charsets, XINT (id), reg94); |
| 88365 | 2665 } |
| 2666 } | |
| 2667 ASET (attrs, coding_attr_safe_charsets, safe_charsets); | |
| 2668 } | |
| 2669 | |
|
50047
8e17fbb2ac77
(CODING_ADD_COMPOSITION_COMPONENT): If the number of
Kenichi Handa <handa@m17n.org>
parents:
49600
diff
changeset
|
2670 |
| 17052 | 2671 /* See the above "GENERAL NOTES on `detect_coding_XXX ()' functions". |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2672 Check if a text is encoded in one of ISO-2022 based codig systems. |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2673 If it is, return 1, else return 0. */ |
| 17052 | 2674 |
|
34531
37f85e931855
(ONE_MORE_BYTE_CHECK_MULTIBYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34197
diff
changeset
|
2675 static int |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2676 detect_coding_iso_2022 (coding, detect_info) |
| 88365 | 2677 struct coding_system *coding; |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2678 struct coding_detection_info *detect_info; |
| 17052 | 2679 { |
| 89483 | 2680 const unsigned char *src = coding->source, *src_base = src; |
| 2681 const unsigned char *src_end = coding->source + coding->src_bytes; | |
| 88365 | 2682 int multibytep = coding->src_multibyte; |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2683 int single_shifting = 0; |
| 88365 | 2684 int id; |
| 2685 int c, c1; | |
| 2686 int consumed_chars = 0; | |
| 2687 int i; | |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2688 int rejected = 0; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2689 int found = 0; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2690 |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2691 detect_info->checked |= CATEGORY_MASK_ISO; |
| 88365 | 2692 |
| 2693 for (i = coding_category_iso_7; i <= coding_category_iso_8_else; i++) | |
| 2694 { | |
| 2695 struct coding_system *this = &(coding_categories[i]); | |
| 2696 Lisp_Object attrs, val; | |
| 2697 | |
|
94944
c16046e21b90
(detect_coding_iso_2022): Ignore a coding category that
Kenichi Handa <handa@m17n.org>
parents:
93877
diff
changeset
|
2698 if (this->id < 0) |
|
c16046e21b90
(detect_coding_iso_2022): Ignore a coding category that
Kenichi Handa <handa@m17n.org>
parents:
93877
diff
changeset
|
2699 continue; |
| 88365 | 2700 attrs = CODING_ID_ATTRS (this->id); |
| 2701 if (CODING_ISO_FLAGS (this) & CODING_ISO_FLAG_FULL_SUPPORT | |
| 2702 && ! EQ (CODING_ATTR_SAFE_CHARSETS (attrs), Viso_2022_charset_list)) | |
| 2703 setup_iso_safe_charsets (attrs); | |
| 2704 val = CODING_ATTR_SAFE_CHARSETS (attrs); | |
| 89483 | 2705 this->max_charset_id = SCHARS (val) - 1; |
| 2706 this->safe_charsets = (char *) SDATA (val); | |
| 88365 | 2707 } |
| 2708 | |
| 2709 /* A coding system of this category is always ASCII compatible. */ | |
| 2710 src += coding->head_ascii; | |
| 2711 | |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2712 while (rejected != CATEGORY_MASK_ISO) |
| 88365 | 2713 { |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
2714 src_base = src; |
| 88365 | 2715 ONE_MORE_BYTE (c); |
| 17052 | 2716 switch (c) |
| 2717 { | |
| 2718 case ISO_CODE_ESC: | |
|
30204
35aec8514228
(inhibit_iso_escape_detection): New variable.
Kenichi Handa <handa@m17n.org>
parents:
29985
diff
changeset
|
2719 if (inhibit_iso_escape_detection) |
|
35aec8514228
(inhibit_iso_escape_detection): New variable.
Kenichi Handa <handa@m17n.org>
parents:
29985
diff
changeset
|
2720 break; |
|
23088
45c36d636f66
(detect_coding_iso2022): Don't check the byte length of
Kenichi Handa <handa@m17n.org>
parents:
23082
diff
changeset
|
2721 single_shifting = 0; |
| 88365 | 2722 ONE_MORE_BYTE (c); |
|
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
2723 if (c >= '(' && c <= '/') |
|
19134
8fa6e23f8d22
(detect_coding_iso2022): Do not exclude posibility of
Kenichi Handa <handa@m17n.org>
parents:
19118
diff
changeset
|
2724 { |
|
8fa6e23f8d22
(detect_coding_iso2022): Do not exclude posibility of
Kenichi Handa <handa@m17n.org>
parents:
19118
diff
changeset
|
2725 /* Designation sequence for a charset of dimension 1. */ |
| 88365 | 2726 ONE_MORE_BYTE (c1); |
|
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
2727 if (c1 < ' ' || c1 >= 0x80 |
| 88365 | 2728 || (id = iso_charset_table[0][c >= ','][c1]) < 0) |
|
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
2729 /* Invalid designation sequence. Just ignore. */ |
|
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
2730 break; |
|
19134
8fa6e23f8d22
(detect_coding_iso2022): Do not exclude posibility of
Kenichi Handa <handa@m17n.org>
parents:
19118
diff
changeset
|
2731 } |
|
8fa6e23f8d22
(detect_coding_iso2022): Do not exclude posibility of
Kenichi Handa <handa@m17n.org>
parents:
19118
diff
changeset
|
2732 else if (c == '$') |
| 17052 | 2733 { |
|
19134
8fa6e23f8d22
(detect_coding_iso2022): Do not exclude posibility of
Kenichi Handa <handa@m17n.org>
parents:
19118
diff
changeset
|
2734 /* Designation sequence for a charset of dimension 2. */ |
| 88365 | 2735 ONE_MORE_BYTE (c); |
|
19134
8fa6e23f8d22
(detect_coding_iso2022): Do not exclude posibility of
Kenichi Handa <handa@m17n.org>
parents:
19118
diff
changeset
|
2736 if (c >= '@' && c <= 'B') |
|
8fa6e23f8d22
(detect_coding_iso2022): Do not exclude posibility of
Kenichi Handa <handa@m17n.org>
parents:
19118
diff
changeset
|
2737 /* Designation for JISX0208.1978, GB2312, or JISX0208. */ |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2738 id = iso_charset_table[1][0][c]; |
|
19134
8fa6e23f8d22
(detect_coding_iso2022): Do not exclude posibility of
Kenichi Handa <handa@m17n.org>
parents:
19118
diff
changeset
|
2739 else if (c >= '(' && c <= '/') |
|
17320
9d15bec5f47e
(detect_coding_iso2022, detect_coding_mask): Ignore
Kenichi Handa <handa@m17n.org>
parents:
17304
diff
changeset
|
2740 { |
| 88365 | 2741 ONE_MORE_BYTE (c1); |
|
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
2742 if (c1 < ' ' || c1 >= 0x80 |
| 88365 | 2743 || (id = iso_charset_table[1][c >= ','][c1]) < 0) |
|
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
2744 /* Invalid designation sequence. Just ignore. */ |
|
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
2745 break; |
|
17320
9d15bec5f47e
(detect_coding_iso2022, detect_coding_mask): Ignore
Kenichi Handa <handa@m17n.org>
parents:
17304
diff
changeset
|
2746 } |
|
19134
8fa6e23f8d22
(detect_coding_iso2022): Do not exclude posibility of
Kenichi Handa <handa@m17n.org>
parents:
19118
diff
changeset
|
2747 else |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2748 /* Invalid designation sequence. Just ignore it. */ |
|
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
2749 break; |
|
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
2750 } |
|
23116
6736da064f4a
(detect_coding_iso2022): Handle ESC N and ESC O
Kenichi Handa <handa@m17n.org>
parents:
23089
diff
changeset
|
2751 else if (c == 'N' || c == 'O') |
|
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
2752 { |
|
23116
6736da064f4a
(detect_coding_iso2022): Handle ESC N and ESC O
Kenichi Handa <handa@m17n.org>
parents:
23089
diff
changeset
|
2753 /* ESC <Fe> for SS2 or SS3. */ |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2754 single_shifting = 1; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2755 rejected |= CATEGORY_MASK_ISO_7BIT | CATEGORY_MASK_ISO_8BIT; |
|
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
2756 break; |
|
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
2757 } |
| 26847 | 2758 else if (c >= '0' && c <= '4') |
| 2759 { | |
| 2760 /* ESC <Fp> for start/end composition. */ | |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2761 found |= CATEGORY_MASK_ISO; |
| 26847 | 2762 break; |
| 2763 } | |
|
19134
8fa6e23f8d22
(detect_coding_iso2022): Do not exclude posibility of
Kenichi Handa <handa@m17n.org>
parents:
19118
diff
changeset
|
2764 else |
| 88365 | 2765 { |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2766 /* Invalid escape sequence. Just ignore it. */ |
| 88365 | 2767 break; |
| 2768 } | |
|
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
2769 |
|
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
2770 /* We found a valid designation sequence for CHARSET. */ |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2771 rejected |= CATEGORY_MASK_ISO_8BIT; |
| 88365 | 2772 if (SAFE_CHARSET_P (&coding_categories[coding_category_iso_7], |
| 2773 id)) | |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2774 found |= CATEGORY_MASK_ISO_7; |
|
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
2775 else |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2776 rejected |= CATEGORY_MASK_ISO_7; |
| 88365 | 2777 if (SAFE_CHARSET_P (&coding_categories[coding_category_iso_7_tight], |
| 2778 id)) | |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2779 found |= CATEGORY_MASK_ISO_7_TIGHT; |
|
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
2780 else |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2781 rejected |= CATEGORY_MASK_ISO_7_TIGHT; |
| 88365 | 2782 if (SAFE_CHARSET_P (&coding_categories[coding_category_iso_7_else], |
| 2783 id)) | |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2784 found |= CATEGORY_MASK_ISO_7_ELSE; |
|
23116
6736da064f4a
(detect_coding_iso2022): Handle ESC N and ESC O
Kenichi Handa <handa@m17n.org>
parents:
23089
diff
changeset
|
2785 else |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2786 rejected |= CATEGORY_MASK_ISO_7_ELSE; |
| 88365 | 2787 if (SAFE_CHARSET_P (&coding_categories[coding_category_iso_8_else], |
| 2788 id)) | |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2789 found |= CATEGORY_MASK_ISO_8_ELSE; |
|
23116
6736da064f4a
(detect_coding_iso2022): Handle ESC N and ESC O
Kenichi Handa <handa@m17n.org>
parents:
23089
diff
changeset
|
2790 else |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2791 rejected |= CATEGORY_MASK_ISO_8_ELSE; |
| 17052 | 2792 break; |
| 2793 | |
| 2794 case ISO_CODE_SO: | |
|
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
2795 case ISO_CODE_SI: |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2796 /* Locking shift out/in. */ |
|
30204
35aec8514228
(inhibit_iso_escape_detection): New variable.
Kenichi Handa <handa@m17n.org>
parents:
29985
diff
changeset
|
2797 if (inhibit_iso_escape_detection) |
|
35aec8514228
(inhibit_iso_escape_detection): New variable.
Kenichi Handa <handa@m17n.org>
parents:
29985
diff
changeset
|
2798 break; |
|
23088
45c36d636f66
(detect_coding_iso2022): Don't check the byte length of
Kenichi Handa <handa@m17n.org>
parents:
23082
diff
changeset
|
2799 single_shifting = 0; |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2800 rejected |= CATEGORY_MASK_ISO_7BIT | CATEGORY_MASK_ISO_8BIT; |
|
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
2801 break; |
|
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
2802 |
| 17052 | 2803 case ISO_CODE_CSI: |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2804 /* Control sequence introducer. */ |
|
23088
45c36d636f66
(detect_coding_iso2022): Don't check the byte length of
Kenichi Handa <handa@m17n.org>
parents:
23082
diff
changeset
|
2805 single_shifting = 0; |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2806 rejected |= CATEGORY_MASK_ISO_7BIT | CATEGORY_MASK_ISO_7_ELSE; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2807 found |= CATEGORY_MASK_ISO_8_ELSE; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2808 goto check_extra_latin; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2809 |
| 17052 | 2810 case ISO_CODE_SS2: |
| 2811 case ISO_CODE_SS3: | |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2812 /* Single shift. */ |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2813 if (inhibit_iso_escape_detection) |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2814 break; |
|
89780
a53cb5864a40
(detect_coding_iso_2022): Fix handling of SS2 and SS3.
Kenichi Handa <handa@m17n.org>
parents:
89779
diff
changeset
|
2815 single_shifting = 0; |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2816 rejected |= CATEGORY_MASK_ISO_7BIT; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2817 if (CODING_ISO_FLAGS (&coding_categories[coding_category_iso_8_1]) |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2818 & CODING_ISO_FLAG_SINGLE_SHIFT) |
|
89780
a53cb5864a40
(detect_coding_iso_2022): Fix handling of SS2 and SS3.
Kenichi Handa <handa@m17n.org>
parents:
89779
diff
changeset
|
2819 found |= CATEGORY_MASK_ISO_8_1, single_shifting = 1; |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2820 if (CODING_ISO_FLAGS (&coding_categories[coding_category_iso_8_2]) |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2821 & CODING_ISO_FLAG_SINGLE_SHIFT) |
|
89780
a53cb5864a40
(detect_coding_iso_2022): Fix handling of SS2 and SS3.
Kenichi Handa <handa@m17n.org>
parents:
89779
diff
changeset
|
2822 found |= CATEGORY_MASK_ISO_8_2, single_shifting = 1; |
|
a53cb5864a40
(detect_coding_iso_2022): Fix handling of SS2 and SS3.
Kenichi Handa <handa@m17n.org>
parents:
89779
diff
changeset
|
2823 if (single_shifting) |
|
a53cb5864a40
(detect_coding_iso_2022): Fix handling of SS2 and SS3.
Kenichi Handa <handa@m17n.org>
parents:
89779
diff
changeset
|
2824 break; |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2825 goto check_extra_latin; |
| 17052 | 2826 |
| 2827 default: | |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
2828 if (c < 0) |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
2829 continue; |
| 17052 | 2830 if (c < 0x80) |
|
23088
45c36d636f66
(detect_coding_iso2022): Don't check the byte length of
Kenichi Handa <handa@m17n.org>
parents:
23082
diff
changeset
|
2831 { |
|
45c36d636f66
(detect_coding_iso2022): Don't check the byte length of
Kenichi Handa <handa@m17n.org>
parents:
23082
diff
changeset
|
2832 single_shifting = 0; |
|
45c36d636f66
(detect_coding_iso2022): Don't check the byte length of
Kenichi Handa <handa@m17n.org>
parents:
23082
diff
changeset
|
2833 break; |
|
45c36d636f66
(detect_coding_iso2022): Don't check the byte length of
Kenichi Handa <handa@m17n.org>
parents:
23082
diff
changeset
|
2834 } |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2835 if (c >= 0xA0) |
|
19280
e755044718ee
(ENCODE_ISO_CHARACTER_DIMENSION1): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
19193
diff
changeset
|
2836 { |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2837 rejected |= CATEGORY_MASK_ISO_7BIT | CATEGORY_MASK_ISO_7_ELSE; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2838 found |= CATEGORY_MASK_ISO_8_1; |
|
23088
45c36d636f66
(detect_coding_iso2022): Don't check the byte length of
Kenichi Handa <handa@m17n.org>
parents:
23082
diff
changeset
|
2839 /* Check the length of succeeding codes of the range |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2840 0xA0..0FF. If the byte length is even, we include |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2841 CATEGORY_MASK_ISO_8_2 in `found'. We can check this |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2842 only when we are not single shifting. */ |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2843 if (! single_shifting |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2844 && ! (rejected & CATEGORY_MASK_ISO_8_2)) |
|
23088
45c36d636f66
(detect_coding_iso2022): Don't check the byte length of
Kenichi Handa <handa@m17n.org>
parents:
23082
diff
changeset
|
2845 { |
|
29299
b33b38d81020
(detect_coding_iso2022): Fix code for checking
Kenichi Handa <handa@m17n.org>
parents:
29275
diff
changeset
|
2846 int i = 1; |
|
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2847 while (src < src_end) |
|
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2848 { |
| 88365 | 2849 ONE_MORE_BYTE (c); |
|
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2850 if (c < 0xA0) |
|
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2851 break; |
|
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2852 i++; |
|
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2853 } |
|
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2854 |
|
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2855 if (i & 1 && src < src_end) |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2856 rejected |= CATEGORY_MASK_ISO_8_2; |
|
23088
45c36d636f66
(detect_coding_iso2022): Don't check the byte length of
Kenichi Handa <handa@m17n.org>
parents:
23082
diff
changeset
|
2857 else |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2858 found |= 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
|
2859 } |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2860 break; |
| 17052 | 2861 } |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2862 check_extra_latin: |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2863 single_shifting = 0; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2864 if (! VECTORP (Vlatin_extra_code_table) |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2865 || NILP (XVECTOR (Vlatin_extra_code_table)->contents[c])) |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2866 { |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2867 rejected = CATEGORY_MASK_ISO; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2868 break; |
| 17052 | 2869 } |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2870 if (CODING_ISO_FLAGS (&coding_categories[coding_category_iso_8_1]) |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2871 & CODING_ISO_FLAG_LATIN_EXTRA) |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2872 found |= CATEGORY_MASK_ISO_8_1; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2873 else |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2874 rejected |= CATEGORY_MASK_ISO_8_1; |
|
89780
a53cb5864a40
(detect_coding_iso_2022): Fix handling of SS2 and SS3.
Kenichi Handa <handa@m17n.org>
parents:
89779
diff
changeset
|
2875 rejected |= CATEGORY_MASK_ISO_8_2; |
| 17052 | 2876 } |
| 2877 } | |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2878 detect_info->rejected |= CATEGORY_MASK_ISO; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2879 return 0; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2880 |
| 88365 | 2881 no_more_source: |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2882 detect_info->rejected |= rejected; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2883 detect_info->found |= (found & ~rejected); |
| 88365 | 2884 return 1; |
| 17052 | 2885 } |
| 2886 | |
| 2887 | |
|
89873
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
2888 /* Set designation state into CODING. Set CHARS_96 to -1 if the |
|
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
2889 escape sequence should be kept. */ |
| 88365 | 2890 #define DECODE_DESIGNATION(reg, dim, chars_96, final) \ |
| 2891 do { \ | |
| 2892 int id, prev; \ | |
| 2893 \ | |
| 2894 if (final < '0' || final >= 128 \ | |
| 2895 || ((id = ISO_CHARSET_TABLE (dim, chars_96, final)) < 0) \ | |
| 2896 || !SAFE_CHARSET_P (coding, id)) \ | |
| 2897 { \ | |
| 2898 CODING_ISO_DESIGNATION (coding, reg) = -2; \ | |
|
89873
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
2899 chars_96 = -1; \ |
|
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
2900 break; \ |
| 88365 | 2901 } \ |
| 2902 prev = CODING_ISO_DESIGNATION (coding, reg); \ | |
|
88681
2cdfbffa8a0d
(CODING_ISO_FLAG_USE_ROMAN): New macro
Kenichi Handa <handa@m17n.org>
parents:
88669
diff
changeset
|
2903 if (id == charset_jisx0201_roman) \ |
|
2cdfbffa8a0d
(CODING_ISO_FLAG_USE_ROMAN): New macro
Kenichi Handa <handa@m17n.org>
parents:
88669
diff
changeset
|
2904 { \ |
|
2cdfbffa8a0d
(CODING_ISO_FLAG_USE_ROMAN): New macro
Kenichi Handa <handa@m17n.org>
parents:
88669
diff
changeset
|
2905 if (CODING_ISO_FLAGS (coding) & CODING_ISO_FLAG_USE_ROMAN) \ |
|
2cdfbffa8a0d
(CODING_ISO_FLAG_USE_ROMAN): New macro
Kenichi Handa <handa@m17n.org>
parents:
88669
diff
changeset
|
2906 id = charset_ascii; \ |
|
2cdfbffa8a0d
(CODING_ISO_FLAG_USE_ROMAN): New macro
Kenichi Handa <handa@m17n.org>
parents:
88669
diff
changeset
|
2907 } \ |
|
2cdfbffa8a0d
(CODING_ISO_FLAG_USE_ROMAN): New macro
Kenichi Handa <handa@m17n.org>
parents:
88669
diff
changeset
|
2908 else if (id == charset_jisx0208_1978) \ |
|
2cdfbffa8a0d
(CODING_ISO_FLAG_USE_ROMAN): New macro
Kenichi Handa <handa@m17n.org>
parents:
88669
diff
changeset
|
2909 { \ |
|
2cdfbffa8a0d
(CODING_ISO_FLAG_USE_ROMAN): New macro
Kenichi Handa <handa@m17n.org>
parents:
88669
diff
changeset
|
2910 if (CODING_ISO_FLAGS (coding) & CODING_ISO_FLAG_USE_OLDJIS) \ |
|
2cdfbffa8a0d
(CODING_ISO_FLAG_USE_ROMAN): New macro
Kenichi Handa <handa@m17n.org>
parents:
88669
diff
changeset
|
2911 id = charset_jisx0208; \ |
|
2cdfbffa8a0d
(CODING_ISO_FLAG_USE_ROMAN): New macro
Kenichi Handa <handa@m17n.org>
parents:
88669
diff
changeset
|
2912 } \ |
| 88365 | 2913 CODING_ISO_DESIGNATION (coding, reg) = id; \ |
| 2914 /* If there was an invalid designation to REG previously, and this \ | |
| 2915 designation is ASCII to REG, we should keep this designation \ | |
| 2916 sequence. */ \ | |
| 2917 if (prev == -2 && id == charset_ascii) \ | |
|
89873
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
2918 chars_96 = -1; \ |
| 17052 | 2919 } while (0) |
| 2920 | |
| 88365 | 2921 |
| 2922 #define MAYBE_FINISH_COMPOSITION() \ | |
| 2923 do { \ | |
| 2924 int i; \ | |
| 2925 if (composition_state == COMPOSING_NO) \ | |
| 2926 break; \ | |
| 2927 /* It is assured that we have enough room for producing \ | |
| 2928 characters stored in the table `components'. */ \ | |
| 2929 if (charbuf + component_idx > charbuf_end) \ | |
| 2930 goto no_more_source; \ | |
| 2931 composition_state = COMPOSING_NO; \ | |
| 2932 if (method == COMPOSITION_RELATIVE \ | |
| 2933 || method == COMPOSITION_WITH_ALTCHARS) \ | |
| 2934 { \ | |
| 2935 for (i = 0; i < component_idx; i++) \ | |
| 2936 *charbuf++ = components[i]; \ | |
| 2937 char_offset += component_idx; \ | |
| 2938 } \ | |
| 2939 else \ | |
| 2940 { \ | |
| 2941 for (i = 0; i < component_idx; i += 2) \ | |
| 2942 *charbuf++ = components[i]; \ | |
| 2943 char_offset += (component_idx / 2) + 1; \ | |
| 2944 } \ | |
| 2945 } while (0) | |
| 2946 | |
|
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
2947 |
|
34888
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
2948 /* Handle composition start sequence ESC 0, ESC 2, ESC 3, or ESC 4. |
|
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
2949 ESC 0 : relative composition : ESC 0 CHAR ... ESC 1 |
|
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
2950 ESC 2 : rulebase composition : ESC 2 CHAR RULE CHAR RULE ... CHAR ESC 1 |
| 88365 | 2951 ESC 3 : altchar composition : ESC 3 CHAR ... ESC 0 CHAR ... ESC 1 |
| 2952 ESC 4 : alt&rule composition : ESC 4 CHAR RULE ... CHAR ESC 0 CHAR ... ESC 1 | |
|
34888
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
2953 */ |
| 26847 | 2954 |
| 88365 | 2955 #define DECODE_COMPOSITION_START(c1) \ |
| 26847 | 2956 do { \ |
| 88365 | 2957 if (c1 == '0' \ |
|
88585
c7772f702227
(ONE_MORE_BYTE_NO_CHECK): Increment consumed_chars.
Kenichi Handa <handa@m17n.org>
parents:
88573
diff
changeset
|
2958 && composition_state == COMPOSING_COMPONENT_RULE) \ |
| 26847 | 2959 { \ |
| 88365 | 2960 component_len = component_idx; \ |
| 2961 composition_state = COMPOSING_CHAR; \ | |
| 26847 | 2962 } \ |
| 2963 else \ | |
| 2964 { \ | |
| 89483 | 2965 const unsigned char *p; \ |
| 88365 | 2966 \ |
| 2967 MAYBE_FINISH_COMPOSITION (); \ | |
| 2968 if (charbuf + MAX_COMPOSITION_COMPONENTS > charbuf_end) \ | |
| 2969 goto no_more_source; \ | |
| 2970 for (p = src; p < src_end - 1; p++) \ | |
| 2971 if (*p == ISO_CODE_ESC && p[1] == '1') \ | |
| 2972 break; \ | |
| 2973 if (p == src_end - 1) \ | |
| 2974 { \ | |
|
90350
60eaefb08cf7
(DECODE_COMPOSITION_START): If the source is short, set
Kenichi Handa <handa@m17n.org>
parents:
90346
diff
changeset
|
2975 /* The current composition doesn't end in the current \ |
|
60eaefb08cf7
(DECODE_COMPOSITION_START): If the source is short, set
Kenichi Handa <handa@m17n.org>
parents:
90346
diff
changeset
|
2976 source. */ \ |
|
60eaefb08cf7
(DECODE_COMPOSITION_START): If the source is short, set
Kenichi Handa <handa@m17n.org>
parents:
90346
diff
changeset
|
2977 record_conversion_result \ |
|
60eaefb08cf7
(DECODE_COMPOSITION_START): If the source is short, set
Kenichi Handa <handa@m17n.org>
parents:
90346
diff
changeset
|
2978 (coding, CODING_RESULT_INSUFFICIENT_SRC); \ |
| 88365 | 2979 goto no_more_source; \ |
| 2980 } \ | |
| 2981 \ | |
| 2982 /* This is surely the start of a composition. */ \ | |
| 2983 method = (c1 == '0' ? COMPOSITION_RELATIVE \ | |
| 2984 : c1 == '2' ? COMPOSITION_WITH_RULE \ | |
| 2985 : c1 == '3' ? COMPOSITION_WITH_ALTCHARS \ | |
| 2986 : COMPOSITION_WITH_RULE_ALTCHARS); \ | |
| 2987 composition_state = (c1 <= '2' ? COMPOSING_CHAR \ | |
| 2988 : COMPOSING_COMPONENT_CHAR); \ | |
| 2989 component_idx = component_len = 0; \ | |
| 26847 | 2990 } \ |
| 2991 } while (0) | |
| 2992 | |
| 88365 | 2993 |
| 2994 /* Handle compositoin end sequence ESC 1. */ | |
| 2995 | |
| 2996 #define DECODE_COMPOSITION_END() \ | |
| 2997 do { \ | |
| 2998 int nchars = (component_len > 0 ? component_idx - component_len \ | |
| 2999 : method == COMPOSITION_RELATIVE ? component_idx \ | |
| 3000 : (component_idx + 1) / 2); \ | |
| 3001 int i; \ | |
| 3002 int *saved_charbuf = charbuf; \ | |
| 3003 \ | |
|
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
3004 ADD_COMPOSITION_DATA (charbuf, nchars, method); \ |
| 88365 | 3005 if (method != COMPOSITION_RELATIVE) \ |
| 3006 { \ | |
| 3007 if (component_len == 0) \ | |
| 3008 for (i = 0; i < component_idx; i++) \ | |
| 3009 *charbuf++ = components[i]; \ | |
| 3010 else \ | |
| 3011 for (i = 0; i < component_len; i++) \ | |
| 3012 *charbuf++ = components[i]; \ | |
| 3013 *saved_charbuf = saved_charbuf - charbuf; \ | |
| 3014 } \ | |
| 3015 if (method == COMPOSITION_WITH_RULE) \ | |
| 3016 for (i = 0; i < component_idx; i += 2, char_offset++) \ | |
| 3017 *charbuf++ = components[i]; \ | |
| 3018 else \ | |
| 3019 for (i = component_len; i < component_idx; i++, char_offset++) \ | |
| 3020 *charbuf++ = components[i]; \ | |
| 3021 coding->annotated = 1; \ | |
| 3022 composition_state = COMPOSING_NO; \ | |
| 3023 } while (0) | |
| 3024 | |
| 3025 | |
| 26847 | 3026 /* Decode a composition rule from the byte C1 (and maybe one more byte |
| 3027 from SRC) and store one encoded composition rule in | |
| 3028 coding->cmp_data. */ | |
| 3029 | |
| 3030 #define DECODE_COMPOSITION_RULE(c1) \ | |
| 3031 do { \ | |
| 3032 (c1) -= 32; \ | |
| 3033 if (c1 < 81) /* old format (before ver.21) */ \ | |
| 3034 { \ | |
| 3035 int gref = (c1) / 9; \ | |
| 3036 int nref = (c1) % 9; \ | |
| 3037 if (gref == 4) gref = 10; \ | |
| 3038 if (nref == 4) nref = 10; \ | |
| 88365 | 3039 c1 = COMPOSITION_ENCODE_RULE (gref, nref); \ |
| 26847 | 3040 } \ |
|
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3041 else if (c1 < 93) /* new format (after ver.21) */ \ |
| 26847 | 3042 { \ |
| 3043 ONE_MORE_BYTE (c2); \ | |
| 88365 | 3044 c1 = COMPOSITION_ENCODE_RULE (c1 - 81, c2 - 32); \ |
| 26847 | 3045 } \ |
| 88365 | 3046 else \ |
| 3047 c1 = 0; \ | |
| 26847 | 3048 } while (0) |
| 3049 | |
| 3050 | |
| 17052 | 3051 /* See the above "GENERAL NOTES on `decode_coding_XXX ()' functions". */ |
| 3052 | |
|
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3053 static void |
| 88365 | 3054 decode_coding_iso_2022 (coding) |
| 17052 | 3055 struct coding_system *coding; |
| 3056 { | |
| 89483 | 3057 const unsigned char *src = coding->source + coding->consumed; |
| 3058 const unsigned char *src_end = coding->source + coding->src_bytes; | |
| 3059 const unsigned char *src_base; | |
|
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
3060 int *charbuf = coding->charbuf + coding->charbuf_used; |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3061 int *charbuf_end |
|
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
3062 = coding->charbuf + coding->charbuf_size - 4 - MAX_ANNOTATION_LENGTH; |
| 88365 | 3063 int consumed_chars = 0, consumed_chars_base; |
| 3064 int multibytep = coding->src_multibyte; | |
| 17052 | 3065 /* Charsets invoked to graphic plane 0 and 1 respectively. */ |
| 88365 | 3066 int charset_id_0 = CODING_ISO_INVOKED_CHARSET (coding, 0); |
| 3067 int charset_id_1 = CODING_ISO_INVOKED_CHARSET (coding, 1); | |
|
89873
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
3068 int charset_id_2, charset_id_3; |
| 88365 | 3069 struct charset *charset; |
| 3070 int c; | |
| 3071 /* For handling composition sequence. */ | |
| 3072 #define COMPOSING_NO 0 | |
| 3073 #define COMPOSING_CHAR 1 | |
| 3074 #define COMPOSING_RULE 2 | |
| 3075 #define COMPOSING_COMPONENT_CHAR 3 | |
| 3076 #define COMPOSING_COMPONENT_RULE 4 | |
| 3077 | |
| 3078 int composition_state = COMPOSING_NO; | |
| 3079 enum composition_method method; | |
| 3080 int components[MAX_COMPOSITION_COMPONENTS * 2 + 1]; | |
| 3081 int component_idx; | |
| 3082 int component_len; | |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
3083 Lisp_Object attrs, charset_list; |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3084 int char_offset = coding->produced_char; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3085 int last_offset = char_offset; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3086 int last_id = charset_ascii; |
|
92399
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
3087 int eol_crlf = EQ (CODING_ID_EOL_TYPE (coding->id), Qdos); |
|
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
3088 int byte_after_cr = -1; |
| 88365 | 3089 |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
3090 CODING_GET_INFO (coding, attrs, charset_list); |
| 88365 | 3091 setup_iso_safe_charsets (attrs); |
|
90772
b15334b4a9c3
(coding_alloc_by_making_gap): New arg offset.
Kenichi Handa <handa@m17n.org>
parents:
90737
diff
changeset
|
3092 /* Charset list may have been changed. */ |
|
b15334b4a9c3
(coding_alloc_by_making_gap): New arg offset.
Kenichi Handa <handa@m17n.org>
parents:
90737
diff
changeset
|
3093 charset_list = CODING_ATTR_CHARSET_LIST (attrs); |
|
b15334b4a9c3
(coding_alloc_by_making_gap): New arg offset.
Kenichi Handa <handa@m17n.org>
parents:
90737
diff
changeset
|
3094 coding->safe_charsets = (char *) SDATA (CODING_ATTR_SAFE_CHARSETS(attrs)); |
|
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3095 |
|
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3096 while (1) |
|
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3097 { |
|
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3098 int c1, c2; |
|
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3099 |
|
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3100 src_base = src; |
| 88365 | 3101 consumed_chars_base = consumed_chars; |
| 3102 | |
| 3103 if (charbuf >= charbuf_end) | |
| 3104 break; | |
| 3105 | |
|
92399
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
3106 if (byte_after_cr >= 0) |
|
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
3107 c1 = byte_after_cr, byte_after_cr = -1; |
|
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
3108 else |
|
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
3109 ONE_MORE_BYTE (c1); |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
3110 if (c1 < 0) |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
3111 goto invalid_code; |
| 17052 | 3112 |
|
89279
1fd77c471ee6
(decode_coding_utf_8): When eol_type is Qdos, handle
Kenichi Handa <handa@m17n.org>
parents:
89227
diff
changeset
|
3113 /* We produce at most one character. */ |
| 17052 | 3114 switch (iso_code_class [c1]) |
| 3115 { | |
| 3116 case ISO_0x20_or_0x7F: | |
| 88365 | 3117 if (composition_state != COMPOSING_NO) |
| 26847 | 3118 { |
| 88365 | 3119 if (composition_state == COMPOSING_RULE |
| 3120 || composition_state == COMPOSING_COMPONENT_RULE) | |
| 3121 { | |
| 3122 DECODE_COMPOSITION_RULE (c1); | |
| 3123 components[component_idx++] = c1; | |
| 3124 composition_state--; | |
| 3125 continue; | |
| 3126 } | |
| 26847 | 3127 } |
| 88365 | 3128 if (charset_id_0 < 0 |
| 3129 || ! CHARSET_ISO_CHARS_96 (CHARSET_FROM_ID (charset_id_0))) | |
|
88585
c7772f702227
(ONE_MORE_BYTE_NO_CHECK): Increment consumed_chars.
Kenichi Handa <handa@m17n.org>
parents:
88573
diff
changeset
|
3130 /* This is SPACE or DEL. */ |
|
c7772f702227
(ONE_MORE_BYTE_NO_CHECK): Increment consumed_chars.
Kenichi Handa <handa@m17n.org>
parents:
88573
diff
changeset
|
3131 charset = CHARSET_FROM_ID (charset_ascii); |
|
c7772f702227
(ONE_MORE_BYTE_NO_CHECK): Increment consumed_chars.
Kenichi Handa <handa@m17n.org>
parents:
88573
diff
changeset
|
3132 else |
|
c7772f702227
(ONE_MORE_BYTE_NO_CHECK): Increment consumed_chars.
Kenichi Handa <handa@m17n.org>
parents:
88573
diff
changeset
|
3133 charset = CHARSET_FROM_ID (charset_id_0); |
|
c7772f702227
(ONE_MORE_BYTE_NO_CHECK): Increment consumed_chars.
Kenichi Handa <handa@m17n.org>
parents:
88573
diff
changeset
|
3134 break; |
| 17052 | 3135 |
| 3136 case ISO_graphic_plane_0: | |
|
88585
c7772f702227
(ONE_MORE_BYTE_NO_CHECK): Increment consumed_chars.
Kenichi Handa <handa@m17n.org>
parents:
88573
diff
changeset
|
3137 if (composition_state != COMPOSING_NO) |
|
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3138 { |
|
88585
c7772f702227
(ONE_MORE_BYTE_NO_CHECK): Increment consumed_chars.
Kenichi Handa <handa@m17n.org>
parents:
88573
diff
changeset
|
3139 if (composition_state == COMPOSING_RULE |
|
c7772f702227
(ONE_MORE_BYTE_NO_CHECK): Increment consumed_chars.
Kenichi Handa <handa@m17n.org>
parents:
88573
diff
changeset
|
3140 || composition_state == COMPOSING_COMPONENT_RULE) |
|
c7772f702227
(ONE_MORE_BYTE_NO_CHECK): Increment consumed_chars.
Kenichi Handa <handa@m17n.org>
parents:
88573
diff
changeset
|
3141 { |
|
c7772f702227
(ONE_MORE_BYTE_NO_CHECK): Increment consumed_chars.
Kenichi Handa <handa@m17n.org>
parents:
88573
diff
changeset
|
3142 DECODE_COMPOSITION_RULE (c1); |
|
c7772f702227
(ONE_MORE_BYTE_NO_CHECK): Increment consumed_chars.
Kenichi Handa <handa@m17n.org>
parents:
88573
diff
changeset
|
3143 components[component_idx++] = c1; |
|
c7772f702227
(ONE_MORE_BYTE_NO_CHECK): Increment consumed_chars.
Kenichi Handa <handa@m17n.org>
parents:
88573
diff
changeset
|
3144 composition_state--; |
|
c7772f702227
(ONE_MORE_BYTE_NO_CHECK): Increment consumed_chars.
Kenichi Handa <handa@m17n.org>
parents:
88573
diff
changeset
|
3145 continue; |
|
c7772f702227
(ONE_MORE_BYTE_NO_CHECK): Increment consumed_chars.
Kenichi Handa <handa@m17n.org>
parents:
88573
diff
changeset
|
3146 } |
|
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3147 } |
|
89873
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
3148 if (charset_id_0 < 0) |
|
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
3149 charset = CHARSET_FROM_ID (charset_ascii); |
|
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
3150 else |
|
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
3151 charset = CHARSET_FROM_ID (charset_id_0); |
| 17052 | 3152 break; |
| 3153 | |
| 3154 case ISO_0xA0_or_0xFF: | |
| 88365 | 3155 if (charset_id_1 < 0 |
| 3156 || ! CHARSET_ISO_CHARS_96 (CHARSET_FROM_ID (charset_id_1)) | |
| 3157 || CODING_ISO_FLAGS (coding) & CODING_ISO_FLAG_SEVEN_BITS) | |
| 3158 goto invalid_code; | |
| 17052 | 3159 /* This is a graphic character, we fall down ... */ |
| 3160 | |
| 3161 case ISO_graphic_plane_1: | |
| 88365 | 3162 if (charset_id_1 < 0) |
| 3163 goto invalid_code; | |
| 3164 charset = CHARSET_FROM_ID (charset_id_1); | |
| 17052 | 3165 break; |
| 3166 | |
|
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3167 case ISO_control_0: |
|
92399
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
3168 if (eol_crlf && c1 == '\r') |
|
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
3169 ONE_MORE_BYTE (byte_after_cr); |
| 88365 | 3170 MAYBE_FINISH_COMPOSITION (); |
| 3171 charset = CHARSET_FROM_ID (charset_ascii); | |
| 17052 | 3172 break; |
| 3173 | |
|
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3174 case ISO_control_1: |
| 88365 | 3175 MAYBE_FINISH_COMPOSITION (); |
| 3176 goto invalid_code; | |
| 17052 | 3177 |
| 3178 case ISO_shift_out: | |
| 88365 | 3179 if (! (CODING_ISO_FLAGS (coding) & CODING_ISO_FLAG_LOCKING_SHIFT) |
| 3180 || CODING_ISO_DESIGNATION (coding, 1) < 0) | |
| 3181 goto invalid_code; | |
| 3182 CODING_ISO_INVOCATION (coding, 0) = 1; | |
| 3183 charset_id_0 = CODING_ISO_INVOKED_CHARSET (coding, 0); | |
|
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3184 continue; |
| 17052 | 3185 |
| 3186 case ISO_shift_in: | |
| 88365 | 3187 if (! (CODING_ISO_FLAGS (coding) & CODING_ISO_FLAG_LOCKING_SHIFT)) |
| 3188 goto invalid_code; | |
| 3189 CODING_ISO_INVOCATION (coding, 0) = 0; | |
| 3190 charset_id_0 = CODING_ISO_INVOKED_CHARSET (coding, 0); | |
|
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3191 continue; |
| 17052 | 3192 |
| 3193 case ISO_single_shift_2_7: | |
| 3194 case ISO_single_shift_2: | |
| 88365 | 3195 if (! (CODING_ISO_FLAGS (coding) & CODING_ISO_FLAG_SINGLE_SHIFT)) |
| 3196 goto invalid_code; | |
| 17052 | 3197 /* SS2 is handled as an escape sequence of ESC 'N' */ |
| 3198 c1 = 'N'; | |
| 3199 goto label_escape_sequence; | |
| 3200 | |
| 3201 case ISO_single_shift_3: | |
| 88365 | 3202 if (! (CODING_ISO_FLAGS (coding) & CODING_ISO_FLAG_SINGLE_SHIFT)) |
| 3203 goto invalid_code; | |
| 17052 | 3204 /* SS2 is handled as an escape sequence of ESC 'O' */ |
| 3205 c1 = 'O'; | |
| 3206 goto label_escape_sequence; | |
| 3207 | |
| 3208 case ISO_control_sequence_introducer: | |
| 3209 /* CSI is handled as an escape sequence of ESC '[' ... */ | |
| 3210 c1 = '['; | |
| 3211 goto label_escape_sequence; | |
| 3212 | |
| 3213 case ISO_escape: | |
| 3214 ONE_MORE_BYTE (c1); | |
| 3215 label_escape_sequence: | |
| 88365 | 3216 /* Escape sequences handled here are invocation, |
| 17052 | 3217 designation, direction specification, and character |
| 3218 composition specification. */ | |
| 3219 switch (c1) | |
| 3220 { | |
| 3221 case '&': /* revision of following character set */ | |
| 3222 ONE_MORE_BYTE (c1); | |
| 3223 if (!(c1 >= '@' && c1 <= '~')) | |
| 88365 | 3224 goto invalid_code; |
| 17052 | 3225 ONE_MORE_BYTE (c1); |
| 3226 if (c1 != ISO_CODE_ESC) | |
| 88365 | 3227 goto invalid_code; |
| 17052 | 3228 ONE_MORE_BYTE (c1); |
| 3229 goto label_escape_sequence; | |
| 3230 | |
| 3231 case '$': /* designation of 2-byte character set */ | |
| 88365 | 3232 if (! (CODING_ISO_FLAGS (coding) & CODING_ISO_FLAG_DESIGNATION)) |
| 3233 goto invalid_code; | |
|
89873
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
3234 { |
|
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
3235 int reg, chars96; |
|
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
3236 |
|
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
3237 ONE_MORE_BYTE (c1); |
|
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
3238 if (c1 >= '@' && c1 <= 'B') |
|
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
3239 { /* 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
|
3240 or JISX0208.1980 */ |
|
89873
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
3241 reg = 0, chars96 = 0; |
|
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
3242 } |
|
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
3243 else if (c1 >= 0x28 && c1 <= 0x2B) |
|
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
3244 { /* designation of DIMENSION2_CHARS94 character set */ |
|
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
3245 reg = c1 - 0x28, chars96 = 0; |
|
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
3246 ONE_MORE_BYTE (c1); |
|
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
3247 } |
|
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
3248 else if (c1 >= 0x2C && c1 <= 0x2F) |
|
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
3249 { /* designation of DIMENSION2_CHARS96 character set */ |
|
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
3250 reg = c1 - 0x2C, chars96 = 1; |
|
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
3251 ONE_MORE_BYTE (c1); |
|
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
3252 } |
|
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
3253 else |
|
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
3254 goto invalid_code; |
|
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
3255 DECODE_DESIGNATION (reg, 2, chars96, c1); |
|
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
3256 /* We must update these variables now. */ |
|
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
3257 if (reg == 0) |
|
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
3258 charset_id_0 = CODING_ISO_INVOKED_CHARSET (coding, 0); |
|
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
3259 else if (reg == 1) |
|
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
3260 charset_id_1 = CODING_ISO_INVOKED_CHARSET (coding, 1); |
|
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
3261 if (chars96 < 0) |
|
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
3262 goto invalid_code; |
|
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
3263 } |
|
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3264 continue; |
| 17052 | 3265 |
| 3266 case 'n': /* invocation of locking-shift-2 */ | |
| 88365 | 3267 if (! (CODING_ISO_FLAGS (coding) & CODING_ISO_FLAG_LOCKING_SHIFT) |
| 3268 || CODING_ISO_DESIGNATION (coding, 2) < 0) | |
| 3269 goto invalid_code; | |
| 3270 CODING_ISO_INVOCATION (coding, 0) = 2; | |
| 3271 charset_id_0 = CODING_ISO_INVOKED_CHARSET (coding, 0); | |
|
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3272 continue; |
| 17052 | 3273 |
| 3274 case 'o': /* invocation of locking-shift-3 */ | |
| 88365 | 3275 if (! (CODING_ISO_FLAGS (coding) & CODING_ISO_FLAG_LOCKING_SHIFT) |
| 3276 || CODING_ISO_DESIGNATION (coding, 3) < 0) | |
| 3277 goto invalid_code; | |
| 3278 CODING_ISO_INVOCATION (coding, 0) = 3; | |
| 3279 charset_id_0 = CODING_ISO_INVOKED_CHARSET (coding, 0); | |
|
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3280 continue; |
| 17052 | 3281 |
| 3282 case 'N': /* invocation of single-shift-2 */ | |
| 88365 | 3283 if (! (CODING_ISO_FLAGS (coding) & CODING_ISO_FLAG_SINGLE_SHIFT) |
| 3284 || CODING_ISO_DESIGNATION (coding, 2) < 0) | |
| 3285 goto invalid_code; | |
|
89873
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
3286 charset_id_2 = CODING_ISO_DESIGNATION (coding, 2); |
|
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
3287 if (charset_id_2 < 0) |
|
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
3288 charset = CHARSET_FROM_ID (charset_ascii); |
|
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
3289 else |
|
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
3290 charset = CHARSET_FROM_ID (charset_id_2); |
| 17052 | 3291 ONE_MORE_BYTE (c1); |
|
30578
705b94e152b1
(decode_coding_iso2022): More strict check for handling single
Kenichi Handa <handa@m17n.org>
parents:
30487
diff
changeset
|
3292 if (c1 < 0x20 || (c1 >= 0x80 && c1 < 0xA0)) |
| 88365 | 3293 goto invalid_code; |
| 17052 | 3294 break; |
| 3295 | |
| 3296 case 'O': /* invocation of single-shift-3 */ | |
| 88365 | 3297 if (! (CODING_ISO_FLAGS (coding) & CODING_ISO_FLAG_SINGLE_SHIFT) |
| 3298 || CODING_ISO_DESIGNATION (coding, 3) < 0) | |
| 3299 goto invalid_code; | |
|
89873
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
3300 charset_id_3 = CODING_ISO_DESIGNATION (coding, 3); |
|
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
3301 if (charset_id_3 < 0) |
|
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
3302 charset = CHARSET_FROM_ID (charset_ascii); |
|
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
3303 else |
|
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
3304 charset = CHARSET_FROM_ID (charset_id_3); |
| 17052 | 3305 ONE_MORE_BYTE (c1); |
|
30578
705b94e152b1
(decode_coding_iso2022): More strict check for handling single
Kenichi Handa <handa@m17n.org>
parents:
30487
diff
changeset
|
3306 if (c1 < 0x20 || (c1 >= 0x80 && c1 < 0xA0)) |
| 88365 | 3307 goto invalid_code; |
| 17052 | 3308 break; |
| 3309 | |
| 26847 | 3310 case '0': case '2': case '3': case '4': /* start composition */ |
| 88365 | 3311 if (! (coding->common_flags & CODING_ANNOTATE_COMPOSITION_MASK)) |
| 3312 goto invalid_code; | |
| 26847 | 3313 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
|
3314 continue; |
| 17052 | 3315 |
| 26847 | 3316 case '1': /* end composition */ |
| 88365 | 3317 if (composition_state == COMPOSING_NO) |
| 3318 goto invalid_code; | |
| 3319 DECODE_COMPOSITION_END (); | |
|
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3320 continue; |
| 17052 | 3321 |
| 3322 case '[': /* specification of direction */ | |
| 88365 | 3323 if (! CODING_ISO_FLAGS (coding) & CODING_ISO_FLAG_DIRECTION) |
| 3324 goto invalid_code; | |
| 17052 | 3325 /* 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
|
3326 So, `coding->mode & CODING_MODE_DIRECTION' zero means |
| 88365 | 3327 left-to-right, and nozero means right-to-left. */ |
| 17052 | 3328 ONE_MORE_BYTE (c1); |
| 3329 switch (c1) | |
| 3330 { | |
| 3331 case ']': /* end of the current direction */ | |
|
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3332 coding->mode &= ~CODING_MODE_DIRECTION; |
| 17052 | 3333 |
| 3334 case '0': /* end of the current direction */ | |
| 3335 case '1': /* start of left-to-right direction */ | |
| 3336 ONE_MORE_BYTE (c1); | |
| 3337 if (c1 == ']') | |
|
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3338 coding->mode &= ~CODING_MODE_DIRECTION; |
| 17052 | 3339 else |
| 88365 | 3340 goto invalid_code; |
| 17052 | 3341 break; |
| 3342 | |
| 3343 case '2': /* start of right-to-left direction */ | |
| 3344 ONE_MORE_BYTE (c1); | |
| 3345 if (c1 == ']') | |
|
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3346 coding->mode |= CODING_MODE_DIRECTION; |
| 17052 | 3347 else |
| 88365 | 3348 goto invalid_code; |
| 17052 | 3349 break; |
| 3350 | |
| 3351 default: | |
| 88365 | 3352 goto invalid_code; |
| 17052 | 3353 } |
|
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3354 continue; |
| 17052 | 3355 |
| 51311 | 3356 case '%': |
| 3357 ONE_MORE_BYTE (c1); | |
| 3358 if (c1 == '/') | |
| 3359 { | |
| 3360 /* CTEXT extended segment: | |
| 3361 ESC % / [0-4] M L --ENCODING-NAME-- \002 --BYTES-- | |
| 3362 We keep these bytes as is for the moment. | |
| 3363 They may be decoded by post-read-conversion. */ | |
| 3364 int dim, M, L; | |
|
89442
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
3365 int size; |
| 56191 | 3366 |
| 51311 | 3367 ONE_MORE_BYTE (dim); |
| 3368 ONE_MORE_BYTE (M); | |
| 3369 ONE_MORE_BYTE (L); | |
| 3370 size = ((M - 128) * 128) + (L - 128); | |
|
89442
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
3371 if (charbuf + 8 + size > charbuf_end) |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
3372 goto break_loop; |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
3373 *charbuf++ = ISO_CODE_ESC; |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
3374 *charbuf++ = '%'; |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
3375 *charbuf++ = '/'; |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
3376 *charbuf++ = dim; |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
3377 *charbuf++ = BYTE8_TO_CHAR (M); |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
3378 *charbuf++ = BYTE8_TO_CHAR (L); |
| 51311 | 3379 while (size-- > 0) |
| 3380 { | |
| 3381 ONE_MORE_BYTE (c1); | |
|
89442
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
3382 *charbuf++ = ASCII_BYTE_P (c1) ? c1 : BYTE8_TO_CHAR (c1); |
| 51311 | 3383 } |
| 3384 } | |
| 3385 else if (c1 == 'G') | |
| 3386 { | |
| 3387 /* XFree86 extension for embedding UTF-8 in CTEXT: | |
| 3388 ESC % G --UTF-8-BYTES-- ESC % @ | |
| 3389 We keep these bytes as is for the moment. | |
| 3390 They may be decoded by post-read-conversion. */ | |
|
89442
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
3391 int *p = charbuf; |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
3392 |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
3393 if (p + 6 > charbuf_end) |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
3394 goto break_loop; |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
3395 *p++ = ISO_CODE_ESC; |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
3396 *p++ = '%'; |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
3397 *p++ = 'G'; |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
3398 while (p < charbuf_end) |
| 51311 | 3399 { |
| 3400 ONE_MORE_BYTE (c1); | |
| 3401 if (c1 == ISO_CODE_ESC | |
| 3402 && src + 1 < src_end | |
| 3403 && src[0] == '%' | |
| 3404 && src[1] == '@') | |
|
53239
82690620d562
(decode_coding_iso2022): Fix for preserving UTF-8
Kenichi Handa <handa@m17n.org>
parents:
53087
diff
changeset
|
3405 { |
|
82690620d562
(decode_coding_iso2022): Fix for preserving UTF-8
Kenichi Handa <handa@m17n.org>
parents:
53087
diff
changeset
|
3406 src += 2; |
|
82690620d562
(decode_coding_iso2022): Fix for preserving UTF-8
Kenichi Handa <handa@m17n.org>
parents:
53087
diff
changeset
|
3407 break; |
|
82690620d562
(decode_coding_iso2022): Fix for preserving UTF-8
Kenichi Handa <handa@m17n.org>
parents:
53087
diff
changeset
|
3408 } |
|
89442
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
3409 *p++ = ASCII_BYTE_P (c1) ? c1 : BYTE8_TO_CHAR (c1); |
| 51311 | 3410 } |
|
89442
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
3411 if (p + 3 > charbuf_end) |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
3412 goto break_loop; |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
3413 *p++ = ISO_CODE_ESC; |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
3414 *p++ = '%'; |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
3415 *p++ = '@'; |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
3416 charbuf = p; |
| 51311 | 3417 } |
| 3418 else | |
|
89442
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
3419 goto invalid_code; |
| 51311 | 3420 continue; |
|
89442
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
3421 break; |
| 51311 | 3422 |
| 17052 | 3423 default: |
| 88365 | 3424 if (! (CODING_ISO_FLAGS (coding) & CODING_ISO_FLAG_DESIGNATION)) |
| 3425 goto invalid_code; | |
|
89873
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
3426 { |
|
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
3427 int reg, chars96; |
|
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
3428 |
|
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
3429 if (c1 >= 0x28 && c1 <= 0x2B) |
|
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
3430 { /* designation of DIMENSION1_CHARS94 character set */ |
|
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
3431 reg = c1 - 0x28, chars96 = 0; |
|
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
3432 ONE_MORE_BYTE (c1); |
|
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
3433 } |
|
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
3434 else if (c1 >= 0x2C && c1 <= 0x2F) |
|
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
3435 { /* designation of DIMENSION1_CHARS96 character set */ |
|
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
3436 reg = c1 - 0x2C, chars96 = 1; |
|
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
3437 ONE_MORE_BYTE (c1); |
|
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
3438 } |
|
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
3439 else |
|
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
3440 goto invalid_code; |
|
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
3441 DECODE_DESIGNATION (reg, 1, chars96, c1); |
|
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
3442 /* We must update these variables now. */ |
|
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
3443 if (reg == 0) |
|
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
3444 charset_id_0 = CODING_ISO_INVOKED_CHARSET (coding, 0); |
|
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
3445 else if (reg == 1) |
|
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
3446 charset_id_1 = CODING_ISO_INVOKED_CHARSET (coding, 1); |
|
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
3447 if (chars96 < 0) |
|
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
3448 goto invalid_code; |
|
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
3449 } |
|
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3450 continue; |
| 17052 | 3451 } |
|
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3452 } |
|
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3453 |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3454 if (charset->id != charset_ascii |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3455 && last_id != charset->id) |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3456 { |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3457 if (last_id != charset_ascii) |
|
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
3458 ADD_CHARSET_DATA (charbuf, char_offset - last_offset, last_id); |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3459 last_id = charset->id; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3460 last_offset = char_offset; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3461 } |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3462 |
|
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3463 /* Now we know CHARSET and 1st position code C1 of a character. |
| 88365 | 3464 Produce a decoded character while getting 2nd position code |
| 3465 C2 if necessary. */ | |
| 3466 c1 &= 0x7F; | |
| 3467 if (CHARSET_DIMENSION (charset) > 1) | |
|
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3468 { |
|
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3469 ONE_MORE_BYTE (c2); |
| 88365 | 3470 if (c2 < 0x20 || (c2 >= 0x80 && c2 < 0xA0)) |
|
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3471 /* C2 is not in a valid range. */ |
| 88365 | 3472 goto invalid_code; |
| 3473 c1 = (c1 << 8) | (c2 & 0x7F); | |
| 3474 if (CHARSET_DIMENSION (charset) > 2) | |
| 3475 { | |
| 3476 ONE_MORE_BYTE (c2); | |
| 3477 if (c2 < 0x20 || (c2 >= 0x80 && c2 < 0xA0)) | |
| 3478 /* C2 is not in a valid range. */ | |
| 3479 goto invalid_code; | |
| 3480 c1 = (c1 << 8) | (c2 & 0x7F); | |
| 3481 } | |
| 17052 | 3482 } |
| 88365 | 3483 |
| 3484 CODING_DECODE_CHAR (coding, src, src_base, src_end, charset, c1, c); | |
| 3485 if (c < 0) | |
| 3486 { | |
| 3487 MAYBE_FINISH_COMPOSITION (); | |
| 3488 for (; src_base < src; src_base++, char_offset++) | |
| 3489 { | |
| 3490 if (ASCII_BYTE_P (*src_base)) | |
| 3491 *charbuf++ = *src_base; | |
| 3492 else | |
| 3493 *charbuf++ = BYTE8_TO_CHAR (*src_base); | |
| 3494 } | |
| 3495 } | |
| 3496 else if (composition_state == COMPOSING_NO) | |
| 3497 { | |
| 3498 *charbuf++ = c; | |
| 3499 char_offset++; | |
| 3500 } | |
| 3501 else | |
|
88585
c7772f702227
(ONE_MORE_BYTE_NO_CHECK): Increment consumed_chars.
Kenichi Handa <handa@m17n.org>
parents:
88573
diff
changeset
|
3502 { |
|
c7772f702227
(ONE_MORE_BYTE_NO_CHECK): Increment consumed_chars.
Kenichi Handa <handa@m17n.org>
parents:
88573
diff
changeset
|
3503 components[component_idx++] = c; |
|
c7772f702227
(ONE_MORE_BYTE_NO_CHECK): Increment consumed_chars.
Kenichi Handa <handa@m17n.org>
parents:
88573
diff
changeset
|
3504 if (method == COMPOSITION_WITH_RULE |
|
c7772f702227
(ONE_MORE_BYTE_NO_CHECK): Increment consumed_chars.
Kenichi Handa <handa@m17n.org>
parents:
88573
diff
changeset
|
3505 || (method == COMPOSITION_WITH_RULE_ALTCHARS |
|
c7772f702227
(ONE_MORE_BYTE_NO_CHECK): Increment consumed_chars.
Kenichi Handa <handa@m17n.org>
parents:
88573
diff
changeset
|
3506 && composition_state == COMPOSING_COMPONENT_CHAR)) |
|
c7772f702227
(ONE_MORE_BYTE_NO_CHECK): Increment consumed_chars.
Kenichi Handa <handa@m17n.org>
parents:
88573
diff
changeset
|
3507 composition_state++; |
|
c7772f702227
(ONE_MORE_BYTE_NO_CHECK): Increment consumed_chars.
Kenichi Handa <handa@m17n.org>
parents:
88573
diff
changeset
|
3508 } |
| 17052 | 3509 continue; |
| 3510 | |
| 88365 | 3511 invalid_code: |
| 3512 MAYBE_FINISH_COMPOSITION (); | |
| 3513 src = src_base; | |
| 3514 consumed_chars = consumed_chars_base; | |
| 3515 ONE_MORE_BYTE (c); | |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
3516 *charbuf++ = c < 0 ? -c : ASCII_BYTE_P (c) ? c : BYTE8_TO_CHAR (c); |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3517 char_offset++; |
|
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3518 coding->errors++; |
|
89442
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
3519 continue; |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
3520 |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
3521 break_loop: |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
3522 break; |
| 88365 | 3523 } |
| 3524 | |
| 3525 no_more_source: | |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3526 if (last_id != charset_ascii) |
|
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
3527 ADD_CHARSET_DATA (charbuf, char_offset - last_offset, last_id); |
| 88365 | 3528 coding->consumed_char += consumed_chars_base; |
| 3529 coding->consumed = src_base - coding->source; | |
| 3530 coding->charbuf_used = charbuf - coding->charbuf; | |
| 17052 | 3531 } |
| 3532 | |
|
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3533 |
| 18766 | 3534 /* ISO2022 encoding stuff. */ |
| 17052 | 3535 |
| 3536 /* | |
| 18766 | 3537 It is not enough to say just "ISO2022" on encoding, we have to |
| 88365 | 3538 specify more details. In Emacs, each coding system of ISO2022 |
| 17052 | 3539 variant has the following specifications: |
| 88365 | 3540 1. Initial designation to G0 thru G3. |
| 17052 | 3541 2. Allows short-form designation? |
| 3542 3. ASCII should be designated to G0 before control characters? | |
| 3543 4. ASCII should be designated to G0 at end of line? | |
| 3544 5. 7-bit environment or 8-bit environment? | |
| 3545 6. Use locking-shift? | |
| 3546 7. Use Single-shift? | |
| 3547 And the following two are only for Japanese: | |
| 3548 8. Use ASCII in place of JIS0201-1976-Roman? | |
| 3549 9. Use JISX0208-1983 in place of JISX0208-1978? | |
| 88365 | 3550 These specifications are encoded in CODING_ISO_FLAGS (coding) as flag bits |
| 3551 defined by macros CODING_ISO_FLAG_XXX. See `coding.h' for more | |
| 18766 | 3552 details. |
| 17052 | 3553 */ |
| 3554 | |
| 3555 /* 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
|
3556 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
|
3557 '@', '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
|
3558 designation sequence of short-form. */ |
| 17052 | 3559 |
| 3560 #define ENCODE_DESIGNATION(charset, reg, coding) \ | |
| 3561 do { \ | |
| 88365 | 3562 unsigned char final_char = CHARSET_ISO_FINAL (charset); \ |
| 17052 | 3563 char *intermediate_char_94 = "()*+"; \ |
| 3564 char *intermediate_char_96 = ",-./"; \ | |
| 88365 | 3565 int revision = -1; \ |
| 3566 int c; \ | |
| 3567 \ | |
| 3568 if (CODING_ISO_FLAGS (coding) & CODING_ISO_FLAG_REVISION) \ | |
| 88856 | 3569 revision = CHARSET_ISO_REVISION (charset); \ |
| 88365 | 3570 \ |
| 3571 if (revision >= 0) \ | |
|
20150
402b6e5f4b58
(encode_designation_at_bol): Fix bug of finding graphic
Kenichi Handa <handa@m17n.org>
parents:
20105
diff
changeset
|
3572 { \ |
| 88365 | 3573 EMIT_TWO_ASCII_BYTES (ISO_CODE_ESC, '&'); \ |
| 3574 EMIT_ONE_BYTE ('@' + revision); \ | |
| 17052 | 3575 } \ |
| 88365 | 3576 EMIT_ONE_ASCII_BYTE (ISO_CODE_ESC); \ |
| 17052 | 3577 if (CHARSET_DIMENSION (charset) == 1) \ |
| 3578 { \ | |
| 88365 | 3579 if (! CHARSET_ISO_CHARS_96 (charset)) \ |
| 3580 c = intermediate_char_94[reg]; \ | |
| 17052 | 3581 else \ |
| 88365 | 3582 c = intermediate_char_96[reg]; \ |
| 3583 EMIT_ONE_ASCII_BYTE (c); \ | |
| 17052 | 3584 } \ |
| 3585 else \ | |
| 3586 { \ | |
| 88365 | 3587 EMIT_ONE_ASCII_BYTE ('$'); \ |
| 3588 if (! CHARSET_ISO_CHARS_96 (charset)) \ | |
| 17052 | 3589 { \ |
| 88365 | 3590 if (CODING_ISO_FLAGS (coding) & CODING_ISO_FLAG_LONG_FORM \ |
|
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3591 || reg != 0 \ |
|
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3592 || final_char < '@' || final_char > 'B') \ |
| 88365 | 3593 EMIT_ONE_ASCII_BYTE (intermediate_char_94[reg]); \ |
| 17052 | 3594 } \ |
| 3595 else \ | |
| 88365 | 3596 EMIT_ONE_ASCII_BYTE (intermediate_char_96[reg]); \ |
| 17052 | 3597 } \ |
| 88365 | 3598 EMIT_ONE_ASCII_BYTE (final_char); \ |
| 3599 \ | |
| 3600 CODING_ISO_DESIGNATION (coding, reg) = CHARSET_ID (charset); \ | |
| 17052 | 3601 } while (0) |
| 3602 | |
| 88365 | 3603 |
| 17052 | 3604 /* The following two macros produce codes (control character or escape |
| 3605 sequence) for ISO2022 single-shift functions (single-shift-2 and | |
| 3606 single-shift-3). */ | |
| 3607 | |
| 88365 | 3608 #define ENCODE_SINGLE_SHIFT_2 \ |
| 3609 do { \ | |
| 3610 if (CODING_ISO_FLAGS (coding) & CODING_ISO_FLAG_SEVEN_BITS) \ | |
| 3611 EMIT_TWO_ASCII_BYTES (ISO_CODE_ESC, 'N'); \ | |
| 3612 else \ | |
| 3613 EMIT_ONE_BYTE (ISO_CODE_SS2); \ | |
| 3614 CODING_ISO_SINGLE_SHIFTING (coding) = 1; \ | |
| 17052 | 3615 } while (0) |
| 3616 | |
| 88365 | 3617 |
| 3618 #define ENCODE_SINGLE_SHIFT_3 \ | |
| 3619 do { \ | |
| 3620 if (CODING_ISO_FLAGS (coding) & CODING_ISO_FLAG_SEVEN_BITS) \ | |
| 3621 EMIT_TWO_ASCII_BYTES (ISO_CODE_ESC, 'O'); \ | |
| 3622 else \ | |
| 3623 EMIT_ONE_BYTE (ISO_CODE_SS3); \ | |
| 3624 CODING_ISO_SINGLE_SHIFTING (coding) = 1; \ | |
| 17052 | 3625 } while (0) |
| 3626 | |
| 88365 | 3627 |
| 17052 | 3628 /* The following four macros produce codes (control character or |
| 3629 escape sequence) for ISO2022 locking-shift functions (shift-in, | |
| 3630 shift-out, locking-shift-2, and locking-shift-3). */ | |
| 3631 | |
| 88365 | 3632 #define ENCODE_SHIFT_IN \ |
| 3633 do { \ | |
| 3634 EMIT_ONE_ASCII_BYTE (ISO_CODE_SI); \ | |
| 3635 CODING_ISO_INVOCATION (coding, 0) = 0; \ | |
| 17052 | 3636 } while (0) |
| 3637 | |
| 88365 | 3638 |
| 3639 #define ENCODE_SHIFT_OUT \ | |
| 3640 do { \ | |
| 3641 EMIT_ONE_ASCII_BYTE (ISO_CODE_SO); \ | |
| 3642 CODING_ISO_INVOCATION (coding, 0) = 1; \ | |
| 17052 | 3643 } while (0) |
| 3644 | |
| 88365 | 3645 |
| 3646 #define ENCODE_LOCKING_SHIFT_2 \ | |
| 3647 do { \ | |
| 3648 EMIT_TWO_ASCII_BYTES (ISO_CODE_ESC, 'n'); \ | |
| 3649 CODING_ISO_INVOCATION (coding, 0) = 2; \ | |
| 17052 | 3650 } while (0) |
| 3651 | |
| 88365 | 3652 |
| 3653 #define ENCODE_LOCKING_SHIFT_3 \ | |
| 3654 do { \ | |
| 3655 EMIT_TWO_ASCII_BYTES (ISO_CODE_ESC, 'n'); \ | |
| 3656 CODING_ISO_INVOCATION (coding, 0) = 3; \ | |
| 17052 | 3657 } while (0) |
| 3658 | |
| 88365 | 3659 |
| 18766 | 3660 /* Produce codes for a DIMENSION1 character whose character set is |
| 3661 CHARSET and whose position-code is C1. Designation and invocation | |
| 17052 | 3662 sequences are also produced in advance if necessary. */ |
| 3663 | |
|
19285
af3d00fde172
(Fset_terminal_coding_system_internal): Set
Kenichi Handa <handa@m17n.org>
parents:
19280
diff
changeset
|
3664 #define ENCODE_ISO_CHARACTER_DIMENSION1(charset, c1) \ |
|
af3d00fde172
(Fset_terminal_coding_system_internal): Set
Kenichi Handa <handa@m17n.org>
parents:
19280
diff
changeset
|
3665 do { \ |
| 88365 | 3666 int id = CHARSET_ID (charset); \ |
|
88681
2cdfbffa8a0d
(CODING_ISO_FLAG_USE_ROMAN): New macro
Kenichi Handa <handa@m17n.org>
parents:
88669
diff
changeset
|
3667 \ |
|
2cdfbffa8a0d
(CODING_ISO_FLAG_USE_ROMAN): New macro
Kenichi Handa <handa@m17n.org>
parents:
88669
diff
changeset
|
3668 if ((CODING_ISO_FLAGS (coding) & CODING_ISO_FLAG_USE_ROMAN) \ |
|
2cdfbffa8a0d
(CODING_ISO_FLAG_USE_ROMAN): New macro
Kenichi Handa <handa@m17n.org>
parents:
88669
diff
changeset
|
3669 && id == charset_ascii) \ |
|
19285
af3d00fde172
(Fset_terminal_coding_system_internal): Set
Kenichi Handa <handa@m17n.org>
parents:
19280
diff
changeset
|
3670 { \ |
|
88681
2cdfbffa8a0d
(CODING_ISO_FLAG_USE_ROMAN): New macro
Kenichi Handa <handa@m17n.org>
parents:
88669
diff
changeset
|
3671 id = charset_jisx0201_roman; \ |
|
2cdfbffa8a0d
(CODING_ISO_FLAG_USE_ROMAN): New macro
Kenichi Handa <handa@m17n.org>
parents:
88669
diff
changeset
|
3672 charset = CHARSET_FROM_ID (id); \ |
|
19285
af3d00fde172
(Fset_terminal_coding_system_internal): Set
Kenichi Handa <handa@m17n.org>
parents:
19280
diff
changeset
|
3673 } \ |
|
88681
2cdfbffa8a0d
(CODING_ISO_FLAG_USE_ROMAN): New macro
Kenichi Handa <handa@m17n.org>
parents:
88669
diff
changeset
|
3674 \ |
| 88365 | 3675 if (CODING_ISO_SINGLE_SHIFTING (coding)) \ |
|
19285
af3d00fde172
(Fset_terminal_coding_system_internal): Set
Kenichi Handa <handa@m17n.org>
parents:
19280
diff
changeset
|
3676 { \ |
| 88365 | 3677 if (CODING_ISO_FLAGS (coding) & CODING_ISO_FLAG_SEVEN_BITS) \ |
| 3678 EMIT_ONE_ASCII_BYTE (c1 & 0x7F); \ | |
|
19285
af3d00fde172
(Fset_terminal_coding_system_internal): Set
Kenichi Handa <handa@m17n.org>
parents:
19280
diff
changeset
|
3679 else \ |
| 88365 | 3680 EMIT_ONE_BYTE (c1 | 0x80); \ |
| 3681 CODING_ISO_SINGLE_SHIFTING (coding) = 0; \ | |
|
19285
af3d00fde172
(Fset_terminal_coding_system_internal): Set
Kenichi Handa <handa@m17n.org>
parents:
19280
diff
changeset
|
3682 break; \ |
|
af3d00fde172
(Fset_terminal_coding_system_internal): Set
Kenichi Handa <handa@m17n.org>
parents:
19280
diff
changeset
|
3683 } \ |
| 88365 | 3684 else if (id == CODING_ISO_INVOKED_CHARSET (coding, 0)) \ |
|
19285
af3d00fde172
(Fset_terminal_coding_system_internal): Set
Kenichi Handa <handa@m17n.org>
parents:
19280
diff
changeset
|
3685 { \ |
| 88365 | 3686 EMIT_ONE_ASCII_BYTE (c1 & 0x7F); \ |
|
19285
af3d00fde172
(Fset_terminal_coding_system_internal): Set
Kenichi Handa <handa@m17n.org>
parents:
19280
diff
changeset
|
3687 break; \ |
|
af3d00fde172
(Fset_terminal_coding_system_internal): Set
Kenichi Handa <handa@m17n.org>
parents:
19280
diff
changeset
|
3688 } \ |
| 88365 | 3689 else if (id == CODING_ISO_INVOKED_CHARSET (coding, 1)) \ |
|
19285
af3d00fde172
(Fset_terminal_coding_system_internal): Set
Kenichi Handa <handa@m17n.org>
parents:
19280
diff
changeset
|
3690 { \ |
| 88365 | 3691 EMIT_ONE_BYTE (c1 | 0x80); \ |
|
19285
af3d00fde172
(Fset_terminal_coding_system_internal): Set
Kenichi Handa <handa@m17n.org>
parents:
19280
diff
changeset
|
3692 break; \ |
|
af3d00fde172
(Fset_terminal_coding_system_internal): Set
Kenichi Handa <handa@m17n.org>
parents:
19280
diff
changeset
|
3693 } \ |
|
af3d00fde172
(Fset_terminal_coding_system_internal): Set
Kenichi Handa <handa@m17n.org>
parents:
19280
diff
changeset
|
3694 else \ |
|
af3d00fde172
(Fset_terminal_coding_system_internal): Set
Kenichi Handa <handa@m17n.org>
parents:
19280
diff
changeset
|
3695 /* 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
|
3696 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
|
3697 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
|
3698 character. */ \ |
| 88365 | 3699 dst = encode_invocation_designation (charset, coding, dst, \ |
| 3700 &produced_chars); \ | |
| 17052 | 3701 } while (1) |
| 3702 | |
| 88365 | 3703 |
| 3704 /* Produce codes for a DIMENSION2 character whose character set is | |
| 3705 CHARSET and whose position-codes are C1 and C2. Designation and | |
| 3706 invocation codes are also produced in advance if necessary. */ | |
| 3707 | |
| 3708 #define ENCODE_ISO_CHARACTER_DIMENSION2(charset, c1, c2) \ | |
|
24506
219c99669e4b
(ENCODE_ISO_CHARACTER): Check validity of CHARSET. If
Kenichi Handa <handa@m17n.org>
parents:
24460
diff
changeset
|
3709 do { \ |
| 88365 | 3710 int id = CHARSET_ID (charset); \ |
|
88681
2cdfbffa8a0d
(CODING_ISO_FLAG_USE_ROMAN): New macro
Kenichi Handa <handa@m17n.org>
parents:
88669
diff
changeset
|
3711 \ |
|
2cdfbffa8a0d
(CODING_ISO_FLAG_USE_ROMAN): New macro
Kenichi Handa <handa@m17n.org>
parents:
88669
diff
changeset
|
3712 if ((CODING_ISO_FLAGS (coding) & CODING_ISO_FLAG_USE_OLDJIS) \ |
|
2cdfbffa8a0d
(CODING_ISO_FLAG_USE_ROMAN): New macro
Kenichi Handa <handa@m17n.org>
parents:
88669
diff
changeset
|
3713 && id == charset_jisx0208) \ |
|
2cdfbffa8a0d
(CODING_ISO_FLAG_USE_ROMAN): New macro
Kenichi Handa <handa@m17n.org>
parents:
88669
diff
changeset
|
3714 { \ |
|
2cdfbffa8a0d
(CODING_ISO_FLAG_USE_ROMAN): New macro
Kenichi Handa <handa@m17n.org>
parents:
88669
diff
changeset
|
3715 id = charset_jisx0208_1978; \ |
|
2cdfbffa8a0d
(CODING_ISO_FLAG_USE_ROMAN): New macro
Kenichi Handa <handa@m17n.org>
parents:
88669
diff
changeset
|
3716 charset = CHARSET_FROM_ID (id); \ |
|
2cdfbffa8a0d
(CODING_ISO_FLAG_USE_ROMAN): New macro
Kenichi Handa <handa@m17n.org>
parents:
88669
diff
changeset
|
3717 } \ |
|
2cdfbffa8a0d
(CODING_ISO_FLAG_USE_ROMAN): New macro
Kenichi Handa <handa@m17n.org>
parents:
88669
diff
changeset
|
3718 \ |
| 88365 | 3719 if (CODING_ISO_SINGLE_SHIFTING (coding)) \ |
| 3720 { \ | |
| 3721 if (CODING_ISO_FLAGS (coding) & CODING_ISO_FLAG_SEVEN_BITS) \ | |
| 3722 EMIT_TWO_ASCII_BYTES ((c1) & 0x7F, (c2) & 0x7F); \ | |
| 3723 else \ | |
| 3724 EMIT_TWO_BYTES ((c1) | 0x80, (c2) | 0x80); \ | |
| 3725 CODING_ISO_SINGLE_SHIFTING (coding) = 0; \ | |
| 3726 break; \ | |
| 3727 } \ | |
| 3728 else if (id == CODING_ISO_INVOKED_CHARSET (coding, 0)) \ | |
| 3729 { \ | |
| 3730 EMIT_TWO_ASCII_BYTES ((c1) & 0x7F, (c2) & 0x7F); \ | |
| 3731 break; \ | |
| 3732 } \ | |
| 3733 else if (id == CODING_ISO_INVOKED_CHARSET (coding, 1)) \ | |
| 3734 { \ | |
| 3735 EMIT_TWO_BYTES ((c1) | 0x80, (c2) | 0x80); \ | |
| 3736 break; \ | |
| 3737 } \ | |
| 3738 else \ | |
| 3739 /* Since CHARSET is not yet invoked to any graphic planes, we \ | |
| 3740 must invoke it, or, at first, designate it to some graphic \ | |
| 3741 register. Then repeat the loop to actually produce the \ | |
| 3742 character. */ \ | |
| 3743 dst = encode_invocation_designation (charset, coding, dst, \ | |
| 3744 &produced_chars); \ | |
| 3745 } while (1) | |
| 3746 | |
| 3747 | |
| 3748 #define ENCODE_ISO_CHARACTER(charset, c) \ | |
| 3749 do { \ | |
| 3750 int code = ENCODE_CHAR ((charset),(c)); \ | |
| 3751 \ | |
| 3752 if (CHARSET_DIMENSION (charset) == 1) \ | |
| 3753 ENCODE_ISO_CHARACTER_DIMENSION1 ((charset), code); \ | |
| 3754 else \ | |
| 3755 ENCODE_ISO_CHARACTER_DIMENSION2 ((charset), code >> 8, code & 0xFF); \ | |
|
22119
592bb8b9bcfd
Change terms unify/unification to
Kenichi Handa <handa@m17n.org>
parents:
22020
diff
changeset
|
3756 } while (0) |
|
17725
92f042f73be2
(Valternate_charset_table): The valiable deleted.
Kenichi Handa <handa@m17n.org>
parents:
17717
diff
changeset
|
3757 |
|
30487
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
3758 |
| 17052 | 3759 /* Produce designation and invocation codes at a place pointed by DST |
| 88365 | 3760 to use CHARSET. The element `spec.iso_2022' of *CODING is updated. |
| 17052 | 3761 Return new DST. */ |
| 3762 | |
| 3763 unsigned char * | |
| 88365 | 3764 encode_invocation_designation (charset, coding, dst, p_nchars) |
| 3765 struct charset *charset; | |
| 17052 | 3766 struct coding_system *coding; |
| 3767 unsigned char *dst; | |
| 88365 | 3768 int *p_nchars; |
| 17052 | 3769 { |
| 88365 | 3770 int multibytep = coding->dst_multibyte; |
| 3771 int produced_chars = *p_nchars; | |
| 17052 | 3772 int reg; /* graphic register number */ |
| 88365 | 3773 int id = CHARSET_ID (charset); |
| 17052 | 3774 |
| 3775 /* At first, check designations. */ | |
| 3776 for (reg = 0; reg < 4; reg++) | |
| 88365 | 3777 if (id == CODING_ISO_DESIGNATION (coding, reg)) |
| 17052 | 3778 break; |
| 3779 | |
| 3780 if (reg >= 4) | |
| 3781 { | |
| 3782 /* CHARSET is not yet designated to any graphic registers. */ | |
| 3783 /* At first check the requested designation. */ | |
| 88365 | 3784 reg = CODING_ISO_REQUEST (coding, id); |
| 3785 if (reg < 0) | |
|
18002
a14261786239
(encode_invocation_designation): Use macro
Kenichi Handa <handa@m17n.org>
parents:
17835
diff
changeset
|
3786 /* Since CHARSET requests no special designation, designate it |
|
a14261786239
(encode_invocation_designation): Use macro
Kenichi Handa <handa@m17n.org>
parents:
17835
diff
changeset
|
3787 to graphic register 0. */ |
| 17052 | 3788 reg = 0; |
| 3789 | |
| 3790 ENCODE_DESIGNATION (charset, reg, coding); | |
| 3791 } | |
| 3792 | |
| 88365 | 3793 if (CODING_ISO_INVOCATION (coding, 0) != reg |
| 3794 && CODING_ISO_INVOCATION (coding, 1) != reg) | |
| 17052 | 3795 { |
| 3796 /* Since the graphic register REG is not invoked to any graphic | |
| 3797 planes, invoke it to graphic plane 0. */ | |
| 3798 switch (reg) | |
| 3799 { | |
| 3800 case 0: /* graphic register 0 */ | |
| 3801 ENCODE_SHIFT_IN; | |
| 3802 break; | |
| 3803 | |
| 3804 case 1: /* graphic register 1 */ | |
| 3805 ENCODE_SHIFT_OUT; | |
| 3806 break; | |
| 3807 | |
| 3808 case 2: /* graphic register 2 */ | |
| 88365 | 3809 if (CODING_ISO_FLAGS (coding) & CODING_ISO_FLAG_SINGLE_SHIFT) |
| 17052 | 3810 ENCODE_SINGLE_SHIFT_2; |
| 3811 else | |
| 3812 ENCODE_LOCKING_SHIFT_2; | |
| 3813 break; | |
| 3814 | |
| 3815 case 3: /* graphic register 3 */ | |
| 88365 | 3816 if (CODING_ISO_FLAGS (coding) & CODING_ISO_FLAG_SINGLE_SHIFT) |
| 17052 | 3817 ENCODE_SINGLE_SHIFT_3; |
| 3818 else | |
| 3819 ENCODE_LOCKING_SHIFT_3; | |
| 3820 break; | |
| 3821 } | |
| 3822 } | |
|
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3823 |
| 88365 | 3824 *p_nchars = produced_chars; |
| 17052 | 3825 return dst; |
| 3826 } | |
| 3827 | |
| 3828 /* The following three macros produce codes for indicating direction | |
| 3829 of text. */ | |
| 88365 | 3830 #define ENCODE_CONTROL_SEQUENCE_INTRODUCER \ |
| 3831 do { \ | |
| 3832 if (CODING_ISO_FLAGS (coding) == CODING_ISO_FLAG_SEVEN_BITS) \ | |
| 3833 EMIT_TWO_ASCII_BYTES (ISO_CODE_ESC, '['); \ | |
| 3834 else \ | |
| 3835 EMIT_ONE_BYTE (ISO_CODE_CSI); \ | |
| 17052 | 3836 } while (0) |
| 3837 | |
| 88365 | 3838 |
| 3839 #define ENCODE_DIRECTION_R2L() \ | |
| 3840 do { \ | |
| 3841 ENCODE_CONTROL_SEQUENCE_INTRODUCER (dst); \ | |
| 3842 EMIT_TWO_ASCII_BYTES ('2', ']'); \ | |
| 3843 } while (0) | |
| 3844 | |
| 3845 | |
| 3846 #define ENCODE_DIRECTION_L2R() \ | |
| 3847 do { \ | |
| 3848 ENCODE_CONTROL_SEQUENCE_INTRODUCER (dst); \ | |
| 3849 EMIT_TWO_ASCII_BYTES ('0', ']'); \ | |
| 3850 } while (0) | |
| 3851 | |
| 17052 | 3852 |
| 3853 /* Produce codes for designation and invocation to reset the graphic | |
| 3854 planes and registers to initial state. */ | |
| 88365 | 3855 #define ENCODE_RESET_PLANE_AND_REGISTER() \ |
| 3856 do { \ | |
| 3857 int reg; \ | |
| 3858 struct charset *charset; \ | |
| 3859 \ | |
| 3860 if (CODING_ISO_INVOCATION (coding, 0) != 0) \ | |
| 3861 ENCODE_SHIFT_IN; \ | |
| 3862 for (reg = 0; reg < 4; reg++) \ | |
| 3863 if (CODING_ISO_INITIAL (coding, reg) >= 0 \ | |
| 3864 && (CODING_ISO_DESIGNATION (coding, reg) \ | |
| 3865 != CODING_ISO_INITIAL (coding, reg))) \ | |
| 3866 { \ | |
| 3867 charset = CHARSET_FROM_ID (CODING_ISO_INITIAL (coding, reg)); \ | |
| 3868 ENCODE_DESIGNATION (charset, reg, coding); \ | |
| 3869 } \ | |
| 17052 | 3870 } while (0) |
| 3871 | |
| 88365 | 3872 |
|
17725
92f042f73be2
(Valternate_charset_table): The valiable deleted.
Kenichi Handa <handa@m17n.org>
parents:
17717
diff
changeset
|
3873 /* 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
|
3874 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
|
3875 |
|
92f042f73be2
(Valternate_charset_table): The valiable deleted.
Kenichi Handa <handa@m17n.org>
parents:
17717
diff
changeset
|
3876 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
|
3877 find all the necessary designations. */ |
|
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3878 |
|
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3879 static unsigned char * |
| 88365 | 3880 encode_designation_at_bol (coding, charbuf, charbuf_end, dst) |
|
17119
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
3881 struct coding_system *coding; |
| 88365 | 3882 int *charbuf, *charbuf_end; |
|
59168
0345f2b10f1d
(decode_coding_XXX, decode_composition_emacs_mule)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
59095
diff
changeset
|
3883 unsigned char *dst; |
|
17119
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
3884 { |
| 88365 | 3885 struct charset *charset; |
|
17725
92f042f73be2
(Valternate_charset_table): The valiable deleted.
Kenichi Handa <handa@m17n.org>
parents:
17717
diff
changeset
|
3886 /* 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
|
3887 int r[4]; |
| 88365 | 3888 int c, found = 0, reg; |
| 3889 int produced_chars = 0; | |
| 3890 int multibytep = coding->dst_multibyte; | |
| 3891 Lisp_Object attrs; | |
| 3892 Lisp_Object charset_list; | |
| 3893 | |
| 3894 attrs = CODING_ID_ATTRS (coding->id); | |
| 3895 charset_list = CODING_ATTR_CHARSET_LIST (attrs); | |
| 3896 if (EQ (charset_list, Qiso_2022)) | |
| 3897 charset_list = Viso_2022_charset_list; | |
|
17725
92f042f73be2
(Valternate_charset_table): The valiable deleted.
Kenichi Handa <handa@m17n.org>
parents:
17717
diff
changeset
|
3898 |
|
92f042f73be2
(Valternate_charset_table): The valiable deleted.
Kenichi Handa <handa@m17n.org>
parents:
17717
diff
changeset
|
3899 for (reg = 0; reg < 4; reg++) |
|
92f042f73be2
(Valternate_charset_table): The valiable deleted.
Kenichi Handa <handa@m17n.org>
parents:
17717
diff
changeset
|
3900 r[reg] = -1; |
|
92f042f73be2
(Valternate_charset_table): The valiable deleted.
Kenichi Handa <handa@m17n.org>
parents:
17717
diff
changeset
|
3901 |
|
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3902 while (found < 4) |
|
17119
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
3903 { |
| 88365 | 3904 int id; |
| 3905 | |
| 3906 c = *charbuf++; | |
|
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3907 if (c == '\n') |
|
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3908 break; |
| 88365 | 3909 charset = char_charset (c, charset_list, NULL); |
| 3910 id = CHARSET_ID (charset); | |
| 3911 reg = CODING_ISO_REQUEST (coding, id); | |
| 3912 if (reg >= 0 && r[reg] < 0) | |
|
17725
92f042f73be2
(Valternate_charset_table): The valiable deleted.
Kenichi Handa <handa@m17n.org>
parents:
17717
diff
changeset
|
3913 { |
|
92f042f73be2
(Valternate_charset_table): The valiable deleted.
Kenichi Handa <handa@m17n.org>
parents:
17717
diff
changeset
|
3914 found++; |
| 88365 | 3915 r[reg] = id; |
|
17119
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
3916 } |
|
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
3917 } |
|
17725
92f042f73be2
(Valternate_charset_table): The valiable deleted.
Kenichi Handa <handa@m17n.org>
parents:
17717
diff
changeset
|
3918 |
|
92f042f73be2
(Valternate_charset_table): The valiable deleted.
Kenichi Handa <handa@m17n.org>
parents:
17717
diff
changeset
|
3919 if (found) |
|
92f042f73be2
(Valternate_charset_table): The valiable deleted.
Kenichi Handa <handa@m17n.org>
parents:
17717
diff
changeset
|
3920 { |
|
92f042f73be2
(Valternate_charset_table): The valiable deleted.
Kenichi Handa <handa@m17n.org>
parents:
17717
diff
changeset
|
3921 for (reg = 0; reg < 4; reg++) |
|
92f042f73be2
(Valternate_charset_table): The valiable deleted.
Kenichi Handa <handa@m17n.org>
parents:
17717
diff
changeset
|
3922 if (r[reg] >= 0 |
| 88365 | 3923 && CODING_ISO_DESIGNATION (coding, reg) != r[reg]) |
| 3924 ENCODE_DESIGNATION (CHARSET_FROM_ID (r[reg]), reg, coding); | |
|
17725
92f042f73be2
(Valternate_charset_table): The valiable deleted.
Kenichi Handa <handa@m17n.org>
parents:
17717
diff
changeset
|
3925 } |
|
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3926 |
|
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3927 return dst; |
|
17119
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
3928 } |
|
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
3929 |
| 17052 | 3930 /* See the above "GENERAL NOTES on `encode_coding_XXX ()' functions". */ |
| 3931 | |
| 88365 | 3932 static int |
| 3933 encode_coding_iso_2022 (coding) | |
| 17052 | 3934 struct coding_system *coding; |
| 3935 { | |
| 88365 | 3936 int multibytep = coding->dst_multibyte; |
| 3937 int *charbuf = coding->charbuf; | |
| 3938 int *charbuf_end = charbuf + coding->charbuf_used; | |
| 3939 unsigned char *dst = coding->destination + coding->produced; | |
| 3940 unsigned char *dst_end = coding->destination + coding->dst_bytes; | |
| 3941 int safe_room = 16; | |
| 3942 int bol_designation | |
| 3943 = (CODING_ISO_FLAGS (coding) & CODING_ISO_FLAG_DESIGNATE_AT_BOL | |
| 3944 && CODING_ISO_BOL (coding)); | |
| 3945 int produced_chars = 0; | |
| 3946 Lisp_Object attrs, eol_type, charset_list; | |
| 3947 int ascii_compatible; | |
|
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3948 int c; |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3949 int preferred_charset_id = -1; |
| 88365 | 3950 |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
3951 CODING_GET_INFO (coding, attrs, charset_list); |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
3952 eol_type = CODING_ID_EOL_TYPE (coding->id); |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
3953 if (VECTORP (eol_type)) |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
3954 eol_type = Qunix; |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
3955 |
|
88497
d2b9e0d4c2f6
(Fdecode_sjis_char): Fix typo (0x7F->0xFF). Fix the
Kenichi Handa <handa@m17n.org>
parents:
88485
diff
changeset
|
3956 setup_iso_safe_charsets (attrs); |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3957 /* Charset list may have been changed. */ |
|
90772
b15334b4a9c3
(coding_alloc_by_making_gap): New arg offset.
Kenichi Handa <handa@m17n.org>
parents:
90737
diff
changeset
|
3958 charset_list = CODING_ATTR_CHARSET_LIST (attrs); |
| 89483 | 3959 coding->safe_charsets = (char *) SDATA (CODING_ATTR_SAFE_CHARSETS(attrs)); |
| 88365 | 3960 |
| 3961 ascii_compatible = ! NILP (CODING_ATTR_ASCII_COMPAT (attrs)); | |
| 3962 | |
| 3963 while (charbuf < charbuf_end) | |
| 3964 { | |
| 3965 ASSURE_DESTINATION (safe_room); | |
| 3966 | |
| 3967 if (bol_designation) | |
|
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3968 { |
| 88365 | 3969 unsigned char *dst_prev = dst; |
| 3970 | |
|
17725
92f042f73be2
(Valternate_charset_table): The valiable deleted.
Kenichi Handa <handa@m17n.org>
parents:
17717
diff
changeset
|
3971 /* We have to produce designation sequences if any now. */ |
| 88365 | 3972 dst = encode_designation_at_bol (coding, charbuf, charbuf_end, dst); |
| 3973 bol_designation = 0; | |
| 3974 /* We are sure that designation sequences are all ASCII bytes. */ | |
| 3975 produced_chars += dst - dst_prev; | |
|
17119
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
3976 } |
|
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
3977 |
| 88365 | 3978 c = *charbuf++; |
|
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3979 |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3980 if (c < 0) |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3981 { |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3982 /* Handle an annotation. */ |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3983 switch (*charbuf) |
| 17052 | 3984 { |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3985 case CODING_ANNOTATE_COMPOSITION_MASK: |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3986 /* Not yet implemented. */ |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3987 break; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3988 case CODING_ANNOTATE_CHARSET_MASK: |
|
90014
ade0c9a12f99
(encode_coding_iso_2022): Fix handling of charset
Kenichi Handa <handa@m17n.org>
parents:
90011
diff
changeset
|
3989 preferred_charset_id = charbuf[2]; |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3990 if (preferred_charset_id >= 0 |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3991 && NILP (Fmemq (make_number (preferred_charset_id), |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3992 charset_list))) |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3993 preferred_charset_id = -1; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3994 break; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3995 default: |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3996 abort (); |
| 26847 | 3997 } |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3998 charbuf += -c - 1; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3999 continue; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
4000 } |
|
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4001 |
|
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4002 /* 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
|
4003 if (c < 0x20 || c == 0x7F) |
| 17052 | 4004 { |
| 88365 | 4005 if (c == '\n' |
| 4006 || (c == '\r' && EQ (eol_type, Qmac))) | |
|
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4007 { |
| 88365 | 4008 if (CODING_ISO_FLAGS (coding) & CODING_ISO_FLAG_RESET_AT_EOL) |
| 4009 ENCODE_RESET_PLANE_AND_REGISTER (); | |
| 4010 if (CODING_ISO_FLAGS (coding) & CODING_ISO_FLAG_INIT_AT_BOL) | |
| 4011 { | |
| 4012 int i; | |
| 4013 | |
| 4014 for (i = 0; i < 4; i++) | |
| 4015 CODING_ISO_DESIGNATION (coding, i) | |
| 4016 = CODING_ISO_INITIAL (coding, i); | |
| 4017 } | |
| 4018 bol_designation | |
| 4019 = CODING_ISO_FLAGS (coding) & CODING_ISO_FLAG_DESIGNATE_AT_BOL; | |
|
19052
302a7b2a6948
(encode_coding_iso2022): Write out invalid multibyte
Kenichi Handa <handa@m17n.org>
parents:
18910
diff
changeset
|
4020 } |
| 88365 | 4021 else if (CODING_ISO_FLAGS (coding) & CODING_ISO_FLAG_RESET_AT_CNTL) |
| 4022 ENCODE_RESET_PLANE_AND_REGISTER (); | |
| 4023 EMIT_ONE_ASCII_BYTE (c); | |
|
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4024 } |
| 88365 | 4025 else if (ASCII_CHAR_P (c)) |
|
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4026 { |
| 88365 | 4027 if (ascii_compatible) |
| 4028 EMIT_ONE_ASCII_BYTE (c); | |
| 4029 else | |
|
88681
2cdfbffa8a0d
(CODING_ISO_FLAG_USE_ROMAN): New macro
Kenichi Handa <handa@m17n.org>
parents:
88669
diff
changeset
|
4030 { |
|
2cdfbffa8a0d
(CODING_ISO_FLAG_USE_ROMAN): New macro
Kenichi Handa <handa@m17n.org>
parents:
88669
diff
changeset
|
4031 struct charset *charset = CHARSET_FROM_ID (charset_ascii); |
|
2cdfbffa8a0d
(CODING_ISO_FLAG_USE_ROMAN): New macro
Kenichi Handa <handa@m17n.org>
parents:
88669
diff
changeset
|
4032 ENCODE_ISO_CHARACTER (charset, c); |
|
2cdfbffa8a0d
(CODING_ISO_FLAG_USE_ROMAN): New macro
Kenichi Handa <handa@m17n.org>
parents:
88669
diff
changeset
|
4033 } |
| 17052 | 4034 } |
|
88690
7f284ac55b07
(encode_coding_emacs_mule): Pay attention to raw-8-bit chars.
Kenichi Handa <handa@m17n.org>
parents:
88681
diff
changeset
|
4035 else if (CHAR_BYTE8_P (c)) |
|
7f284ac55b07
(encode_coding_emacs_mule): Pay attention to raw-8-bit chars.
Kenichi Handa <handa@m17n.org>
parents:
88681
diff
changeset
|
4036 { |
|
7f284ac55b07
(encode_coding_emacs_mule): Pay attention to raw-8-bit chars.
Kenichi Handa <handa@m17n.org>
parents:
88681
diff
changeset
|
4037 c = CHAR_TO_BYTE8 (c); |
|
7f284ac55b07
(encode_coding_emacs_mule): Pay attention to raw-8-bit chars.
Kenichi Handa <handa@m17n.org>
parents:
88681
diff
changeset
|
4038 EMIT_ONE_BYTE (c); |
|
7f284ac55b07
(encode_coding_emacs_mule): Pay attention to raw-8-bit chars.
Kenichi Handa <handa@m17n.org>
parents:
88681
diff
changeset
|
4039 } |
|
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4040 else |
| 88365 | 4041 { |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
4042 struct charset *charset; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
4043 |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
4044 if (preferred_charset_id >= 0) |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
4045 { |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
4046 charset = CHARSET_FROM_ID (preferred_charset_id); |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
4047 if (! CHAR_CHARSET_P (c, charset)) |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
4048 charset = char_charset (c, charset_list, NULL); |
|
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4049 } |
|
42104
d69c2368e549
(DECODE_COMPOSITION_END): Fixed a typo in the last
Sam Steingold <sds@gnu.org>
parents:
42103
diff
changeset
|
4050 else |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
4051 charset = char_charset (c, charset_list, NULL); |
| 88365 | 4052 if (!charset) |
| 17052 | 4053 { |
|
88573
133bf7ab1bad
(encode_coding_iso_2022): If coding requires safe
Kenichi Handa <handa@m17n.org>
parents:
88544
diff
changeset
|
4054 if (coding->mode & CODING_MODE_SAFE_ENCODING) |
|
133bf7ab1bad
(encode_coding_iso_2022): If coding requires safe
Kenichi Handa <handa@m17n.org>
parents:
88544
diff
changeset
|
4055 { |
|
133bf7ab1bad
(encode_coding_iso_2022): If coding requires safe
Kenichi Handa <handa@m17n.org>
parents:
88544
diff
changeset
|
4056 c = CODING_INHIBIT_CHARACTER_SUBSTITUTION; |
|
133bf7ab1bad
(encode_coding_iso_2022): If coding requires safe
Kenichi Handa <handa@m17n.org>
parents:
88544
diff
changeset
|
4057 charset = CHARSET_FROM_ID (charset_ascii); |
|
133bf7ab1bad
(encode_coding_iso_2022): If coding requires safe
Kenichi Handa <handa@m17n.org>
parents:
88544
diff
changeset
|
4058 } |
|
133bf7ab1bad
(encode_coding_iso_2022): If coding requires safe
Kenichi Handa <handa@m17n.org>
parents:
88544
diff
changeset
|
4059 else |
|
133bf7ab1bad
(encode_coding_iso_2022): If coding requires safe
Kenichi Handa <handa@m17n.org>
parents:
88544
diff
changeset
|
4060 { |
|
133bf7ab1bad
(encode_coding_iso_2022): If coding requires safe
Kenichi Handa <handa@m17n.org>
parents:
88544
diff
changeset
|
4061 c = coding->default_char; |
|
133bf7ab1bad
(encode_coding_iso_2022): If coding requires safe
Kenichi Handa <handa@m17n.org>
parents:
88544
diff
changeset
|
4062 charset = char_charset (c, charset_list, NULL); |
|
133bf7ab1bad
(encode_coding_iso_2022): If coding requires safe
Kenichi Handa <handa@m17n.org>
parents:
88544
diff
changeset
|
4063 } |
|
19052
302a7b2a6948
(encode_coding_iso2022): Write out invalid multibyte
Kenichi Handa <handa@m17n.org>
parents:
18910
diff
changeset
|
4064 } |
| 88365 | 4065 ENCODE_ISO_CHARACTER (charset, c); |
| 4066 } | |
| 4067 } | |
| 4068 | |
| 4069 if (coding->mode & CODING_MODE_LAST_BLOCK | |
| 4070 && CODING_ISO_FLAGS (coding) & CODING_ISO_FLAG_RESET_AT_EOL) | |
| 4071 { | |
| 4072 ASSURE_DESTINATION (safe_room); | |
| 4073 ENCODE_RESET_PLANE_AND_REGISTER (); | |
| 4074 } | |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
4075 record_conversion_result (coding, CODING_RESULT_SUCCESS); |
| 88365 | 4076 CODING_ISO_BOL (coding) = bol_designation; |
| 4077 coding->produced_char += produced_chars; | |
| 4078 coding->produced = dst - coding->destination; | |
| 4079 return 0; | |
| 17052 | 4080 } |
| 4081 | |
| 4082 | |
| 88365 | 4083 /*** 8,9. SJIS and BIG5 handlers ***/ |
| 4084 | |
| 4085 /* Although SJIS and BIG5 are not ISO's coding system, they are used | |
| 17052 | 4086 quite widely. So, for the moment, Emacs supports them in the bare |
| 4087 C code. But, in the future, they may be supported only by CCL. */ | |
| 4088 | |
| 4089 /* SJIS is a coding system encoding three character sets: ASCII, right | |
| 4090 half of JISX0201-Kana, and JISX0208. An ASCII character is encoded | |
| 4091 as is. A character of charset katakana-jisx0201 is encoded by | |
| 4092 "position-code + 0x80". A character of charset japanese-jisx0208 | |
| 4093 is encoded in 2-byte but two position-codes are divided and shifted | |
| 88365 | 4094 so that it fit in the range below. |
| 17052 | 4095 |
| 4096 --- CODE RANGE of SJIS --- | |
| 4097 (character set) (range) | |
| 4098 ASCII 0x00 .. 0x7F | |
| 88365 | 4099 KATAKANA-JISX0201 0xA0 .. 0xDF |
|
24324
2eec590faf26
(Fdecode_sjis_char, Fencode_sjis_char): Hanlde
Kenichi Handa <handa@m17n.org>
parents:
24316
diff
changeset
|
4100 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
|
4101 (2nd byte) 0x40 .. 0x7E and 0x80 .. 0xFC |
| 17052 | 4102 ------------------------------- |
| 4103 | |
| 4104 */ | |
| 4105 | |
| 4106 /* BIG5 is a coding system encoding two character sets: ASCII and | |
| 4107 Big5. An ASCII character is encoded as is. Big5 is a two-byte | |
| 88365 | 4108 character set and is encoded in two-byte. |
| 17052 | 4109 |
| 4110 --- CODE RANGE of BIG5 --- | |
| 4111 (character set) (range) | |
| 4112 ASCII 0x00 .. 0x7F | |
| 4113 Big5 (1st byte) 0xA1 .. 0xFE | |
| 4114 (2nd byte) 0x40 .. 0x7E and 0xA1 .. 0xFE | |
| 4115 -------------------------- | |
| 4116 | |
| 88365 | 4117 */ |
| 17052 | 4118 |
| 4119 /* See the above "GENERAL NOTES on `detect_coding_XXX ()' functions". | |
| 4120 Check if a text is encoded in SJIS. If it is, return | |
| 88365 | 4121 CATEGORY_MASK_SJIS, else return 0. */ |
| 17052 | 4122 |
|
34531
37f85e931855
(ONE_MORE_BYTE_CHECK_MULTIBYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34197
diff
changeset
|
4123 static int |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
4124 detect_coding_sjis (coding, detect_info) |
| 88365 | 4125 struct coding_system *coding; |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
4126 struct coding_detection_info *detect_info; |
| 17052 | 4127 { |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
4128 const unsigned char *src = coding->source, *src_base; |
| 89483 | 4129 const unsigned char *src_end = coding->source + coding->src_bytes; |
| 88365 | 4130 int multibytep = coding->src_multibyte; |
| 4131 int consumed_chars = 0; | |
| 4132 int found = 0; | |
|
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4133 int c; |
| 88365 | 4134 |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
4135 detect_info->checked |= CATEGORY_MASK_SJIS; |
| 88365 | 4136 /* A coding system of this category is always ASCII compatible. */ |
| 4137 src += coding->head_ascii; | |
|
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4138 |
|
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4139 while (1) |
| 17052 | 4140 { |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
4141 src_base = src; |
| 88365 | 4142 ONE_MORE_BYTE (c); |
|
36647
0a75ccbe42b2
(detect_coding_sjis): Do more rigid check.
Kenichi Handa <handa@m17n.org>
parents:
36520
diff
changeset
|
4143 if (c < 0x80) |
|
0a75ccbe42b2
(detect_coding_sjis): Do more rigid check.
Kenichi Handa <handa@m17n.org>
parents:
36520
diff
changeset
|
4144 continue; |
| 88365 | 4145 if ((c >= 0x81 && c <= 0x9F) || (c >= 0xE0 && c <= 0xEF)) |
| 17052 | 4146 { |
| 88365 | 4147 ONE_MORE_BYTE (c); |
|
36647
0a75ccbe42b2
(detect_coding_sjis): Do more rigid check.
Kenichi Handa <handa@m17n.org>
parents:
36520
diff
changeset
|
4148 if (c < 0x40 || c == 0x7F || c > 0xFC) |
| 88365 | 4149 break; |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
4150 found = CATEGORY_MASK_SJIS; |
| 17052 | 4151 } |
| 88365 | 4152 else if (c >= 0xA0 && c < 0xE0) |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
4153 found = CATEGORY_MASK_SJIS; |
| 88365 | 4154 else |
| 4155 break; | |
| 4156 } | |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
4157 detect_info->rejected |= CATEGORY_MASK_SJIS; |
| 88365 | 4158 return 0; |
| 4159 | |
| 4160 no_more_source: | |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
4161 if (src_base < src && coding->mode & CODING_MODE_LAST_BLOCK) |
|
89193
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
4162 { |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
4163 detect_info->rejected |= CATEGORY_MASK_SJIS; |
|
89193
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
4164 return 0; |
|
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
4165 } |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
4166 detect_info->found |= found; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
4167 return 1; |
| 17052 | 4168 } |
| 4169 | |
| 4170 /* See the above "GENERAL NOTES on `detect_coding_XXX ()' functions". | |
| 4171 Check if a text is encoded in BIG5. If it is, return | |
| 88365 | 4172 CATEGORY_MASK_BIG5, else return 0. */ |
| 17052 | 4173 |
|
34531
37f85e931855
(ONE_MORE_BYTE_CHECK_MULTIBYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34197
diff
changeset
|
4174 static int |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
4175 detect_coding_big5 (coding, detect_info) |
| 88365 | 4176 struct coding_system *coding; |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
4177 struct coding_detection_info *detect_info; |
| 17052 | 4178 { |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
4179 const unsigned char *src = coding->source, *src_base; |
| 89483 | 4180 const unsigned char *src_end = coding->source + coding->src_bytes; |
| 88365 | 4181 int multibytep = coding->src_multibyte; |
| 4182 int consumed_chars = 0; | |
| 4183 int found = 0; | |
|
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4184 int c; |
| 88365 | 4185 |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
4186 detect_info->checked |= CATEGORY_MASK_BIG5; |
| 88365 | 4187 /* A coding system of this category is always ASCII compatible. */ |
| 4188 src += coding->head_ascii; | |
|
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4189 |
|
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4190 while (1) |
|
28022
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
4191 { |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
4192 src_base = src; |
| 88365 | 4193 ONE_MORE_BYTE (c); |
| 4194 if (c < 0x80) | |
|
28022
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
4195 continue; |
| 88365 | 4196 if (c >= 0xA1) |
|
28022
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
4197 { |
| 88365 | 4198 ONE_MORE_BYTE (c); |
| 4199 if (c < 0x40 || (c >= 0x7F && c <= 0xA0)) | |
|
28022
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
4200 return 0; |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
4201 found = CATEGORY_MASK_BIG5; |
|
28022
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
4202 } |
| 88365 | 4203 else |
| 4204 break; | |
| 4205 } | |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
4206 detect_info->rejected |= CATEGORY_MASK_BIG5; |
|
28022
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
4207 return 0; |
| 88365 | 4208 |
| 4209 no_more_source: | |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
4210 if (src_base < src && coding->mode & CODING_MODE_LAST_BLOCK) |
|
89193
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
4211 { |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
4212 detect_info->rejected |= CATEGORY_MASK_BIG5; |
|
89193
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
4213 return 0; |
|
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
4214 } |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
4215 detect_info->found |= found; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
4216 return 1; |
|
28022
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
4217 } |
|
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
4218 |
| 17052 | 4219 /* See the above "GENERAL NOTES on `decode_coding_XXX ()' functions". |
| 4220 If SJIS_P is 1, decode SJIS text, else decode BIG5 test. */ | |
| 4221 | |
|
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4222 static void |
| 88365 | 4223 decode_coding_sjis (coding) |
| 17052 | 4224 struct coding_system *coding; |
| 4225 { | |
| 89483 | 4226 const unsigned char *src = coding->source + coding->consumed; |
| 4227 const unsigned char *src_end = coding->source + coding->src_bytes; | |
|
59168
0345f2b10f1d
(decode_coding_XXX, decode_composition_emacs_mule)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
59095
diff
changeset
|
4228 const unsigned char *src_base; |
|
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
4229 int *charbuf = coding->charbuf + coding->charbuf_used; |
|
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
4230 int *charbuf_end |
|
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
4231 = coding->charbuf + coding->charbuf_size - MAX_ANNOTATION_LENGTH; |
| 88365 | 4232 int consumed_chars = 0, consumed_chars_base; |
| 4233 int multibytep = coding->src_multibyte; | |
| 4234 struct charset *charset_roman, *charset_kanji, *charset_kana; | |
|
89764
e3d26232ab78
(decode_coding_sjis): Handle 4th charset (typically JISX0212).
Kenichi Handa <handa@m17n.org>
parents:
89759
diff
changeset
|
4235 struct charset *charset_kanji2; |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4236 Lisp_Object attrs, charset_list, val; |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
4237 int char_offset = coding->produced_char; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
4238 int last_offset = char_offset; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
4239 int last_id = charset_ascii; |
|
92399
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
4240 int eol_crlf = EQ (CODING_ID_EOL_TYPE (coding->id), Qdos); |
|
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
4241 int byte_after_cr = -1; |
| 88365 | 4242 |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4243 CODING_GET_INFO (coding, attrs, charset_list); |
| 88365 | 4244 |
| 4245 val = charset_list; | |
| 4246 charset_roman = CHARSET_FROM_ID (XINT (XCAR (val))), val = XCDR (val); | |
|
89193
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
4247 charset_kana = CHARSET_FROM_ID (XINT (XCAR (val))), val = XCDR (val); |
|
89764
e3d26232ab78
(decode_coding_sjis): Handle 4th charset (typically JISX0212).
Kenichi Handa <handa@m17n.org>
parents:
89759
diff
changeset
|
4248 charset_kanji = CHARSET_FROM_ID (XINT (XCAR (val))), val = XCDR (val); |
|
e3d26232ab78
(decode_coding_sjis): Handle 4th charset (typically JISX0212).
Kenichi Handa <handa@m17n.org>
parents:
89759
diff
changeset
|
4249 charset_kanji2 = NILP (val) ? NULL : CHARSET_FROM_ID (XINT (XCAR (val))); |
| 88365 | 4250 |
|
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4251 while (1) |
| 17052 | 4252 { |
| 88365 | 4253 int c, c1; |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4254 struct charset *charset; |
|
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4255 |
|
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4256 src_base = src; |
| 88365 | 4257 consumed_chars_base = consumed_chars; |
| 4258 | |
| 4259 if (charbuf >= charbuf_end) | |
| 4260 break; | |
| 4261 | |
|
92399
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
4262 if (byte_after_cr >= 0) |
|
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
4263 c = byte_after_cr, byte_after_cr = -1; |
|
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
4264 else |
|
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
4265 ONE_MORE_BYTE (c); |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
4266 if (c < 0) |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
4267 goto invalid_code; |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4268 if (c < 0x80) |
|
92399
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
4269 { |
|
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
4270 if (eol_crlf && c == '\r') |
|
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
4271 ONE_MORE_BYTE (byte_after_cr); |
|
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
4272 charset = charset_roman; |
|
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
4273 } |
|
89764
e3d26232ab78
(decode_coding_sjis): Handle 4th charset (typically JISX0212).
Kenichi Handa <handa@m17n.org>
parents:
89759
diff
changeset
|
4274 else if (c == 0x80 || c == 0xA0) |
|
89730
d8fcefca5cf6
(decode_coding_sjis): Check the first byte rigidly.
Kenichi Handa <handa@m17n.org>
parents:
89686
diff
changeset
|
4275 goto invalid_code; |
|
89764
e3d26232ab78
(decode_coding_sjis): Handle 4th charset (typically JISX0212).
Kenichi Handa <handa@m17n.org>
parents:
89759
diff
changeset
|
4276 else if (c >= 0xA1 && c <= 0xDF) |
|
e3d26232ab78
(decode_coding_sjis): Handle 4th charset (typically JISX0212).
Kenichi Handa <handa@m17n.org>
parents:
89759
diff
changeset
|
4277 { |
|
e3d26232ab78
(decode_coding_sjis): Handle 4th charset (typically JISX0212).
Kenichi Handa <handa@m17n.org>
parents:
89759
diff
changeset
|
4278 /* SJIS -> JISX0201-Kana */ |
|
e3d26232ab78
(decode_coding_sjis): Handle 4th charset (typically JISX0212).
Kenichi Handa <handa@m17n.org>
parents:
89759
diff
changeset
|
4279 c &= 0x7F; |
|
e3d26232ab78
(decode_coding_sjis): Handle 4th charset (typically JISX0212).
Kenichi Handa <handa@m17n.org>
parents:
89759
diff
changeset
|
4280 charset = charset_kana; |
|
e3d26232ab78
(decode_coding_sjis): Handle 4th charset (typically JISX0212).
Kenichi Handa <handa@m17n.org>
parents:
89759
diff
changeset
|
4281 } |
|
e3d26232ab78
(decode_coding_sjis): Handle 4th charset (typically JISX0212).
Kenichi Handa <handa@m17n.org>
parents:
89759
diff
changeset
|
4282 else if (c <= 0xEF) |
|
e3d26232ab78
(decode_coding_sjis): Handle 4th charset (typically JISX0212).
Kenichi Handa <handa@m17n.org>
parents:
89759
diff
changeset
|
4283 { |
|
e3d26232ab78
(decode_coding_sjis): Handle 4th charset (typically JISX0212).
Kenichi Handa <handa@m17n.org>
parents:
89759
diff
changeset
|
4284 /* SJIS -> JISX0208 */ |
|
e3d26232ab78
(decode_coding_sjis): Handle 4th charset (typically JISX0212).
Kenichi Handa <handa@m17n.org>
parents:
89759
diff
changeset
|
4285 ONE_MORE_BYTE (c1); |
|
e3d26232ab78
(decode_coding_sjis): Handle 4th charset (typically JISX0212).
Kenichi Handa <handa@m17n.org>
parents:
89759
diff
changeset
|
4286 if (c1 < 0x40 || c1 == 0x7F || c1 > 0xFC) |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4287 goto invalid_code; |
|
89764
e3d26232ab78
(decode_coding_sjis): Handle 4th charset (typically JISX0212).
Kenichi Handa <handa@m17n.org>
parents:
89759
diff
changeset
|
4288 c = (c << 8) | c1; |
|
e3d26232ab78
(decode_coding_sjis): Handle 4th charset (typically JISX0212).
Kenichi Handa <handa@m17n.org>
parents:
89759
diff
changeset
|
4289 SJIS_TO_JIS (c); |
|
e3d26232ab78
(decode_coding_sjis): Handle 4th charset (typically JISX0212).
Kenichi Handa <handa@m17n.org>
parents:
89759
diff
changeset
|
4290 charset = charset_kanji; |
|
e3d26232ab78
(decode_coding_sjis): Handle 4th charset (typically JISX0212).
Kenichi Handa <handa@m17n.org>
parents:
89759
diff
changeset
|
4291 } |
|
e3d26232ab78
(decode_coding_sjis): Handle 4th charset (typically JISX0212).
Kenichi Handa <handa@m17n.org>
parents:
89759
diff
changeset
|
4292 else if (c <= 0xFC && charset_kanji2) |
|
e3d26232ab78
(decode_coding_sjis): Handle 4th charset (typically JISX0212).
Kenichi Handa <handa@m17n.org>
parents:
89759
diff
changeset
|
4293 { |
|
89779
74c503490829
(decode_coding_sjis): Fix comment.
Kenichi Handa <handa@m17n.org>
parents:
89764
diff
changeset
|
4294 /* SJIS -> JISX0213-2 */ |
|
89764
e3d26232ab78
(decode_coding_sjis): Handle 4th charset (typically JISX0212).
Kenichi Handa <handa@m17n.org>
parents:
89759
diff
changeset
|
4295 ONE_MORE_BYTE (c1); |
|
e3d26232ab78
(decode_coding_sjis): Handle 4th charset (typically JISX0212).
Kenichi Handa <handa@m17n.org>
parents:
89759
diff
changeset
|
4296 if (c1 < 0x40 || c1 == 0x7F || c1 > 0xFC) |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4297 goto invalid_code; |
|
89764
e3d26232ab78
(decode_coding_sjis): Handle 4th charset (typically JISX0212).
Kenichi Handa <handa@m17n.org>
parents:
89759
diff
changeset
|
4298 c = (c << 8) | c1; |
|
e3d26232ab78
(decode_coding_sjis): Handle 4th charset (typically JISX0212).
Kenichi Handa <handa@m17n.org>
parents:
89759
diff
changeset
|
4299 SJIS_TO_JIS2 (c); |
|
e3d26232ab78
(decode_coding_sjis): Handle 4th charset (typically JISX0212).
Kenichi Handa <handa@m17n.org>
parents:
89759
diff
changeset
|
4300 charset = charset_kanji2; |
| 17052 | 4301 } |
|
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4302 else |
|
89764
e3d26232ab78
(decode_coding_sjis): Handle 4th charset (typically JISX0212).
Kenichi Handa <handa@m17n.org>
parents:
89759
diff
changeset
|
4303 goto invalid_code; |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4304 if (charset->id != charset_ascii |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4305 && last_id != charset->id) |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4306 { |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4307 if (last_id != charset_ascii) |
|
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
4308 ADD_CHARSET_DATA (charbuf, char_offset - last_offset, last_id); |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4309 last_id = charset->id; |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4310 last_offset = char_offset; |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4311 } |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4312 CODING_DECODE_CHAR (coding, src, src_base, src_end, charset, c, c); |
| 88365 | 4313 *charbuf++ = c; |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
4314 char_offset++; |
|
20931
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
4315 continue; |
|
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
4316 |
| 88365 | 4317 invalid_code: |
| 17052 | 4318 src = src_base; |
| 88365 | 4319 consumed_chars = consumed_chars_base; |
| 4320 ONE_MORE_BYTE (c); | |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
4321 *charbuf++ = c < 0 ? -c : BYTE8_TO_CHAR (c); |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
4322 char_offset++; |
| 88365 | 4323 coding->errors++; |
| 4324 } | |
| 4325 | |
| 4326 no_more_source: | |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
4327 if (last_id != charset_ascii) |
|
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
4328 ADD_CHARSET_DATA (charbuf, char_offset - last_offset, last_id); |
| 88365 | 4329 coding->consumed_char += consumed_chars_base; |
| 4330 coding->consumed = src_base - coding->source; | |
| 4331 coding->charbuf_used = charbuf - coding->charbuf; | |
| 4332 } | |
| 4333 | |
| 4334 static void | |
| 4335 decode_coding_big5 (coding) | |
| 4336 struct coding_system *coding; | |
| 4337 { | |
| 89483 | 4338 const unsigned char *src = coding->source + coding->consumed; |
| 4339 const unsigned char *src_end = coding->source + coding->src_bytes; | |
| 4340 const unsigned char *src_base; | |
|
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
4341 int *charbuf = coding->charbuf + coding->charbuf_used; |
|
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
4342 int *charbuf_end |
|
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
4343 = coding->charbuf + coding->charbuf_size - MAX_ANNOTATION_LENGTH; |
| 88365 | 4344 int consumed_chars = 0, consumed_chars_base; |
| 4345 int multibytep = coding->src_multibyte; | |
| 4346 struct charset *charset_roman, *charset_big5; | |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4347 Lisp_Object attrs, charset_list, val; |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
4348 int char_offset = coding->produced_char; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
4349 int last_offset = char_offset; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
4350 int last_id = charset_ascii; |
|
92399
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
4351 int eol_crlf = EQ (CODING_ID_EOL_TYPE (coding->id), Qdos); |
|
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
4352 int byte_after_cr = -1; |
| 88365 | 4353 |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4354 CODING_GET_INFO (coding, attrs, charset_list); |
| 88365 | 4355 val = charset_list; |
| 4356 charset_roman = CHARSET_FROM_ID (XINT (XCAR (val))), val = XCDR (val); | |
| 4357 charset_big5 = CHARSET_FROM_ID (XINT (XCAR (val))); | |
| 4358 | |
| 4359 while (1) | |
| 4360 { | |
| 4361 int c, c1; | |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4362 struct charset *charset; |
| 88365 | 4363 |
| 4364 src_base = src; | |
| 4365 consumed_chars_base = consumed_chars; | |
| 4366 | |
| 4367 if (charbuf >= charbuf_end) | |
| 4368 break; | |
| 4369 | |
|
92399
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
4370 if (byte_after_cr >= 0) |
|
92406
c36bda0a03cc
(decode_coding_big5, produce_chars): Fix typos in last
Andreas Schwab <schwab@suse.de>
parents:
92399
diff
changeset
|
4371 c = byte_after_cr, byte_after_cr = -1; |
|
92399
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
4372 else |
|
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
4373 ONE_MORE_BYTE (c); |
| 88365 | 4374 |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
4375 if (c < 0) |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
4376 goto invalid_code; |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4377 if (c < 0x80) |
|
92399
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
4378 { |
|
92406
c36bda0a03cc
(decode_coding_big5, produce_chars): Fix typos in last
Andreas Schwab <schwab@suse.de>
parents:
92399
diff
changeset
|
4379 if (eol_crlf && c == '\r') |
|
92399
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
4380 ONE_MORE_BYTE (byte_after_cr); |
|
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
4381 charset = charset_roman; |
|
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
4382 } |
| 88365 | 4383 else |
| 4384 { | |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4385 /* BIG5 -> Big5 */ |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4386 if (c < 0xA1 || c > 0xFE) |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4387 goto invalid_code; |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4388 ONE_MORE_BYTE (c1); |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4389 if (c1 < 0x40 || (c1 > 0x7E && c1 < 0xA1) || c1 > 0xFE) |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4390 goto invalid_code; |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4391 c = c << 8 | c1; |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4392 charset = charset_big5; |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4393 } |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4394 if (charset->id != charset_ascii |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4395 && last_id != charset->id) |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4396 { |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4397 if (last_id != charset_ascii) |
|
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
4398 ADD_CHARSET_DATA (charbuf, char_offset - last_offset, last_id); |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4399 last_id = charset->id; |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4400 last_offset = char_offset; |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4401 } |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4402 CODING_DECODE_CHAR (coding, src, src_base, src_end, charset, c, c); |
| 88365 | 4403 *charbuf++ = c; |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
4404 char_offset++; |
|
20931
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
4405 continue; |
|
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
4406 |
| 88365 | 4407 invalid_code: |
| 17052 | 4408 src = src_base; |
| 88365 | 4409 consumed_chars = consumed_chars_base; |
| 4410 ONE_MORE_BYTE (c); | |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
4411 *charbuf++ = c < 0 ? -c : BYTE8_TO_CHAR (c); |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
4412 char_offset++; |
| 88365 | 4413 coding->errors++; |
| 4414 } | |
| 4415 | |
| 4416 no_more_source: | |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
4417 if (last_id != charset_ascii) |
|
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
4418 ADD_CHARSET_DATA (charbuf, char_offset - last_offset, last_id); |
| 88365 | 4419 coding->consumed_char += consumed_chars_base; |
| 4420 coding->consumed = src_base - coding->source; | |
| 4421 coding->charbuf_used = charbuf - coding->charbuf; | |
| 17052 | 4422 } |
| 4423 | |
| 4424 /* 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
|
4425 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
|
4426 `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
|
4427 are sure that all these charsets are registered as official charset |
| 17052 | 4428 (i.e. do not have extended leading-codes). Characters of other |
| 4429 charsets are produced without any encoding. If SJIS_P is 1, encode | |
| 4430 SJIS text, else encode BIG5 text. */ | |
| 4431 | |
| 88365 | 4432 static int |
| 4433 encode_coding_sjis (coding) | |
| 17052 | 4434 struct coding_system *coding; |
| 4435 { | |
| 88365 | 4436 int multibytep = coding->dst_multibyte; |
| 4437 int *charbuf = coding->charbuf; | |
| 4438 int *charbuf_end = charbuf + coding->charbuf_used; | |
| 4439 unsigned char *dst = coding->destination + coding->produced; | |
| 4440 unsigned char *dst_end = coding->destination + coding->dst_bytes; | |
| 4441 int safe_room = 4; | |
| 4442 int produced_chars = 0; | |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4443 Lisp_Object attrs, charset_list, val; |
| 88365 | 4444 int ascii_compatible; |
| 4445 struct charset *charset_roman, *charset_kanji, *charset_kana; | |
|
89764
e3d26232ab78
(decode_coding_sjis): Handle 4th charset (typically JISX0212).
Kenichi Handa <handa@m17n.org>
parents:
89759
diff
changeset
|
4446 struct charset *charset_kanji2; |
| 88365 | 4447 int c; |
| 4448 | |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4449 CODING_GET_INFO (coding, attrs, charset_list); |
| 88365 | 4450 val = charset_list; |
| 4451 charset_roman = CHARSET_FROM_ID (XINT (XCAR (val))), val = XCDR (val); | |
| 4452 charset_kana = CHARSET_FROM_ID (XINT (XCAR (val))), val = XCDR (val); | |
|
89764
e3d26232ab78
(decode_coding_sjis): Handle 4th charset (typically JISX0212).
Kenichi Handa <handa@m17n.org>
parents:
89759
diff
changeset
|
4453 charset_kanji = CHARSET_FROM_ID (XINT (XCAR (val))), val = XCDR (val); |
|
e3d26232ab78
(decode_coding_sjis): Handle 4th charset (typically JISX0212).
Kenichi Handa <handa@m17n.org>
parents:
89759
diff
changeset
|
4454 charset_kanji2 = NILP (val) ? NULL : CHARSET_FROM_ID (XINT (XCAR (val))); |
| 88365 | 4455 |
| 4456 ascii_compatible = ! NILP (CODING_ATTR_ASCII_COMPAT (attrs)); | |
| 4457 | |
| 4458 while (charbuf < charbuf_end) | |
| 4459 { | |
| 4460 ASSURE_DESTINATION (safe_room); | |
| 4461 c = *charbuf++; | |
|
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4462 /* Now encode the character C. */ |
| 88365 | 4463 if (ASCII_CHAR_P (c) && ascii_compatible) |
| 4464 EMIT_ONE_ASCII_BYTE (c); | |
|
88690
7f284ac55b07
(encode_coding_emacs_mule): Pay attention to raw-8-bit chars.
Kenichi Handa <handa@m17n.org>
parents:
88681
diff
changeset
|
4465 else if (CHAR_BYTE8_P (c)) |
|
7f284ac55b07
(encode_coding_emacs_mule): Pay attention to raw-8-bit chars.
Kenichi Handa <handa@m17n.org>
parents:
88681
diff
changeset
|
4466 { |
|
7f284ac55b07
(encode_coding_emacs_mule): Pay attention to raw-8-bit chars.
Kenichi Handa <handa@m17n.org>
parents:
88681
diff
changeset
|
4467 c = CHAR_TO_BYTE8 (c); |
|
7f284ac55b07
(encode_coding_emacs_mule): Pay attention to raw-8-bit chars.
Kenichi Handa <handa@m17n.org>
parents:
88681
diff
changeset
|
4468 EMIT_ONE_BYTE (c); |
|
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4469 } |
|
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4470 else |
|
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4471 { |
| 88365 | 4472 unsigned code; |
| 4473 struct charset *charset = char_charset (c, charset_list, &code); | |
| 4474 | |
| 4475 if (!charset) | |
|
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4476 { |
|
88573
133bf7ab1bad
(encode_coding_iso_2022): If coding requires safe
Kenichi Handa <handa@m17n.org>
parents:
88544
diff
changeset
|
4477 if (coding->mode & CODING_MODE_SAFE_ENCODING) |
|
133bf7ab1bad
(encode_coding_iso_2022): If coding requires safe
Kenichi Handa <handa@m17n.org>
parents:
88544
diff
changeset
|
4478 { |
|
133bf7ab1bad
(encode_coding_iso_2022): If coding requires safe
Kenichi Handa <handa@m17n.org>
parents:
88544
diff
changeset
|
4479 code = CODING_INHIBIT_CHARACTER_SUBSTITUTION; |
|
133bf7ab1bad
(encode_coding_iso_2022): If coding requires safe
Kenichi Handa <handa@m17n.org>
parents:
88544
diff
changeset
|
4480 charset = CHARSET_FROM_ID (charset_ascii); |
|
133bf7ab1bad
(encode_coding_iso_2022): If coding requires safe
Kenichi Handa <handa@m17n.org>
parents:
88544
diff
changeset
|
4481 } |
|
133bf7ab1bad
(encode_coding_iso_2022): If coding requires safe
Kenichi Handa <handa@m17n.org>
parents:
88544
diff
changeset
|
4482 else |
|
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4483 { |
|
88573
133bf7ab1bad
(encode_coding_iso_2022): If coding requires safe
Kenichi Handa <handa@m17n.org>
parents:
88544
diff
changeset
|
4484 c = coding->default_char; |
|
133bf7ab1bad
(encode_coding_iso_2022): If coding requires safe
Kenichi Handa <handa@m17n.org>
parents:
88544
diff
changeset
|
4485 charset = char_charset (c, charset_list, &code); |
|
133bf7ab1bad
(encode_coding_iso_2022): If coding requires safe
Kenichi Handa <handa@m17n.org>
parents:
88544
diff
changeset
|
4486 } |
| 88365 | 4487 } |
| 4488 if (code == CHARSET_INVALID_CODE (charset)) | |
| 4489 abort (); | |
| 4490 if (charset == charset_kanji) | |
|
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4491 { |
| 88365 | 4492 int c1, c2; |
| 4493 JIS_TO_SJIS (code); | |
| 4494 c1 = code >> 8, c2 = code & 0xFF; | |
| 4495 EMIT_TWO_BYTES (c1, c2); | |
| 4496 } | |
| 4497 else if (charset == charset_kana) | |
| 4498 EMIT_ONE_BYTE (code | 0x80); | |
|
89764
e3d26232ab78
(decode_coding_sjis): Handle 4th charset (typically JISX0212).
Kenichi Handa <handa@m17n.org>
parents:
89759
diff
changeset
|
4499 else if (charset_kanji2 && charset == charset_kanji2) |
|
e3d26232ab78
(decode_coding_sjis): Handle 4th charset (typically JISX0212).
Kenichi Handa <handa@m17n.org>
parents:
89759
diff
changeset
|
4500 { |
|
e3d26232ab78
(decode_coding_sjis): Handle 4th charset (typically JISX0212).
Kenichi Handa <handa@m17n.org>
parents:
89759
diff
changeset
|
4501 int c1, c2; |
|
e3d26232ab78
(decode_coding_sjis): Handle 4th charset (typically JISX0212).
Kenichi Handa <handa@m17n.org>
parents:
89759
diff
changeset
|
4502 |
|
e3d26232ab78
(decode_coding_sjis): Handle 4th charset (typically JISX0212).
Kenichi Handa <handa@m17n.org>
parents:
89759
diff
changeset
|
4503 c1 = code >> 8; |
|
e3d26232ab78
(decode_coding_sjis): Handle 4th charset (typically JISX0212).
Kenichi Handa <handa@m17n.org>
parents:
89759
diff
changeset
|
4504 if (c1 == 0x21 || (c1 >= 0x23 && c1 < 0x25) |
|
e3d26232ab78
(decode_coding_sjis): Handle 4th charset (typically JISX0212).
Kenichi Handa <handa@m17n.org>
parents:
89759
diff
changeset
|
4505 || (c1 >= 0x2C && c1 <= 0x2F) || c1 >= 0x6E) |
|
e3d26232ab78
(decode_coding_sjis): Handle 4th charset (typically JISX0212).
Kenichi Handa <handa@m17n.org>
parents:
89759
diff
changeset
|
4506 { |
|
e3d26232ab78
(decode_coding_sjis): Handle 4th charset (typically JISX0212).
Kenichi Handa <handa@m17n.org>
parents:
89759
diff
changeset
|
4507 JIS_TO_SJIS2 (code); |
|
e3d26232ab78
(decode_coding_sjis): Handle 4th charset (typically JISX0212).
Kenichi Handa <handa@m17n.org>
parents:
89759
diff
changeset
|
4508 c1 = code >> 8, c2 = code & 0xFF; |
|
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4509 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
|
4510 } |
|
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4511 else |
|
89764
e3d26232ab78
(decode_coding_sjis): Handle 4th charset (typically JISX0212).
Kenichi Handa <handa@m17n.org>
parents:
89759
diff
changeset
|
4512 EMIT_ONE_ASCII_BYTE (code & 0x7F); |
|
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4513 } |
| 17052 | 4514 else |
| 88365 | 4515 EMIT_ONE_ASCII_BYTE (code & 0x7F); |
| 4516 } | |
| 4517 } | |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
4518 record_conversion_result (coding, CODING_RESULT_SUCCESS); |
| 88365 | 4519 coding->produced_char += produced_chars; |
| 4520 coding->produced = dst - coding->destination; | |
| 4521 return 0; | |
| 4522 } | |
| 4523 | |
| 4524 static int | |
| 4525 encode_coding_big5 (coding) | |
| 4526 struct coding_system *coding; | |
| 4527 { | |
| 4528 int multibytep = coding->dst_multibyte; | |
| 4529 int *charbuf = coding->charbuf; | |
| 4530 int *charbuf_end = charbuf + coding->charbuf_used; | |
| 4531 unsigned char *dst = coding->destination + coding->produced; | |
| 4532 unsigned char *dst_end = coding->destination + coding->dst_bytes; | |
| 4533 int safe_room = 4; | |
| 4534 int produced_chars = 0; | |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4535 Lisp_Object attrs, charset_list, val; |
| 88365 | 4536 int ascii_compatible; |
| 4537 struct charset *charset_roman, *charset_big5; | |
| 4538 int c; | |
| 4539 | |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4540 CODING_GET_INFO (coding, attrs, charset_list); |
| 88365 | 4541 val = charset_list; |
| 4542 charset_roman = CHARSET_FROM_ID (XINT (XCAR (val))), val = XCDR (val); | |
| 4543 charset_big5 = CHARSET_FROM_ID (XINT (XCAR (val))); | |
| 4544 ascii_compatible = ! NILP (CODING_ATTR_ASCII_COMPAT (attrs)); | |
| 4545 | |
| 4546 while (charbuf < charbuf_end) | |
| 4547 { | |
| 4548 ASSURE_DESTINATION (safe_room); | |
| 4549 c = *charbuf++; | |
| 4550 /* Now encode the character C. */ | |
| 4551 if (ASCII_CHAR_P (c) && ascii_compatible) | |
| 4552 EMIT_ONE_ASCII_BYTE (c); | |
|
88690
7f284ac55b07
(encode_coding_emacs_mule): Pay attention to raw-8-bit chars.
Kenichi Handa <handa@m17n.org>
parents:
88681
diff
changeset
|
4553 else if (CHAR_BYTE8_P (c)) |
|
7f284ac55b07
(encode_coding_emacs_mule): Pay attention to raw-8-bit chars.
Kenichi Handa <handa@m17n.org>
parents:
88681
diff
changeset
|
4554 { |
|
7f284ac55b07
(encode_coding_emacs_mule): Pay attention to raw-8-bit chars.
Kenichi Handa <handa@m17n.org>
parents:
88681
diff
changeset
|
4555 c = CHAR_TO_BYTE8 (c); |
|
7f284ac55b07
(encode_coding_emacs_mule): Pay attention to raw-8-bit chars.
Kenichi Handa <handa@m17n.org>
parents:
88681
diff
changeset
|
4556 EMIT_ONE_BYTE (c); |
|
7f284ac55b07
(encode_coding_emacs_mule): Pay attention to raw-8-bit chars.
Kenichi Handa <handa@m17n.org>
parents:
88681
diff
changeset
|
4557 } |
| 88365 | 4558 else |
| 4559 { | |
| 4560 unsigned code; | |
| 4561 struct charset *charset = char_charset (c, charset_list, &code); | |
| 4562 | |
| 4563 if (! charset) | |
|
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4564 { |
|
88573
133bf7ab1bad
(encode_coding_iso_2022): If coding requires safe
Kenichi Handa <handa@m17n.org>
parents:
88544
diff
changeset
|
4565 if (coding->mode & CODING_MODE_SAFE_ENCODING) |
|
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4566 { |
|
88573
133bf7ab1bad
(encode_coding_iso_2022): If coding requires safe
Kenichi Handa <handa@m17n.org>
parents:
88544
diff
changeset
|
4567 code = CODING_INHIBIT_CHARACTER_SUBSTITUTION; |
|
133bf7ab1bad
(encode_coding_iso_2022): If coding requires safe
Kenichi Handa <handa@m17n.org>
parents:
88544
diff
changeset
|
4568 charset = CHARSET_FROM_ID (charset_ascii); |
|
51140
94d903190cee
(ENCODE_UNSAFE_CHARACTER): Adjusted for the name change
Kenichi Handa <handa@m17n.org>
parents:
51090
diff
changeset
|
4569 } |
|
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4570 else |
|
88573
133bf7ab1bad
(encode_coding_iso_2022): If coding requires safe
Kenichi Handa <handa@m17n.org>
parents:
88544
diff
changeset
|
4571 { |
|
133bf7ab1bad
(encode_coding_iso_2022): If coding requires safe
Kenichi Handa <handa@m17n.org>
parents:
88544
diff
changeset
|
4572 c = coding->default_char; |
|
133bf7ab1bad
(encode_coding_iso_2022): If coding requires safe
Kenichi Handa <handa@m17n.org>
parents:
88544
diff
changeset
|
4573 charset = char_charset (c, charset_list, &code); |
|
133bf7ab1bad
(encode_coding_iso_2022): If coding requires safe
Kenichi Handa <handa@m17n.org>
parents:
88544
diff
changeset
|
4574 } |
|
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4575 } |
| 88365 | 4576 if (code == CHARSET_INVALID_CODE (charset)) |
| 4577 abort (); | |
| 4578 if (charset == charset_big5) | |
| 4579 { | |
| 4580 int c1, c2; | |
| 4581 | |
| 4582 c1 = code >> 8, c2 = code & 0xFF; | |
| 4583 EMIT_TWO_BYTES (c1, c2); | |
|
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4584 } |
| 17052 | 4585 else |
| 88365 | 4586 EMIT_ONE_ASCII_BYTE (code & 0x7F); |
| 17052 | 4587 } |
| 88365 | 4588 } |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
4589 record_conversion_result (coding, CODING_RESULT_SUCCESS); |
| 88365 | 4590 coding->produced_char += produced_chars; |
| 4591 coding->produced = dst - coding->destination; | |
| 4592 return 0; | |
| 17052 | 4593 } |
| 4594 | |
| 4595 | |
| 88365 | 4596 /*** 10. CCL handlers ***/ |
|
22874
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
4597 |
|
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
4598 /* See the above "GENERAL NOTES on `detect_coding_XXX ()' functions". |
|
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
4599 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
|
4600 encoder/decoder are written in CCL program. If it is, return |
| 88365 | 4601 CATEGORY_MASK_CCL, else return 0. */ |
|
22874
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
4602 |
|
34531
37f85e931855
(ONE_MORE_BYTE_CHECK_MULTIBYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34197
diff
changeset
|
4603 static int |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
4604 detect_coding_ccl (coding, detect_info) |
| 88365 | 4605 struct coding_system *coding; |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
4606 struct coding_detection_info *detect_info; |
| 88365 | 4607 { |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
4608 const unsigned char *src = coding->source, *src_base; |
| 89483 | 4609 const unsigned char *src_end = coding->source + coding->src_bytes; |
| 88365 | 4610 int multibytep = coding->src_multibyte; |
| 4611 int consumed_chars = 0; | |
| 4612 int found = 0; | |
|
89848
3edfa038a435
(detect_coding_emacs_mule): Fix counting of encoded
Kenichi Handa <handa@m17n.org>
parents:
89842
diff
changeset
|
4613 unsigned char *valids; |
| 88365 | 4614 int head_ascii = coding->head_ascii; |
| 4615 Lisp_Object attrs; | |
| 4616 | |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
4617 detect_info->checked |= CATEGORY_MASK_CCL; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
4618 |
| 88365 | 4619 coding = &coding_categories[coding_category_ccl]; |
|
89848
3edfa038a435
(detect_coding_emacs_mule): Fix counting of encoded
Kenichi Handa <handa@m17n.org>
parents:
89842
diff
changeset
|
4620 valids = CODING_CCL_VALIDS (coding); |
| 88365 | 4621 attrs = CODING_ID_ATTRS (coding->id); |
| 4622 if (! NILP (CODING_ATTR_ASCII_COMPAT (attrs))) | |
| 4623 src += head_ascii; | |
| 4624 | |
|
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4625 while (1) |
|
22874
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
4626 { |
| 88365 | 4627 int c; |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
4628 |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
4629 src_base = src; |
| 88365 | 4630 ONE_MORE_BYTE (c); |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
4631 if (c < 0 || ! valids[c]) |
| 88365 | 4632 break; |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
4633 if ((valids[c] > 1)) |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
4634 found = CATEGORY_MASK_CCL; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
4635 } |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
4636 detect_info->rejected |= CATEGORY_MASK_CCL; |
| 88365 | 4637 return 0; |
| 4638 | |
| 4639 no_more_source: | |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
4640 detect_info->found |= found; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
4641 return 1; |
| 88365 | 4642 } |
| 4643 | |
| 4644 static void | |
| 4645 decode_coding_ccl (coding) | |
| 4646 struct coding_system *coding; | |
|
22874
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
4647 { |
|
88876
af9012fdad56
(LEADING_CODE_PRIVATE_11, LEADING_CODE_PRIVATE_12,
Kenichi Handa <handa@m17n.org>
parents:
88862
diff
changeset
|
4648 const unsigned char *src = coding->source + coding->consumed; |
| 89483 | 4649 const unsigned char *src_end = coding->source + coding->src_bytes; |
|
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
4650 int *charbuf = coding->charbuf + coding->charbuf_used; |
|
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
4651 int *charbuf_end = coding->charbuf + coding->charbuf_size; |
| 88365 | 4652 int consumed_chars = 0; |
| 4653 int multibytep = coding->src_multibyte; | |
| 4654 struct ccl_program ccl; | |
| 4655 int source_charbuf[1024]; | |
| 4656 int source_byteidx[1024]; | |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4657 Lisp_Object attrs, charset_list; |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4658 |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4659 CODING_GET_INFO (coding, attrs, charset_list); |
| 88365 | 4660 setup_ccl_program (&ccl, CODING_CCL_DECODER (coding)); |
| 4661 | |
| 4662 while (src < src_end) | |
| 4663 { | |
|
88876
af9012fdad56
(LEADING_CODE_PRIVATE_11, LEADING_CODE_PRIVATE_12,
Kenichi Handa <handa@m17n.org>
parents:
88862
diff
changeset
|
4664 const unsigned char *p = src; |
| 88365 | 4665 int *source, *source_end; |
| 4666 int i = 0; | |
| 4667 | |
| 4668 if (multibytep) | |
| 4669 while (i < 1024 && p < src_end) | |
| 4670 { | |
| 4671 source_byteidx[i] = p - src; | |
| 4672 source_charbuf[i++] = STRING_CHAR_ADVANCE (p); | |
| 4673 } | |
| 4674 else | |
| 4675 while (i < 1024 && p < src_end) | |
| 4676 source_charbuf[i++] = *p++; | |
| 89483 | 4677 |
| 88365 | 4678 if (p == src_end && coding->mode & CODING_MODE_LAST_BLOCK) |
| 4679 ccl.last_block = 1; | |
| 4680 | |
| 4681 source = source_charbuf; | |
| 4682 source_end = source + i; | |
| 4683 while (source < source_end) | |
| 4684 { | |
| 4685 ccl_driver (&ccl, source, charbuf, | |
|
89373
4cc9e57fcabc
(decode_coding_ccl, encode_coding_ccl): Call ccl_driver
Kenichi Handa <handa@m17n.org>
parents:
89331
diff
changeset
|
4686 source_end - source, charbuf_end - charbuf, |
|
4cc9e57fcabc
(decode_coding_ccl, encode_coding_ccl): Call ccl_driver
Kenichi Handa <handa@m17n.org>
parents:
89331
diff
changeset
|
4687 charset_list); |
| 88365 | 4688 source += ccl.consumed; |
| 4689 charbuf += ccl.produced; | |
| 4690 if (ccl.status != CCL_STAT_SUSPEND_BY_DST) | |
| 4691 break; | |
| 4692 } | |
| 4693 if (source < source_end) | |
| 4694 src += source_byteidx[source - source_charbuf]; | |
| 4695 else | |
| 4696 src = p; | |
| 4697 consumed_chars += source - source_charbuf; | |
| 4698 | |
| 4699 if (ccl.status != CCL_STAT_SUSPEND_BY_SRC | |
| 4700 && ccl.status != CODING_RESULT_INSUFFICIENT_SRC) | |
| 4701 break; | |
| 4702 } | |
| 4703 | |
| 4704 switch (ccl.status) | |
| 4705 { | |
| 4706 case CCL_STAT_SUSPEND_BY_SRC: | |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
4707 record_conversion_result (coding, CODING_RESULT_INSUFFICIENT_SRC); |
| 88365 | 4708 break; |
| 4709 case CCL_STAT_SUSPEND_BY_DST: | |
| 4710 break; | |
| 4711 case CCL_STAT_QUIT: | |
| 4712 case CCL_STAT_INVALID_CMD: | |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
4713 record_conversion_result (coding, CODING_RESULT_INTERRUPT); |
| 88365 | 4714 break; |
| 4715 default: | |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
4716 record_conversion_result (coding, CODING_RESULT_SUCCESS); |
| 88365 | 4717 break; |
| 4718 } | |
| 4719 coding->consumed_char += consumed_chars; | |
| 4720 coding->consumed = src - coding->source; | |
| 4721 coding->charbuf_used = charbuf - coding->charbuf; | |
|
22874
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
4722 } |
|
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
4723 |
| 88365 | 4724 static int |
| 4725 encode_coding_ccl (coding) | |
| 4726 struct coding_system *coding; | |
| 4727 { | |
| 4728 struct ccl_program ccl; | |
| 4729 int multibytep = coding->dst_multibyte; | |
| 4730 int *charbuf = coding->charbuf; | |
| 4731 int *charbuf_end = charbuf + coding->charbuf_used; | |
| 4732 unsigned char *dst = coding->destination + coding->produced; | |
| 4733 unsigned char *dst_end = coding->destination + coding->dst_bytes; | |
| 4734 int destination_charbuf[1024]; | |
| 4735 int i, produced_chars = 0; | |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4736 Lisp_Object attrs, charset_list; |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4737 |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4738 CODING_GET_INFO (coding, attrs, charset_list); |
| 88365 | 4739 setup_ccl_program (&ccl, CODING_CCL_ENCODER (coding)); |
| 4740 | |
| 4741 ccl.last_block = coding->mode & CODING_MODE_LAST_BLOCK; | |
| 4742 ccl.dst_multibyte = coding->dst_multibyte; | |
| 4743 | |
|
90346
bba59a8cdae0
(encode_coding_ccl): Allocate destination dynamically
Kenichi Handa <handa@m17n.org>
parents:
90336
diff
changeset
|
4744 while (charbuf < charbuf_end) |
|
bba59a8cdae0
(encode_coding_ccl): Allocate destination dynamically
Kenichi Handa <handa@m17n.org>
parents:
90336
diff
changeset
|
4745 { |
| 88365 | 4746 ccl_driver (&ccl, charbuf, destination_charbuf, |
|
90346
bba59a8cdae0
(encode_coding_ccl): Allocate destination dynamically
Kenichi Handa <handa@m17n.org>
parents:
90336
diff
changeset
|
4747 charbuf_end - charbuf, 1024, charset_list); |
| 88365 | 4748 if (multibytep) |
|
90346
bba59a8cdae0
(encode_coding_ccl): Allocate destination dynamically
Kenichi Handa <handa@m17n.org>
parents:
90336
diff
changeset
|
4749 { |
|
bba59a8cdae0
(encode_coding_ccl): Allocate destination dynamically
Kenichi Handa <handa@m17n.org>
parents:
90336
diff
changeset
|
4750 ASSURE_DESTINATION (ccl.produced * 2); |
|
bba59a8cdae0
(encode_coding_ccl): Allocate destination dynamically
Kenichi Handa <handa@m17n.org>
parents:
90336
diff
changeset
|
4751 for (i = 0; i < ccl.produced; i++) |
|
bba59a8cdae0
(encode_coding_ccl): Allocate destination dynamically
Kenichi Handa <handa@m17n.org>
parents:
90336
diff
changeset
|
4752 EMIT_ONE_BYTE (destination_charbuf[i] & 0xFF); |
|
bba59a8cdae0
(encode_coding_ccl): Allocate destination dynamically
Kenichi Handa <handa@m17n.org>
parents:
90336
diff
changeset
|
4753 } |
| 88365 | 4754 else |
| 4755 { | |
|
90346
bba59a8cdae0
(encode_coding_ccl): Allocate destination dynamically
Kenichi Handa <handa@m17n.org>
parents:
90336
diff
changeset
|
4756 ASSURE_DESTINATION (ccl.produced); |
|
93877
62d97ebb13a9
* coding.c (detect_coding_emacs_mule)
Michael Albinus <michael.albinus@gmx.de>
parents:
93595
diff
changeset
|
4757 for (i = 0; i < ccl.produced; i++) |
| 88365 | 4758 *dst++ = destination_charbuf[i] & 0xFF; |
| 4759 produced_chars += ccl.produced; | |
| 4760 } | |
|
90346
bba59a8cdae0
(encode_coding_ccl): Allocate destination dynamically
Kenichi Handa <handa@m17n.org>
parents:
90336
diff
changeset
|
4761 charbuf += ccl.consumed; |
|
bba59a8cdae0
(encode_coding_ccl): Allocate destination dynamically
Kenichi Handa <handa@m17n.org>
parents:
90336
diff
changeset
|
4762 if (ccl.status == CCL_STAT_QUIT |
|
bba59a8cdae0
(encode_coding_ccl): Allocate destination dynamically
Kenichi Handa <handa@m17n.org>
parents:
90336
diff
changeset
|
4763 || ccl.status == CCL_STAT_INVALID_CMD) |
|
bba59a8cdae0
(encode_coding_ccl): Allocate destination dynamically
Kenichi Handa <handa@m17n.org>
parents:
90336
diff
changeset
|
4764 break; |
| 88365 | 4765 } |
| 4766 | |
| 4767 switch (ccl.status) | |
| 4768 { | |
| 4769 case CCL_STAT_SUSPEND_BY_SRC: | |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
4770 record_conversion_result (coding, CODING_RESULT_INSUFFICIENT_SRC); |
| 88365 | 4771 break; |
| 4772 case CCL_STAT_SUSPEND_BY_DST: | |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
4773 record_conversion_result (coding, CODING_RESULT_INSUFFICIENT_DST); |
| 88365 | 4774 break; |
| 4775 case CCL_STAT_QUIT: | |
| 4776 case CCL_STAT_INVALID_CMD: | |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
4777 record_conversion_result (coding, CODING_RESULT_INTERRUPT); |
| 88365 | 4778 break; |
| 4779 default: | |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
4780 record_conversion_result (coding, CODING_RESULT_SUCCESS); |
| 88365 | 4781 break; |
| 4782 } | |
| 4783 | |
| 4784 coding->produced_char += produced_chars; | |
| 4785 coding->produced = dst - coding->destination; | |
| 4786 return 0; | |
| 4787 } | |
| 4788 | |
|
22874
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
4789 |
|
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
4790 |
| 88365 | 4791 /*** 10, 11. no-conversion handlers ***/ |
| 17052 | 4792 |
|
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4793 /* 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
|
4794 |
|
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4795 static void |
| 88365 | 4796 decode_coding_raw_text (coding) |
| 17052 | 4797 struct coding_system *coding; |
| 4798 { | |
|
92399
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
4799 int eol_crlf = EQ (CODING_ID_EOL_TYPE (coding->id), Qdos); |
|
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
4800 |
| 88365 | 4801 coding->chars_at_source = 1; |
|
92399
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
4802 coding->consumed_char = coding->src_chars; |
|
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
4803 coding->consumed = coding->src_bytes; |
|
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
4804 if (eol_crlf && coding->source[coding->src_bytes - 1] == '\r') |
|
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
4805 { |
|
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
4806 coding->consumed_char--; |
|
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
4807 coding->consumed--; |
|
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
4808 record_conversion_result (coding, CODING_RESULT_INSUFFICIENT_SRC); |
|
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
4809 } |
|
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
4810 else |
|
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
4811 record_conversion_result (coding, CODING_RESULT_SUCCESS); |
| 88365 | 4812 } |
| 4813 | |
| 4814 static int | |
| 4815 encode_coding_raw_text (coding) | |
| 17052 | 4816 struct coding_system *coding; |
| 88365 | 4817 { |
| 4818 int multibytep = coding->dst_multibyte; | |
| 4819 int *charbuf = coding->charbuf; | |
| 4820 int *charbuf_end = coding->charbuf + coding->charbuf_used; | |
| 4821 unsigned char *dst = coding->destination + coding->produced; | |
| 4822 unsigned char *dst_end = coding->destination + coding->dst_bytes; | |
| 4823 int produced_chars = 0; | |
|
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4824 int c; |
|
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4825 |
| 88365 | 4826 if (multibytep) |
| 4827 { | |
| 4828 int safe_room = MAX_MULTIBYTE_LENGTH * 2; | |
| 4829 | |
| 4830 if (coding->src_multibyte) | |
| 4831 while (charbuf < charbuf_end) | |
| 4832 { | |
| 4833 ASSURE_DESTINATION (safe_room); | |
| 4834 c = *charbuf++; | |
| 4835 if (ASCII_CHAR_P (c)) | |
| 4836 EMIT_ONE_ASCII_BYTE (c); | |
| 4837 else if (CHAR_BYTE8_P (c)) | |
| 4838 { | |
| 4839 c = CHAR_TO_BYTE8 (c); | |
| 4840 EMIT_ONE_BYTE (c); | |
| 4841 } | |
| 4842 else | |
| 4843 { | |
| 4844 unsigned char str[MAX_MULTIBYTE_LENGTH], *p0 = str, *p1 = str; | |
| 4845 | |
| 4846 CHAR_STRING_ADVANCE (c, p1); | |
| 4847 while (p0 < p1) | |
|
88950
ad258ee59fbb
* coding.c (make_conversion_work_buffer): Adjusted for the change
Kenichi Handa <handa@m17n.org>
parents:
88936
diff
changeset
|
4848 { |
|
ad258ee59fbb
* coding.c (make_conversion_work_buffer): Adjusted for the change
Kenichi Handa <handa@m17n.org>
parents:
88936
diff
changeset
|
4849 EMIT_ONE_BYTE (*p0); |
|
ad258ee59fbb
* coding.c (make_conversion_work_buffer): Adjusted for the change
Kenichi Handa <handa@m17n.org>
parents:
88936
diff
changeset
|
4850 p0++; |
|
ad258ee59fbb
* coding.c (make_conversion_work_buffer): Adjusted for the change
Kenichi Handa <handa@m17n.org>
parents:
88936
diff
changeset
|
4851 } |
| 88365 | 4852 } |
| 4853 } | |
| 4854 else | |
| 4855 while (charbuf < charbuf_end) | |
| 4856 { | |
| 4857 ASSURE_DESTINATION (safe_room); | |
| 4858 c = *charbuf++; | |
|
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4859 EMIT_ONE_BYTE (c); |
| 88365 | 4860 } |
|
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4861 } |
|
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4862 else |
|
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4863 { |
| 88365 | 4864 if (coding->src_multibyte) |
|
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4865 { |
| 88365 | 4866 int safe_room = MAX_MULTIBYTE_LENGTH; |
| 4867 | |
| 4868 while (charbuf < charbuf_end) | |
|
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4869 { |
| 88365 | 4870 ASSURE_DESTINATION (safe_room); |
| 4871 c = *charbuf++; | |
| 4872 if (ASCII_CHAR_P (c)) | |
| 4873 *dst++ = c; | |
| 4874 else if (CHAR_BYTE8_P (c)) | |
| 4875 *dst++ = CHAR_TO_BYTE8 (c); | |
| 4876 else | |
| 4877 CHAR_STRING_ADVANCE (c, dst); | |
| 4878 produced_chars++; | |
|
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4879 } |
|
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4880 } |
|
20931
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
4881 else |
|
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4882 { |
| 88365 | 4883 ASSURE_DESTINATION (charbuf_end - charbuf); |
| 4884 while (charbuf < charbuf_end && dst < dst_end) | |
| 4885 *dst++ = *charbuf++; | |
| 4886 produced_chars = dst - (coding->destination + coding->dst_bytes); | |
| 89483 | 4887 } |
| 88365 | 4888 } |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
4889 record_conversion_result (coding, CODING_RESULT_SUCCESS); |
| 88365 | 4890 coding->produced_char += produced_chars; |
| 4891 coding->produced = dst - coding->destination; | |
| 4892 return 0; | |
| 4893 } | |
| 4894 | |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
4895 /* See the above "GENERAL NOTES on `detect_coding_XXX ()' functions". |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
4896 Check if a text is encoded in a charset-based coding system. If it |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
4897 is, return 1, else return 0. */ |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
4898 |
| 88365 | 4899 static int |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
4900 detect_coding_charset (coding, detect_info) |
| 88365 | 4901 struct coding_system *coding; |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
4902 struct coding_detection_info *detect_info; |
| 88365 | 4903 { |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
4904 const unsigned char *src = coding->source, *src_base; |
| 89483 | 4905 const unsigned char *src_end = coding->source + coding->src_bytes; |
| 88365 | 4906 int multibytep = coding->src_multibyte; |
| 4907 int consumed_chars = 0; | |
| 4908 Lisp_Object attrs, valids; | |
|
89225
32058afc72e2
(detect_coding_charset): If only ASCII bytes are found, return 0.
Kenichi Handa <handa@m17n.org>
parents:
89221
diff
changeset
|
4909 int found = 0; |
|
90651
23c1467f8640
(detect_coding_charset): Fix detection of multi-byte
Kenichi Handa <handa@m17n.org>
parents:
90599
diff
changeset
|
4910 int head_ascii = coding->head_ascii; |
| 88365 | 4911 |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
4912 detect_info->checked |= CATEGORY_MASK_CHARSET; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
4913 |
| 88365 | 4914 coding = &coding_categories[coding_category_charset]; |
| 4915 attrs = CODING_ID_ATTRS (coding->id); | |
| 4916 valids = AREF (attrs, coding_attr_charset_valids); | |
| 4917 | |
| 4918 if (! NILP (CODING_ATTR_ASCII_COMPAT (attrs))) | |
|
90651
23c1467f8640
(detect_coding_charset): Fix detection of multi-byte
Kenichi Handa <handa@m17n.org>
parents:
90599
diff
changeset
|
4919 src += head_ascii; |
| 88365 | 4920 |
| 4921 while (1) | |
| 4922 { | |
| 4923 int c; | |
|
90651
23c1467f8640
(detect_coding_charset): Fix detection of multi-byte
Kenichi Handa <handa@m17n.org>
parents:
90599
diff
changeset
|
4924 Lisp_Object val; |
|
23c1467f8640
(detect_coding_charset): Fix detection of multi-byte
Kenichi Handa <handa@m17n.org>
parents:
90599
diff
changeset
|
4925 struct charset *charset; |
|
23c1467f8640
(detect_coding_charset): Fix detection of multi-byte
Kenichi Handa <handa@m17n.org>
parents:
90599
diff
changeset
|
4926 int dim, idx; |
| 88365 | 4927 |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
4928 src_base = src; |
| 88365 | 4929 ONE_MORE_BYTE (c); |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
4930 if (c < 0) |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
4931 continue; |
|
90651
23c1467f8640
(detect_coding_charset): Fix detection of multi-byte
Kenichi Handa <handa@m17n.org>
parents:
90599
diff
changeset
|
4932 val = AREF (valids, c); |
|
23c1467f8640
(detect_coding_charset): Fix detection of multi-byte
Kenichi Handa <handa@m17n.org>
parents:
90599
diff
changeset
|
4933 if (NILP (val)) |
| 88365 | 4934 break; |
|
89225
32058afc72e2
(detect_coding_charset): If only ASCII bytes are found, return 0.
Kenichi Handa <handa@m17n.org>
parents:
89221
diff
changeset
|
4935 if (c >= 0x80) |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
4936 found = CATEGORY_MASK_CHARSET; |
|
90651
23c1467f8640
(detect_coding_charset): Fix detection of multi-byte
Kenichi Handa <handa@m17n.org>
parents:
90599
diff
changeset
|
4937 if (INTEGERP (val)) |
|
23c1467f8640
(detect_coding_charset): Fix detection of multi-byte
Kenichi Handa <handa@m17n.org>
parents:
90599
diff
changeset
|
4938 { |
|
23c1467f8640
(detect_coding_charset): Fix detection of multi-byte
Kenichi Handa <handa@m17n.org>
parents:
90599
diff
changeset
|
4939 charset = CHARSET_FROM_ID (XFASTINT (val)); |
|
23c1467f8640
(detect_coding_charset): Fix detection of multi-byte
Kenichi Handa <handa@m17n.org>
parents:
90599
diff
changeset
|
4940 dim = CHARSET_DIMENSION (charset); |
|
23c1467f8640
(detect_coding_charset): Fix detection of multi-byte
Kenichi Handa <handa@m17n.org>
parents:
90599
diff
changeset
|
4941 for (idx = 1; idx < dim; idx++) |
|
20931
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
4942 { |
|
90651
23c1467f8640
(detect_coding_charset): Fix detection of multi-byte
Kenichi Handa <handa@m17n.org>
parents:
90599
diff
changeset
|
4943 if (src == src_end) |
|
23c1467f8640
(detect_coding_charset): Fix detection of multi-byte
Kenichi Handa <handa@m17n.org>
parents:
90599
diff
changeset
|
4944 goto too_short; |
|
23c1467f8640
(detect_coding_charset): Fix detection of multi-byte
Kenichi Handa <handa@m17n.org>
parents:
90599
diff
changeset
|
4945 ONE_MORE_BYTE (c); |
|
93877
62d97ebb13a9
* coding.c (detect_coding_emacs_mule)
Michael Albinus <michael.albinus@gmx.de>
parents:
93595
diff
changeset
|
4946 if (c < charset->code_space[(dim - 1 - idx) * 2] |
|
90651
23c1467f8640
(detect_coding_charset): Fix detection of multi-byte
Kenichi Handa <handa@m17n.org>
parents:
90599
diff
changeset
|
4947 || c > charset->code_space[(dim - 1 - idx) * 2 + 1]) |
|
23c1467f8640
(detect_coding_charset): Fix detection of multi-byte
Kenichi Handa <handa@m17n.org>
parents:
90599
diff
changeset
|
4948 break; |
|
23c1467f8640
(detect_coding_charset): Fix detection of multi-byte
Kenichi Handa <handa@m17n.org>
parents:
90599
diff
changeset
|
4949 } |
|
23c1467f8640
(detect_coding_charset): Fix detection of multi-byte
Kenichi Handa <handa@m17n.org>
parents:
90599
diff
changeset
|
4950 if (idx < dim) |
|
23c1467f8640
(detect_coding_charset): Fix detection of multi-byte
Kenichi Handa <handa@m17n.org>
parents:
90599
diff
changeset
|
4951 break; |
|
23c1467f8640
(detect_coding_charset): Fix detection of multi-byte
Kenichi Handa <handa@m17n.org>
parents:
90599
diff
changeset
|
4952 } |
|
23c1467f8640
(detect_coding_charset): Fix detection of multi-byte
Kenichi Handa <handa@m17n.org>
parents:
90599
diff
changeset
|
4953 else |
|
23c1467f8640
(detect_coding_charset): Fix detection of multi-byte
Kenichi Handa <handa@m17n.org>
parents:
90599
diff
changeset
|
4954 { |
|
23c1467f8640
(detect_coding_charset): Fix detection of multi-byte
Kenichi Handa <handa@m17n.org>
parents:
90599
diff
changeset
|
4955 idx = 1; |
|
23c1467f8640
(detect_coding_charset): Fix detection of multi-byte
Kenichi Handa <handa@m17n.org>
parents:
90599
diff
changeset
|
4956 for (; CONSP (val); val = XCDR (val)) |
|
23c1467f8640
(detect_coding_charset): Fix detection of multi-byte
Kenichi Handa <handa@m17n.org>
parents:
90599
diff
changeset
|
4957 { |
|
23c1467f8640
(detect_coding_charset): Fix detection of multi-byte
Kenichi Handa <handa@m17n.org>
parents:
90599
diff
changeset
|
4958 charset = CHARSET_FROM_ID (XFASTINT (XCAR (val))); |
|
23c1467f8640
(detect_coding_charset): Fix detection of multi-byte
Kenichi Handa <handa@m17n.org>
parents:
90599
diff
changeset
|
4959 dim = CHARSET_DIMENSION (charset); |
|
23c1467f8640
(detect_coding_charset): Fix detection of multi-byte
Kenichi Handa <handa@m17n.org>
parents:
90599
diff
changeset
|
4960 while (idx < dim) |
|
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4961 { |
|
90651
23c1467f8640
(detect_coding_charset): Fix detection of multi-byte
Kenichi Handa <handa@m17n.org>
parents:
90599
diff
changeset
|
4962 if (src == src_end) |
|
23c1467f8640
(detect_coding_charset): Fix detection of multi-byte
Kenichi Handa <handa@m17n.org>
parents:
90599
diff
changeset
|
4963 goto too_short; |
|
23c1467f8640
(detect_coding_charset): Fix detection of multi-byte
Kenichi Handa <handa@m17n.org>
parents:
90599
diff
changeset
|
4964 ONE_MORE_BYTE (c); |
|
23c1467f8640
(detect_coding_charset): Fix detection of multi-byte
Kenichi Handa <handa@m17n.org>
parents:
90599
diff
changeset
|
4965 if (c < charset->code_space[(dim - 1 - idx) * 4] |
|
23c1467f8640
(detect_coding_charset): Fix detection of multi-byte
Kenichi Handa <handa@m17n.org>
parents:
90599
diff
changeset
|
4966 || c > charset->code_space[(dim - 1 - idx) * 4 + 1]) |
|
23c1467f8640
(detect_coding_charset): Fix detection of multi-byte
Kenichi Handa <handa@m17n.org>
parents:
90599
diff
changeset
|
4967 break; |
|
23c1467f8640
(detect_coding_charset): Fix detection of multi-byte
Kenichi Handa <handa@m17n.org>
parents:
90599
diff
changeset
|
4968 idx++; |
|
23c1467f8640
(detect_coding_charset): Fix detection of multi-byte
Kenichi Handa <handa@m17n.org>
parents:
90599
diff
changeset
|
4969 } |
|
23c1467f8640
(detect_coding_charset): Fix detection of multi-byte
Kenichi Handa <handa@m17n.org>
parents:
90599
diff
changeset
|
4970 if (idx == dim) |
|
23c1467f8640
(detect_coding_charset): Fix detection of multi-byte
Kenichi Handa <handa@m17n.org>
parents:
90599
diff
changeset
|
4971 { |
|
23c1467f8640
(detect_coding_charset): Fix detection of multi-byte
Kenichi Handa <handa@m17n.org>
parents:
90599
diff
changeset
|
4972 val = Qnil; |
|
23c1467f8640
(detect_coding_charset): Fix detection of multi-byte
Kenichi Handa <handa@m17n.org>
parents:
90599
diff
changeset
|
4973 break; |
|
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4974 } |
|
20931
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
4975 } |
|
90651
23c1467f8640
(detect_coding_charset): Fix detection of multi-byte
Kenichi Handa <handa@m17n.org>
parents:
90599
diff
changeset
|
4976 if (CONSP (val)) |
|
23c1467f8640
(detect_coding_charset): Fix detection of multi-byte
Kenichi Handa <handa@m17n.org>
parents:
90599
diff
changeset
|
4977 break; |
|
23c1467f8640
(detect_coding_charset): Fix detection of multi-byte
Kenichi Handa <handa@m17n.org>
parents:
90599
diff
changeset
|
4978 } |
|
23c1467f8640
(detect_coding_charset): Fix detection of multi-byte
Kenichi Handa <handa@m17n.org>
parents:
90599
diff
changeset
|
4979 } |
|
23c1467f8640
(detect_coding_charset): Fix detection of multi-byte
Kenichi Handa <handa@m17n.org>
parents:
90599
diff
changeset
|
4980 too_short: |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
4981 detect_info->rejected |= CATEGORY_MASK_CHARSET; |
| 88365 | 4982 return 0; |
| 4983 | |
| 4984 no_more_source: | |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
4985 detect_info->found |= found; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
4986 return 1; |
| 88365 | 4987 } |
|
29005
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 static void |
| 88365 | 4990 decode_coding_charset (coding) |
| 17052 | 4991 struct coding_system *coding; |
| 88365 | 4992 { |
| 89483 | 4993 const unsigned char *src = coding->source + coding->consumed; |
| 4994 const unsigned char *src_end = coding->source + coding->src_bytes; | |
|
46548
cb1914307488
(encode_eol, detect_coding, detect_eol):
Ken Raeburn <raeburn@raeburn.org>
parents:
46462
diff
changeset
|
4995 const unsigned char *src_base; |
|
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
4996 int *charbuf = coding->charbuf + coding->charbuf_used; |
|
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
4997 int *charbuf_end |
|
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
4998 = coding->charbuf + coding->charbuf_size - MAX_ANNOTATION_LENGTH; |
| 88365 | 4999 int consumed_chars = 0, consumed_chars_base; |
| 5000 int multibytep = coding->src_multibyte; | |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5001 Lisp_Object attrs, charset_list, valids; |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
5002 int char_offset = coding->produced_char; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
5003 int last_offset = char_offset; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
5004 int last_id = charset_ascii; |
|
92399
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
5005 int eol_crlf = EQ (CODING_ID_EOL_TYPE (coding->id), Qdos); |
|
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
5006 int byte_after_cr = -1; |
| 88365 | 5007 |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5008 CODING_GET_INFO (coding, attrs, charset_list); |
|
88465
ae455bb40718
(decode_coding_charset, encode_coding_charset): Handle
Kenichi Handa <handa@m17n.org>
parents:
88456
diff
changeset
|
5009 valids = AREF (attrs, coding_attr_charset_valids); |
| 88365 | 5010 |
| 5011 while (1) | |
| 5012 { | |
|
88465
ae455bb40718
(decode_coding_charset, encode_coding_charset): Handle
Kenichi Handa <handa@m17n.org>
parents:
88456
diff
changeset
|
5013 int c; |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5014 Lisp_Object val; |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5015 struct charset *charset; |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5016 int dim; |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5017 int len = 1; |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5018 unsigned code; |
| 88365 | 5019 |
|
29093
176708661b08
(encode_eol): Fix a bug of DOS style EOL encoding.
Kenichi Handa <handa@m17n.org>
parents:
29005
diff
changeset
|
5020 src_base = src; |
| 88365 | 5021 consumed_chars_base = consumed_chars; |
| 5022 | |
| 5023 if (charbuf >= charbuf_end) | |
| 5024 break; | |
| 5025 | |
|
92399
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
5026 if (byte_after_cr >= 0) |
|
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
5027 { |
|
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
5028 c = byte_after_cr; |
|
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
5029 byte_after_cr = -1; |
|
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
5030 } |
|
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
5031 else |
|
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
5032 { |
|
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
5033 ONE_MORE_BYTE (c); |
|
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
5034 if (eol_crlf && c == '\r') |
|
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
5035 ONE_MORE_BYTE (byte_after_cr); |
|
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
5036 } |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
5037 if (c < 0) |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
5038 goto invalid_code; |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5039 code = c; |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5040 |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5041 val = AREF (valids, c); |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5042 if (NILP (val)) |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5043 goto invalid_code; |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5044 if (INTEGERP (val)) |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5045 { |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5046 charset = CHARSET_FROM_ID (XFASTINT (val)); |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5047 dim = CHARSET_DIMENSION (charset); |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5048 while (len < dim) |
|
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5049 { |
|
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
5050 ONE_MORE_BYTE (c); |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5051 code = (code << 8) | c; |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5052 len++; |
|
20931
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
5053 } |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5054 CODING_DECODE_CHAR (coding, src, src_base, src_end, |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5055 charset, code, c); |
|
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5056 } |
|
20931
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
5057 else |
|
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5058 { |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5059 /* VAL is a list of charset IDs. It is assured that the |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5060 list is sorted by charset dimensions (smaller one |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5061 comes first). */ |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5062 while (CONSP (val)) |
|
88465
ae455bb40718
(decode_coding_charset, encode_coding_charset): Handle
Kenichi Handa <handa@m17n.org>
parents:
88456
diff
changeset
|
5063 { |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5064 charset = CHARSET_FROM_ID (XFASTINT (XCAR (val))); |
|
88597
74b74f59bc09
(decode_coding_charset): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
88587
diff
changeset
|
5065 dim = CHARSET_DIMENSION (charset); |
|
88607
18436bf3d6dd
(Fdefine_coding_system_internal): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
88598
diff
changeset
|
5066 while (len < dim) |
|
88465
ae455bb40718
(decode_coding_charset, encode_coding_charset): Handle
Kenichi Handa <handa@m17n.org>
parents:
88456
diff
changeset
|
5067 { |
|
88598
b88195f69856
(decode_coding_charset): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
88597
diff
changeset
|
5068 ONE_MORE_BYTE (c); |
|
b88195f69856
(decode_coding_charset): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
88597
diff
changeset
|
5069 code = (code << 8) | c; |
|
88607
18436bf3d6dd
(Fdefine_coding_system_internal): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
88598
diff
changeset
|
5070 len++; |
|
88465
ae455bb40718
(decode_coding_charset, encode_coding_charset): Handle
Kenichi Handa <handa@m17n.org>
parents:
88456
diff
changeset
|
5071 } |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5072 CODING_DECODE_CHAR (coding, src, src_base, |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5073 src_end, charset, code, c); |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5074 if (c >= 0) |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5075 break; |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5076 val = XCDR (val); |
|
88465
ae455bb40718
(decode_coding_charset, encode_coding_charset): Handle
Kenichi Handa <handa@m17n.org>
parents:
88456
diff
changeset
|
5077 } |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5078 } |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5079 if (c < 0) |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5080 goto invalid_code; |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5081 if (charset->id != charset_ascii |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5082 && last_id != charset->id) |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5083 { |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5084 if (last_id != charset_ascii) |
|
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
5085 ADD_CHARSET_DATA (charbuf, char_offset - last_offset, last_id); |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5086 last_id = charset->id; |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5087 last_offset = char_offset; |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5088 } |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5089 |
| 88365 | 5090 *charbuf++ = c; |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
5091 char_offset++; |
| 88365 | 5092 continue; |
| 5093 | |
| 5094 invalid_code: | |
| 5095 src = src_base; | |
| 5096 consumed_chars = consumed_chars_base; | |
| 5097 ONE_MORE_BYTE (c); | |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
5098 *charbuf++ = c < 0 ? -c : ASCII_BYTE_P (c) ? c : BYTE8_TO_CHAR (c); |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
5099 char_offset++; |
| 88365 | 5100 coding->errors++; |
| 5101 } | |
| 5102 | |
| 5103 no_more_source: | |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
5104 if (last_id != charset_ascii) |
|
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
5105 ADD_CHARSET_DATA (charbuf, char_offset - last_offset, last_id); |
| 88365 | 5106 coding->consumed_char += consumed_chars_base; |
| 5107 coding->consumed = src_base - coding->source; | |
| 5108 coding->charbuf_used = charbuf - coding->charbuf; | |
| 5109 } | |
| 5110 | |
| 5111 static int | |
| 5112 encode_coding_charset (coding) | |
| 5113 struct coding_system *coding; | |
| 5114 { | |
| 5115 int multibytep = coding->dst_multibyte; | |
| 5116 int *charbuf = coding->charbuf; | |
| 5117 int *charbuf_end = charbuf + coding->charbuf_used; | |
| 5118 unsigned char *dst = coding->destination + coding->produced; | |
| 5119 unsigned char *dst_end = coding->destination + coding->dst_bytes; | |
| 5120 int safe_room = MAX_MULTIBYTE_LENGTH; | |
| 5121 int produced_chars = 0; | |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5122 Lisp_Object attrs, charset_list; |
| 88365 | 5123 int ascii_compatible; |
| 5124 int c; | |
| 5125 | |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5126 CODING_GET_INFO (coding, attrs, charset_list); |
| 88365 | 5127 ascii_compatible = ! NILP (CODING_ATTR_ASCII_COMPAT (attrs)); |
| 5128 | |
| 5129 while (charbuf < charbuf_end) | |
| 5130 { | |
|
88465
ae455bb40718
(decode_coding_charset, encode_coding_charset): Handle
Kenichi Handa <handa@m17n.org>
parents:
88456
diff
changeset
|
5131 struct charset *charset; |
| 88365 | 5132 unsigned code; |
| 89483 | 5133 |
| 88365 | 5134 ASSURE_DESTINATION (safe_room); |
| 5135 c = *charbuf++; | |
| 5136 if (ascii_compatible && ASCII_CHAR_P (c)) | |
| 5137 EMIT_ONE_ASCII_BYTE (c); | |
|
88690
7f284ac55b07
(encode_coding_emacs_mule): Pay attention to raw-8-bit chars.
Kenichi Handa <handa@m17n.org>
parents:
88681
diff
changeset
|
5138 else if (CHAR_BYTE8_P (c)) |
|
7f284ac55b07
(encode_coding_emacs_mule): Pay attention to raw-8-bit chars.
Kenichi Handa <handa@m17n.org>
parents:
88681
diff
changeset
|
5139 { |
|
7f284ac55b07
(encode_coding_emacs_mule): Pay attention to raw-8-bit chars.
Kenichi Handa <handa@m17n.org>
parents:
88681
diff
changeset
|
5140 c = CHAR_TO_BYTE8 (c); |
|
7f284ac55b07
(encode_coding_emacs_mule): Pay attention to raw-8-bit chars.
Kenichi Handa <handa@m17n.org>
parents:
88681
diff
changeset
|
5141 EMIT_ONE_BYTE (c); |
|
7f284ac55b07
(encode_coding_emacs_mule): Pay attention to raw-8-bit chars.
Kenichi Handa <handa@m17n.org>
parents:
88681
diff
changeset
|
5142 } |
| 88365 | 5143 else |
|
88465
ae455bb40718
(decode_coding_charset, encode_coding_charset): Handle
Kenichi Handa <handa@m17n.org>
parents:
88456
diff
changeset
|
5144 { |
|
ae455bb40718
(decode_coding_charset, encode_coding_charset): Handle
Kenichi Handa <handa@m17n.org>
parents:
88456
diff
changeset
|
5145 charset = char_charset (c, charset_list, &code); |
|
ae455bb40718
(decode_coding_charset, encode_coding_charset): Handle
Kenichi Handa <handa@m17n.org>
parents:
88456
diff
changeset
|
5146 if (charset) |
|
ae455bb40718
(decode_coding_charset, encode_coding_charset): Handle
Kenichi Handa <handa@m17n.org>
parents:
88456
diff
changeset
|
5147 { |
|
ae455bb40718
(decode_coding_charset, encode_coding_charset): Handle
Kenichi Handa <handa@m17n.org>
parents:
88456
diff
changeset
|
5148 if (CHARSET_DIMENSION (charset) == 1) |
|
ae455bb40718
(decode_coding_charset, encode_coding_charset): Handle
Kenichi Handa <handa@m17n.org>
parents:
88456
diff
changeset
|
5149 EMIT_ONE_BYTE (code); |
|
ae455bb40718
(decode_coding_charset, encode_coding_charset): Handle
Kenichi Handa <handa@m17n.org>
parents:
88456
diff
changeset
|
5150 else if (CHARSET_DIMENSION (charset) == 2) |
|
ae455bb40718
(decode_coding_charset, encode_coding_charset): Handle
Kenichi Handa <handa@m17n.org>
parents:
88456
diff
changeset
|
5151 EMIT_TWO_BYTES (code >> 8, code & 0xFF); |
|
ae455bb40718
(decode_coding_charset, encode_coding_charset): Handle
Kenichi Handa <handa@m17n.org>
parents:
88456
diff
changeset
|
5152 else if (CHARSET_DIMENSION (charset) == 3) |
|
ae455bb40718
(decode_coding_charset, encode_coding_charset): Handle
Kenichi Handa <handa@m17n.org>
parents:
88456
diff
changeset
|
5153 EMIT_THREE_BYTES (code >> 16, (code >> 8) & 0xFF, code & 0xFF); |
|
ae455bb40718
(decode_coding_charset, encode_coding_charset): Handle
Kenichi Handa <handa@m17n.org>
parents:
88456
diff
changeset
|
5154 else |
|
ae455bb40718
(decode_coding_charset, encode_coding_charset): Handle
Kenichi Handa <handa@m17n.org>
parents:
88456
diff
changeset
|
5155 EMIT_FOUR_BYTES (code >> 24, (code >> 16) & 0xFF, |
|
ae455bb40718
(decode_coding_charset, encode_coding_charset): Handle
Kenichi Handa <handa@m17n.org>
parents:
88456
diff
changeset
|
5156 (code >> 8) & 0xFF, code & 0xFF); |
|
ae455bb40718
(decode_coding_charset, encode_coding_charset): Handle
Kenichi Handa <handa@m17n.org>
parents:
88456
diff
changeset
|
5157 } |
|
ae455bb40718
(decode_coding_charset, encode_coding_charset): Handle
Kenichi Handa <handa@m17n.org>
parents:
88456
diff
changeset
|
5158 else |
|
88573
133bf7ab1bad
(encode_coding_iso_2022): If coding requires safe
Kenichi Handa <handa@m17n.org>
parents:
88544
diff
changeset
|
5159 { |
|
133bf7ab1bad
(encode_coding_iso_2022): If coding requires safe
Kenichi Handa <handa@m17n.org>
parents:
88544
diff
changeset
|
5160 if (coding->mode & CODING_MODE_SAFE_ENCODING) |
|
133bf7ab1bad
(encode_coding_iso_2022): If coding requires safe
Kenichi Handa <handa@m17n.org>
parents:
88544
diff
changeset
|
5161 c = CODING_INHIBIT_CHARACTER_SUBSTITUTION; |
|
133bf7ab1bad
(encode_coding_iso_2022): If coding requires safe
Kenichi Handa <handa@m17n.org>
parents:
88544
diff
changeset
|
5162 else |
|
133bf7ab1bad
(encode_coding_iso_2022): If coding requires safe
Kenichi Handa <handa@m17n.org>
parents:
88544
diff
changeset
|
5163 c = coding->default_char; |
|
133bf7ab1bad
(encode_coding_iso_2022): If coding requires safe
Kenichi Handa <handa@m17n.org>
parents:
88544
diff
changeset
|
5164 EMIT_ONE_BYTE (c); |
|
133bf7ab1bad
(encode_coding_iso_2022): If coding requires safe
Kenichi Handa <handa@m17n.org>
parents:
88544
diff
changeset
|
5165 } |
|
88465
ae455bb40718
(decode_coding_charset, encode_coding_charset): Handle
Kenichi Handa <handa@m17n.org>
parents:
88456
diff
changeset
|
5166 } |
| 88365 | 5167 } |
| 5168 | |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
5169 record_conversion_result (coding, CODING_RESULT_SUCCESS); |
| 88365 | 5170 coding->produced_char += produced_chars; |
| 5171 coding->produced = dst - coding->destination; | |
| 5172 return 0; | |
| 17052 | 5173 } |
| 5174 | |
| 5175 | |
|
22874
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
5176 /*** 7. C library functions ***/ |
| 17052 | 5177 |
| 88365 | 5178 /* Setup coding context CODING from information about CODING_SYSTEM. |
| 5179 If CODING_SYSTEM is nil, `no-conversion' is assumed. If | |
| 5180 CODING_SYSTEM is invalid, signal an error. */ | |
| 5181 | |
| 5182 void | |
|
17119
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
5183 setup_coding_system (coding_system, coding) |
|
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
5184 Lisp_Object coding_system; |
| 17052 | 5185 struct coding_system *coding; |
| 5186 { | |
| 88365 | 5187 Lisp_Object attrs; |
| 5188 Lisp_Object eol_type; | |
| 5189 Lisp_Object coding_type; | |
|
20105
c017642863c2
(Qcoding_system_spec): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
19824
diff
changeset
|
5190 Lisp_Object val; |
| 17052 | 5191 |
|
24460
be35d27a4bfb
(setup_coding_system): Check for CODING_SYSTEM = nil.
Kenichi Handa <handa@m17n.org>
parents:
24425
diff
changeset
|
5192 if (NILP (coding_system)) |
|
90011
26cef35a1562
(setup_coding_system): If coding_system is nil, use
Kenichi Handa <handa@m17n.org>
parents:
89976
diff
changeset
|
5193 coding_system = Qundecided; |
| 88365 | 5194 |
| 5195 CHECK_CODING_SYSTEM_GET_ID (coding_system, coding->id); | |
| 5196 | |
| 5197 attrs = CODING_ID_ATTRS (coding->id); | |
| 5198 eol_type = CODING_ID_EOL_TYPE (coding->id); | |
| 5199 | |
| 5200 coding->mode = 0; | |
| 5201 coding->head_ascii = -1; | |
| 17052 | 5202 if (VECTORP (eol_type)) |
|
90587
fe721cfad011
(setup_coding_system): Fix setting of
Kenichi Handa <handa@m17n.org>
parents:
90573
diff
changeset
|
5203 coding->common_flags = (CODING_REQUIRE_DECODING_MASK |
|
fe721cfad011
(setup_coding_system): Fix setting of
Kenichi Handa <handa@m17n.org>
parents:
90573
diff
changeset
|
5204 | CODING_REQUIRE_DETECTION_MASK); |
|
fe721cfad011
(setup_coding_system): Fix setting of
Kenichi Handa <handa@m17n.org>
parents:
90573
diff
changeset
|
5205 else if (! EQ (eol_type, Qunix)) |
|
fe721cfad011
(setup_coding_system): Fix setting of
Kenichi Handa <handa@m17n.org>
parents:
90573
diff
changeset
|
5206 coding->common_flags = (CODING_REQUIRE_DECODING_MASK |
|
fe721cfad011
(setup_coding_system): Fix setting of
Kenichi Handa <handa@m17n.org>
parents:
90573
diff
changeset
|
5207 | CODING_REQUIRE_ENCODING_MASK); |
|
fe721cfad011
(setup_coding_system): Fix setting of
Kenichi Handa <handa@m17n.org>
parents:
90573
diff
changeset
|
5208 else |
|
fe721cfad011
(setup_coding_system): Fix setting of
Kenichi Handa <handa@m17n.org>
parents:
90573
diff
changeset
|
5209 coding->common_flags = 0; |
|
89448
de8b460070cc
(setup_coding_system): If coding has
Kenichi Handa <handa@m17n.org>
parents:
89446
diff
changeset
|
5210 if (! NILP (CODING_ATTR_POST_READ (attrs))) |
|
de8b460070cc
(setup_coding_system): If coding has
Kenichi Handa <handa@m17n.org>
parents:
89446
diff
changeset
|
5211 coding->common_flags |= CODING_REQUIRE_DECODING_MASK; |
|
de8b460070cc
(setup_coding_system): If coding has
Kenichi Handa <handa@m17n.org>
parents:
89446
diff
changeset
|
5212 if (! NILP (CODING_ATTR_PRE_WRITE (attrs))) |
|
de8b460070cc
(setup_coding_system): If coding has
Kenichi Handa <handa@m17n.org>
parents:
89446
diff
changeset
|
5213 coding->common_flags |= CODING_REQUIRE_ENCODING_MASK; |
| 89483 | 5214 if (! NILP (CODING_ATTR_FOR_UNIBYTE (attrs))) |
| 5215 coding->common_flags |= CODING_FOR_UNIBYTE_MASK; | |
| 88365 | 5216 |
| 5217 val = CODING_ATTR_SAFE_CHARSETS (attrs); | |
| 89483 | 5218 coding->max_charset_id = SCHARS (val) - 1; |
| 5219 coding->safe_charsets = (char *) SDATA (val); | |
| 88365 | 5220 coding->default_char = XINT (CODING_ATTR_DEFAULT_CHAR (attrs)); |
| 5221 | |
| 5222 coding_type = CODING_ATTR_TYPE (attrs); | |
| 5223 if (EQ (coding_type, Qundecided)) | |
| 5224 { | |
| 5225 coding->detector = NULL; | |
| 5226 coding->decoder = decode_coding_raw_text; | |
| 5227 coding->encoder = encode_coding_raw_text; | |
| 5228 coding->common_flags |= CODING_REQUIRE_DETECTION_MASK; | |
| 5229 } | |
| 5230 else if (EQ (coding_type, Qiso_2022)) | |
| 5231 { | |
| 5232 int i; | |
| 5233 int flags = XINT (AREF (attrs, coding_attr_iso_flags)); | |
| 5234 | |
| 5235 /* Invoke graphic register 0 to plane 0. */ | |
| 5236 CODING_ISO_INVOCATION (coding, 0) = 0; | |
| 5237 /* Invoke graphic register 1 to plane 1 if we can use 8-bit. */ | |
| 5238 CODING_ISO_INVOCATION (coding, 1) | |
| 5239 = (flags & CODING_ISO_FLAG_SEVEN_BITS ? -1 : 1); | |
| 5240 /* Setup the initial status of designation. */ | |
| 5241 for (i = 0; i < 4; i++) | |
| 5242 CODING_ISO_DESIGNATION (coding, i) = CODING_ISO_INITIAL (coding, i); | |
| 5243 /* Not single shifting initially. */ | |
| 5244 CODING_ISO_SINGLE_SHIFTING (coding) = 0; | |
| 5245 /* Beginning of buffer should also be regarded as bol. */ | |
| 5246 CODING_ISO_BOL (coding) = 1; | |
| 5247 coding->detector = detect_coding_iso_2022; | |
| 5248 coding->decoder = decode_coding_iso_2022; | |
| 5249 coding->encoder = encode_coding_iso_2022; | |
| 5250 if (flags & CODING_ISO_FLAG_SAFE) | |
| 5251 coding->mode |= CODING_MODE_SAFE_ENCODING; | |
|
20227
71008f909642
(setup_coding_system): Initialize common_flags member
Kenichi Handa <handa@m17n.org>
parents:
20150
diff
changeset
|
5252 coding->common_flags |
| 88365 | 5253 |= (CODING_REQUIRE_DECODING_MASK | CODING_REQUIRE_ENCODING_MASK |
| 5254 | CODING_REQUIRE_FLUSHING_MASK); | |
| 5255 if (flags & CODING_ISO_FLAG_COMPOSITION) | |
| 5256 coding->common_flags |= CODING_ANNOTATE_COMPOSITION_MASK; | |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
5257 if (flags & CODING_ISO_FLAG_DESIGNATION) |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
5258 coding->common_flags |= CODING_ANNOTATE_CHARSET_MASK; |
| 88365 | 5259 if (flags & CODING_ISO_FLAG_FULL_SUPPORT) |
|
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5260 { |
| 88365 | 5261 setup_iso_safe_charsets (attrs); |
| 5262 val = CODING_ATTR_SAFE_CHARSETS (attrs); | |
| 89483 | 5263 coding->max_charset_id = SCHARS (val) - 1; |
| 5264 coding->safe_charsets = (char *) SDATA (val); | |
|
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5265 } |
| 88365 | 5266 CODING_ISO_FLAGS (coding) = flags; |
| 5267 } | |
| 5268 else if (EQ (coding_type, Qcharset)) | |
| 5269 { | |
| 5270 coding->detector = detect_coding_charset; | |
| 5271 coding->decoder = decode_coding_charset; | |
| 5272 coding->encoder = encode_coding_charset; | |
|
34888
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
5273 coding->common_flags |
| 88365 | 5274 |= (CODING_REQUIRE_DECODING_MASK | CODING_REQUIRE_ENCODING_MASK); |
| 5275 } | |
| 5276 else if (EQ (coding_type, Qutf_8)) | |
| 5277 { | |
| 5278 coding->detector = detect_coding_utf_8; | |
| 5279 coding->decoder = decode_coding_utf_8; | |
| 5280 coding->encoder = encode_coding_utf_8; | |
|
34888
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
5281 coding->common_flags |
| 88365 | 5282 |= (CODING_REQUIRE_DECODING_MASK | CODING_REQUIRE_ENCODING_MASK); |
| 5283 } | |
| 5284 else if (EQ (coding_type, Qutf_16)) | |
| 5285 { | |
| 5286 val = AREF (attrs, coding_attr_utf_16_bom); | |
| 5287 CODING_UTF_16_BOM (coding) = (CONSP (val) ? utf_16_detect_bom | |
| 5288 : EQ (val, Qt) ? utf_16_with_bom | |
| 5289 : utf_16_without_bom); | |
| 5290 val = AREF (attrs, coding_attr_utf_16_endian); | |
|
89420
c3e67ce6ee0f
(Qsignature, Qendian): Delete these variables.
Kenichi Handa <handa@m17n.org>
parents:
89418
diff
changeset
|
5291 CODING_UTF_16_ENDIAN (coding) = (EQ (val, Qbig) ? utf_16_big_endian |
| 88365 | 5292 : utf_16_little_endian); |
|
88438
3a34b722dd71
(encode_coding_utf_8): Initialize produced_chars to 0.
Kenichi Handa <handa@m17n.org>
parents:
88430
diff
changeset
|
5293 CODING_UTF_16_SURROGATE (coding) = 0; |
| 88365 | 5294 coding->detector = detect_coding_utf_16; |
| 5295 coding->decoder = decode_coding_utf_16; | |
| 5296 coding->encoder = encode_coding_utf_16; | |
|
20227
71008f909642
(setup_coding_system): Initialize common_flags member
Kenichi Handa <handa@m17n.org>
parents:
20150
diff
changeset
|
5297 coding->common_flags |
| 88365 | 5298 |= (CODING_REQUIRE_DECODING_MASK | CODING_REQUIRE_ENCODING_MASK); |
|
89420
c3e67ce6ee0f
(Qsignature, Qendian): Delete these variables.
Kenichi Handa <handa@m17n.org>
parents:
89418
diff
changeset
|
5299 if (CODING_UTF_16_BOM (coding) == utf_16_detect_bom) |
|
c3e67ce6ee0f
(Qsignature, Qendian): Delete these variables.
Kenichi Handa <handa@m17n.org>
parents:
89418
diff
changeset
|
5300 coding->common_flags |= CODING_REQUIRE_DETECTION_MASK; |
| 88365 | 5301 } |
| 5302 else if (EQ (coding_type, Qccl)) | |
| 5303 { | |
| 5304 coding->detector = detect_coding_ccl; | |
| 5305 coding->decoder = decode_coding_ccl; | |
| 5306 coding->encoder = encode_coding_ccl; | |
|
20227
71008f909642
(setup_coding_system): Initialize common_flags member
Kenichi Handa <handa@m17n.org>
parents:
20150
diff
changeset
|
5307 coding->common_flags |
| 88365 | 5308 |= (CODING_REQUIRE_DECODING_MASK | CODING_REQUIRE_ENCODING_MASK |
| 5309 | CODING_REQUIRE_FLUSHING_MASK); | |
| 5310 } | |
| 5311 else if (EQ (coding_type, Qemacs_mule)) | |
| 5312 { | |
| 5313 coding->detector = detect_coding_emacs_mule; | |
| 5314 coding->decoder = decode_coding_emacs_mule; | |
| 5315 coding->encoder = encode_coding_emacs_mule; | |
|
20227
71008f909642
(setup_coding_system): Initialize common_flags member
Kenichi Handa <handa@m17n.org>
parents:
20150
diff
changeset
|
5316 coding->common_flags |
| 88365 | 5317 |= (CODING_REQUIRE_DECODING_MASK | CODING_REQUIRE_ENCODING_MASK); |
| 5318 if (! NILP (AREF (attrs, coding_attr_emacs_mule_full)) | |
| 5319 && ! EQ (CODING_ATTR_CHARSET_LIST (attrs), Vemacs_mule_charset_list)) | |
| 5320 { | |
| 5321 Lisp_Object tail, safe_charsets; | |
| 5322 int max_charset_id = 0; | |
| 5323 | |
| 5324 for (tail = Vemacs_mule_charset_list; CONSP (tail); | |
| 5325 tail = XCDR (tail)) | |
| 5326 if (max_charset_id < XFASTINT (XCAR (tail))) | |
| 5327 max_charset_id = XFASTINT (XCAR (tail)); | |
| 5328 safe_charsets = Fmake_string (make_number (max_charset_id + 1), | |
| 5329 make_number (255)); | |
| 5330 for (tail = Vemacs_mule_charset_list; CONSP (tail); | |
| 5331 tail = XCDR (tail)) | |
| 89483 | 5332 SSET (safe_charsets, XFASTINT (XCAR (tail)), 0); |
| 88365 | 5333 coding->max_charset_id = max_charset_id; |
| 89483 | 5334 coding->safe_charsets = (char *) SDATA (safe_charsets); |
| 88365 | 5335 } |
| 5336 } | |
| 5337 else if (EQ (coding_type, Qshift_jis)) | |
| 5338 { | |
| 5339 coding->detector = detect_coding_sjis; | |
| 5340 coding->decoder = decode_coding_sjis; | |
| 5341 coding->encoder = encode_coding_sjis; | |
| 5342 coding->common_flags | |
| 5343 |= (CODING_REQUIRE_DECODING_MASK | CODING_REQUIRE_ENCODING_MASK); | |
| 5344 } | |
| 5345 else if (EQ (coding_type, Qbig5)) | |
| 5346 { | |
| 5347 coding->detector = detect_coding_big5; | |
| 5348 coding->decoder = decode_coding_big5; | |
| 5349 coding->encoder = encode_coding_big5; | |
|
20227
71008f909642
(setup_coding_system): Initialize common_flags member
Kenichi Handa <handa@m17n.org>
parents:
20150
diff
changeset
|
5350 coding->common_flags |
| 88365 | 5351 |= (CODING_REQUIRE_DECODING_MASK | CODING_REQUIRE_ENCODING_MASK); |
| 5352 } | |
| 5353 else /* EQ (coding_type, Qraw_text) */ | |
| 5354 { | |
| 5355 coding->detector = NULL; | |
| 5356 coding->decoder = decode_coding_raw_text; | |
| 5357 coding->encoder = encode_coding_raw_text; | |
|
89933
48af0ea7d387
(setup_coding_system): Set coding->common_flags
Kenichi Handa <handa@m17n.org>
parents:
89924
diff
changeset
|
5358 if (! EQ (eol_type, Qunix)) |
|
48af0ea7d387
(setup_coding_system): Set coding->common_flags
Kenichi Handa <handa@m17n.org>
parents:
89924
diff
changeset
|
5359 { |
|
48af0ea7d387
(setup_coding_system): Set coding->common_flags
Kenichi Handa <handa@m17n.org>
parents:
89924
diff
changeset
|
5360 coding->common_flags |= CODING_REQUIRE_DECODING_MASK; |
|
48af0ea7d387
(setup_coding_system): Set coding->common_flags
Kenichi Handa <handa@m17n.org>
parents:
89924
diff
changeset
|
5361 if (! VECTORP (eol_type)) |
|
48af0ea7d387
(setup_coding_system): Set coding->common_flags
Kenichi Handa <handa@m17n.org>
parents:
89924
diff
changeset
|
5362 coding->common_flags |= CODING_REQUIRE_ENCODING_MASK; |
|
48af0ea7d387
(setup_coding_system): Set coding->common_flags
Kenichi Handa <handa@m17n.org>
parents:
89924
diff
changeset
|
5363 } |
|
48af0ea7d387
(setup_coding_system): Set coding->common_flags
Kenichi Handa <handa@m17n.org>
parents:
89924
diff
changeset
|
5364 |
| 88365 | 5365 } |
| 5366 | |
|
22616
c493ce6a31e4
(setup_raw_text_coding_system): New function.
Kenichi Handa <handa@m17n.org>
parents:
22529
diff
changeset
|
5367 return; |
|
c493ce6a31e4
(setup_raw_text_coding_system): New function.
Kenichi Handa <handa@m17n.org>
parents:
22529
diff
changeset
|
5368 } |
|
c493ce6a31e4
(setup_raw_text_coding_system): New function.
Kenichi Handa <handa@m17n.org>
parents:
22529
diff
changeset
|
5369 |
|
90061
48210be97b12
Cancel the change done in HEAD on 2004-11-30.
Kenichi Handa <handa@m17n.org>
parents:
90054
diff
changeset
|
5370 /* Return a list of charsets supported by CODING. */ |
|
48210be97b12
Cancel the change done in HEAD on 2004-11-30.
Kenichi Handa <handa@m17n.org>
parents:
90054
diff
changeset
|
5371 |
|
48210be97b12
Cancel the change done in HEAD on 2004-11-30.
Kenichi Handa <handa@m17n.org>
parents:
90054
diff
changeset
|
5372 Lisp_Object |
|
48210be97b12
Cancel the change done in HEAD on 2004-11-30.
Kenichi Handa <handa@m17n.org>
parents:
90054
diff
changeset
|
5373 coding_charset_list (coding) |
| 26847 | 5374 struct coding_system *coding; |
| 5375 { | |
|
90214
460ee00505d5
(QCascii_compatible_p): New variable.
Kenichi Handa <handa@m17n.org>
parents:
90201
diff
changeset
|
5376 Lisp_Object attrs, charset_list; |
|
90061
48210be97b12
Cancel the change done in HEAD on 2004-11-30.
Kenichi Handa <handa@m17n.org>
parents:
90054
diff
changeset
|
5377 |
|
48210be97b12
Cancel the change done in HEAD on 2004-11-30.
Kenichi Handa <handa@m17n.org>
parents:
90054
diff
changeset
|
5378 CODING_GET_INFO (coding, attrs, charset_list); |
|
48210be97b12
Cancel the change done in HEAD on 2004-11-30.
Kenichi Handa <handa@m17n.org>
parents:
90054
diff
changeset
|
5379 if (EQ (CODING_ATTR_TYPE (attrs), Qiso_2022)) |
|
48210be97b12
Cancel the change done in HEAD on 2004-11-30.
Kenichi Handa <handa@m17n.org>
parents:
90054
diff
changeset
|
5380 { |
|
48210be97b12
Cancel the change done in HEAD on 2004-11-30.
Kenichi Handa <handa@m17n.org>
parents:
90054
diff
changeset
|
5381 int flags = XINT (AREF (attrs, coding_attr_iso_flags)); |
|
48210be97b12
Cancel the change done in HEAD on 2004-11-30.
Kenichi Handa <handa@m17n.org>
parents:
90054
diff
changeset
|
5382 |
|
48210be97b12
Cancel the change done in HEAD on 2004-11-30.
Kenichi Handa <handa@m17n.org>
parents:
90054
diff
changeset
|
5383 if (flags & CODING_ISO_FLAG_FULL_SUPPORT) |
|
48210be97b12
Cancel the change done in HEAD on 2004-11-30.
Kenichi Handa <handa@m17n.org>
parents:
90054
diff
changeset
|
5384 charset_list = Viso_2022_charset_list; |
|
48210be97b12
Cancel the change done in HEAD on 2004-11-30.
Kenichi Handa <handa@m17n.org>
parents:
90054
diff
changeset
|
5385 } |
|
48210be97b12
Cancel the change done in HEAD on 2004-11-30.
Kenichi Handa <handa@m17n.org>
parents:
90054
diff
changeset
|
5386 else if (EQ (CODING_ATTR_TYPE (attrs), Qemacs_mule)) |
|
48210be97b12
Cancel the change done in HEAD on 2004-11-30.
Kenichi Handa <handa@m17n.org>
parents:
90054
diff
changeset
|
5387 { |
|
48210be97b12
Cancel the change done in HEAD on 2004-11-30.
Kenichi Handa <handa@m17n.org>
parents:
90054
diff
changeset
|
5388 charset_list = Vemacs_mule_charset_list; |
|
48210be97b12
Cancel the change done in HEAD on 2004-11-30.
Kenichi Handa <handa@m17n.org>
parents:
90054
diff
changeset
|
5389 } |
|
48210be97b12
Cancel the change done in HEAD on 2004-11-30.
Kenichi Handa <handa@m17n.org>
parents:
90054
diff
changeset
|
5390 return charset_list; |
|
48210be97b12
Cancel the change done in HEAD on 2004-11-30.
Kenichi Handa <handa@m17n.org>
parents:
90054
diff
changeset
|
5391 } |
|
48210be97b12
Cancel the change done in HEAD on 2004-11-30.
Kenichi Handa <handa@m17n.org>
parents:
90054
diff
changeset
|
5392 |
|
48210be97b12
Cancel the change done in HEAD on 2004-11-30.
Kenichi Handa <handa@m17n.org>
parents:
90054
diff
changeset
|
5393 |
| 88365 | 5394 /* Return raw-text or one of its subsidiaries that has the same |
| 5395 eol_type as CODING-SYSTEM. */ | |
| 5396 | |
| 5397 Lisp_Object | |
| 5398 raw_text_coding_system (coding_system) | |
| 5399 Lisp_Object coding_system; | |
| 26847 | 5400 { |
|
88430
6418a272b97e
* coding.c: Delete unused variables.
Kenichi Handa <handa@m17n.org>
parents:
88365
diff
changeset
|
5401 Lisp_Object spec, attrs; |
| 88365 | 5402 Lisp_Object eol_type, raw_text_eol_type; |
| 5403 | |
|
89462
4e359ebf3984
(decode_coding_iso_2022): Fix handling of invalid
Kenichi Handa <handa@m17n.org>
parents:
89448
diff
changeset
|
5404 if (NILP (coding_system)) |
|
4e359ebf3984
(decode_coding_iso_2022): Fix handling of invalid
Kenichi Handa <handa@m17n.org>
parents:
89448
diff
changeset
|
5405 return Qraw_text; |
| 88365 | 5406 spec = CODING_SYSTEM_SPEC (coding_system); |
| 5407 attrs = AREF (spec, 0); | |
| 89483 | 5408 |
| 88365 | 5409 if (EQ (CODING_ATTR_TYPE (attrs), Qraw_text)) |
| 5410 return coding_system; | |
| 5411 | |
| 5412 eol_type = AREF (spec, 2); | |
| 5413 if (VECTORP (eol_type)) | |
| 5414 return Qraw_text; | |
| 5415 spec = CODING_SYSTEM_SPEC (Qraw_text); | |
| 5416 raw_text_eol_type = AREF (spec, 2); | |
| 5417 return (EQ (eol_type, Qunix) ? AREF (raw_text_eol_type, 0) | |
| 5418 : EQ (eol_type, Qdos) ? AREF (raw_text_eol_type, 1) | |
| 5419 : AREF (raw_text_eol_type, 2)); | |
| 26847 | 5420 } |
| 5421 | |
| 88365 | 5422 |
| 5423 /* If CODING_SYSTEM doesn't specify end-of-line format but PARENT | |
| 5424 does, return one of the subsidiary that has the same eol-spec as | |
|
90394
263867fe7b55
(system_eol_type): Sync with HEAD.
Kenichi Handa <handa@m17n.org>
parents:
90380
diff
changeset
|
5425 PARENT. Otherwise, return CODING_SYSTEM. If PARENT is nil, |
|
263867fe7b55
(system_eol_type): Sync with HEAD.
Kenichi Handa <handa@m17n.org>
parents:
90380
diff
changeset
|
5426 inherit end-of-line format from the system's setting |
|
263867fe7b55
(system_eol_type): Sync with HEAD.
Kenichi Handa <handa@m17n.org>
parents:
90380
diff
changeset
|
5427 (system_eol_type). */ |
| 88365 | 5428 |
| 5429 Lisp_Object | |
| 5430 coding_inherit_eol_type (coding_system, parent) | |
| 88473 | 5431 Lisp_Object coding_system, parent; |
|
22616
c493ce6a31e4
(setup_raw_text_coding_system): New function.
Kenichi Handa <handa@m17n.org>
parents:
22529
diff
changeset
|
5432 { |
|
89545
4f394eed6ff2
(inhibit_pre_post_conversion): Removed (unused).
Dave Love <fx@gnu.org>
parents:
89519
diff
changeset
|
5433 Lisp_Object spec, eol_type; |
| 88365 | 5434 |
|
89462
4e359ebf3984
(decode_coding_iso_2022): Fix handling of invalid
Kenichi Handa <handa@m17n.org>
parents:
89448
diff
changeset
|
5435 if (NILP (coding_system)) |
|
4e359ebf3984
(decode_coding_iso_2022): Fix handling of invalid
Kenichi Handa <handa@m17n.org>
parents:
89448
diff
changeset
|
5436 coding_system = Qraw_text; |
| 88365 | 5437 spec = CODING_SYSTEM_SPEC (coding_system); |
| 5438 eol_type = AREF (spec, 2); | |
|
90394
263867fe7b55
(system_eol_type): Sync with HEAD.
Kenichi Handa <handa@m17n.org>
parents:
90380
diff
changeset
|
5439 if (VECTORP (eol_type)) |
|
263867fe7b55
(system_eol_type): Sync with HEAD.
Kenichi Handa <handa@m17n.org>
parents:
90380
diff
changeset
|
5440 { |
| 88365 | 5441 Lisp_Object parent_eol_type; |
| 5442 | |
|
90394
263867fe7b55
(system_eol_type): Sync with HEAD.
Kenichi Handa <handa@m17n.org>
parents:
90380
diff
changeset
|
5443 if (! NILP (parent)) |
|
263867fe7b55
(system_eol_type): Sync with HEAD.
Kenichi Handa <handa@m17n.org>
parents:
90380
diff
changeset
|
5444 { |
|
263867fe7b55
(system_eol_type): Sync with HEAD.
Kenichi Handa <handa@m17n.org>
parents:
90380
diff
changeset
|
5445 Lisp_Object parent_spec; |
|
263867fe7b55
(system_eol_type): Sync with HEAD.
Kenichi Handa <handa@m17n.org>
parents:
90380
diff
changeset
|
5446 |
|
90587
fe721cfad011
(setup_coding_system): Fix setting of
Kenichi Handa <handa@m17n.org>
parents:
90573
diff
changeset
|
5447 parent_spec = CODING_SYSTEM_SPEC (parent); |
|
90394
263867fe7b55
(system_eol_type): Sync with HEAD.
Kenichi Handa <handa@m17n.org>
parents:
90380
diff
changeset
|
5448 parent_eol_type = AREF (parent_spec, 2); |
|
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5449 } |
|
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5450 else |
|
90394
263867fe7b55
(system_eol_type): Sync with HEAD.
Kenichi Handa <handa@m17n.org>
parents:
90380
diff
changeset
|
5451 parent_eol_type = system_eol_type; |
| 88365 | 5452 if (EQ (parent_eol_type, Qunix)) |
| 5453 coding_system = AREF (eol_type, 0); | |
| 5454 else if (EQ (parent_eol_type, Qdos)) | |
| 5455 coding_system = AREF (eol_type, 1); | |
| 5456 else if (EQ (parent_eol_type, Qmac)) | |
| 5457 coding_system = AREF (eol_type, 2); | |
| 5458 } | |
| 5459 return coding_system; | |
|
22616
c493ce6a31e4
(setup_raw_text_coding_system): New function.
Kenichi Handa <handa@m17n.org>
parents:
22529
diff
changeset
|
5460 } |
|
c493ce6a31e4
(setup_raw_text_coding_system): New function.
Kenichi Handa <handa@m17n.org>
parents:
22529
diff
changeset
|
5461 |
| 17052 | 5462 /* Emacs has a mechanism to automatically detect a coding system if it |
| 5463 is one of Emacs' internal format, ISO2022, SJIS, and BIG5. But, | |
| 5464 it's impossible to distinguish some coding systems accurately | |
| 5465 because they use the same range of codes. So, at first, coding | |
| 5466 systems are categorized into 7, those are: | |
| 5467 | |
|
17835
f36ffb6f1208
Name change through the code:
Kenichi Handa <handa@m17n.org>
parents:
17725
diff
changeset
|
5468 o coding-category-emacs-mule |
| 17052 | 5469 |
| 5470 The category for a coding system which has the same code range | |
| 5471 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
|
5472 symbol) `emacs-mule' by default. |
| 17052 | 5473 |
| 5474 o coding-category-sjis | |
| 5475 | |
| 5476 The category for a coding system which has the same code range | |
| 5477 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
|
5478 symbol) `japanese-shift-jis' by default. |
| 17052 | 5479 |
| 5480 o coding-category-iso-7 | |
| 5481 | |
| 5482 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
|
5483 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
|
5484 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
|
5485 charsets. Assigned the coding-system (Lisp symbol) |
|
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5486 `iso-2022-7bit' by default. |
|
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5487 |
|
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5488 o coding-category-iso-7-tight |
|
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5489 |
|
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5490 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
|
5491 encode/decode only the specified charsets. |
| 17052 | 5492 |
| 5493 o coding-category-iso-8-1 | |
| 5494 | |
| 5495 The category for a coding system which has the same code range | |
| 5496 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
|
5497 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
|
5498 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
|
5499 symbol) `iso-latin-1' by default. |
| 17052 | 5500 |
| 5501 o coding-category-iso-8-2 | |
| 5502 | |
| 5503 The category for a coding system which has the same code range | |
| 5504 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
|
5505 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
|
5506 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
|
5507 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
|
5508 |
|
954e6be0a757
(detect_coding_iso2022): Distinguish coding-category-iso-7-else and
Kenichi Handa <handa@m17n.org>
parents:
18766
diff
changeset
|
5509 o coding-category-iso-7-else |
| 17052 | 5510 |
| 5511 The category for a coding system which has the same code range | |
| 88365 | 5512 as ISO2022 of 7-bit environemnt but uses locking shift or |
|
18787
954e6be0a757
(detect_coding_iso2022): Distinguish coding-category-iso-7-else and
Kenichi Handa <handa@m17n.org>
parents:
18766
diff
changeset
|
5513 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
|
5514 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
|
5515 |
|
954e6be0a757
(detect_coding_iso2022): Distinguish coding-category-iso-7-else and
Kenichi Handa <handa@m17n.org>
parents:
18766
diff
changeset
|
5516 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
|
5517 |
|
954e6be0a757
(detect_coding_iso2022): Distinguish coding-category-iso-7-else and
Kenichi Handa <handa@m17n.org>
parents:
18766
diff
changeset
|
5518 The category for a coding system which has the same code range |
| 88365 | 5519 as ISO2022 of 8-bit environemnt but uses locking shift or |
|
18787
954e6be0a757
(detect_coding_iso2022): Distinguish coding-category-iso-7-else and
Kenichi Handa <handa@m17n.org>
parents:
18766
diff
changeset
|
5520 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
|
5521 symbol) `iso-2022-8bit-ss2' by default. |
| 17052 | 5522 |
| 5523 o coding-category-big5 | |
| 5524 | |
| 5525 The category for a coding system which has the same code range | |
| 5526 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
|
5527 `cn-big5' by default. |
| 17052 | 5528 |
|
28022
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
5529 o coding-category-utf-8 |
|
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
5530 |
|
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
5531 The category for a coding system which has the same code range |
| 54303 | 5532 as UTF-8 (cf. RFC3629). Assigned the coding-system (Lisp |
|
28022
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
5533 symbol) `utf-8' by default. |
|
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
5534 |
|
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
5535 o coding-category-utf-16-be |
|
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
5536 |
|
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
5537 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
|
5538 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
|
5539 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
|
5540 `utf-16-be' by default. |
|
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
5541 |
|
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
5542 o coding-category-utf-16-le |
|
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
5543 |
|
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
5544 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
|
5545 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
|
5546 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
|
5547 symbol) `utf-16-le' by default. |
|
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
5548 |
|
22874
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
5549 o coding-category-ccl |
|
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
5550 |
|
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
5551 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
|
5552 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
|
5553 coding system is assigned. |
|
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
5554 |
| 17052 | 5555 o coding-category-binary |
| 5556 | |
| 5557 The category for a coding system not categorized in any of the | |
| 5558 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
|
5559 `no-conversion' by default. |
| 17052 | 5560 |
| 5561 Each of them is a Lisp symbol and the value is an actual | |
| 88365 | 5562 `coding-system's (this is also a Lisp symbol) assigned by a user. |
| 17052 | 5563 What Emacs does actually is to detect a category of coding system. |
| 5564 Then, it uses a `coding-system' assigned to it. If Emacs can't | |
| 88365 | 5565 decide only one possible category, it selects a category of the |
| 17052 | 5566 highest priority. Priorities of categories are also specified by a |
| 5567 user in a Lisp variable `coding-category-list'. | |
| 5568 | |
| 5569 */ | |
| 5570 | |
| 88365 | 5571 #define EOL_SEEN_NONE 0 |
| 5572 #define EOL_SEEN_LF 1 | |
| 5573 #define EOL_SEEN_CR 2 | |
| 5574 #define EOL_SEEN_CRLF 4 | |
| 17052 | 5575 |
|
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5576 /* Detect how end-of-line of a text of length SRC_BYTES pointed by |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
5577 SOURCE is encoded. If CATEGORY is one of |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
5578 coding_category_utf_16_XXXX, assume that CR and LF are encoded by |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
5579 two-byte, else they are encoded by one-byte. |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
5580 |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
5581 Return one of EOL_SEEN_XXX. */ |
| 17052 | 5582 |
|
19173
04ed7c3f5cee
(detect_eol_type): If EOL representation does not
Richard M. Stallman <rms@gnu.org>
parents:
19134
diff
changeset
|
5583 #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
|
5584 |
|
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5585 static int |
|
89193
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
5586 detect_eol (source, src_bytes, category) |
|
84646
922a7e3b7383
(detect_eol_type, detect_eol_type_in_2_octet_form):
Micha?l Cadilhac <michael.cadilhac@lrde.org>
parents:
83648
diff
changeset
|
5587 const unsigned char *source; |
| 88365 | 5588 EMACS_INT src_bytes; |
|
89193
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
5589 enum coding_category category; |
| 17052 | 5590 { |
|
84646
922a7e3b7383
(detect_eol_type, detect_eol_type_in_2_octet_form):
Micha?l Cadilhac <michael.cadilhac@lrde.org>
parents:
83648
diff
changeset
|
5591 const unsigned char *src = source, *src_end = src + src_bytes; |
| 17052 | 5592 unsigned char c; |
| 88365 | 5593 int total = 0; |
| 5594 int eol_seen = EOL_SEEN_NONE; | |
| 5595 | |
|
89193
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
5596 if ((1 << category) & CATEGORY_MASK_UTF_16) |
| 88365 | 5597 { |
| 5598 int msb, lsb; | |
| 5599 | |
|
89193
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
5600 msb = category == (coding_category_utf_16_le |
|
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
5601 | coding_category_utf_16_le_nosig); |
| 88365 | 5602 lsb = 1 - msb; |
| 5603 | |
| 5604 while (src + 1 < src_end) | |
| 17052 | 5605 { |
| 88365 | 5606 c = src[lsb]; |
| 5607 if (src[msb] == 0 && (c == '\n' || c == '\r')) | |
|
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5608 { |
| 88365 | 5609 int this_eol; |
| 5610 | |
| 5611 if (c == '\n') | |
| 5612 this_eol = EOL_SEEN_LF; | |
| 5613 else if (src + 3 >= src_end | |
| 5614 || src[msb + 2] != 0 | |
| 5615 || src[lsb + 2] != '\n') | |
| 5616 this_eol = EOL_SEEN_CR; | |
| 5617 else | |
| 89483 | 5618 this_eol = EOL_SEEN_CRLF; |
| 88365 | 5619 |
| 5620 if (eol_seen == EOL_SEEN_NONE) | |
| 5621 /* This is the first end-of-line. */ | |
| 5622 eol_seen = this_eol; | |
| 5623 else if (eol_seen != this_eol) | |
| 5624 { | |
| 5625 /* The found type is different from what found before. */ | |
| 5626 eol_seen = EOL_SEEN_LF; | |
| 5627 break; | |
| 5628 } | |
| 5629 if (++total == MAX_EOL_CHECK_COUNT) | |
| 5630 break; | |
| 5631 } | |
| 5632 src += 2; | |
| 5633 } | |
|
30833
2db6e42a6ba3
(MINIMUM_CONVERSION_BUFFER_SIZE): Macro deleted.
Kenichi Handa <handa@m17n.org>
parents:
30756
diff
changeset
|
5634 } |
| 88365 | 5635 else |
| 5636 { | |
| 5637 while (src < src_end) | |
| 5638 { | |
| 5639 c = *src++; | |
| 5640 if (c == '\n' || c == '\r') | |
|
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5641 { |
| 88365 | 5642 int this_eol; |
| 5643 | |
| 5644 if (c == '\n') | |
| 5645 this_eol = EOL_SEEN_LF; | |
| 5646 else if (src >= src_end || *src != '\n') | |
| 5647 this_eol = EOL_SEEN_CR; | |
| 5648 else | |
| 5649 this_eol = EOL_SEEN_CRLF, src++; | |
| 5650 | |
| 5651 if (eol_seen == EOL_SEEN_NONE) | |
| 5652 /* This is the first end-of-line. */ | |
| 5653 eol_seen = this_eol; | |
| 5654 else if (eol_seen != this_eol) | |
| 5655 { | |
| 5656 /* The found type is different from what found before. */ | |
| 5657 eol_seen = EOL_SEEN_LF; | |
| 5658 break; | |
| 5659 } | |
| 5660 if (++total == MAX_EOL_CHECK_COUNT) | |
| 5661 break; | |
|
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5662 } |
| 17052 | 5663 } |
| 5664 } | |
| 88365 | 5665 return eol_seen; |
| 17052 | 5666 } |
| 5667 | |
| 88365 | 5668 |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5669 static Lisp_Object |
| 88365 | 5670 adjust_coding_eol_type (coding, eol_seen) |
| 5671 struct coding_system *coding; | |
| 5672 int eol_seen; | |
| 5673 { | |
|
88430
6418a272b97e
* coding.c: Delete unused variables.
Kenichi Handa <handa@m17n.org>
parents:
88365
diff
changeset
|
5674 Lisp_Object eol_type; |
| 89483 | 5675 |
| 88365 | 5676 eol_type = CODING_ID_EOL_TYPE (coding->id); |
| 5677 if (eol_seen & EOL_SEEN_LF) | |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5678 { |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5679 coding->id = CODING_SYSTEM_ID (AREF (eol_type, 0)); |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5680 eol_type = Qunix; |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5681 } |
|
88862
108e2535280d
(adjust_coding_eol_type): Fix eol_type/eol_seen mixup.
Dave Love <fx@gnu.org>
parents:
88856
diff
changeset
|
5682 else if (eol_seen & EOL_SEEN_CRLF) |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5683 { |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5684 coding->id = CODING_SYSTEM_ID (AREF (eol_type, 1)); |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5685 eol_type = Qdos; |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5686 } |
|
88862
108e2535280d
(adjust_coding_eol_type): Fix eol_type/eol_seen mixup.
Dave Love <fx@gnu.org>
parents:
88856
diff
changeset
|
5687 else if (eol_seen & EOL_SEEN_CR) |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5688 { |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5689 coding->id = CODING_SYSTEM_ID (AREF (eol_type, 2)); |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5690 eol_type = Qmac; |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5691 } |
|
19181
917138730635
(detect_eol_type): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
19173
diff
changeset
|
5692 return eol_type; |
| 17052 | 5693 } |
| 5694 | |
| 88365 | 5695 /* Detect how a text specified in CODING is encoded. If a coding |
| 5696 system is detected, update fields of CODING by the detected coding | |
| 5697 system. */ | |
| 17052 | 5698 |
| 5699 void | |
| 88365 | 5700 detect_coding (coding) |
| 17052 | 5701 struct coding_system *coding; |
|
28022
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
5702 { |
| 89483 | 5703 const unsigned char *src, *src_end; |
| 88365 | 5704 |
| 5705 coding->consumed = coding->consumed_char = 0; | |
| 5706 coding->produced = coding->produced_char = 0; | |
| 5707 coding_set_source (coding); | |
| 5708 | |
| 5709 src_end = coding->source + coding->src_bytes; | |
| 5710 | |
| 5711 /* If we have not yet decided the text encoding type, detect it | |
| 5712 now. */ | |
| 5713 if (EQ (CODING_ATTR_TYPE (CODING_ID_ATTRS (coding->id)), Qundecided)) | |
| 5714 { | |
| 5715 int c, i; | |
|
89974
2fef8edebd5c
(detect_coding_utf_16): Don't set detect_info->found if
Kenichi Handa <handa@m17n.org>
parents:
89933
diff
changeset
|
5716 struct coding_detection_info detect_info; |
|
93595
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
5717 int null_byte_found = 0, eight_bit_found = 0; |
|
89974
2fef8edebd5c
(detect_coding_utf_16): Don't set detect_info->found if
Kenichi Handa <handa@m17n.org>
parents:
89933
diff
changeset
|
5718 |
|
2fef8edebd5c
(detect_coding_utf_16): Don't set detect_info->found if
Kenichi Handa <handa@m17n.org>
parents:
89933
diff
changeset
|
5719 detect_info.checked = detect_info.found = detect_info.rejected = 0; |
|
93595
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
5720 coding->head_ascii = -1; |
|
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
5721 for (src = coding->source; src < src_end; src++) |
|
28022
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
5722 { |
| 88365 | 5723 c = *src; |
|
89974
2fef8edebd5c
(detect_coding_utf_16): Don't set detect_info->found if
Kenichi Handa <handa@m17n.org>
parents:
89933
diff
changeset
|
5724 if (c & 0x80) |
|
93595
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
5725 { |
|
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
5726 eight_bit_found = 1; |
|
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
5727 if (coding->head_ascii < 0) |
|
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
5728 coding->head_ascii = src - coding->source; |
|
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
5729 if (null_byte_found) |
|
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
5730 break; |
|
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
5731 } |
|
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
5732 else if (c < 0x20) |
|
34892
3868f2e7355a
(setup_coding_system): Initialize
Kenichi Handa <handa@m17n.org>
parents:
34888
diff
changeset
|
5733 { |
|
93595
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
5734 if ((c == ISO_CODE_ESC || c == ISO_CODE_SI || c == ISO_CODE_SO) |
|
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
5735 && ! inhibit_iso_escape_detection |
|
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
5736 && ! detect_info.checked) |
|
34892
3868f2e7355a
(setup_coding_system): Initialize
Kenichi Handa <handa@m17n.org>
parents:
34888
diff
changeset
|
5737 { |
|
93595
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
5738 if (coding->head_ascii < 0) |
|
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
5739 coding->head_ascii = src - coding->source; |
|
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
5740 if (detect_coding_iso_2022 (coding, &detect_info)) |
|
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
5741 { |
|
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
5742 /* We have scanned the whole data. */ |
|
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
5743 if (! (detect_info.rejected & CATEGORY_MASK_ISO_7_ELSE)) |
|
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
5744 /* We didn't find an 8-bit code. We may have |
|
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
5745 found a null-byte, but it's very rare that |
|
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
5746 a binary file confirm to ISO-2022. */ |
|
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
5747 src = src_end; |
|
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
5748 break; |
|
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
5749 } |
|
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
5750 } |
|
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
5751 else if (! c) |
|
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
5752 { |
|
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
5753 null_byte_found = 1; |
|
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
5754 if (eight_bit_found) |
|
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
5755 break; |
|
34892
3868f2e7355a
(setup_coding_system): Initialize
Kenichi Handa <handa@m17n.org>
parents:
34888
diff
changeset
|
5756 } |
|
3868f2e7355a
(setup_coding_system): Initialize
Kenichi Handa <handa@m17n.org>
parents:
34888
diff
changeset
|
5757 } |
|
89974
2fef8edebd5c
(detect_coding_utf_16): Don't set detect_info->found if
Kenichi Handa <handa@m17n.org>
parents:
89933
diff
changeset
|
5758 } |
|
93595
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
5759 if (coding->head_ascii < 0) |
|
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
5760 coding->head_ascii = src - coding->source; |
|
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
5761 |
|
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
5762 if (null_byte_found || eight_bit_found |
|
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
5763 || coding->head_ascii < coding->src_bytes |
|
89974
2fef8edebd5c
(detect_coding_utf_16): Don't set detect_info->found if
Kenichi Handa <handa@m17n.org>
parents:
89933
diff
changeset
|
5764 || detect_info.found) |
|
2fef8edebd5c
(detect_coding_utf_16): Don't set detect_info->found if
Kenichi Handa <handa@m17n.org>
parents:
89933
diff
changeset
|
5765 { |
|
2fef8edebd5c
(detect_coding_utf_16): Don't set detect_info->found if
Kenichi Handa <handa@m17n.org>
parents:
89933
diff
changeset
|
5766 enum coding_category category; |
|
2fef8edebd5c
(detect_coding_utf_16): Don't set detect_info->found if
Kenichi Handa <handa@m17n.org>
parents:
89933
diff
changeset
|
5767 struct coding_system *this; |
|
2fef8edebd5c
(detect_coding_utf_16): Don't set detect_info->found if
Kenichi Handa <handa@m17n.org>
parents:
89933
diff
changeset
|
5768 |
|
2fef8edebd5c
(detect_coding_utf_16): Don't set detect_info->found if
Kenichi Handa <handa@m17n.org>
parents:
89933
diff
changeset
|
5769 if (coding->head_ascii == coding->src_bytes) |
|
2fef8edebd5c
(detect_coding_utf_16): Don't set detect_info->found if
Kenichi Handa <handa@m17n.org>
parents:
89933
diff
changeset
|
5770 /* As all bytes are 7-bit, we can ignore non-ISO-2022 codings. */ |
|
2fef8edebd5c
(detect_coding_utf_16): Don't set detect_info->found if
Kenichi Handa <handa@m17n.org>
parents:
89933
diff
changeset
|
5771 for (i = 0; i < coding_category_raw_text; i++) |
|
2fef8edebd5c
(detect_coding_utf_16): Don't set detect_info->found if
Kenichi Handa <handa@m17n.org>
parents:
89933
diff
changeset
|
5772 { |
|
2fef8edebd5c
(detect_coding_utf_16): Don't set detect_info->found if
Kenichi Handa <handa@m17n.org>
parents:
89933
diff
changeset
|
5773 category = coding_priorities[i]; |
|
2fef8edebd5c
(detect_coding_utf_16): Don't set detect_info->found if
Kenichi Handa <handa@m17n.org>
parents:
89933
diff
changeset
|
5774 this = coding_categories + category; |
|
2fef8edebd5c
(detect_coding_utf_16): Don't set detect_info->found if
Kenichi Handa <handa@m17n.org>
parents:
89933
diff
changeset
|
5775 if (detect_info.found & (1 << category)) |
|
2fef8edebd5c
(detect_coding_utf_16): Don't set detect_info->found if
Kenichi Handa <handa@m17n.org>
parents:
89933
diff
changeset
|
5776 break; |
|
2fef8edebd5c
(detect_coding_utf_16): Don't set detect_info->found if
Kenichi Handa <handa@m17n.org>
parents:
89933
diff
changeset
|
5777 } |
|
2fef8edebd5c
(detect_coding_utf_16): Don't set detect_info->found if
Kenichi Handa <handa@m17n.org>
parents:
89933
diff
changeset
|
5778 else |
|
93595
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
5779 { |
|
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
5780 if (null_byte_found) |
|
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
5781 { |
|
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
5782 detect_info.checked |= ~CATEGORY_MASK_UTF_16; |
|
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
5783 detect_info.rejected |= ~CATEGORY_MASK_UTF_16; |
|
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
5784 } |
|
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
5785 for (i = 0; i < coding_category_raw_text; i++) |
|
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
5786 { |
|
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
5787 category = coding_priorities[i]; |
|
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
5788 this = coding_categories + category; |
|
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
5789 if (this->id < 0) |
|
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
5790 { |
|
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
5791 /* No coding system of this category is defined. */ |
|
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
5792 detect_info.rejected |= (1 << category); |
|
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
5793 } |
|
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
5794 else if (category >= coding_category_raw_text) |
|
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
5795 continue; |
|
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
5796 else if (detect_info.checked & (1 << category)) |
|
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
5797 { |
|
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
5798 if (detect_info.found & (1 << category)) |
|
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
5799 break; |
|
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
5800 } |
|
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
5801 else if ((*(this->detector)) (coding, &detect_info) |
|
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
5802 && detect_info.found & (1 << category)) |
|
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
5803 { |
|
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
5804 if (category == coding_category_utf_16_auto) |
|
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
5805 { |
|
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
5806 if (detect_info.found & CATEGORY_MASK_UTF_16_LE) |
|
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
5807 category = coding_category_utf_16_le; |
|
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
5808 else |
|
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
5809 category = coding_category_utf_16_be; |
|
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
5810 } |
|
89974
2fef8edebd5c
(detect_coding_utf_16): Don't set detect_info->found if
Kenichi Handa <handa@m17n.org>
parents:
89933
diff
changeset
|
5811 break; |
|
93595
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
5812 } |
|
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
5813 } |
|
93877
62d97ebb13a9
* coding.c (detect_coding_emacs_mule)
Michael Albinus <michael.albinus@gmx.de>
parents:
93595
diff
changeset
|
5814 |
|
93595
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
5815 if (i < coding_category_raw_text) |
|
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
5816 setup_coding_system (CODING_ID_NAME (this->id), coding); |
|
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
5817 else if (null_byte_found) |
|
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
5818 setup_coding_system (Qno_conversion, coding); |
|
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
5819 else if ((detect_info.rejected & CATEGORY_MASK_ANY) |
|
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
5820 == CATEGORY_MASK_ANY) |
|
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
5821 setup_coding_system (Qraw_text, coding); |
|
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
5822 else if (detect_info.rejected) |
|
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
5823 for (i = 0; i < coding_category_raw_text; i++) |
|
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
5824 if (! (detect_info.rejected & (1 << coding_priorities[i]))) |
|
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
5825 { |
|
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
5826 this = coding_categories + coding_priorities[i]; |
|
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
5827 setup_coding_system (CODING_ID_NAME (this->id), coding); |
|
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
5828 break; |
|
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
5829 } |
|
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
5830 } |
| 88365 | 5831 } |
| 5832 } | |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5833 else if (XINT (CODING_ATTR_CATEGORY (CODING_ID_ATTRS (coding->id))) |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5834 == coding_category_utf_16_auto) |
|
89420
c3e67ce6ee0f
(Qsignature, Qendian): Delete these variables.
Kenichi Handa <handa@m17n.org>
parents:
89418
diff
changeset
|
5835 { |
|
c3e67ce6ee0f
(Qsignature, Qendian): Delete these variables.
Kenichi Handa <handa@m17n.org>
parents:
89418
diff
changeset
|
5836 Lisp_Object coding_systems; |
|
c3e67ce6ee0f
(Qsignature, Qendian): Delete these variables.
Kenichi Handa <handa@m17n.org>
parents:
89418
diff
changeset
|
5837 struct coding_detection_info detect_info; |
|
c3e67ce6ee0f
(Qsignature, Qendian): Delete these variables.
Kenichi Handa <handa@m17n.org>
parents:
89418
diff
changeset
|
5838 |
|
c3e67ce6ee0f
(Qsignature, Qendian): Delete these variables.
Kenichi Handa <handa@m17n.org>
parents:
89418
diff
changeset
|
5839 coding_systems |
|
c3e67ce6ee0f
(Qsignature, Qendian): Delete these variables.
Kenichi Handa <handa@m17n.org>
parents:
89418
diff
changeset
|
5840 = AREF (CODING_ID_ATTRS (coding->id), coding_attr_utf_16_bom); |
|
c3e67ce6ee0f
(Qsignature, Qendian): Delete these variables.
Kenichi Handa <handa@m17n.org>
parents:
89418
diff
changeset
|
5841 detect_info.found = detect_info.rejected = 0; |
|
c3e67ce6ee0f
(Qsignature, Qendian): Delete these variables.
Kenichi Handa <handa@m17n.org>
parents:
89418
diff
changeset
|
5842 if (CONSP (coding_systems) |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5843 && detect_coding_utf_16 (coding, &detect_info)) |
|
89420
c3e67ce6ee0f
(Qsignature, Qendian): Delete these variables.
Kenichi Handa <handa@m17n.org>
parents:
89418
diff
changeset
|
5844 { |
|
c3e67ce6ee0f
(Qsignature, Qendian): Delete these variables.
Kenichi Handa <handa@m17n.org>
parents:
89418
diff
changeset
|
5845 if (detect_info.found & CATEGORY_MASK_UTF_16_LE) |
|
c3e67ce6ee0f
(Qsignature, Qendian): Delete these variables.
Kenichi Handa <handa@m17n.org>
parents:
89418
diff
changeset
|
5846 setup_coding_system (XCAR (coding_systems), coding); |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5847 else if (detect_info.found & CATEGORY_MASK_UTF_16_BE) |
|
89420
c3e67ce6ee0f
(Qsignature, Qendian): Delete these variables.
Kenichi Handa <handa@m17n.org>
parents:
89418
diff
changeset
|
5848 setup_coding_system (XCDR (coding_systems), coding); |
|
c3e67ce6ee0f
(Qsignature, Qendian): Delete these variables.
Kenichi Handa <handa@m17n.org>
parents:
89418
diff
changeset
|
5849 } |
|
c3e67ce6ee0f
(Qsignature, Qendian): Delete these variables.
Kenichi Handa <handa@m17n.org>
parents:
89418
diff
changeset
|
5850 } |
| 88365 | 5851 } |
| 5852 | |
|
29725
2bc397e9b09a
(setup_coding_system) <4>: Reset member `cr_carryover'.
Kenichi Handa <handa@m17n.org>
parents:
29663
diff
changeset
|
5853 |
|
2bc397e9b09a
(setup_coding_system) <4>: Reset member `cr_carryover'.
Kenichi Handa <handa@m17n.org>
parents:
29663
diff
changeset
|
5854 static void |
| 88365 | 5855 decode_eol (coding) |
|
29725
2bc397e9b09a
(setup_coding_system) <4>: Reset member `cr_carryover'.
Kenichi Handa <handa@m17n.org>
parents:
29663
diff
changeset
|
5856 struct coding_system *coding; |
| 88365 | 5857 { |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5858 Lisp_Object eol_type; |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5859 unsigned char *p, *pbeg, *pend; |
|
93877
62d97ebb13a9
* coding.c (detect_coding_emacs_mule)
Michael Albinus <michael.albinus@gmx.de>
parents:
93595
diff
changeset
|
5860 |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5861 eol_type = CODING_ID_EOL_TYPE (coding->id); |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5862 if (EQ (eol_type, Qunix)) |
| 17052 | 5863 return; |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5864 |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5865 if (NILP (coding->dst_object)) |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5866 pbeg = coding->destination; |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5867 else |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5868 pbeg = BYTE_POS_ADDR (coding->dst_pos_byte); |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5869 pend = pbeg + coding->produced; |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5870 |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5871 if (VECTORP (eol_type)) |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5872 { |
| 88365 | 5873 int eol_seen = EOL_SEEN_NONE; |
| 5874 | |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5875 for (p = pbeg; p < pend; p++) |
| 88365 | 5876 { |
| 5877 if (*p == '\n') | |
| 5878 eol_seen |= EOL_SEEN_LF; | |
| 5879 else if (*p == '\r') | |
|
29725
2bc397e9b09a
(setup_coding_system) <4>: Reset member `cr_carryover'.
Kenichi Handa <handa@m17n.org>
parents:
29663
diff
changeset
|
5880 { |
| 88365 | 5881 if (p + 1 < pend && *(p + 1) == '\n') |
|
29725
2bc397e9b09a
(setup_coding_system) <4>: Reset member `cr_carryover'.
Kenichi Handa <handa@m17n.org>
parents:
29663
diff
changeset
|
5882 { |
| 88365 | 5883 eol_seen |= EOL_SEEN_CRLF; |
| 5884 p++; | |
|
29725
2bc397e9b09a
(setup_coding_system) <4>: Reset member `cr_carryover'.
Kenichi Handa <handa@m17n.org>
parents:
29663
diff
changeset
|
5885 } |
|
2bc397e9b09a
(setup_coding_system) <4>: Reset member `cr_carryover'.
Kenichi Handa <handa@m17n.org>
parents:
29663
diff
changeset
|
5886 else |
| 88365 | 5887 eol_seen |= EOL_SEEN_CR; |
|
29725
2bc397e9b09a
(setup_coding_system) <4>: Reset member `cr_carryover'.
Kenichi Handa <handa@m17n.org>
parents:
29663
diff
changeset
|
5888 } |
|
28022
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
5889 } |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5890 if (eol_seen != EOL_SEEN_NONE |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5891 && eol_seen != EOL_SEEN_LF |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5892 && eol_seen != EOL_SEEN_CRLF |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5893 && eol_seen != EOL_SEEN_CR) |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5894 eol_seen = EOL_SEEN_LF; |
| 88365 | 5895 if (eol_seen != EOL_SEEN_NONE) |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5896 eol_type = adjust_coding_eol_type (coding, eol_seen); |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5897 } |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5898 |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5899 if (EQ (eol_type, Qmac)) |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5900 { |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5901 for (p = pbeg; p < pend; p++) |
| 88365 | 5902 if (*p == '\r') |
| 5903 *p = '\n'; | |
| 5904 } | |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5905 else if (EQ (eol_type, Qdos)) |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5906 { |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5907 int n = 0; |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5908 |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5909 if (NILP (coding->dst_object)) |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5910 { |
|
90378
0aec08f4c729
(decode_eol): Pay attention to buffer relocation in
Kenichi Handa <handa@m17n.org>
parents:
90363
diff
changeset
|
5911 /* Start deleting '\r' from the tail to minimize the memory |
|
0aec08f4c729
(decode_eol): Pay attention to buffer relocation in
Kenichi Handa <handa@m17n.org>
parents:
90363
diff
changeset
|
5912 movement. */ |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5913 for (p = pend - 2; p >= pbeg; p--) |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5914 if (*p == '\r') |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5915 { |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5916 safe_bcopy ((char *) (p + 1), (char *) p, pend-- - p - 1); |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5917 n++; |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5918 } |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5919 } |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5920 else |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5921 { |
|
90378
0aec08f4c729
(decode_eol): Pay attention to buffer relocation in
Kenichi Handa <handa@m17n.org>
parents:
90363
diff
changeset
|
5922 int pos_byte = coding->dst_pos_byte; |
|
0aec08f4c729
(decode_eol): Pay attention to buffer relocation in
Kenichi Handa <handa@m17n.org>
parents:
90363
diff
changeset
|
5923 int pos = coding->dst_pos; |
|
0aec08f4c729
(decode_eol): Pay attention to buffer relocation in
Kenichi Handa <handa@m17n.org>
parents:
90363
diff
changeset
|
5924 int pos_end = pos + coding->produced_char - 1; |
|
0aec08f4c729
(decode_eol): Pay attention to buffer relocation in
Kenichi Handa <handa@m17n.org>
parents:
90363
diff
changeset
|
5925 |
|
0aec08f4c729
(decode_eol): Pay attention to buffer relocation in
Kenichi Handa <handa@m17n.org>
parents:
90363
diff
changeset
|
5926 while (pos < pos_end) |
|
0aec08f4c729
(decode_eol): Pay attention to buffer relocation in
Kenichi Handa <handa@m17n.org>
parents:
90363
diff
changeset
|
5927 { |
|
0aec08f4c729
(decode_eol): Pay attention to buffer relocation in
Kenichi Handa <handa@m17n.org>
parents:
90363
diff
changeset
|
5928 p = BYTE_POS_ADDR (pos_byte); |
|
0aec08f4c729
(decode_eol): Pay attention to buffer relocation in
Kenichi Handa <handa@m17n.org>
parents:
90363
diff
changeset
|
5929 if (*p == '\r' && p[1] == '\n') |
|
0aec08f4c729
(decode_eol): Pay attention to buffer relocation in
Kenichi Handa <handa@m17n.org>
parents:
90363
diff
changeset
|
5930 { |
|
0aec08f4c729
(decode_eol): Pay attention to buffer relocation in
Kenichi Handa <handa@m17n.org>
parents:
90363
diff
changeset
|
5931 del_range_2 (pos, pos_byte, pos + 1, pos_byte + 1, 0); |
|
0aec08f4c729
(decode_eol): Pay attention to buffer relocation in
Kenichi Handa <handa@m17n.org>
parents:
90363
diff
changeset
|
5932 n++; |
|
0aec08f4c729
(decode_eol): Pay attention to buffer relocation in
Kenichi Handa <handa@m17n.org>
parents:
90363
diff
changeset
|
5933 pos_end--; |
|
0aec08f4c729
(decode_eol): Pay attention to buffer relocation in
Kenichi Handa <handa@m17n.org>
parents:
90363
diff
changeset
|
5934 } |
|
0aec08f4c729
(decode_eol): Pay attention to buffer relocation in
Kenichi Handa <handa@m17n.org>
parents:
90363
diff
changeset
|
5935 pos++; |
|
91535
419a669bc4f2
(decode_eol): Pay attention to coding->dst_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
91367
diff
changeset
|
5936 if (coding->dst_multibyte) |
|
419a669bc4f2
(decode_eol): Pay attention to coding->dst_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
91367
diff
changeset
|
5937 pos_byte += BYTES_BY_CHAR_HEAD (*p); |
|
419a669bc4f2
(decode_eol): Pay attention to coding->dst_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
91367
diff
changeset
|
5938 else |
|
419a669bc4f2
(decode_eol): Pay attention to coding->dst_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
91367
diff
changeset
|
5939 pos_byte++; |
|
90378
0aec08f4c729
(decode_eol): Pay attention to buffer relocation in
Kenichi Handa <handa@m17n.org>
parents:
90363
diff
changeset
|
5940 } |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5941 } |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5942 coding->produced -= n; |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5943 coding->produced_char -= n; |
| 17052 | 5944 } |
| 5945 } | |
| 5946 | |
|
89732
8acde12aba89
(get_translation_table): New function.
Kenichi Handa <handa@m17n.org>
parents:
89730
diff
changeset
|
5947 |
|
89759
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
5948 /* Return a translation table (or list of them) from coding system |
|
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
5949 attribute vector ATTRS for encoding (ENCODEP is nonzero) or |
|
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
5950 decoding (ENCODEP is zero). */ |
|
89732
8acde12aba89
(get_translation_table): New function.
Kenichi Handa <handa@m17n.org>
parents:
89730
diff
changeset
|
5951 |
|
89858
23cb9ed79225
(get_translation_table): Declare it as Lisp_Object.
Kenichi Handa <handa@m17n.org>
parents:
89856
diff
changeset
|
5952 static Lisp_Object |
|
89859
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
5953 get_translation_table (attrs, encodep, max_lookup) |
|
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
5954 Lisp_Object attrs; |
|
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
5955 int encodep, *max_lookup; |
|
89732
8acde12aba89
(get_translation_table): New function.
Kenichi Handa <handa@m17n.org>
parents:
89730
diff
changeset
|
5956 { |
|
8acde12aba89
(get_translation_table): New function.
Kenichi Handa <handa@m17n.org>
parents:
89730
diff
changeset
|
5957 Lisp_Object standard, translation_table; |
|
89859
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
5958 Lisp_Object val; |
|
89732
8acde12aba89
(get_translation_table): New function.
Kenichi Handa <handa@m17n.org>
parents:
89730
diff
changeset
|
5959 |
|
8acde12aba89
(get_translation_table): New function.
Kenichi Handa <handa@m17n.org>
parents:
89730
diff
changeset
|
5960 if (encodep) |
|
8acde12aba89
(get_translation_table): New function.
Kenichi Handa <handa@m17n.org>
parents:
89730
diff
changeset
|
5961 translation_table = CODING_ATTR_ENCODE_TBL (attrs), |
|
8acde12aba89
(get_translation_table): New function.
Kenichi Handa <handa@m17n.org>
parents:
89730
diff
changeset
|
5962 standard = Vstandard_translation_table_for_encode; |
|
8acde12aba89
(get_translation_table): New function.
Kenichi Handa <handa@m17n.org>
parents:
89730
diff
changeset
|
5963 else |
|
8acde12aba89
(get_translation_table): New function.
Kenichi Handa <handa@m17n.org>
parents:
89730
diff
changeset
|
5964 translation_table = CODING_ATTR_DECODE_TBL (attrs), |
|
8acde12aba89
(get_translation_table): New function.
Kenichi Handa <handa@m17n.org>
parents:
89730
diff
changeset
|
5965 standard = Vstandard_translation_table_for_decode; |
|
89759
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
5966 if (NILP (translation_table)) |
|
89859
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
5967 translation_table = standard; |
|
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
5968 else |
|
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
5969 { |
|
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
5970 if (SYMBOLP (translation_table)) |
|
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
5971 translation_table = Fget (translation_table, Qtranslation_table); |
|
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
5972 else if (CONSP (translation_table)) |
|
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
5973 { |
|
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
5974 translation_table = Fcopy_sequence (translation_table); |
|
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
5975 for (val = translation_table; CONSP (val); val = XCDR (val)) |
|
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
5976 if (SYMBOLP (XCAR (val))) |
|
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
5977 XSETCAR (val, Fget (XCAR (val), Qtranslation_table)); |
|
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
5978 } |
|
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
5979 if (CHAR_TABLE_P (standard)) |
|
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
5980 { |
|
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
5981 if (CONSP (translation_table)) |
|
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
5982 translation_table = nconc2 (translation_table, |
|
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
5983 Fcons (standard, Qnil)); |
|
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
5984 else |
|
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
5985 translation_table = Fcons (translation_table, |
|
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
5986 Fcons (standard, Qnil)); |
|
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
5987 } |
|
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
5988 } |
|
89861
7160ded23e55
(get_translation_table): Allow max_lookup to be NULL.
Kenichi Handa <handa@m17n.org>
parents:
89859
diff
changeset
|
5989 |
|
7160ded23e55
(get_translation_table): Allow max_lookup to be NULL.
Kenichi Handa <handa@m17n.org>
parents:
89859
diff
changeset
|
5990 if (max_lookup) |
|
7160ded23e55
(get_translation_table): Allow max_lookup to be NULL.
Kenichi Handa <handa@m17n.org>
parents:
89859
diff
changeset
|
5991 { |
|
7160ded23e55
(get_translation_table): Allow max_lookup to be NULL.
Kenichi Handa <handa@m17n.org>
parents:
89859
diff
changeset
|
5992 *max_lookup = 1; |
|
7160ded23e55
(get_translation_table): Allow max_lookup to be NULL.
Kenichi Handa <handa@m17n.org>
parents:
89859
diff
changeset
|
5993 if (CHAR_TABLE_P (translation_table) |
|
7160ded23e55
(get_translation_table): Allow max_lookup to be NULL.
Kenichi Handa <handa@m17n.org>
parents:
89859
diff
changeset
|
5994 && CHAR_TABLE_EXTRA_SLOTS (XCHAR_TABLE (translation_table)) > 1) |
|
7160ded23e55
(get_translation_table): Allow max_lookup to be NULL.
Kenichi Handa <handa@m17n.org>
parents:
89859
diff
changeset
|
5995 { |
|
7160ded23e55
(get_translation_table): Allow max_lookup to be NULL.
Kenichi Handa <handa@m17n.org>
parents:
89859
diff
changeset
|
5996 val = XCHAR_TABLE (translation_table)->extras[1]; |
|
7160ded23e55
(get_translation_table): Allow max_lookup to be NULL.
Kenichi Handa <handa@m17n.org>
parents:
89859
diff
changeset
|
5997 if (NATNUMP (val) && *max_lookup < XFASTINT (val)) |
|
7160ded23e55
(get_translation_table): Allow max_lookup to be NULL.
Kenichi Handa <handa@m17n.org>
parents:
89859
diff
changeset
|
5998 *max_lookup = XFASTINT (val); |
|
7160ded23e55
(get_translation_table): Allow max_lookup to be NULL.
Kenichi Handa <handa@m17n.org>
parents:
89859
diff
changeset
|
5999 } |
|
7160ded23e55
(get_translation_table): Allow max_lookup to be NULL.
Kenichi Handa <handa@m17n.org>
parents:
89859
diff
changeset
|
6000 else if (CONSP (translation_table)) |
|
7160ded23e55
(get_translation_table): Allow max_lookup to be NULL.
Kenichi Handa <handa@m17n.org>
parents:
89859
diff
changeset
|
6001 { |
|
7160ded23e55
(get_translation_table): Allow max_lookup to be NULL.
Kenichi Handa <handa@m17n.org>
parents:
89859
diff
changeset
|
6002 Lisp_Object tail, val; |
|
7160ded23e55
(get_translation_table): Allow max_lookup to be NULL.
Kenichi Handa <handa@m17n.org>
parents:
89859
diff
changeset
|
6003 |
|
7160ded23e55
(get_translation_table): Allow max_lookup to be NULL.
Kenichi Handa <handa@m17n.org>
parents:
89859
diff
changeset
|
6004 for (tail = translation_table; CONSP (tail); tail = XCDR (tail)) |
|
7160ded23e55
(get_translation_table): Allow max_lookup to be NULL.
Kenichi Handa <handa@m17n.org>
parents:
89859
diff
changeset
|
6005 if (CHAR_TABLE_P (XCAR (tail)) |
|
7160ded23e55
(get_translation_table): Allow max_lookup to be NULL.
Kenichi Handa <handa@m17n.org>
parents:
89859
diff
changeset
|
6006 && CHAR_TABLE_EXTRA_SLOTS (XCHAR_TABLE (XCAR (tail))) > 1) |
|
7160ded23e55
(get_translation_table): Allow max_lookup to be NULL.
Kenichi Handa <handa@m17n.org>
parents:
89859
diff
changeset
|
6007 { |
|
7160ded23e55
(get_translation_table): Allow max_lookup to be NULL.
Kenichi Handa <handa@m17n.org>
parents:
89859
diff
changeset
|
6008 val = XCHAR_TABLE (XCAR (tail))->extras[1]; |
|
7160ded23e55
(get_translation_table): Allow max_lookup to be NULL.
Kenichi Handa <handa@m17n.org>
parents:
89859
diff
changeset
|
6009 if (NATNUMP (val) && *max_lookup < XFASTINT (val)) |
|
7160ded23e55
(get_translation_table): Allow max_lookup to be NULL.
Kenichi Handa <handa@m17n.org>
parents:
89859
diff
changeset
|
6010 *max_lookup = XFASTINT (val); |
|
7160ded23e55
(get_translation_table): Allow max_lookup to be NULL.
Kenichi Handa <handa@m17n.org>
parents:
89859
diff
changeset
|
6011 } |
|
7160ded23e55
(get_translation_table): Allow max_lookup to be NULL.
Kenichi Handa <handa@m17n.org>
parents:
89859
diff
changeset
|
6012 } |
|
89759
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
6013 } |
|
89732
8acde12aba89
(get_translation_table): New function.
Kenichi Handa <handa@m17n.org>
parents:
89730
diff
changeset
|
6014 return translation_table; |
|
8acde12aba89
(get_translation_table): New function.
Kenichi Handa <handa@m17n.org>
parents:
89730
diff
changeset
|
6015 } |
|
8acde12aba89
(get_translation_table): New function.
Kenichi Handa <handa@m17n.org>
parents:
89730
diff
changeset
|
6016 |
|
89859
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
6017 #define LOOKUP_TRANSLATION_TABLE(table, c, trans) \ |
|
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
6018 do { \ |
|
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
6019 trans = Qnil; \ |
|
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
6020 if (CHAR_TABLE_P (table)) \ |
|
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
6021 { \ |
|
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
6022 trans = CHAR_TABLE_REF (table, c); \ |
|
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
6023 if (CHARACTERP (trans)) \ |
|
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
6024 c = XFASTINT (trans), trans = Qnil; \ |
|
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
6025 } \ |
|
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
6026 else if (CONSP (table)) \ |
|
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
6027 { \ |
|
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
6028 Lisp_Object tail; \ |
|
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
6029 \ |
|
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
6030 for (tail = table; CONSP (tail); tail = XCDR (tail)) \ |
|
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
6031 if (CHAR_TABLE_P (XCAR (tail))) \ |
|
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
6032 { \ |
|
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
6033 trans = CHAR_TABLE_REF (XCAR (tail), c); \ |
|
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
6034 if (CHARACTERP (trans)) \ |
|
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
6035 c = XFASTINT (trans), trans = Qnil; \ |
|
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
6036 else if (! NILP (trans)) \ |
|
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
6037 break; \ |
|
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
6038 } \ |
|
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
6039 } \ |
|
89858
23cb9ed79225
(get_translation_table): Declare it as Lisp_Object.
Kenichi Handa <handa@m17n.org>
parents:
89856
diff
changeset
|
6040 } while (0) |
|
23cb9ed79225
(get_translation_table): Declare it as Lisp_Object.
Kenichi Handa <handa@m17n.org>
parents:
89856
diff
changeset
|
6041 |
|
89732
8acde12aba89
(get_translation_table): New function.
Kenichi Handa <handa@m17n.org>
parents:
89730
diff
changeset
|
6042 |
|
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
6043 static Lisp_Object |
|
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
6044 get_translation (val, buf, buf_end, last_block, from_nchars, to_nchars) |
|
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
6045 Lisp_Object val; |
|
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
6046 int *buf, *buf_end; |
|
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
6047 int last_block; |
|
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
6048 int *from_nchars, *to_nchars; |
|
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
6049 { |
|
89856
18b52da60a76
(get_translation): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89852
diff
changeset
|
6050 /* VAL is TO or (([FROM-CHAR ...] . TO) ...) where TO is TO-CHAR or |
|
18b52da60a76
(get_translation): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89852
diff
changeset
|
6051 [TO-CHAR ...]. */ |
|
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
6052 if (CONSP (val)) |
|
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
6053 { |
|
89856
18b52da60a76
(get_translation): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89852
diff
changeset
|
6054 Lisp_Object from, tail; |
|
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
6055 int i, len; |
|
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
6056 |
|
89856
18b52da60a76
(get_translation): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89852
diff
changeset
|
6057 for (tail = val; CONSP (tail); tail = XCDR (tail)) |
|
18b52da60a76
(get_translation): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89852
diff
changeset
|
6058 { |
|
18b52da60a76
(get_translation): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89852
diff
changeset
|
6059 val = XCAR (tail); |
|
18b52da60a76
(get_translation): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89852
diff
changeset
|
6060 from = XCAR (val); |
|
18b52da60a76
(get_translation): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89852
diff
changeset
|
6061 len = ASIZE (from); |
|
18b52da60a76
(get_translation): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89852
diff
changeset
|
6062 for (i = 0; i < len; i++) |
|
29725
2bc397e9b09a
(setup_coding_system) <4>: Reset member `cr_carryover'.
Kenichi Handa <handa@m17n.org>
parents:
29663
diff
changeset
|
6063 { |
|
89856
18b52da60a76
(get_translation): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89852
diff
changeset
|
6064 if (buf + i == buf_end) |
|
29725
2bc397e9b09a
(setup_coding_system) <4>: Reset member `cr_carryover'.
Kenichi Handa <handa@m17n.org>
parents:
29663
diff
changeset
|
6065 { |
|
89856
18b52da60a76
(get_translation): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89852
diff
changeset
|
6066 if (! last_block) |
|
18b52da60a76
(get_translation): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89852
diff
changeset
|
6067 return Qt; |
|
18b52da60a76
(get_translation): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89852
diff
changeset
|
6068 break; |
|
29725
2bc397e9b09a
(setup_coding_system) <4>: Reset member `cr_carryover'.
Kenichi Handa <handa@m17n.org>
parents:
29663
diff
changeset
|
6069 } |
|
89856
18b52da60a76
(get_translation): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89852
diff
changeset
|
6070 if (XINT (AREF (from, i)) != buf[i]) |
|
18b52da60a76
(get_translation): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89852
diff
changeset
|
6071 break; |
|
18b52da60a76
(get_translation): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89852
diff
changeset
|
6072 } |
|
18b52da60a76
(get_translation): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89852
diff
changeset
|
6073 if (i == len) |
|
18b52da60a76
(get_translation): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89852
diff
changeset
|
6074 { |
|
18b52da60a76
(get_translation): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89852
diff
changeset
|
6075 val = XCDR (val); |
|
18b52da60a76
(get_translation): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89852
diff
changeset
|
6076 *from_nchars = len; |
|
18b52da60a76
(get_translation): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89852
diff
changeset
|
6077 break; |
|
29725
2bc397e9b09a
(setup_coding_system) <4>: Reset member `cr_carryover'.
Kenichi Handa <handa@m17n.org>
parents:
29663
diff
changeset
|
6078 } |
|
2bc397e9b09a
(setup_coding_system) <4>: Reset member `cr_carryover'.
Kenichi Handa <handa@m17n.org>
parents:
29663
diff
changeset
|
6079 } |
|
89856
18b52da60a76
(get_translation): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89852
diff
changeset
|
6080 if (! CONSP (tail)) |
|
18b52da60a76
(get_translation): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89852
diff
changeset
|
6081 return Qnil; |
|
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
6082 } |
|
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
6083 if (VECTORP (val)) |
|
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
6084 *buf = XINT (AREF (val, 0)), *to_nchars = ASIZE (val); |
|
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
6085 else |
|
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
6086 *buf = XINT (val); |
|
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
6087 return val; |
|
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
6088 } |
|
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
6089 |
|
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
6090 |
| 88365 | 6091 static int |
|
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
6092 produce_chars (coding, translation_table, last_block) |
| 17052 | 6093 struct coding_system *coding; |
|
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
6094 Lisp_Object translation_table; |
|
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
6095 int last_block; |
| 17052 | 6096 { |
| 88365 | 6097 unsigned char *dst = coding->destination + coding->produced; |
| 6098 unsigned char *dst_end = coding->destination + coding->dst_bytes; | |
|
92399
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
6099 EMACS_INT produced; |
|
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
6100 EMACS_INT produced_chars = 0; |
|
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
6101 int carryover = 0; |
| 88365 | 6102 |
| 6103 if (! coding->chars_at_source) | |
| 6104 { | |
|
92399
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
6105 /* Source characters are in coding->charbuf. */ |
|
89575
59d10ebd2a0b
(produce_chars): Revert last change.
Andreas Schwab <schwab@suse.de>
parents:
89571
diff
changeset
|
6106 int *buf = coding->charbuf; |
|
59d10ebd2a0b
(produce_chars): Revert last change.
Andreas Schwab <schwab@suse.de>
parents:
89571
diff
changeset
|
6107 int *buf_end = buf + coding->charbuf_used; |
| 88365 | 6108 |
|
92992
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
6109 if (EQ (coding->src_object, coding->dst_object)) |
|
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
6110 { |
|
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
6111 coding_set_source (coding); |
|
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
6112 dst_end = ((unsigned char *) coding->source) + coding->consumed; |
|
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
6113 } |
| 88365 | 6114 |
| 6115 while (buf < buf_end) | |
| 6116 { | |
|
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
6117 int c = *buf, i; |
|
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
6118 |
| 88365 | 6119 if (c >= 0) |
| 6120 { | |
|
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
6121 int from_nchars = 1, to_nchars = 1; |
|
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
6122 Lisp_Object trans = Qnil; |
|
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
6123 |
|
89859
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
6124 LOOKUP_TRANSLATION_TABLE (translation_table, c, trans); |
|
89858
23cb9ed79225
(get_translation_table): Declare it as Lisp_Object.
Kenichi Handa <handa@m17n.org>
parents:
89856
diff
changeset
|
6125 if (! NILP (trans)) |
|
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
6126 { |
|
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
6127 trans = get_translation (trans, buf, buf_end, last_block, |
|
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
6128 &from_nchars, &to_nchars); |
|
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
6129 if (EQ (trans, Qt)) |
|
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
6130 break; |
|
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
6131 c = *buf; |
|
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
6132 } |
|
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
6133 |
|
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
6134 if (dst + MAX_MULTIBYTE_LENGTH * to_nchars > dst_end) |
|
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
6135 { |
|
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
6136 dst = alloc_destination (coding, |
|
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
6137 buf_end - buf |
|
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
6138 + MAX_MULTIBYTE_LENGTH * to_nchars, |
|
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
6139 dst); |
|
92992
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
6140 if (EQ (coding->src_object, coding->dst_object)) |
|
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
6141 { |
|
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
6142 coding_set_source (coding); |
|
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
6143 dst_end = ((unsigned char *) coding->source) + coding->consumed; |
|
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
6144 } |
|
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
6145 else |
|
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
6146 dst_end = coding->destination + coding->dst_bytes; |
|
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
6147 } |
|
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
6148 |
|
89856
18b52da60a76
(get_translation): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89852
diff
changeset
|
6149 for (i = 0; i < to_nchars; i++) |
|
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
6150 { |
|
89856
18b52da60a76
(get_translation): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89852
diff
changeset
|
6151 if (i > 0) |
|
18b52da60a76
(get_translation): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89852
diff
changeset
|
6152 c = XINT (AREF (trans, i)); |
|
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
6153 if (coding->dst_multibyte |
|
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
6154 || ! CHAR_BYTE8_P (c)) |
|
92992
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
6155 CHAR_STRING_ADVANCE_NO_UNIFY (c, dst); |
|
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
6156 else |
|
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
6157 *dst++ = CHAR_TO_BYTE8 (c); |
|
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
6158 } |
|
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
6159 produced_chars += to_nchars; |
|
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
6160 *buf++ = to_nchars; |
|
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
6161 while (--from_nchars > 0) |
|
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
6162 *buf++ = 0; |
| 88365 | 6163 } |
| 6164 else | |
|
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
6165 /* This is an annotation datum. (-C) is the length. */ |
|
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
6166 buf += -c; |
|
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
6167 } |
|
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
6168 carryover = buf_end - buf; |
|
30833
2db6e42a6ba3
(MINIMUM_CONVERSION_BUFFER_SIZE): Macro deleted.
Kenichi Handa <handa@m17n.org>
parents:
30756
diff
changeset
|
6169 } |
|
2db6e42a6ba3
(MINIMUM_CONVERSION_BUFFER_SIZE): Macro deleted.
Kenichi Handa <handa@m17n.org>
parents:
30756
diff
changeset
|
6170 else |
|
2db6e42a6ba3
(MINIMUM_CONVERSION_BUFFER_SIZE): Macro deleted.
Kenichi Handa <handa@m17n.org>
parents:
30756
diff
changeset
|
6171 { |
|
92399
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
6172 /* Source characters are at coding->source. */ |
| 89483 | 6173 const unsigned char *src = coding->source; |
|
92399
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
6174 const unsigned char *src_end = src + coding->consumed; |
| 88365 | 6175 |
|
92992
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
6176 if (EQ (coding->dst_object, coding->src_object)) |
|
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
6177 dst_end = (unsigned char *) src; |
| 88365 | 6178 if (coding->src_multibyte != coding->dst_multibyte) |
|
34892
3868f2e7355a
(setup_coding_system): Initialize
Kenichi Handa <handa@m17n.org>
parents:
34888
diff
changeset
|
6179 { |
| 88365 | 6180 if (coding->src_multibyte) |
|
34892
3868f2e7355a
(setup_coding_system): Initialize
Kenichi Handa <handa@m17n.org>
parents:
34888
diff
changeset
|
6181 { |
|
88443
6b86cf30a0b9
(produce_chars): Set the variable `multibytep' correctly.
Kenichi Handa <handa@m17n.org>
parents:
88438
diff
changeset
|
6182 int multibytep = 1; |
|
92399
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
6183 EMACS_INT consumed_chars; |
| 88365 | 6184 |
| 6185 while (1) | |
|
34892
3868f2e7355a
(setup_coding_system): Initialize
Kenichi Handa <handa@m17n.org>
parents:
34888
diff
changeset
|
6186 { |
| 89483 | 6187 const unsigned char *src_base = src; |
| 88365 | 6188 int c; |
| 6189 | |
| 6190 ONE_MORE_BYTE (c); | |
| 6191 if (dst == dst_end) | |
| 6192 { | |
|
92399
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
6193 if (EQ (coding->src_object, coding->dst_object)) |
|
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
6194 dst_end = (unsigned char *) src; |
|
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
6195 if (dst == dst_end) |
|
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
6196 { |
|
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
6197 EMACS_INT offset = src - coding->source; |
|
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
6198 |
|
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
6199 dst = alloc_destination (coding, src_end - src + 1, |
|
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
6200 dst); |
|
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
6201 dst_end = coding->destination + coding->dst_bytes; |
|
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
6202 coding_set_source (coding); |
|
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
6203 src = coding->source + offset; |
|
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
6204 src_end = coding->source + coding->src_bytes; |
|
92992
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
6205 if (EQ (coding->src_object, coding->dst_object)) |
|
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
6206 dst_end = (unsigned char *) src; |
|
92399
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
6207 } |
| 88365 | 6208 } |
| 6209 *dst++ = c; | |
| 6210 produced_chars++; | |
| 6211 } | |
| 6212 no_more_source: | |
| 6213 ; | |
| 6214 } | |
|
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
6215 else |
| 88365 | 6216 while (src < src_end) |
| 6217 { | |
|
88443
6b86cf30a0b9
(produce_chars): Set the variable `multibytep' correctly.
Kenichi Handa <handa@m17n.org>
parents:
88438
diff
changeset
|
6218 int multibytep = 1; |
| 88365 | 6219 int c = *src++; |
| 6220 | |
| 6221 if (dst >= dst_end - 1) | |
| 6222 { | |
|
88456
a7b309f72920
(coding_alloc_by_making_gap): Check the case that the
Kenichi Handa <handa@m17n.org>
parents:
88443
diff
changeset
|
6223 if (EQ (coding->src_object, coding->dst_object)) |
| 89483 | 6224 dst_end = (unsigned char *) src; |
|
88456
a7b309f72920
(coding_alloc_by_making_gap): Check the case that the
Kenichi Handa <handa@m17n.org>
parents:
88443
diff
changeset
|
6225 if (dst >= dst_end - 1) |
|
a7b309f72920
(coding_alloc_by_making_gap): Check the case that the
Kenichi Handa <handa@m17n.org>
parents:
88443
diff
changeset
|
6226 { |
|
92399
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
6227 EMACS_INT offset = src - coding->source; |
|
92992
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
6228 EMACS_INT more_bytes; |
|
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
6229 |
|
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
6230 if (EQ (coding->src_object, coding->dst_object)) |
|
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
6231 more_bytes = ((src_end - src) / 2) + 2; |
|
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
6232 else |
|
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
6233 more_bytes = src_end - src + 2; |
|
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
6234 dst = alloc_destination (coding, more_bytes, dst); |
|
88456
a7b309f72920
(coding_alloc_by_making_gap): Check the case that the
Kenichi Handa <handa@m17n.org>
parents:
88443
diff
changeset
|
6235 dst_end = coding->destination + coding->dst_bytes; |
|
a7b309f72920
(coding_alloc_by_making_gap): Check the case that the
Kenichi Handa <handa@m17n.org>
parents:
88443
diff
changeset
|
6236 coding_set_source (coding); |
|
92399
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
6237 src = coding->source + offset; |
|
88456
a7b309f72920
(coding_alloc_by_making_gap): Check the case that the
Kenichi Handa <handa@m17n.org>
parents:
88443
diff
changeset
|
6238 src_end = coding->source + coding->src_bytes; |
|
92992
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
6239 if (EQ (coding->src_object, coding->dst_object)) |
|
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
6240 dst_end = (unsigned char *) src; |
|
88456
a7b309f72920
(coding_alloc_by_making_gap): Check the case that the
Kenichi Handa <handa@m17n.org>
parents:
88443
diff
changeset
|
6241 } |
| 88365 | 6242 } |
| 6243 EMIT_ONE_BYTE (c); | |
| 6244 } | |
| 6245 } | |
| 6246 else | |
| 6247 { | |
| 6248 if (!EQ (coding->src_object, coding->dst_object)) | |
| 6249 { | |
|
92399
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
6250 EMACS_INT require = coding->src_bytes - coding->dst_bytes; |
| 88365 | 6251 |
| 6252 if (require > 0) | |
|
23325
bbd06336cd0c
(check_composing_code): If the current composing
Kenichi Handa <handa@m17n.org>
parents:
23315
diff
changeset
|
6253 { |
| 88365 | 6254 EMACS_INT offset = src - coding->source; |
| 6255 | |
| 6256 dst = alloc_destination (coding, require, dst); | |
| 6257 coding_set_source (coding); | |
| 6258 src = coding->source + offset; | |
| 6259 src_end = coding->source + coding->src_bytes; | |
|
23325
bbd06336cd0c
(check_composing_code): If the current composing
Kenichi Handa <handa@m17n.org>
parents:
23315
diff
changeset
|
6260 } |
|
34892
3868f2e7355a
(setup_coding_system): Initialize
Kenichi Handa <handa@m17n.org>
parents:
34888
diff
changeset
|
6261 } |
|
92399
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
6262 produced_chars = coding->consumed_char; |
| 88365 | 6263 while (src < src_end) |
|
92406
c36bda0a03cc
(decode_coding_big5, produce_chars): Fix typos in last
Andreas Schwab <schwab@suse.de>
parents:
92399
diff
changeset
|
6264 *dst++ = *src++; |
|
92399
fbc07b3a6baf
(decode_coding_utf_8): When eol-type of CODING is
Kenichi Handa <handa@m17n.org>
parents:
92030
diff
changeset
|
6265 } |
| 88365 | 6266 } |
| 6267 | |
| 6268 produced = dst - (coding->destination + coding->produced); | |
|
90809
3c52757d5f6e
(produce_chars): Don't call insert_from_gap if no
Kenichi Handa <handa@m17n.org>
parents:
90772
diff
changeset
|
6269 if (BUFFERP (coding->dst_object) && produced_chars > 0) |
| 88365 | 6270 insert_from_gap (produced_chars, produced); |
| 6271 coding->produced += produced; | |
| 6272 coding->produced_char += produced_chars; | |
|
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
6273 return carryover; |
| 88365 | 6274 } |
| 6275 | |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6276 /* Compose text in CODING->object according to the annotation data at |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6277 CHARBUF. CHARBUF is an array: |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6278 [ -LENGTH ANNOTATION_MASK FROM TO METHOD COMP_LEN [ COMPONENTS... ] ] |
| 88365 | 6279 */ |
| 6280 | |
| 6281 static INLINE void | |
|
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
6282 produce_composition (coding, charbuf, pos) |
| 88365 | 6283 struct coding_system *coding; |
| 6284 int *charbuf; | |
|
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
6285 EMACS_INT pos; |
| 88365 | 6286 { |
| 6287 int len; | |
|
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
6288 EMACS_INT to; |
| 88365 | 6289 enum composition_method method; |
| 6290 Lisp_Object components; | |
| 6291 | |
| 6292 len = -charbuf[0]; | |
|
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
6293 to = pos + charbuf[2]; |
| 89892 | 6294 if (to <= pos) |
| 6295 return; | |
|
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
6296 method = (enum composition_method) (charbuf[3]); |
| 88365 | 6297 |
| 6298 if (method == COMPOSITION_RELATIVE) | |
| 6299 components = Qnil; | |
| 89892 | 6300 else if (method >= COMPOSITION_WITH_RULE |
| 6301 && method <= COMPOSITION_WITH_RULE_ALTCHARS) | |
| 88365 | 6302 { |
| 6303 Lisp_Object args[MAX_COMPOSITION_COMPONENTS * 2 - 1]; | |
| 6304 int i; | |
| 6305 | |
|
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
6306 len -= 4; |
|
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
6307 charbuf += 4; |
| 88365 | 6308 for (i = 0; i < len; i++) |
| 89892 | 6309 { |
| 6310 args[i] = make_number (charbuf[i]); | |
|
90359
041f75914d0c
(produce_composition): Compare charbuf[i] instead of
Kenichi Handa <handa@m17n.org>
parents:
90354
diff
changeset
|
6311 if (charbuf[i] < 0) |
| 89892 | 6312 return; |
| 6313 } | |
| 88365 | 6314 components = (method == COMPOSITION_WITH_ALTCHARS |
| 6315 ? Fstring (len, args) : Fvector (len, args)); | |
|
30833
2db6e42a6ba3
(MINIMUM_CONVERSION_BUFFER_SIZE): Macro deleted.
Kenichi Handa <handa@m17n.org>
parents:
30756
diff
changeset
|
6316 } |
|
2db6e42a6ba3
(MINIMUM_CONVERSION_BUFFER_SIZE): Macro deleted.
Kenichi Handa <handa@m17n.org>
parents:
30756
diff
changeset
|
6317 else |
| 89892 | 6318 return; |
|
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
6319 compose_text (pos, to, components, Qnil, coding->dst_object); |
|
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
6320 } |
|
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
6321 |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6322 |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6323 /* Put `charset' property on text in CODING->object according to |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6324 the annotation data at CHARBUF. CHARBUF is an array: |
|
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
6325 [ -LENGTH ANNOTATION_MASK NCHARS CHARSET-ID ] |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6326 */ |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6327 |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6328 static INLINE void |
|
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
6329 produce_charset (coding, charbuf, pos) |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6330 struct coding_system *coding; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6331 int *charbuf; |
|
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
6332 EMACS_INT pos; |
|
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
6333 { |
|
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
6334 EMACS_INT from = pos - charbuf[2]; |
|
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
6335 struct charset *charset = CHARSET_FROM_ID (charbuf[3]); |
|
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
6336 |
|
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
6337 Fput_text_property (make_number (from), make_number (pos), |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6338 Qcharset, CHARSET_NAME (charset), |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6339 coding->dst_object); |
| 88365 | 6340 } |
| 6341 | |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6342 |
| 88365 | 6343 #define CHARBUF_SIZE 0x4000 |
| 6344 | |
| 6345 #define ALLOC_CONVERSION_WORK_AREA(coding) \ | |
| 6346 do { \ | |
| 6347 int size = CHARBUF_SIZE;; \ | |
| 6348 \ | |
| 6349 coding->charbuf = NULL; \ | |
| 6350 while (size > 1024) \ | |
| 6351 { \ | |
| 6352 coding->charbuf = (int *) alloca (sizeof (int) * size); \ | |
| 6353 if (coding->charbuf) \ | |
| 6354 break; \ | |
| 6355 size >>= 1; \ | |
| 6356 } \ | |
| 6357 if (! coding->charbuf) \ | |
| 6358 { \ | |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
6359 record_conversion_result (coding, CODING_RESULT_INSUFFICIENT_MEM); \ |
| 88365 | 6360 return coding->result; \ |
| 6361 } \ | |
| 6362 coding->charbuf_size = size; \ | |
| 6363 } while (0) | |
| 6364 | |
|
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
6365 |
|
30833
2db6e42a6ba3
(MINIMUM_CONVERSION_BUFFER_SIZE): Macro deleted.
Kenichi Handa <handa@m17n.org>
parents:
30756
diff
changeset
|
6366 static void |
|
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
6367 produce_annotation (coding, pos) |
|
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
6368 struct coding_system *coding; |
|
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
6369 EMACS_INT pos; |
|
29725
2bc397e9b09a
(setup_coding_system) <4>: Reset member `cr_carryover'.
Kenichi Handa <handa@m17n.org>
parents:
29663
diff
changeset
|
6370 { |
| 88365 | 6371 int *charbuf = coding->charbuf; |
| 6372 int *charbuf_end = charbuf + coding->charbuf_used; | |
| 6373 | |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6374 if (NILP (coding->dst_object)) |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6375 return; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6376 |
| 88365 | 6377 while (charbuf < charbuf_end) |
| 6378 { | |
| 6379 if (*charbuf >= 0) | |
|
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
6380 pos += *charbuf++; |
| 88365 | 6381 else |
|
29877
7b43e1fb478a
(decode_eol_post_ccl): Special handling for undecided
Eli Zaretskii <eliz@gnu.org>
parents:
29725
diff
changeset
|
6382 { |
| 88365 | 6383 int len = -*charbuf; |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6384 switch (charbuf[1]) |
|
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
6385 { |
| 88365 | 6386 case CODING_ANNOTATE_COMPOSITION_MASK: |
|
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
6387 produce_composition (coding, charbuf, pos); |
| 88365 | 6388 break; |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6389 case CODING_ANNOTATE_CHARSET_MASK: |
|
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
6390 produce_charset (coding, charbuf, pos); |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6391 break; |
| 88365 | 6392 default: |
| 6393 abort (); | |
|
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
6394 } |
| 88365 | 6395 charbuf += len; |
|
29725
2bc397e9b09a
(setup_coding_system) <4>: Reset member `cr_carryover'.
Kenichi Handa <handa@m17n.org>
parents:
29663
diff
changeset
|
6396 } |
|
2bc397e9b09a
(setup_coding_system) <4>: Reset member `cr_carryover'.
Kenichi Handa <handa@m17n.org>
parents:
29663
diff
changeset
|
6397 } |
|
2bc397e9b09a
(setup_coding_system) <4>: Reset member `cr_carryover'.
Kenichi Handa <handa@m17n.org>
parents:
29663
diff
changeset
|
6398 } |
|
2bc397e9b09a
(setup_coding_system) <4>: Reset member `cr_carryover'.
Kenichi Handa <handa@m17n.org>
parents:
29663
diff
changeset
|
6399 |
| 88365 | 6400 /* Decode the data at CODING->src_object into CODING->dst_object. |
| 6401 CODING->src_object is a buffer, a string, or nil. | |
| 6402 CODING->dst_object is a buffer. | |
| 6403 | |
| 6404 If CODING->src_object is a buffer, it must be the current buffer. | |
| 6405 In this case, if CODING->src_pos is positive, it is a position of | |
| 6406 the source text in the buffer, otherwise, the source text is in the | |
| 6407 gap area of the buffer, and CODING->src_pos specifies the offset of | |
| 6408 the text from GPT (which must be the same as PT). If this is the | |
| 6409 same buffer as CODING->dst_object, CODING->src_pos must be | |
| 6410 negative. | |
| 6411 | |
|
90380
4bf7966e0788
(decode_coding): Typo in comment fixed.
Kenichi Handa <handa@m17n.org>
parents:
90378
diff
changeset
|
6412 If CODING->src_object is a string, CODING->src_pos is an index to |
| 88365 | 6413 that string. |
| 6414 | |
| 6415 If CODING->src_object is nil, CODING->source must already point to | |
| 6416 the non-relocatable memory area. In this case, CODING->src_pos is | |
| 6417 an offset from CODING->source. | |
| 6418 | |
| 6419 The decoded data is inserted at the current point of the buffer | |
| 6420 CODING->dst_object. | |
| 6421 */ | |
| 6422 | |
| 6423 static int | |
| 6424 decode_coding (coding) | |
|
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
6425 struct coding_system *coding; |
|
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
6426 { |
| 88365 | 6427 Lisp_Object attrs; |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6428 Lisp_Object undo_list; |
|
89732
8acde12aba89
(get_translation_table): New function.
Kenichi Handa <handa@m17n.org>
parents:
89730
diff
changeset
|
6429 Lisp_Object translation_table; |
|
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
6430 int carryover; |
|
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
6431 int i; |
| 88365 | 6432 |
| 6433 if (BUFFERP (coding->src_object) | |
| 6434 && coding->src_pos > 0 | |
| 6435 && coding->src_pos < GPT | |
| 6436 && coding->src_pos + coding->src_chars > GPT) | |
| 6437 move_gap_both (coding->src_pos, coding->src_pos_byte); | |
| 6438 | |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6439 undo_list = Qt; |
| 88365 | 6440 if (BUFFERP (coding->dst_object)) |
| 6441 { | |
| 6442 if (current_buffer != XBUFFER (coding->dst_object)) | |
| 6443 set_buffer_internal (XBUFFER (coding->dst_object)); | |
| 6444 if (GPT != PT) | |
| 6445 move_gap_both (PT, PT_BYTE); | |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6446 undo_list = current_buffer->undo_list; |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6447 current_buffer->undo_list = Qt; |
| 88365 | 6448 } |
| 6449 | |
| 6450 coding->consumed = coding->consumed_char = 0; | |
|
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
6451 coding->produced = coding->produced_char = 0; |
| 88365 | 6452 coding->chars_at_source = 0; |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
6453 record_conversion_result (coding, CODING_RESULT_SUCCESS); |
|
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
6454 coding->errors = 0; |
| 88365 | 6455 |
| 6456 ALLOC_CONVERSION_WORK_AREA (coding); | |
| 6457 | |
| 6458 attrs = CODING_ID_ATTRS (coding->id); | |
|
89861
7160ded23e55
(get_translation_table): Allow max_lookup to be NULL.
Kenichi Handa <handa@m17n.org>
parents:
89859
diff
changeset
|
6459 translation_table = get_translation_table (attrs, 0, NULL); |
| 88365 | 6460 |
|
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
6461 carryover = 0; |
| 88365 | 6462 do |
| 6463 { | |
|
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
6464 EMACS_INT pos = coding->dst_pos + coding->produced_char; |
|
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
6465 |
| 88365 | 6466 coding_set_source (coding); |
| 6467 coding->annotated = 0; | |
|
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
6468 coding->charbuf_used = carryover; |
| 88365 | 6469 (*(coding->decoder)) (coding); |
| 6470 coding_set_destination (coding); | |
|
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
6471 carryover = produce_chars (coding, translation_table, 0); |
| 88365 | 6472 if (coding->annotated) |
|
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
6473 produce_annotation (coding, pos); |
|
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
6474 for (i = 0; i < carryover; i++) |
|
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
6475 coding->charbuf[i] |
|
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
6476 = coding->charbuf[coding->charbuf_used - carryover + i]; |
| 88365 | 6477 } |
| 6478 while (coding->consumed < coding->src_bytes | |
|
90336
f0338dbf2276
(decode_coding): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
90327
diff
changeset
|
6479 && (coding->result == CODING_RESULT_SUCCESS |
|
f0338dbf2276
(decode_coding): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
90327
diff
changeset
|
6480 || coding->result == CODING_RESULT_INVALID_SRC)); |
| 88365 | 6481 |
|
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
6482 if (carryover > 0) |
|
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
6483 { |
|
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
6484 coding_set_destination (coding); |
|
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
6485 coding->charbuf_used = carryover; |
|
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
6486 produce_chars (coding, translation_table, 1); |
|
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
6487 } |
|
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
6488 |
| 88365 | 6489 coding->carryover_bytes = 0; |
| 6490 if (coding->consumed < coding->src_bytes) | |
| 6491 { | |
| 6492 int nbytes = coding->src_bytes - coding->consumed; | |
| 89483 | 6493 const unsigned char *src; |
| 88365 | 6494 |
| 6495 coding_set_source (coding); | |
| 6496 coding_set_destination (coding); | |
| 6497 src = coding->source + coding->consumed; | |
| 6498 | |
| 6499 if (coding->mode & CODING_MODE_LAST_BLOCK) | |
|
29725
2bc397e9b09a
(setup_coding_system) <4>: Reset member `cr_carryover'.
Kenichi Handa <handa@m17n.org>
parents:
29663
diff
changeset
|
6500 { |
| 88365 | 6501 /* Flush out unprocessed data as binary chars. We are sure |
| 6502 that the number of data is less than the size of | |
| 6503 coding->charbuf. */ | |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
6504 coding->charbuf_used = 0; |
| 88365 | 6505 while (nbytes-- > 0) |
| 6506 { | |
| 6507 int c = *src++; | |
|
89279
1fd77c471ee6
(decode_coding_utf_8): When eol_type is Qdos, handle
Kenichi Handa <handa@m17n.org>
parents:
89227
diff
changeset
|
6508 |
|
90243
c59afb15f5c6
(decode_coding): Fix handling of invalid bytes.
Kenichi Handa <handa@m17n.org>
parents:
90231
diff
changeset
|
6509 if (c & 0x80) |
|
c59afb15f5c6
(decode_coding): Fix handling of invalid bytes.
Kenichi Handa <handa@m17n.org>
parents:
90231
diff
changeset
|
6510 c = BYTE8_TO_CHAR (c); |
|
c59afb15f5c6
(decode_coding): Fix handling of invalid bytes.
Kenichi Handa <handa@m17n.org>
parents:
90231
diff
changeset
|
6511 coding->charbuf[coding->charbuf_used++] = c; |
| 88365 | 6512 } |
|
89863
428fc37b2ae6
Add many prototypes for static functions.
Kenichi Handa <handa@m17n.org>
parents:
89861
diff
changeset
|
6513 produce_chars (coding, Qnil, 1); |
|
29725
2bc397e9b09a
(setup_coding_system) <4>: Reset member `cr_carryover'.
Kenichi Handa <handa@m17n.org>
parents:
29663
diff
changeset
|
6514 } |
|
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
6515 else |
|
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
6516 { |
| 88365 | 6517 /* Record unprocessed bytes in coding->carryover. We are |
| 6518 sure that the number of data is less than the size of | |
| 6519 coding->carryover. */ | |
| 6520 unsigned char *p = coding->carryover; | |
| 6521 | |
| 6522 coding->carryover_bytes = nbytes; | |
| 6523 while (nbytes-- > 0) | |
| 6524 *p++ = *src++; | |
|
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
6525 } |
| 88365 | 6526 coding->consumed = coding->src_bytes; |
| 6527 } | |
| 6528 | |
|
90378
0aec08f4c729
(decode_eol): Pay attention to buffer relocation in
Kenichi Handa <handa@m17n.org>
parents:
90363
diff
changeset
|
6529 if (! EQ (CODING_ID_EOL_TYPE (coding->id), Qunix)) |
|
0aec08f4c729
(decode_eol): Pay attention to buffer relocation in
Kenichi Handa <handa@m17n.org>
parents:
90363
diff
changeset
|
6530 decode_eol (coding); |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6531 if (BUFFERP (coding->dst_object)) |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6532 { |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6533 current_buffer->undo_list = undo_list; |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6534 record_insert (coding->dst_pos, coding->produced_char); |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6535 } |
|
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
6536 return coding->result; |
|
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
6537 } |
|
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
6538 |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6539 |
|
89394
6ffca50f25b9
(Fcheck_coding_systems_region): Fix type errors.
Dave Love <fx@gnu.org>
parents:
89373
diff
changeset
|
6540 /* Extract an annotation datum from a composition starting at POS and |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6541 ending before LIMIT of CODING->src_object (buffer or string), store |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6542 the data in BUF, set *STOP to a starting position of the next |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6543 composition (if any) or to LIMIT, and return the address of the |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6544 next element of BUF. |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6545 |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6546 If such an annotation is not found, set *STOP to a starting |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6547 position of a composition after POS (if any) or to LIMIT, and |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6548 return BUF. */ |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6549 |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6550 static INLINE int * |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6551 handle_composition_annotation (pos, limit, coding, buf, stop) |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6552 EMACS_INT pos, limit; |
| 26847 | 6553 struct coding_system *coding; |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6554 int *buf; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6555 EMACS_INT *stop; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6556 { |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6557 EMACS_INT start, end; |
| 26847 | 6558 Lisp_Object prop; |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6559 |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6560 if (! find_composition (pos, limit, &start, &end, &prop, coding->src_object) |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6561 || end > limit) |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6562 *stop = limit; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6563 else if (start > pos) |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6564 *stop = start; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6565 else |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6566 { |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6567 if (start == pos) |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6568 { |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6569 /* We found a composition. Store the corresponding |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6570 annotation data in BUF. */ |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6571 int *head = buf; |
| 26847 | 6572 enum composition_method method = COMPOSITION_METHOD (prop); |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6573 int nchars = COMPOSITION_LENGTH (prop); |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6574 |
|
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
6575 ADD_COMPOSITION_DATA (buf, nchars, method); |
| 26847 | 6576 if (method != COMPOSITION_RELATIVE) |
| 6577 { | |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6578 Lisp_Object components; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6579 int len, i, i_byte; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6580 |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6581 components = COMPOSITION_COMPONENTS (prop); |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6582 if (VECTORP (components)) |
| 26847 | 6583 { |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6584 len = XVECTOR (components)->size; |
| 26847 | 6585 for (i = 0; i < len; i++) |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6586 *buf++ = XINT (AREF (components, i)); |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6587 } |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6588 else if (STRINGP (components)) |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6589 { |
| 89483 | 6590 len = SCHARS (components); |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6591 i = i_byte = 0; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6592 while (i < len) |
| 26847 | 6593 { |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6594 FETCH_STRING_CHAR_ADVANCE (*buf, components, i, i_byte); |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6595 buf++; |
| 26847 | 6596 } |
| 6597 } | |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6598 else if (INTEGERP (components)) |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6599 { |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6600 len = 1; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6601 *buf++ = XINT (components); |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6602 } |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6603 else if (CONSP (components)) |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6604 { |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6605 for (len = 0; CONSP (components); |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6606 len++, components = XCDR (components)) |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6607 *buf++ = XINT (XCAR (components)); |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6608 } |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6609 else |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6610 abort (); |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6611 *head -= len; |
| 26847 | 6612 } |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6613 } |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6614 |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6615 if (find_composition (end, limit, &start, &end, &prop, |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6616 coding->src_object) |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6617 && end <= limit) |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6618 *stop = start; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6619 else |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6620 *stop = limit; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6621 } |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6622 return buf; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6623 } |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6624 |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6625 |
|
89394
6ffca50f25b9
(Fcheck_coding_systems_region): Fix type errors.
Dave Love <fx@gnu.org>
parents:
89373
diff
changeset
|
6626 /* Extract an annotation datum from a text property `charset' at POS of |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6627 CODING->src_object (buffer of string), store the data in BUF, set |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6628 *STOP to the position where the value of `charset' property changes |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6629 (limiting by LIMIT), and return the address of the next element of |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6630 BUF. |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6631 |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6632 If the property value is nil, set *STOP to the position where the |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6633 property value is non-nil (limiting by LIMIT), and return BUF. */ |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6634 |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6635 static INLINE int * |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6636 handle_charset_annotation (pos, limit, coding, buf, stop) |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6637 EMACS_INT pos, limit; |
| 26847 | 6638 struct coding_system *coding; |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6639 int *buf; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6640 EMACS_INT *stop; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6641 { |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6642 Lisp_Object val, next; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6643 int id; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6644 |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6645 val = Fget_text_property (make_number (pos), Qcharset, coding->src_object); |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6646 if (! NILP (val) && CHARSETP (val)) |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6647 id = XINT (CHARSET_SYMBOL_ID (val)); |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6648 else |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6649 id = -1; |
|
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
6650 ADD_CHARSET_DATA (buf, 0, id); |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6651 next = Fnext_single_property_change (make_number (pos), Qcharset, |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6652 coding->src_object, |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6653 make_number (limit)); |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6654 *stop = XINT (next); |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6655 return buf; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6656 } |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6657 |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6658 |
| 88365 | 6659 static void |
|
89859
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
6660 consume_chars (coding, translation_table, max_lookup) |
|
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
6661 struct coding_system *coding; |
|
89856
18b52da60a76
(get_translation): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89852
diff
changeset
|
6662 Lisp_Object translation_table; |
|
89859
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
6663 int max_lookup; |
|
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
6664 { |
| 88365 | 6665 int *buf = coding->charbuf; |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6666 int *buf_end = coding->charbuf + coding->charbuf_size; |
|
88876
af9012fdad56
(LEADING_CODE_PRIVATE_11, LEADING_CODE_PRIVATE_12,
Kenichi Handa <handa@m17n.org>
parents:
88862
diff
changeset
|
6667 const unsigned char *src = coding->source + coding->consumed; |
|
89442
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
6668 const unsigned char *src_end = coding->source + coding->src_bytes; |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6669 EMACS_INT pos = coding->src_pos + coding->consumed_char; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6670 EMACS_INT end_pos = coding->src_pos + coding->src_chars; |
| 88365 | 6671 int multibytep = coding->src_multibyte; |
| 6672 Lisp_Object eol_type; | |
| 6673 int c; | |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6674 EMACS_INT stop, stop_composition, stop_charset; |
|
89859
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
6675 int *lookup_buf = NULL; |
|
89856
18b52da60a76
(get_translation): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89852
diff
changeset
|
6676 |
|
18b52da60a76
(get_translation): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89852
diff
changeset
|
6677 if (! NILP (translation_table)) |
|
89859
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
6678 lookup_buf = alloca (sizeof (int) * max_lookup); |
| 88365 | 6679 |
| 6680 eol_type = CODING_ID_EOL_TYPE (coding->id); | |
| 6681 if (VECTORP (eol_type)) | |
| 6682 eol_type = Qunix; | |
| 6683 | |
| 6684 /* Note: composition handling is not yet implemented. */ | |
| 6685 coding->common_flags &= ~CODING_ANNOTATE_COMPOSITION_MASK; | |
| 6686 | |
|
89562
12fbcfebb9ad
(consume_chars): If coding->src_object is nil, don't check annotation.
Kenichi Handa <handa@m17n.org>
parents:
89545
diff
changeset
|
6687 if (NILP (coding->src_object)) |
|
12fbcfebb9ad
(consume_chars): If coding->src_object is nil, don't check annotation.
Kenichi Handa <handa@m17n.org>
parents:
89545
diff
changeset
|
6688 stop = stop_composition = stop_charset = end_pos; |
|
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
6689 else |
|
89562
12fbcfebb9ad
(consume_chars): If coding->src_object is nil, don't check annotation.
Kenichi Handa <handa@m17n.org>
parents:
89545
diff
changeset
|
6690 { |
|
12fbcfebb9ad
(consume_chars): If coding->src_object is nil, don't check annotation.
Kenichi Handa <handa@m17n.org>
parents:
89545
diff
changeset
|
6691 if (coding->common_flags & CODING_ANNOTATE_COMPOSITION_MASK) |
|
12fbcfebb9ad
(consume_chars): If coding->src_object is nil, don't check annotation.
Kenichi Handa <handa@m17n.org>
parents:
89545
diff
changeset
|
6692 stop = stop_composition = pos; |
|
12fbcfebb9ad
(consume_chars): If coding->src_object is nil, don't check annotation.
Kenichi Handa <handa@m17n.org>
parents:
89545
diff
changeset
|
6693 else |
|
12fbcfebb9ad
(consume_chars): If coding->src_object is nil, don't check annotation.
Kenichi Handa <handa@m17n.org>
parents:
89545
diff
changeset
|
6694 stop = stop_composition = end_pos; |
|
12fbcfebb9ad
(consume_chars): If coding->src_object is nil, don't check annotation.
Kenichi Handa <handa@m17n.org>
parents:
89545
diff
changeset
|
6695 if (coding->common_flags & CODING_ANNOTATE_CHARSET_MASK) |
|
12fbcfebb9ad
(consume_chars): If coding->src_object is nil, don't check annotation.
Kenichi Handa <handa@m17n.org>
parents:
89545
diff
changeset
|
6696 stop = stop_charset = pos; |
|
12fbcfebb9ad
(consume_chars): If coding->src_object is nil, don't check annotation.
Kenichi Handa <handa@m17n.org>
parents:
89545
diff
changeset
|
6697 else |
|
12fbcfebb9ad
(consume_chars): If coding->src_object is nil, don't check annotation.
Kenichi Handa <handa@m17n.org>
parents:
89545
diff
changeset
|
6698 stop_charset = end_pos; |
|
12fbcfebb9ad
(consume_chars): If coding->src_object is nil, don't check annotation.
Kenichi Handa <handa@m17n.org>
parents:
89545
diff
changeset
|
6699 } |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6700 |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6701 /* Compensate for CRLF and conversion. */ |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6702 buf_end -= 1 + MAX_ANNOTATION_LENGTH; |
| 88365 | 6703 while (buf < buf_end) |
| 6704 { | |
|
89856
18b52da60a76
(get_translation): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89852
diff
changeset
|
6705 Lisp_Object trans; |
|
18b52da60a76
(get_translation): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89852
diff
changeset
|
6706 |
| 88365 | 6707 if (pos == stop) |
|
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
6708 { |
| 88365 | 6709 if (pos == end_pos) |
| 6710 break; | |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6711 if (pos == stop_composition) |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6712 buf = handle_composition_annotation (pos, end_pos, coding, |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6713 buf, &stop_composition); |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6714 if (pos == stop_charset) |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6715 buf = handle_charset_annotation (pos, end_pos, coding, |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6716 buf, &stop_charset); |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6717 stop = (stop_composition < stop_charset |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6718 ? stop_composition : stop_charset); |
| 88365 | 6719 } |
| 6720 | |
| 6721 if (! multibytep) | |
|
89442
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
6722 { |
|
89462
4e359ebf3984
(decode_coding_iso_2022): Fix handling of invalid
Kenichi Handa <handa@m17n.org>
parents:
89448
diff
changeset
|
6723 EMACS_INT bytes; |
|
4e359ebf3984
(decode_coding_iso_2022): Fix handling of invalid
Kenichi Handa <handa@m17n.org>
parents:
89448
diff
changeset
|
6724 |
|
89933
48af0ea7d387
(setup_coding_system): Set coding->common_flags
Kenichi Handa <handa@m17n.org>
parents:
89924
diff
changeset
|
6725 if (coding->encoder == encode_coding_raw_text) |
|
48af0ea7d387
(setup_coding_system): Set coding->common_flags
Kenichi Handa <handa@m17n.org>
parents:
89924
diff
changeset
|
6726 c = *src++, pos++; |
|
48af0ea7d387
(setup_coding_system): Set coding->common_flags
Kenichi Handa <handa@m17n.org>
parents:
89924
diff
changeset
|
6727 else if ((bytes = MULTIBYTE_LENGTH (src, src_end)) > 0) |
|
92992
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
6728 c = STRING_CHAR_ADVANCE_NO_UNIFY (src), pos += bytes; |
|
89442
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
6729 else |
|
89917
1763eef5ad02
(encode_coding_utf_8): Fix handling of raw-byte char.
Kenichi Handa <handa@m17n.org>
parents:
89905
diff
changeset
|
6730 c = BYTE8_TO_CHAR (*src), src++, pos++; |
|
89442
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
6731 } |
| 88365 | 6732 else |
|
92992
49c4ea77b83a
(CHAR_STRING_ADVANCE_NO_UNIFY)
Kenichi Handa <handa@m17n.org>
parents:
92458
diff
changeset
|
6733 c = STRING_CHAR_ADVANCE_NO_UNIFY (src), pos++; |
| 88365 | 6734 if ((c == '\r') && (coding->mode & CODING_MODE_SELECTIVE_DISPLAY)) |
| 6735 c = '\n'; | |
| 6736 if (! EQ (eol_type, Qunix)) | |
| 6737 { | |
| 6738 if (c == '\n') | |
|
32443
57fa108c491f
(code_convert_region): Be sure to initialize coding->category_idx.
Kenichi Handa <handa@m17n.org>
parents:
31458
diff
changeset
|
6739 { |
| 88365 | 6740 if (EQ (eol_type, Qdos)) |
| 6741 *buf++ = '\r'; | |
| 6742 else | |
| 6743 c = '\r'; | |
|
32443
57fa108c491f
(code_convert_region): Be sure to initialize coding->category_idx.
Kenichi Handa <handa@m17n.org>
parents:
31458
diff
changeset
|
6744 } |
|
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
6745 } |
|
89856
18b52da60a76
(get_translation): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89852
diff
changeset
|
6746 |
|
89858
23cb9ed79225
(get_translation_table): Declare it as Lisp_Object.
Kenichi Handa <handa@m17n.org>
parents:
89856
diff
changeset
|
6747 trans = Qnil; |
|
89859
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
6748 LOOKUP_TRANSLATION_TABLE (translation_table, c, trans); |
|
89858
23cb9ed79225
(get_translation_table): Declare it as Lisp_Object.
Kenichi Handa <handa@m17n.org>
parents:
89856
diff
changeset
|
6749 if (NILP (trans)) |
|
89856
18b52da60a76
(get_translation): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89852
diff
changeset
|
6750 *buf++ = c; |
| 26847 | 6751 else |
|
89856
18b52da60a76
(get_translation): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89852
diff
changeset
|
6752 { |
|
18b52da60a76
(get_translation): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89852
diff
changeset
|
6753 int from_nchars = 1, to_nchars = 1; |
|
18b52da60a76
(get_translation): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89852
diff
changeset
|
6754 int *lookup_buf_end; |
|
18b52da60a76
(get_translation): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89852
diff
changeset
|
6755 const unsigned char *p = src; |
|
18b52da60a76
(get_translation): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89852
diff
changeset
|
6756 int i; |
|
18b52da60a76
(get_translation): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89852
diff
changeset
|
6757 |
|
18b52da60a76
(get_translation): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89852
diff
changeset
|
6758 lookup_buf[0] = c; |
|
18b52da60a76
(get_translation): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89852
diff
changeset
|
6759 for (i = 1; i < max_lookup && p < src_end; i++) |
|
18b52da60a76
(get_translation): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89852
diff
changeset
|
6760 lookup_buf[i] = STRING_CHAR_ADVANCE (p); |
|
18b52da60a76
(get_translation): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89852
diff
changeset
|
6761 lookup_buf_end = lookup_buf + i; |
|
18b52da60a76
(get_translation): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89852
diff
changeset
|
6762 trans = get_translation (trans, lookup_buf, lookup_buf_end, 1, |
|
18b52da60a76
(get_translation): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89852
diff
changeset
|
6763 &from_nchars, &to_nchars); |
|
18b52da60a76
(get_translation): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89852
diff
changeset
|
6764 if (EQ (trans, Qt) |
|
18b52da60a76
(get_translation): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89852
diff
changeset
|
6765 || buf + to_nchars > buf_end) |
|
23881
20d595402dea
(DECODE_DESIGNATION): Jump to label_invalid_code if
Kenichi Handa <handa@m17n.org>
parents:
23564
diff
changeset
|
6766 break; |
|
89856
18b52da60a76
(get_translation): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89852
diff
changeset
|
6767 *buf++ = *lookup_buf; |
|
18b52da60a76
(get_translation): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89852
diff
changeset
|
6768 for (i = 1; i < to_nchars; i++) |
|
18b52da60a76
(get_translation): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89852
diff
changeset
|
6769 *buf++ = XINT (AREF (trans, i)); |
|
18b52da60a76
(get_translation): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89852
diff
changeset
|
6770 for (i = 1; i < from_nchars; i++, pos++) |
|
18b52da60a76
(get_translation): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89852
diff
changeset
|
6771 src += MULTIBYTE_LENGTH_NO_CHECK (src); |
|
18b52da60a76
(get_translation): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89852
diff
changeset
|
6772 } |
| 88365 | 6773 } |
| 6774 | |
| 6775 coding->consumed = src - coding->source; | |
| 6776 coding->consumed_char = pos - coding->src_pos; | |
| 6777 coding->charbuf_used = buf - coding->charbuf; | |
| 6778 coding->chars_at_source = 0; | |
|
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
6779 } |
|
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
6780 |
| 88365 | 6781 |
| 6782 /* Encode the text at CODING->src_object into CODING->dst_object. | |
| 6783 CODING->src_object is a buffer or a string. | |
| 6784 CODING->dst_object is a buffer or nil. | |
| 6785 | |
| 6786 If CODING->src_object is a buffer, it must be the current buffer. | |
| 6787 In this case, if CODING->src_pos is positive, it is a position of | |
| 6788 the source text in the buffer, otherwise. the source text is in the | |
| 6789 gap area of the buffer, and coding->src_pos specifies the offset of | |
| 6790 the text from GPT (which must be the same as PT). If this is the | |
| 6791 same buffer as CODING->dst_object, CODING->src_pos must be | |
| 6792 negative and CODING should not have `pre-write-conversion'. | |
| 6793 | |
| 6794 If CODING->src_object is a string, CODING should not have | |
| 6795 `pre-write-conversion'. | |
| 6796 | |
| 6797 If CODING->dst_object is a buffer, the encoded data is inserted at | |
| 6798 the current point of that buffer. | |
| 6799 | |
| 6800 If CODING->dst_object is nil, the encoded data is placed at the | |
| 6801 memory area specified by CODING->destination. */ | |
| 6802 | |
| 6803 static int | |
| 6804 encode_coding (coding) | |
|
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
6805 struct coding_system *coding; |
|
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
6806 { |
| 88365 | 6807 Lisp_Object attrs; |
|
89732
8acde12aba89
(get_translation_table): New function.
Kenichi Handa <handa@m17n.org>
parents:
89730
diff
changeset
|
6808 Lisp_Object translation_table; |
|
89859
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
6809 int max_lookup; |
| 88365 | 6810 |
| 6811 attrs = CODING_ID_ATTRS (coding->id); | |
|
89933
48af0ea7d387
(setup_coding_system): Set coding->common_flags
Kenichi Handa <handa@m17n.org>
parents:
89924
diff
changeset
|
6812 if (coding->encoder == encode_coding_raw_text) |
|
48af0ea7d387
(setup_coding_system): Set coding->common_flags
Kenichi Handa <handa@m17n.org>
parents:
89924
diff
changeset
|
6813 translation_table = Qnil, max_lookup = 0; |
|
42661
e85e4d9494b1
(code_convert_region): Don't copy old text if undo disabled.
Richard M. Stallman <rms@gnu.org>
parents:
42105
diff
changeset
|
6814 else |
|
89933
48af0ea7d387
(setup_coding_system): Set coding->common_flags
Kenichi Handa <handa@m17n.org>
parents:
89924
diff
changeset
|
6815 translation_table = get_translation_table (attrs, 1, &max_lookup); |
| 88365 | 6816 |
| 6817 if (BUFFERP (coding->dst_object)) | |
| 6818 { | |
| 6819 set_buffer_internal (XBUFFER (coding->dst_object)); | |
| 6820 coding->dst_multibyte | |
| 6821 = ! NILP (current_buffer->enable_multibyte_characters); | |
| 6822 } | |
| 6823 | |
| 6824 coding->consumed = coding->consumed_char = 0; | |
| 6825 coding->produced = coding->produced_char = 0; | |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
6826 record_conversion_result (coding, CODING_RESULT_SUCCESS); |
| 88365 | 6827 coding->errors = 0; |
| 6828 | |
| 6829 ALLOC_CONVERSION_WORK_AREA (coding); | |
| 6830 | |
| 6831 do { | |
| 6832 coding_set_source (coding); | |
|
89859
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
6833 consume_chars (coding, translation_table, max_lookup); |
| 88365 | 6834 coding_set_destination (coding); |
| 6835 (*(coding->encoder)) (coding); | |
| 6836 } while (coding->consumed_char < coding->src_chars); | |
| 6837 | |
|
90809
3c52757d5f6e
(produce_chars): Don't call insert_from_gap if no
Kenichi Handa <handa@m17n.org>
parents:
90772
diff
changeset
|
6838 if (BUFFERP (coding->dst_object) && coding->produced_char > 0) |
| 88365 | 6839 insert_from_gap (coding->produced_char, coding->produced); |
| 6840 | |
| 6841 return (coding->result); | |
| 6842 } | |
| 6843 | |
|
89442
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
6844 |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6845 /* Name (or base name) of work buffer for code conversion. */ |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6846 static Lisp_Object Vcode_conversion_workbuf_name; |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6847 |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6848 /* A working buffer used by the top level conversion. Once it is |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6849 created, it is never destroyed. It has the name |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6850 Vcode_conversion_workbuf_name. The other working buffers are |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6851 destroyed after the use is finished, and their names are modified |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6852 versions of Vcode_conversion_workbuf_name. */ |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6853 static Lisp_Object Vcode_conversion_reused_workbuf; |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6854 |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6855 /* 1 iff Vcode_conversion_reused_workbuf is already in use. */ |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6856 static int reused_workbuf_in_use; |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6857 |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6858 |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6859 /* Return a working buffer of code convesion. MULTIBYTE specifies the |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6860 multibyteness of returning buffer. */ |
| 88365 | 6861 |
|
89863
428fc37b2ae6
Add many prototypes for static functions.
Kenichi Handa <handa@m17n.org>
parents:
89861
diff
changeset
|
6862 static Lisp_Object |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6863 make_conversion_work_buffer (multibyte) |
|
89863
428fc37b2ae6
Add many prototypes for static functions.
Kenichi Handa <handa@m17n.org>
parents:
89861
diff
changeset
|
6864 int multibyte; |
| 88365 | 6865 { |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6866 Lisp_Object name, workbuf; |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6867 struct buffer *current; |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6868 |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6869 if (reused_workbuf_in_use++) |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
6870 { |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
6871 name = Fgenerate_new_buffer_name (Vcode_conversion_workbuf_name, Qnil); |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
6872 workbuf = Fget_buffer_create (name); |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
6873 } |
|
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
6874 else |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
6875 { |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
6876 name = Vcode_conversion_workbuf_name; |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
6877 workbuf = Fget_buffer_create (name); |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
6878 if (NILP (Vcode_conversion_reused_workbuf)) |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
6879 Vcode_conversion_reused_workbuf = workbuf; |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
6880 } |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6881 current = current_buffer; |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6882 set_buffer_internal (XBUFFER (workbuf)); |
|
93877
62d97ebb13a9
* coding.c (detect_coding_emacs_mule)
Michael Albinus <michael.albinus@gmx.de>
parents:
93595
diff
changeset
|
6883 Ferase_buffer (); |
| 88365 | 6884 current_buffer->undo_list = Qt; |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6885 current_buffer->enable_multibyte_characters = multibyte ? Qt : Qnil; |
| 88365 | 6886 set_buffer_internal (current); |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6887 return workbuf; |
|
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
6888 } |
|
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
6889 |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6890 |
|
89442
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
6891 static Lisp_Object |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6892 code_conversion_restore (arg) |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6893 Lisp_Object arg; |
|
26067
f54ca66e2571
(code_convert_string): Add record_unwind_protect to
Kenichi Handa <handa@m17n.org>
parents:
25860
diff
changeset
|
6894 { |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6895 Lisp_Object current, workbuf; |
|
90263
80fb4c061e99
(code_conversion_restore): GCPRO arg.
Kenichi Handa <handa@m17n.org>
parents:
90261
diff
changeset
|
6896 struct gcpro gcpro1; |
|
80fb4c061e99
(code_conversion_restore): GCPRO arg.
Kenichi Handa <handa@m17n.org>
parents:
90261
diff
changeset
|
6897 |
|
80fb4c061e99
(code_conversion_restore): GCPRO arg.
Kenichi Handa <handa@m17n.org>
parents:
90261
diff
changeset
|
6898 GCPRO1 (arg); |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6899 current = XCAR (arg); |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6900 workbuf = XCDR (arg); |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6901 if (! NILP (workbuf)) |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6902 { |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6903 if (EQ (workbuf, Vcode_conversion_reused_workbuf)) |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6904 reused_workbuf_in_use = 0; |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6905 else if (! NILP (Fbuffer_live_p (workbuf))) |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6906 Fkill_buffer (workbuf); |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6907 } |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6908 set_buffer_internal (XBUFFER (current)); |
|
90263
80fb4c061e99
(code_conversion_restore): GCPRO arg.
Kenichi Handa <handa@m17n.org>
parents:
90261
diff
changeset
|
6909 UNGCPRO; |
|
89442
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
6910 return Qnil; |
|
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
6911 } |
|
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
6912 |
|
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
6913 Lisp_Object |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6914 code_conversion_save (with_work_buf, multibyte) |
|
89442
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
6915 int with_work_buf, multibyte; |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
6916 { |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6917 Lisp_Object workbuf = Qnil; |
|
89442
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
6918 |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
6919 if (with_work_buf) |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6920 workbuf = make_conversion_work_buffer (multibyte); |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6921 record_unwind_protect (code_conversion_restore, |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6922 Fcons (Fcurrent_buffer (), workbuf)); |
|
89442
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
6923 return workbuf; |
| 17052 | 6924 } |
| 6925 | |
|
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
6926 int |
| 88365 | 6927 decode_coding_gap (coding, chars, bytes) |
|
29725
2bc397e9b09a
(setup_coding_system) <4>: Reset member `cr_carryover'.
Kenichi Handa <handa@m17n.org>
parents:
29663
diff
changeset
|
6928 struct coding_system *coding; |
| 88365 | 6929 EMACS_INT chars, bytes; |
| 6930 { | |
| 6931 int count = specpdl_ptr - specpdl; | |
|
89448
de8b460070cc
(setup_coding_system): If coding has
Kenichi Handa <handa@m17n.org>
parents:
89446
diff
changeset
|
6932 Lisp_Object attrs; |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6933 |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6934 code_conversion_save (0, 0); |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6935 |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6936 coding->src_object = Fcurrent_buffer (); |
| 88365 | 6937 coding->src_chars = chars; |
| 6938 coding->src_bytes = bytes; | |
| 6939 coding->src_pos = -chars; | |
| 6940 coding->src_pos_byte = -bytes; | |
| 6941 coding->src_multibyte = chars < bytes; | |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6942 coding->dst_object = coding->src_object; |
| 88365 | 6943 coding->dst_pos = PT; |
| 6944 coding->dst_pos_byte = PT_BYTE; | |
|
88443
6b86cf30a0b9
(produce_chars): Set the variable `multibytep' correctly.
Kenichi Handa <handa@m17n.org>
parents:
88438
diff
changeset
|
6945 coding->dst_multibyte = ! NILP (current_buffer->enable_multibyte_characters); |
| 88365 | 6946 |
| 6947 if (CODING_REQUIRE_DETECTION (coding)) | |
| 6948 detect_coding (coding); | |
| 89483 | 6949 |
|
90350
60eaefb08cf7
(DECODE_COMPOSITION_START): If the source is short, set
Kenichi Handa <handa@m17n.org>
parents:
90346
diff
changeset
|
6950 coding->mode |= CODING_MODE_LAST_BLOCK; |
|
90772
b15334b4a9c3
(coding_alloc_by_making_gap): New arg offset.
Kenichi Handa <handa@m17n.org>
parents:
90737
diff
changeset
|
6951 current_buffer->text->inhibit_shrinking = 1; |
| 88365 | 6952 decode_coding (coding); |
|
90772
b15334b4a9c3
(coding_alloc_by_making_gap): New arg offset.
Kenichi Handa <handa@m17n.org>
parents:
90737
diff
changeset
|
6953 current_buffer->text->inhibit_shrinking = 0; |
| 88365 | 6954 |
|
89448
de8b460070cc
(setup_coding_system): If coding has
Kenichi Handa <handa@m17n.org>
parents:
89446
diff
changeset
|
6955 attrs = CODING_ID_ATTRS (coding->id); |
|
de8b460070cc
(setup_coding_system): If coding has
Kenichi Handa <handa@m17n.org>
parents:
89446
diff
changeset
|
6956 if (! NILP (CODING_ATTR_POST_READ (attrs))) |
|
de8b460070cc
(setup_coding_system): If coding has
Kenichi Handa <handa@m17n.org>
parents:
89446
diff
changeset
|
6957 { |
|
de8b460070cc
(setup_coding_system): If coding has
Kenichi Handa <handa@m17n.org>
parents:
89446
diff
changeset
|
6958 EMACS_INT prev_Z = Z, prev_Z_BYTE = Z_BYTE; |
|
de8b460070cc
(setup_coding_system): If coding has
Kenichi Handa <handa@m17n.org>
parents:
89446
diff
changeset
|
6959 Lisp_Object val; |
|
de8b460070cc
(setup_coding_system): If coding has
Kenichi Handa <handa@m17n.org>
parents:
89446
diff
changeset
|
6960 |
|
de8b460070cc
(setup_coding_system): If coding has
Kenichi Handa <handa@m17n.org>
parents:
89446
diff
changeset
|
6961 TEMP_SET_PT_BOTH (coding->dst_pos, coding->dst_pos_byte); |
|
de8b460070cc
(setup_coding_system): If coding has
Kenichi Handa <handa@m17n.org>
parents:
89446
diff
changeset
|
6962 val = call1 (CODING_ATTR_POST_READ (attrs), |
|
de8b460070cc
(setup_coding_system): If coding has
Kenichi Handa <handa@m17n.org>
parents:
89446
diff
changeset
|
6963 make_number (coding->produced_char)); |
|
de8b460070cc
(setup_coding_system): If coding has
Kenichi Handa <handa@m17n.org>
parents:
89446
diff
changeset
|
6964 CHECK_NATNUM (val); |
|
de8b460070cc
(setup_coding_system): If coding has
Kenichi Handa <handa@m17n.org>
parents:
89446
diff
changeset
|
6965 coding->produced_char += Z - prev_Z; |
|
de8b460070cc
(setup_coding_system): If coding has
Kenichi Handa <handa@m17n.org>
parents:
89446
diff
changeset
|
6966 coding->produced += Z_BYTE - prev_Z_BYTE; |
|
de8b460070cc
(setup_coding_system): If coding has
Kenichi Handa <handa@m17n.org>
parents:
89446
diff
changeset
|
6967 } |
|
de8b460070cc
(setup_coding_system): If coding has
Kenichi Handa <handa@m17n.org>
parents:
89446
diff
changeset
|
6968 |
| 88365 | 6969 unbind_to (count, Qnil); |
|
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
6970 return coding->result; |
|
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
6971 } |
|
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
6972 |
|
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
6973 int |
| 88365 | 6974 encode_coding_gap (coding, chars, bytes) |
|
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
6975 struct coding_system *coding; |
| 88365 | 6976 EMACS_INT chars, bytes; |
| 26847 | 6977 { |
| 88365 | 6978 int count = specpdl_ptr - specpdl; |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6979 |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6980 code_conversion_save (0, 0); |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6981 |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6982 coding->src_object = Fcurrent_buffer (); |
| 88365 | 6983 coding->src_chars = chars; |
| 6984 coding->src_bytes = bytes; | |
| 6985 coding->src_pos = -chars; | |
| 6986 coding->src_pos_byte = -bytes; | |
| 6987 coding->src_multibyte = chars < bytes; | |
| 6988 coding->dst_object = coding->src_object; | |
| 6989 coding->dst_pos = PT; | |
| 6990 coding->dst_pos_byte = PT_BYTE; | |
| 6991 | |
| 6992 encode_coding (coding); | |
| 6993 | |
| 6994 unbind_to (count, Qnil); | |
| 6995 return coding->result; | |
| 26847 | 6996 } |
| 6997 | |
| 88365 | 6998 |
| 6999 /* Decode the text in the range FROM/FROM_BYTE and TO/TO_BYTE in | |
| 7000 SRC_OBJECT into DST_OBJECT by coding context CODING. | |
| 7001 | |
| 7002 SRC_OBJECT is a buffer, a string, or Qnil. | |
| 7003 | |
| 7004 If it is a buffer, the text is at point of the buffer. FROM and TO | |
| 7005 are positions in the buffer. | |
| 7006 | |
| 7007 If it is a string, the text is at the beginning of the string. | |
| 7008 FROM and TO are indices to the string. | |
| 7009 | |
| 7010 If it is nil, the text is at coding->source. FROM and TO are | |
| 7011 indices to coding->source. | |
| 7012 | |
| 7013 DST_OBJECT is a buffer, Qt, or Qnil. | |
| 7014 | |
| 7015 If it is a buffer, the decoded text is inserted at point of the | |
| 7016 buffer. If the buffer is the same as SRC_OBJECT, the source text | |
| 7017 is deleted. | |
| 7018 | |
| 7019 If it is Qt, a string is made from the decoded text, and | |
| 7020 set in CODING->dst_object. | |
| 7021 | |
| 7022 If it is Qnil, the decoded text is stored at CODING->destination. | |
|
89418
a9c2b3712863
(coding_set_source): Fix for the case that the current
Kenichi Handa <handa@m17n.org>
parents:
89404
diff
changeset
|
7023 The caller must allocate CODING->dst_bytes bytes at |
| 88365 | 7024 CODING->destination by xmalloc. If the decoded text is longer than |
| 7025 CODING->dst_bytes, CODING->destination is relocated by xrealloc. | |
| 7026 */ | |
| 26847 | 7027 |
| 7028 void | |
| 88365 | 7029 decode_coding_object (coding, src_object, from, from_byte, to, to_byte, |
| 7030 dst_object) | |
| 26847 | 7031 struct coding_system *coding; |
| 88365 | 7032 Lisp_Object src_object; |
| 7033 EMACS_INT from, from_byte, to, to_byte; | |
| 7034 Lisp_Object dst_object; | |
| 26847 | 7035 { |
| 88365 | 7036 int count = specpdl_ptr - specpdl; |
| 7037 unsigned char *destination; | |
| 7038 EMACS_INT dst_bytes; | |
| 7039 EMACS_INT chars = to - from; | |
| 7040 EMACS_INT bytes = to_byte - from_byte; | |
| 7041 Lisp_Object attrs; | |
|
89442
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
7042 int saved_pt = -1, saved_pt_byte; |
|
91344
56f3473b139e
(decode_coding_object): Adjuste marker positions after
Kenichi Handa <handa@m17n.org>
parents:
91327
diff
changeset
|
7043 int need_marker_adjustment = 0; |
|
91838
7bed61cbed0c
(decode_coding_object, encode_coding_object): Preserve
Kenichi Handa <handa@m17n.org>
parents:
91807
diff
changeset
|
7044 Lisp_Object old_deactivate_mark; |
|
7bed61cbed0c
(decode_coding_object, encode_coding_object): Preserve
Kenichi Handa <handa@m17n.org>
parents:
91807
diff
changeset
|
7045 |
|
7bed61cbed0c
(decode_coding_object, encode_coding_object): Preserve
Kenichi Handa <handa@m17n.org>
parents:
91807
diff
changeset
|
7046 old_deactivate_mark = Vdeactivate_mark; |
| 88365 | 7047 |
| 7048 if (NILP (dst_object)) | |
| 7049 { | |
| 7050 destination = coding->destination; | |
| 7051 dst_bytes = coding->dst_bytes; | |
| 7052 } | |
| 7053 | |
| 7054 coding->src_object = src_object; | |
| 7055 coding->src_chars = chars; | |
| 7056 coding->src_bytes = bytes; | |
| 7057 coding->src_multibyte = chars < bytes; | |
| 7058 | |
| 7059 if (STRINGP (src_object)) | |
| 7060 { | |
| 7061 coding->src_pos = from; | |
| 7062 coding->src_pos_byte = from_byte; | |
| 7063 } | |
| 7064 else if (BUFFERP (src_object)) | |
| 7065 { | |
| 7066 set_buffer_internal (XBUFFER (src_object)); | |
| 7067 if (from != GPT) | |
| 7068 move_gap_both (from, from_byte); | |
| 7069 if (EQ (src_object, dst_object)) | |
| 26847 | 7070 { |
|
91344
56f3473b139e
(decode_coding_object): Adjuste marker positions after
Kenichi Handa <handa@m17n.org>
parents:
91327
diff
changeset
|
7071 struct Lisp_Marker *tail; |
|
56f3473b139e
(decode_coding_object): Adjuste marker positions after
Kenichi Handa <handa@m17n.org>
parents:
91327
diff
changeset
|
7072 |
|
56f3473b139e
(decode_coding_object): Adjuste marker positions after
Kenichi Handa <handa@m17n.org>
parents:
91327
diff
changeset
|
7073 for (tail = BUF_MARKERS (current_buffer); tail; tail = tail->next) |
| 26847 | 7074 { |
|
91344
56f3473b139e
(decode_coding_object): Adjuste marker positions after
Kenichi Handa <handa@m17n.org>
parents:
91327
diff
changeset
|
7075 tail->need_adjustment |
|
56f3473b139e
(decode_coding_object): Adjuste marker positions after
Kenichi Handa <handa@m17n.org>
parents:
91327
diff
changeset
|
7076 = tail->charpos == (tail->insertion_type ? from : to); |
|
56f3473b139e
(decode_coding_object): Adjuste marker positions after
Kenichi Handa <handa@m17n.org>
parents:
91327
diff
changeset
|
7077 need_marker_adjustment |= tail->need_adjustment; |
|
56f3473b139e
(decode_coding_object): Adjuste marker positions after
Kenichi Handa <handa@m17n.org>
parents:
91327
diff
changeset
|
7078 } |
|
89442
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
7079 saved_pt = PT, saved_pt_byte = PT_BYTE; |
| 88365 | 7080 TEMP_SET_PT_BOTH (from, from_byte); |
|
92458
5f5f07a5c076
(decode_coding_object): Inhibit gap shrinking while
Andreas Schwab <schwab@suse.de>
parents:
92406
diff
changeset
|
7081 current_buffer->text->inhibit_shrinking = 1; |
| 88365 | 7082 del_range_both (from, from_byte, to, to_byte, 1); |
| 7083 coding->src_pos = -chars; | |
| 7084 coding->src_pos_byte = -bytes; | |
|
20931
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
7085 } |
|
42661
e85e4d9494b1
(code_convert_region): Don't copy old text if undo disabled.
Richard M. Stallman <rms@gnu.org>
parents:
42105
diff
changeset
|
7086 else |
|
e85e4d9494b1
(code_convert_region): Don't copy old text if undo disabled.
Richard M. Stallman <rms@gnu.org>
parents:
42105
diff
changeset
|
7087 { |
| 88365 | 7088 coding->src_pos = from; |
| 7089 coding->src_pos_byte = from_byte; | |
|
29985
c17e78d8c720
(code_convert_region): Even if the length of text is
Kenichi Handa <handa@m17n.org>
parents:
29932
diff
changeset
|
7090 } |
| 88365 | 7091 } |
| 7092 | |
| 7093 if (CODING_REQUIRE_DETECTION (coding)) | |
| 7094 detect_coding (coding); | |
| 7095 attrs = CODING_ID_ATTRS (coding->id); | |
| 7096 | |
|
89418
a9c2b3712863
(coding_set_source): Fix for the case that the current
Kenichi Handa <handa@m17n.org>
parents:
89404
diff
changeset
|
7097 if (EQ (dst_object, Qt) |
|
a9c2b3712863
(coding_set_source): Fix for the case that the current
Kenichi Handa <handa@m17n.org>
parents:
89404
diff
changeset
|
7098 || (! NILP (CODING_ATTR_POST_READ (attrs)) |
|
a9c2b3712863
(coding_set_source): Fix for the case that the current
Kenichi Handa <handa@m17n.org>
parents:
89404
diff
changeset
|
7099 && NILP (dst_object))) |
| 88365 | 7100 { |
|
93321
c3fe9ef79b56
(decode_coding_object): Fix last change.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
93197
diff
changeset
|
7101 coding->dst_multibyte = !CODING_FOR_UNIBYTE (coding); |
|
c3fe9ef79b56
(decode_coding_object): Fix last change.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
93197
diff
changeset
|
7102 coding->dst_object = code_conversion_save (1, coding->dst_multibyte); |
| 88365 | 7103 coding->dst_pos = BEG; |
| 7104 coding->dst_pos_byte = BEG_BYTE; | |
| 7105 } | |
| 7106 else if (BUFFERP (dst_object)) | |
| 7107 { | |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
7108 code_conversion_save (0, 0); |
| 88365 | 7109 coding->dst_object = dst_object; |
| 7110 coding->dst_pos = BUF_PT (XBUFFER (dst_object)); | |
| 7111 coding->dst_pos_byte = BUF_PT_BYTE (XBUFFER (dst_object)); | |
| 7112 coding->dst_multibyte | |
| 7113 = ! NILP (XBUFFER (dst_object)->enable_multibyte_characters); | |
| 7114 } | |
|
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
7115 else |
|
29172
46ad5a027334
(run_pre_post_conversion_on_str): Set point to the
Kenichi Handa <handa@m17n.org>
parents:
29093
diff
changeset
|
7116 { |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
7117 code_conversion_save (0, 0); |
| 88365 | 7118 coding->dst_object = Qnil; |
|
93322
3b82aab9d8fc
(decode_coding_object): Revert part of last change.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
93321
diff
changeset
|
7119 /* Most callers presume this will return a multibyte result, and they |
|
3b82aab9d8fc
(decode_coding_object): Revert part of last change.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
93321
diff
changeset
|
7120 won't use `binary' or `raw-text' anyway, so let's not worry about |
|
3b82aab9d8fc
(decode_coding_object): Revert part of last change.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
93321
diff
changeset
|
7121 CODING_FOR_UNIBYTE. */ |
|
93323
06e93ffa2e9f
(decode_coding_object): Fix last change.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
93322
diff
changeset
|
7122 coding->dst_multibyte = 1; |
| 88365 | 7123 } |
| 7124 | |
| 7125 decode_coding (coding); | |
| 7126 | |
| 7127 if (BUFFERP (coding->dst_object)) | |
| 7128 set_buffer_internal (XBUFFER (coding->dst_object)); | |
| 7129 | |
| 7130 if (! NILP (CODING_ATTR_POST_READ (attrs))) | |
| 7131 { | |
|
91838
7bed61cbed0c
(decode_coding_object, encode_coding_object): Preserve
Kenichi Handa <handa@m17n.org>
parents:
91807
diff
changeset
|
7132 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5; |
| 88365 | 7133 EMACS_INT prev_Z = Z, prev_Z_BYTE = Z_BYTE; |
| 7134 Lisp_Object val; | |
| 7135 | |
|
88506
a7f0d13affa5
(decode_coding_object): Move point to coding->dst_pos before
Kenichi Handa <handa@m17n.org>
parents:
88497
diff
changeset
|
7136 TEMP_SET_PT_BOTH (coding->dst_pos, coding->dst_pos_byte); |
|
91838
7bed61cbed0c
(decode_coding_object, encode_coding_object): Preserve
Kenichi Handa <handa@m17n.org>
parents:
91807
diff
changeset
|
7137 GCPRO5 (coding->src_object, coding->dst_object, src_object, dst_object, |
|
7bed61cbed0c
(decode_coding_object, encode_coding_object): Preserve
Kenichi Handa <handa@m17n.org>
parents:
91807
diff
changeset
|
7138 old_deactivate_mark); |
|
90131
503a3c779486
(decode_coding_object): Use safe_call1 instead of call1.
Kenichi Handa <handa@m17n.org>
parents:
90127
diff
changeset
|
7139 val = safe_call1 (CODING_ATTR_POST_READ (attrs), |
|
503a3c779486
(decode_coding_object): Use safe_call1 instead of call1.
Kenichi Handa <handa@m17n.org>
parents:
90127
diff
changeset
|
7140 make_number (coding->produced_char)); |
| 88365 | 7141 UNGCPRO; |
| 7142 CHECK_NATNUM (val); | |
| 7143 coding->produced_char += Z - prev_Z; | |
| 7144 coding->produced += Z_BYTE - prev_Z_BYTE; | |
| 7145 } | |
| 7146 | |
| 7147 if (EQ (dst_object, Qt)) | |
| 7148 { | |
| 7149 coding->dst_object = Fbuffer_string (); | |
| 7150 } | |
| 7151 else if (NILP (dst_object) && BUFFERP (coding->dst_object)) | |
| 7152 { | |
| 7153 set_buffer_internal (XBUFFER (coding->dst_object)); | |
| 7154 if (dst_bytes < coding->produced) | |
|
42105
09cc243e2d14
(code_convert_region): Update coding->cmp_data->char_offset
Richard M. Stallman <rms@gnu.org>
parents:
42104
diff
changeset
|
7155 { |
|
91838
7bed61cbed0c
(decode_coding_object, encode_coding_object): Preserve
Kenichi Handa <handa@m17n.org>
parents:
91807
diff
changeset
|
7156 destination = xrealloc (destination, coding->produced); |
| 88365 | 7157 if (! destination) |
| 26847 | 7158 { |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
7159 record_conversion_result (coding, |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
7160 CODING_RESULT_INSUFFICIENT_DST); |
| 88365 | 7161 unbind_to (count, Qnil); |
| 7162 return; | |
| 26847 | 7163 } |
| 88365 | 7164 if (BEGV < GPT && GPT < BEGV + coding->produced_char) |
| 7165 move_gap_both (BEGV, BEGV_BYTE); | |
| 7166 bcopy (BEGV_ADDR, destination, coding->produced); | |
| 7167 coding->destination = destination; | |
|
23279
ca159e828a68
(ccl_coding_driver): If ccl_driver is interrupted by a
Kenichi Handa <handa@m17n.org>
parents:
23258
diff
changeset
|
7168 } |
| 88365 | 7169 } |
| 7170 | |
|
89442
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
7171 if (saved_pt >= 0) |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
7172 { |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
7173 /* This is the case of: |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
7174 (BUFFERP (src_object) && EQ (src_object, dst_object)) |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
7175 As we have moved PT while replacing the original buffer |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
7176 contents, we must recover it now. */ |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
7177 set_buffer_internal (XBUFFER (src_object)); |
|
92458
5f5f07a5c076
(decode_coding_object): Inhibit gap shrinking while
Andreas Schwab <schwab@suse.de>
parents:
92406
diff
changeset
|
7178 current_buffer->text->inhibit_shrinking = 0; |
|
89442
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
7179 if (saved_pt < from) |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
7180 TEMP_SET_PT_BOTH (saved_pt, saved_pt_byte); |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
7181 else if (saved_pt < from + chars) |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
7182 TEMP_SET_PT_BOTH (from, from_byte); |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
7183 else if (! NILP (current_buffer->enable_multibyte_characters)) |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
7184 TEMP_SET_PT_BOTH (saved_pt + (coding->produced_char - chars), |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
7185 saved_pt_byte + (coding->produced - bytes)); |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
7186 else |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
7187 TEMP_SET_PT_BOTH (saved_pt + (coding->produced - bytes), |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
7188 saved_pt_byte + (coding->produced - bytes)); |
|
91344
56f3473b139e
(decode_coding_object): Adjuste marker positions after
Kenichi Handa <handa@m17n.org>
parents:
91327
diff
changeset
|
7189 |
|
56f3473b139e
(decode_coding_object): Adjuste marker positions after
Kenichi Handa <handa@m17n.org>
parents:
91327
diff
changeset
|
7190 if (need_marker_adjustment) |
|
56f3473b139e
(decode_coding_object): Adjuste marker positions after
Kenichi Handa <handa@m17n.org>
parents:
91327
diff
changeset
|
7191 { |
|
56f3473b139e
(decode_coding_object): Adjuste marker positions after
Kenichi Handa <handa@m17n.org>
parents:
91327
diff
changeset
|
7192 struct Lisp_Marker *tail; |
|
56f3473b139e
(decode_coding_object): Adjuste marker positions after
Kenichi Handa <handa@m17n.org>
parents:
91327
diff
changeset
|
7193 |
|
56f3473b139e
(decode_coding_object): Adjuste marker positions after
Kenichi Handa <handa@m17n.org>
parents:
91327
diff
changeset
|
7194 for (tail = BUF_MARKERS (current_buffer); tail; tail = tail->next) |
|
56f3473b139e
(decode_coding_object): Adjuste marker positions after
Kenichi Handa <handa@m17n.org>
parents:
91327
diff
changeset
|
7195 if (tail->need_adjustment) |
|
56f3473b139e
(decode_coding_object): Adjuste marker positions after
Kenichi Handa <handa@m17n.org>
parents:
91327
diff
changeset
|
7196 { |
|
56f3473b139e
(decode_coding_object): Adjuste marker positions after
Kenichi Handa <handa@m17n.org>
parents:
91327
diff
changeset
|
7197 tail->need_adjustment = 0; |
|
56f3473b139e
(decode_coding_object): Adjuste marker positions after
Kenichi Handa <handa@m17n.org>
parents:
91327
diff
changeset
|
7198 if (tail->insertion_type) |
| 26847 | 7199 { |
|
91344
56f3473b139e
(decode_coding_object): Adjuste marker positions after
Kenichi Handa <handa@m17n.org>
parents:
91327
diff
changeset
|
7200 tail->bytepos = from_byte; |
|
56f3473b139e
(decode_coding_object): Adjuste marker positions after
Kenichi Handa <handa@m17n.org>
parents:
91327
diff
changeset
|
7201 tail->charpos = from; |
| 26847 | 7202 } |
|
91344
56f3473b139e
(decode_coding_object): Adjuste marker positions after
Kenichi Handa <handa@m17n.org>
parents:
91327
diff
changeset
|
7203 else |
|
56f3473b139e
(decode_coding_object): Adjuste marker positions after
Kenichi Handa <handa@m17n.org>
parents:
91327
diff
changeset
|
7204 { |
|
56f3473b139e
(decode_coding_object): Adjuste marker positions after
Kenichi Handa <handa@m17n.org>
parents:
91327
diff
changeset
|
7205 tail->bytepos = from_byte + coding->produced; |
|
56f3473b139e
(decode_coding_object): Adjuste marker positions after
Kenichi Handa <handa@m17n.org>
parents:
91327
diff
changeset
|
7206 tail->charpos |
|
56f3473b139e
(decode_coding_object): Adjuste marker positions after
Kenichi Handa <handa@m17n.org>
parents:
91327
diff
changeset
|
7207 = (NILP (current_buffer->enable_multibyte_characters) |
|
56f3473b139e
(decode_coding_object): Adjuste marker positions after
Kenichi Handa <handa@m17n.org>
parents:
91327
diff
changeset
|
7208 ? tail->bytepos : from + coding->produced_char); |
|
56f3473b139e
(decode_coding_object): Adjuste marker positions after
Kenichi Handa <handa@m17n.org>
parents:
91327
diff
changeset
|
7209 } |
|
56f3473b139e
(decode_coding_object): Adjuste marker positions after
Kenichi Handa <handa@m17n.org>
parents:
91327
diff
changeset
|
7210 } |
|
56f3473b139e
(decode_coding_object): Adjuste marker positions after
Kenichi Handa <handa@m17n.org>
parents:
91327
diff
changeset
|
7211 } |
|
89442
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
7212 } |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
7213 |
|
91838
7bed61cbed0c
(decode_coding_object, encode_coding_object): Preserve
Kenichi Handa <handa@m17n.org>
parents:
91807
diff
changeset
|
7214 Vdeactivate_mark = old_deactivate_mark; |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
7215 unbind_to (count, coding->dst_object); |
| 88365 | 7216 } |
| 7217 | |
| 26847 | 7218 |
|
29275
b4ea9178e480
(DECODE_COMPOSITION_START): If coding->cmp_data is not
Kenichi Handa <handa@m17n.org>
parents:
29247
diff
changeset
|
7219 void |
| 88365 | 7220 encode_coding_object (coding, src_object, from, from_byte, to, to_byte, |
| 7221 dst_object) | |
|
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
7222 struct coding_system *coding; |
| 88365 | 7223 Lisp_Object src_object; |
| 7224 EMACS_INT from, from_byte, to, to_byte; | |
| 7225 Lisp_Object dst_object; | |
| 7226 { | |
| 7227 int count = specpdl_ptr - specpdl; | |
| 7228 EMACS_INT chars = to - from; | |
| 7229 EMACS_INT bytes = to_byte - from_byte; | |
| 7230 Lisp_Object attrs; | |
|
89442
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
7231 int saved_pt = -1, saved_pt_byte; |
|
91344
56f3473b139e
(decode_coding_object): Adjuste marker positions after
Kenichi Handa <handa@m17n.org>
parents:
91327
diff
changeset
|
7232 int need_marker_adjustment = 0; |
|
90231
8be9e4c6d687
(encode_coding_object): If a pre-write-conversion
Kenichi Handa <handa@m17n.org>
parents:
90224
diff
changeset
|
7233 int kill_src_buffer = 0; |
|
91838
7bed61cbed0c
(decode_coding_object, encode_coding_object): Preserve
Kenichi Handa <handa@m17n.org>
parents:
91807
diff
changeset
|
7234 Lisp_Object old_deactivate_mark; |
|
7bed61cbed0c
(decode_coding_object, encode_coding_object): Preserve
Kenichi Handa <handa@m17n.org>
parents:
91807
diff
changeset
|
7235 |
|
7bed61cbed0c
(decode_coding_object, encode_coding_object): Preserve
Kenichi Handa <handa@m17n.org>
parents:
91807
diff
changeset
|
7236 old_deactivate_mark = Vdeactivate_mark; |
| 88365 | 7237 |
| 7238 coding->src_object = src_object; | |
| 7239 coding->src_chars = chars; | |
| 7240 coding->src_bytes = bytes; | |
| 7241 coding->src_multibyte = chars < bytes; | |
| 7242 | |
| 7243 attrs = CODING_ID_ATTRS (coding->id); | |
| 7244 | |
|
91344
56f3473b139e
(decode_coding_object): Adjuste marker positions after
Kenichi Handa <handa@m17n.org>
parents:
91327
diff
changeset
|
7245 if (EQ (src_object, dst_object)) |
|
56f3473b139e
(decode_coding_object): Adjuste marker positions after
Kenichi Handa <handa@m17n.org>
parents:
91327
diff
changeset
|
7246 { |
|
56f3473b139e
(decode_coding_object): Adjuste marker positions after
Kenichi Handa <handa@m17n.org>
parents:
91327
diff
changeset
|
7247 struct Lisp_Marker *tail; |
|
56f3473b139e
(decode_coding_object): Adjuste marker positions after
Kenichi Handa <handa@m17n.org>
parents:
91327
diff
changeset
|
7248 |
|
56f3473b139e
(decode_coding_object): Adjuste marker positions after
Kenichi Handa <handa@m17n.org>
parents:
91327
diff
changeset
|
7249 for (tail = BUF_MARKERS (current_buffer); tail; tail = tail->next) |
|
56f3473b139e
(decode_coding_object): Adjuste marker positions after
Kenichi Handa <handa@m17n.org>
parents:
91327
diff
changeset
|
7250 { |
|
56f3473b139e
(decode_coding_object): Adjuste marker positions after
Kenichi Handa <handa@m17n.org>
parents:
91327
diff
changeset
|
7251 tail->need_adjustment |
|
56f3473b139e
(decode_coding_object): Adjuste marker positions after
Kenichi Handa <handa@m17n.org>
parents:
91327
diff
changeset
|
7252 = tail->charpos == (tail->insertion_type ? from : to); |
|
56f3473b139e
(decode_coding_object): Adjuste marker positions after
Kenichi Handa <handa@m17n.org>
parents:
91327
diff
changeset
|
7253 need_marker_adjustment |= tail->need_adjustment; |
|
56f3473b139e
(decode_coding_object): Adjuste marker positions after
Kenichi Handa <handa@m17n.org>
parents:
91327
diff
changeset
|
7254 } |
|
56f3473b139e
(decode_coding_object): Adjuste marker positions after
Kenichi Handa <handa@m17n.org>
parents:
91327
diff
changeset
|
7255 } |
|
56f3473b139e
(decode_coding_object): Adjuste marker positions after
Kenichi Handa <handa@m17n.org>
parents:
91327
diff
changeset
|
7256 |
| 88365 | 7257 if (! NILP (CODING_ATTR_PRE_WRITE (attrs))) |
|
21062
839b22ad1e42
(code_convert_region): Handle the case that codes
Kenichi Handa <handa@m17n.org>
parents:
20999
diff
changeset
|
7258 { |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
7259 coding->src_object = code_conversion_save (1, coding->src_multibyte); |
| 88365 | 7260 set_buffer_internal (XBUFFER (coding->src_object)); |
| 7261 if (STRINGP (src_object)) | |
| 7262 insert_from_string (src_object, from, from_byte, chars, bytes, 0); | |
| 7263 else if (BUFFERP (src_object)) | |
| 7264 insert_from_buffer (XBUFFER (src_object), from, chars, 0); | |
|
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
7265 else |
| 88365 | 7266 insert_1_both (coding->source + from, chars, bytes, 0, 0, 0); |
| 7267 | |
| 7268 if (EQ (src_object, dst_object)) | |
| 7269 { | |
| 7270 set_buffer_internal (XBUFFER (src_object)); | |
|
89442
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
7271 saved_pt = PT, saved_pt_byte = PT_BYTE; |
| 88365 | 7272 del_range_both (from, from_byte, to, to_byte, 1); |
| 7273 set_buffer_internal (XBUFFER (coding->src_object)); | |
| 7274 } | |
| 7275 | |
|
90131
503a3c779486
(decode_coding_object): Use safe_call1 instead of call1.
Kenichi Handa <handa@m17n.org>
parents:
90127
diff
changeset
|
7276 { |
|
503a3c779486
(decode_coding_object): Use safe_call1 instead of call1.
Kenichi Handa <handa@m17n.org>
parents:
90127
diff
changeset
|
7277 Lisp_Object args[3]; |
|
91838
7bed61cbed0c
(decode_coding_object, encode_coding_object): Preserve
Kenichi Handa <handa@m17n.org>
parents:
91807
diff
changeset
|
7278 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5; |
|
7bed61cbed0c
(decode_coding_object, encode_coding_object): Preserve
Kenichi Handa <handa@m17n.org>
parents:
91807
diff
changeset
|
7279 |
|
7bed61cbed0c
(decode_coding_object, encode_coding_object): Preserve
Kenichi Handa <handa@m17n.org>
parents:
91807
diff
changeset
|
7280 GCPRO5 (coding->src_object, coding->dst_object, src_object, dst_object, |
|
7bed61cbed0c
(decode_coding_object, encode_coding_object): Preserve
Kenichi Handa <handa@m17n.org>
parents:
91807
diff
changeset
|
7281 old_deactivate_mark); |
|
90131
503a3c779486
(decode_coding_object): Use safe_call1 instead of call1.
Kenichi Handa <handa@m17n.org>
parents:
90127
diff
changeset
|
7282 args[0] = CODING_ATTR_PRE_WRITE (attrs); |
|
503a3c779486
(decode_coding_object): Use safe_call1 instead of call1.
Kenichi Handa <handa@m17n.org>
parents:
90127
diff
changeset
|
7283 args[1] = make_number (BEG); |
|
503a3c779486
(decode_coding_object): Use safe_call1 instead of call1.
Kenichi Handa <handa@m17n.org>
parents:
90127
diff
changeset
|
7284 args[2] = make_number (Z); |
|
503a3c779486
(decode_coding_object): Use safe_call1 instead of call1.
Kenichi Handa <handa@m17n.org>
parents:
90127
diff
changeset
|
7285 safe_call (3, args); |
|
91838
7bed61cbed0c
(decode_coding_object, encode_coding_object): Preserve
Kenichi Handa <handa@m17n.org>
parents:
91807
diff
changeset
|
7286 UNGCPRO; |
|
90131
503a3c779486
(decode_coding_object): Use safe_call1 instead of call1.
Kenichi Handa <handa@m17n.org>
parents:
90127
diff
changeset
|
7287 } |
|
90231
8be9e4c6d687
(encode_coding_object): If a pre-write-conversion
Kenichi Handa <handa@m17n.org>
parents:
90224
diff
changeset
|
7288 if (XBUFFER (coding->src_object) != current_buffer) |
|
8be9e4c6d687
(encode_coding_object): If a pre-write-conversion
Kenichi Handa <handa@m17n.org>
parents:
90224
diff
changeset
|
7289 kill_src_buffer = 1; |
|
88510
d266b8fb8761
(encode_coding_object): Give correct arguments ot
Kenichi Handa <handa@m17n.org>
parents:
88506
diff
changeset
|
7290 coding->src_object = Fcurrent_buffer (); |
| 88365 | 7291 if (BEG != GPT) |
| 7292 move_gap_both (BEG, BEG_BYTE); | |
| 7293 coding->src_chars = Z - BEG; | |
| 7294 coding->src_bytes = Z_BYTE - BEG_BYTE; | |
| 7295 coding->src_pos = BEG; | |
| 7296 coding->src_pos_byte = BEG_BYTE; | |
| 7297 coding->src_multibyte = Z < Z_BYTE; | |
| 7298 } | |
| 7299 else if (STRINGP (src_object)) | |
| 7300 { | |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
7301 code_conversion_save (0, 0); |
| 88365 | 7302 coding->src_pos = from; |
| 7303 coding->src_pos_byte = from_byte; | |
| 7304 } | |
| 7305 else if (BUFFERP (src_object)) | |
| 7306 { | |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
7307 code_conversion_save (0, 0); |
| 88365 | 7308 set_buffer_internal (XBUFFER (src_object)); |
| 7309 if (EQ (src_object, dst_object)) | |
| 7310 { | |
|
89442
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
7311 saved_pt = PT, saved_pt_byte = PT_BYTE; |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7312 coding->src_object = del_range_1 (from, to, 1, 1); |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7313 coding->src_pos = 0; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7314 coding->src_pos_byte = 0; |
| 88365 | 7315 } |
|
23514
7bad909cd6f1
(setup_coding_system): Fix setting up
Kenichi Handa <handa@m17n.org>
parents:
23475
diff
changeset
|
7316 else |
|
42105
09cc243e2d14
(code_convert_region): Update coding->cmp_data->char_offset
Richard M. Stallman <rms@gnu.org>
parents:
42104
diff
changeset
|
7317 { |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7318 if (from < GPT && to >= GPT) |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7319 move_gap_both (from, from_byte); |
| 88365 | 7320 coding->src_pos = from; |
| 7321 coding->src_pos_byte = from_byte; | |
| 7322 } | |
|
64308
93129de4b8a4
(code_convert_region_unwind): ARG is changed to a cons.
Kenichi Handa <handa@m17n.org>
parents:
64251
diff
changeset
|
7323 } |
|
93129de4b8a4
(code_convert_region_unwind): ARG is changed to a cons.
Kenichi Handa <handa@m17n.org>
parents:
64251
diff
changeset
|
7324 else |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
7325 code_conversion_save (0, 0); |
| 88365 | 7326 |
| 7327 if (BUFFERP (dst_object)) | |
| 7328 { | |
| 7329 coding->dst_object = dst_object; | |
|
89042
2b9f8973f240
(coding_set_destination): Fix coding->destination for
Kenichi Handa <handa@m17n.org>
parents:
88977
diff
changeset
|
7330 if (EQ (src_object, dst_object)) |
|
2b9f8973f240
(coding_set_destination): Fix coding->destination for
Kenichi Handa <handa@m17n.org>
parents:
88977
diff
changeset
|
7331 { |
|
2b9f8973f240
(coding_set_destination): Fix coding->destination for
Kenichi Handa <handa@m17n.org>
parents:
88977
diff
changeset
|
7332 coding->dst_pos = from; |
|
2b9f8973f240
(coding_set_destination): Fix coding->destination for
Kenichi Handa <handa@m17n.org>
parents:
88977
diff
changeset
|
7333 coding->dst_pos_byte = from_byte; |
|
2b9f8973f240
(coding_set_destination): Fix coding->destination for
Kenichi Handa <handa@m17n.org>
parents:
88977
diff
changeset
|
7334 } |
|
2b9f8973f240
(coding_set_destination): Fix coding->destination for
Kenichi Handa <handa@m17n.org>
parents:
88977
diff
changeset
|
7335 else |
|
2b9f8973f240
(coding_set_destination): Fix coding->destination for
Kenichi Handa <handa@m17n.org>
parents:
88977
diff
changeset
|
7336 { |
|
2b9f8973f240
(coding_set_destination): Fix coding->destination for
Kenichi Handa <handa@m17n.org>
parents:
88977
diff
changeset
|
7337 coding->dst_pos = BUF_PT (XBUFFER (dst_object)); |
|
2b9f8973f240
(coding_set_destination): Fix coding->destination for
Kenichi Handa <handa@m17n.org>
parents:
88977
diff
changeset
|
7338 coding->dst_pos_byte = BUF_PT_BYTE (XBUFFER (dst_object)); |
|
2b9f8973f240
(coding_set_destination): Fix coding->destination for
Kenichi Handa <handa@m17n.org>
parents:
88977
diff
changeset
|
7339 } |
| 88365 | 7340 coding->dst_multibyte |
| 7341 = ! NILP (XBUFFER (dst_object)->enable_multibyte_characters); | |
| 7342 } | |
| 7343 else if (EQ (dst_object, Qt)) | |
| 7344 { | |
| 7345 coding->dst_object = Qnil; | |
| 7346 coding->dst_bytes = coding->src_chars; | |
|
88510
d266b8fb8761
(encode_coding_object): Give correct arguments ot
Kenichi Handa <handa@m17n.org>
parents:
88506
diff
changeset
|
7347 if (coding->dst_bytes == 0) |
|
d266b8fb8761
(encode_coding_object): Give correct arguments ot
Kenichi Handa <handa@m17n.org>
parents:
88506
diff
changeset
|
7348 coding->dst_bytes = 1; |
|
d266b8fb8761
(encode_coding_object): Give correct arguments ot
Kenichi Handa <handa@m17n.org>
parents:
88506
diff
changeset
|
7349 coding->destination = (unsigned char *) xmalloc (coding->dst_bytes); |
| 88365 | 7350 coding->dst_multibyte = 0; |
|
65506
f376635f5061
(code_convert_region_unwind): Argument format changed.
Kenichi Handa <handa@m17n.org>
parents:
64770
diff
changeset
|
7351 } |
|
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
7352 else |
|
29172
46ad5a027334
(run_pre_post_conversion_on_str): Set point to the
Kenichi Handa <handa@m17n.org>
parents:
29093
diff
changeset
|
7353 { |
| 88365 | 7354 coding->dst_object = Qnil; |
| 7355 coding->dst_multibyte = 0; | |
| 7356 } | |
| 7357 | |
| 7358 encode_coding (coding); | |
| 7359 | |
| 7360 if (EQ (dst_object, Qt)) | |
| 7361 { | |
| 7362 if (BUFFERP (coding->dst_object)) | |
| 7363 coding->dst_object = Fbuffer_string (); | |
|
23514
7bad909cd6f1
(setup_coding_system): Fix setting up
Kenichi Handa <handa@m17n.org>
parents:
23475
diff
changeset
|
7364 else |
| 88365 | 7365 { |
| 7366 coding->dst_object | |
| 7367 = make_unibyte_string ((char *) coding->destination, | |
| 7368 coding->produced); | |
| 7369 xfree (coding->destination); | |
| 7370 } | |
| 7371 } | |
| 7372 | |
|
89442
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
7373 if (saved_pt >= 0) |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
7374 { |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
7375 /* This is the case of: |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
7376 (BUFFERP (src_object) && EQ (src_object, dst_object)) |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
7377 As we have moved PT while replacing the original buffer |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
7378 contents, we must recover it now. */ |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
7379 set_buffer_internal (XBUFFER (src_object)); |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
7380 if (saved_pt < from) |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
7381 TEMP_SET_PT_BOTH (saved_pt, saved_pt_byte); |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
7382 else if (saved_pt < from + chars) |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
7383 TEMP_SET_PT_BOTH (from, from_byte); |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
7384 else if (! NILP (current_buffer->enable_multibyte_characters)) |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
7385 TEMP_SET_PT_BOTH (saved_pt + (coding->produced_char - chars), |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
7386 saved_pt_byte + (coding->produced - bytes)); |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
7387 else |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
7388 TEMP_SET_PT_BOTH (saved_pt + (coding->produced - bytes), |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
7389 saved_pt_byte + (coding->produced - bytes)); |
|
91344
56f3473b139e
(decode_coding_object): Adjuste marker positions after
Kenichi Handa <handa@m17n.org>
parents:
91327
diff
changeset
|
7390 |
|
56f3473b139e
(decode_coding_object): Adjuste marker positions after
Kenichi Handa <handa@m17n.org>
parents:
91327
diff
changeset
|
7391 if (need_marker_adjustment) |
|
56f3473b139e
(decode_coding_object): Adjuste marker positions after
Kenichi Handa <handa@m17n.org>
parents:
91327
diff
changeset
|
7392 { |
|
56f3473b139e
(decode_coding_object): Adjuste marker positions after
Kenichi Handa <handa@m17n.org>
parents:
91327
diff
changeset
|
7393 struct Lisp_Marker *tail; |
|
56f3473b139e
(decode_coding_object): Adjuste marker positions after
Kenichi Handa <handa@m17n.org>
parents:
91327
diff
changeset
|
7394 |
|
56f3473b139e
(decode_coding_object): Adjuste marker positions after
Kenichi Handa <handa@m17n.org>
parents:
91327
diff
changeset
|
7395 for (tail = BUF_MARKERS (current_buffer); tail; tail = tail->next) |
|
56f3473b139e
(decode_coding_object): Adjuste marker positions after
Kenichi Handa <handa@m17n.org>
parents:
91327
diff
changeset
|
7396 if (tail->need_adjustment) |
|
56f3473b139e
(decode_coding_object): Adjuste marker positions after
Kenichi Handa <handa@m17n.org>
parents:
91327
diff
changeset
|
7397 { |
|
56f3473b139e
(decode_coding_object): Adjuste marker positions after
Kenichi Handa <handa@m17n.org>
parents:
91327
diff
changeset
|
7398 tail->need_adjustment = 0; |
|
56f3473b139e
(decode_coding_object): Adjuste marker positions after
Kenichi Handa <handa@m17n.org>
parents:
91327
diff
changeset
|
7399 if (tail->insertion_type) |
|
56f3473b139e
(decode_coding_object): Adjuste marker positions after
Kenichi Handa <handa@m17n.org>
parents:
91327
diff
changeset
|
7400 { |
|
56f3473b139e
(decode_coding_object): Adjuste marker positions after
Kenichi Handa <handa@m17n.org>
parents:
91327
diff
changeset
|
7401 tail->bytepos = from_byte; |
|
56f3473b139e
(decode_coding_object): Adjuste marker positions after
Kenichi Handa <handa@m17n.org>
parents:
91327
diff
changeset
|
7402 tail->charpos = from; |
|
56f3473b139e
(decode_coding_object): Adjuste marker positions after
Kenichi Handa <handa@m17n.org>
parents:
91327
diff
changeset
|
7403 } |
|
56f3473b139e
(decode_coding_object): Adjuste marker positions after
Kenichi Handa <handa@m17n.org>
parents:
91327
diff
changeset
|
7404 else |
|
56f3473b139e
(decode_coding_object): Adjuste marker positions after
Kenichi Handa <handa@m17n.org>
parents:
91327
diff
changeset
|
7405 { |
|
56f3473b139e
(decode_coding_object): Adjuste marker positions after
Kenichi Handa <handa@m17n.org>
parents:
91327
diff
changeset
|
7406 tail->bytepos = from_byte + coding->produced; |
|
56f3473b139e
(decode_coding_object): Adjuste marker positions after
Kenichi Handa <handa@m17n.org>
parents:
91327
diff
changeset
|
7407 tail->charpos |
|
56f3473b139e
(decode_coding_object): Adjuste marker positions after
Kenichi Handa <handa@m17n.org>
parents:
91327
diff
changeset
|
7408 = (NILP (current_buffer->enable_multibyte_characters) |
|
56f3473b139e
(decode_coding_object): Adjuste marker positions after
Kenichi Handa <handa@m17n.org>
parents:
91327
diff
changeset
|
7409 ? tail->bytepos : from + coding->produced_char); |
|
56f3473b139e
(decode_coding_object): Adjuste marker positions after
Kenichi Handa <handa@m17n.org>
parents:
91327
diff
changeset
|
7410 } |
|
56f3473b139e
(decode_coding_object): Adjuste marker positions after
Kenichi Handa <handa@m17n.org>
parents:
91327
diff
changeset
|
7411 } |
|
56f3473b139e
(decode_coding_object): Adjuste marker positions after
Kenichi Handa <handa@m17n.org>
parents:
91327
diff
changeset
|
7412 } |
|
89442
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
7413 } |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
7414 |
|
90231
8be9e4c6d687
(encode_coding_object): If a pre-write-conversion
Kenichi Handa <handa@m17n.org>
parents:
90224
diff
changeset
|
7415 if (kill_src_buffer) |
|
8be9e4c6d687
(encode_coding_object): If a pre-write-conversion
Kenichi Handa <handa@m17n.org>
parents:
90224
diff
changeset
|
7416 Fkill_buffer (coding->src_object); |
|
91838
7bed61cbed0c
(decode_coding_object, encode_coding_object): Preserve
Kenichi Handa <handa@m17n.org>
parents:
91807
diff
changeset
|
7417 |
|
7bed61cbed0c
(decode_coding_object, encode_coding_object): Preserve
Kenichi Handa <handa@m17n.org>
parents:
91807
diff
changeset
|
7418 Vdeactivate_mark = old_deactivate_mark; |
| 88365 | 7419 unbind_to (count, Qnil); |
|
58637
ff8a37b5299b
(Vcode_conversion_workbuf_name): New variable.
Kenichi Handa <handa@m17n.org>
parents:
58502
diff
changeset
|
7420 } |
|
ff8a37b5299b
(Vcode_conversion_workbuf_name): New variable.
Kenichi Handa <handa@m17n.org>
parents:
58502
diff
changeset
|
7421 |
|
ff8a37b5299b
(Vcode_conversion_workbuf_name): New variable.
Kenichi Handa <handa@m17n.org>
parents:
58502
diff
changeset
|
7422 |
|
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
7423 Lisp_Object |
| 88365 | 7424 preferred_coding_system () |
|
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
7425 { |
| 88365 | 7426 int id = coding_categories[coding_priorities[0]].id; |
| 7427 | |
| 7428 return CODING_ID_NAME (id); | |
|
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
7429 } |
|
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
7430 |
| 17052 | 7431 |
| 7432 #ifdef emacs | |
|
22874
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
7433 /*** 8. Emacs Lisp library functions ***/ |
| 17052 | 7434 |
| 7435 DEFUN ("coding-system-p", Fcoding_system_p, Scoding_system_p, 1, 1, 0, | |
|
40713
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
7436 doc: /* Return t if OBJECT is nil or a coding-system. |
| 88365 | 7437 See the documentation of `define-coding-system' for information |
|
40713
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
7438 about coding-system objects. */) |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
7439 (obj) |
| 17052 | 7440 Lisp_Object obj; |
| 7441 { | |
|
90272
f1df126ec7de
Sync to HEAD for handling autoload-coding-system.
Kenichi Handa <handa@m17n.org>
parents:
90263
diff
changeset
|
7442 if (NILP (obj) |
|
f1df126ec7de
Sync to HEAD for handling autoload-coding-system.
Kenichi Handa <handa@m17n.org>
parents:
90263
diff
changeset
|
7443 || CODING_SYSTEM_ID (obj) >= 0) |
|
20105
c017642863c2
(Qcoding_system_spec): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
19824
diff
changeset
|
7444 return Qt; |
|
90272
f1df126ec7de
Sync to HEAD for handling autoload-coding-system.
Kenichi Handa <handa@m17n.org>
parents:
90263
diff
changeset
|
7445 if (! SYMBOLP (obj) |
|
f1df126ec7de
Sync to HEAD for handling autoload-coding-system.
Kenichi Handa <handa@m17n.org>
parents:
90263
diff
changeset
|
7446 || NILP (Fget (obj, Qcoding_system_define_form))) |
|
20105
c017642863c2
(Qcoding_system_spec): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
19824
diff
changeset
|
7447 return Qnil; |
|
90272
f1df126ec7de
Sync to HEAD for handling autoload-coding-system.
Kenichi Handa <handa@m17n.org>
parents:
90263
diff
changeset
|
7448 return Qt; |
| 17052 | 7449 } |
| 7450 | |
|
17717
4891aaecc5cc
(Fread_coding_system, Fread_non_nil_coding_system):
Richard M. Stallman <rms@gnu.org>
parents:
17485
diff
changeset
|
7451 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
|
7452 Sread_non_nil_coding_system, 1, 1, 0, |
|
40713
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
7453 doc: /* Read a coding system from the minibuffer, prompting with string PROMPT. */) |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
7454 (prompt) |
| 17052 | 7455 Lisp_Object prompt; |
| 7456 { | |
|
17119
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
7457 Lisp_Object val; |
|
17717
4891aaecc5cc
(Fread_coding_system, Fread_non_nil_coding_system):
Richard M. Stallman <rms@gnu.org>
parents:
17485
diff
changeset
|
7458 do |
|
4891aaecc5cc
(Fread_coding_system, Fread_non_nil_coding_system):
Richard M. Stallman <rms@gnu.org>
parents:
17485
diff
changeset
|
7459 { |
|
20105
c017642863c2
(Qcoding_system_spec): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
19824
diff
changeset
|
7460 val = Fcompleting_read (prompt, Vcoding_system_alist, Qnil, |
|
c017642863c2
(Qcoding_system_spec): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
19824
diff
changeset
|
7461 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
|
7462 } |
|
46370
40db0673e6f0
Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents:
46293
diff
changeset
|
7463 while (SCHARS (val) == 0); |
|
17119
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
7464 return (Fintern (val, Qnil)); |
| 17052 | 7465 } |
| 7466 | |
|
19758
49a1662b68dd
(Fread_coding_system): New optional arg DEFAULT_CODING_SYSTEM.
Richard M. Stallman <rms@gnu.org>
parents:
19750
diff
changeset
|
7467 DEFUN ("read-coding-system", Fread_coding_system, Sread_coding_system, 1, 2, 0, |
|
40713
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
7468 doc: /* Read a coding system from the minibuffer, prompting with string PROMPT. |
|
79107
cce707ee192e
(Qcompletion_ignore_case): New external Lisp_Object.
Glenn Morris <rgm@gnu.org>
parents:
78313
diff
changeset
|
7469 If the user enters null input, return second argument DEFAULT-CODING-SYSTEM. |
|
cce707ee192e
(Qcompletion_ignore_case): New external Lisp_Object.
Glenn Morris <rgm@gnu.org>
parents:
78313
diff
changeset
|
7470 Ignores case when completing coding systems (all Emacs coding systems |
|
cce707ee192e
(Qcompletion_ignore_case): New external Lisp_Object.
Glenn Morris <rgm@gnu.org>
parents:
78313
diff
changeset
|
7471 are lower-case). */) |
|
40713
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
7472 (prompt, default_coding_system) |
|
19758
49a1662b68dd
(Fread_coding_system): New optional arg DEFAULT_CODING_SYSTEM.
Richard M. Stallman <rms@gnu.org>
parents:
19750
diff
changeset
|
7473 Lisp_Object prompt, default_coding_system; |
| 17052 | 7474 { |
|
19747
bed06df9cbc5
(setup_coding_system, Ffind_operation_coding_system)
Richard M. Stallman <rms@gnu.org>
parents:
19743
diff
changeset
|
7475 Lisp_Object val; |
|
79107
cce707ee192e
(Qcompletion_ignore_case): New external Lisp_Object.
Glenn Morris <rgm@gnu.org>
parents:
78313
diff
changeset
|
7476 int count = SPECPDL_INDEX (); |
|
cce707ee192e
(Qcompletion_ignore_case): New external Lisp_Object.
Glenn Morris <rgm@gnu.org>
parents:
78313
diff
changeset
|
7477 |
|
19758
49a1662b68dd
(Fread_coding_system): New optional arg DEFAULT_CODING_SYSTEM.
Richard M. Stallman <rms@gnu.org>
parents:
19750
diff
changeset
|
7478 if (SYMBOLP (default_coding_system)) |
|
45396
cab845213388
* coding.c (Fread_coding_system, code_convert_region1)
Ken Raeburn <raeburn@raeburn.org>
parents:
45239
diff
changeset
|
7479 default_coding_system = SYMBOL_NAME (default_coding_system); |
|
79107
cce707ee192e
(Qcompletion_ignore_case): New external Lisp_Object.
Glenn Morris <rgm@gnu.org>
parents:
78313
diff
changeset
|
7480 specbind (Qcompletion_ignore_case, Qt); |
|
20105
c017642863c2
(Qcoding_system_spec): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
19824
diff
changeset
|
7481 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
|
7482 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
|
7483 default_coding_system, Qnil); |
|
79107
cce707ee192e
(Qcompletion_ignore_case): New external Lisp_Object.
Glenn Morris <rgm@gnu.org>
parents:
78313
diff
changeset
|
7484 unbind_to (count, Qnil); |
|
46370
40db0673e6f0
Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents:
46293
diff
changeset
|
7485 return (SCHARS (val) == 0 ? Qnil : Fintern (val, Qnil)); |
| 17052 | 7486 } |
| 7487 | |
| 7488 DEFUN ("check-coding-system", Fcheck_coding_system, Scheck_coding_system, | |
| 7489 1, 1, 0, | |
|
40713
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
7490 doc: /* Check validity of CODING-SYSTEM. |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
7491 If valid, return CODING-SYSTEM, else signal a `coding-system-error' error. |
| 89892 | 7492 It is valid if it is nil or a symbol defined as a coding system by the |
| 7493 function `define-coding-system'. */) | |
| 88365 | 7494 (coding_system) |
| 17052 | 7495 Lisp_Object coding_system; |
| 7496 { | |
|
52794
f4d906e31662
(Qcoding_system_define_form): New variable.
Kenichi Handa <handa@m17n.org>
parents:
52401
diff
changeset
|
7497 Lisp_Object define_form; |
|
f4d906e31662
(Qcoding_system_define_form): New variable.
Kenichi Handa <handa@m17n.org>
parents:
52401
diff
changeset
|
7498 |
|
f4d906e31662
(Qcoding_system_define_form): New variable.
Kenichi Handa <handa@m17n.org>
parents:
52401
diff
changeset
|
7499 define_form = Fget (coding_system, Qcoding_system_define_form); |
|
f4d906e31662
(Qcoding_system_define_form): New variable.
Kenichi Handa <handa@m17n.org>
parents:
52401
diff
changeset
|
7500 if (! NILP (define_form)) |
|
f4d906e31662
(Qcoding_system_define_form): New variable.
Kenichi Handa <handa@m17n.org>
parents:
52401
diff
changeset
|
7501 { |
|
f4d906e31662
(Qcoding_system_define_form): New variable.
Kenichi Handa <handa@m17n.org>
parents:
52401
diff
changeset
|
7502 Fput (coding_system, Qcoding_system_define_form, Qnil); |
|
f4d906e31662
(Qcoding_system_define_form): New variable.
Kenichi Handa <handa@m17n.org>
parents:
52401
diff
changeset
|
7503 safe_eval (define_form); |
|
f4d906e31662
(Qcoding_system_define_form): New variable.
Kenichi Handa <handa@m17n.org>
parents:
52401
diff
changeset
|
7504 } |
| 17052 | 7505 if (!NILP (Fcoding_system_p (coding_system))) |
| 7506 return coding_system; | |
|
71972
eaa3c19b94d2
(Fcheck_coding_system): Use xsignal1. Remove loop.
Kim F. Storm <storm@cua.dk>
parents:
71084
diff
changeset
|
7507 xsignal1 (Qcoding_system_error, coding_system); |
| 17052 | 7508 } |
| 88365 | 7509 |
|
20680
dd46027e8412
(code_convert_region): Always count chars inserted
Richard M. Stallman <rms@gnu.org>
parents:
20668
diff
changeset
|
7510 |
|
89193
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
7511 /* Detect how the bytes at SRC of length SRC_BYTES are encoded. If |
|
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
7512 HIGHEST is nonzero, return the coding system of the highest |
|
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
7513 priority among the detected coding systems. Otherwize return a |
|
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
7514 list of detected coding systems sorted by their priorities. If |
|
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
7515 MULTIBYTEP is nonzero, it is assumed that the bytes are in correct |
|
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
7516 multibyte form but contains only ASCII and eight-bit chars. |
|
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
7517 Otherwise, the bytes are raw bytes. |
|
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
7518 |
|
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
7519 CODING-SYSTEM controls the detection as below: |
|
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
7520 |
|
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
7521 If it is nil, detect both text-format and eol-format. If the |
|
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
7522 text-format part of CODING-SYSTEM is already specified |
|
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
7523 (e.g. `iso-latin-1'), detect only eol-format. If the eol-format |
|
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
7524 part of CODING-SYSTEM is already specified (e.g. `undecided-unix'), |
|
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
7525 detect only text-format. */ |
|
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
7526 |
|
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
7527 Lisp_Object |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
7528 detect_coding_system (src, src_chars, src_bytes, highest, multibytep, |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
7529 coding_system) |
|
46548
cb1914307488
(encode_eol, detect_coding, detect_eol):
Ken Raeburn <raeburn@raeburn.org>
parents:
46462
diff
changeset
|
7530 const unsigned char *src; |
|
91807
507bcfb4342c
* coding.c (coding_set_destination): Use BEG_BYTE rather than hardcoding 1.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91622
diff
changeset
|
7531 EMACS_INT src_chars, src_bytes; |
|
507bcfb4342c
* coding.c (coding_set_destination): Use BEG_BYTE rather than hardcoding 1.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91622
diff
changeset
|
7532 int highest; |
|
34531
37f85e931855
(ONE_MORE_BYTE_CHECK_MULTIBYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34197
diff
changeset
|
7533 int multibytep; |
| 88365 | 7534 Lisp_Object coding_system; |
| 17052 | 7535 { |
| 89483 | 7536 const unsigned char *src_end = src + src_bytes; |
| 88365 | 7537 Lisp_Object attrs, eol_type; |
| 7538 Lisp_Object val; | |
| 7539 struct coding_system coding; | |
|
89193
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
7540 int id; |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7541 struct coding_detection_info detect_info; |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
7542 enum coding_category base_category; |
|
93595
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
7543 int null_byte_found = 0, eight_bit_found = 0; |
| 88365 | 7544 |
| 7545 if (NILP (coding_system)) | |
| 7546 coding_system = Qundecided; | |
| 7547 setup_coding_system (coding_system, &coding); | |
| 7548 attrs = CODING_ID_ATTRS (coding.id); | |
| 7549 eol_type = CODING_ID_EOL_TYPE (coding.id); | |
|
89193
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
7550 coding_system = CODING_ATTR_BASE_NAME (attrs); |
| 88365 | 7551 |
| 7552 coding.source = src; | |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
7553 coding.src_chars = src_chars; |
| 88365 | 7554 coding.src_bytes = src_bytes; |
| 7555 coding.src_multibyte = multibytep; | |
| 7556 coding.consumed = 0; | |
|
89193
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
7557 coding.mode |= CODING_MODE_LAST_BLOCK; |
|
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
7558 |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7559 detect_info.checked = detect_info.found = detect_info.rejected = 0; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7560 |
|
89193
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
7561 /* At first, detect text-format if necessary. */ |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
7562 base_category = XINT (CODING_ATTR_CATEGORY (attrs)); |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
7563 if (base_category == coding_category_undecided) |
|
89193
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
7564 { |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7565 enum coding_category category; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7566 struct coding_system *this; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7567 int c, i; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7568 |
|
93595
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
7569 coding.head_ascii = -1; |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
7570 /* Skip all ASCII bytes except for a few ISO2022 controls. */ |
|
93595
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
7571 for (; src < src_end; src++) |
| 17052 | 7572 { |
| 88365 | 7573 c = *src; |
|
89974
2fef8edebd5c
(detect_coding_utf_16): Don't set detect_info->found if
Kenichi Handa <handa@m17n.org>
parents:
89933
diff
changeset
|
7574 if (c & 0x80) |
|
93595
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
7575 { |
|
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
7576 eight_bit_found = 1; |
|
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
7577 if (coding.head_ascii < 0) |
|
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
7578 coding.head_ascii = src - coding.source; |
|
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
7579 if (null_byte_found) |
|
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
7580 break; |
|
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
7581 } |
|
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
7582 if (c < 0x20) |
|
89974
2fef8edebd5c
(detect_coding_utf_16): Don't set detect_info->found if
Kenichi Handa <handa@m17n.org>
parents:
89933
diff
changeset
|
7583 { |
|
93595
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
7584 if ((c == ISO_CODE_ESC || c == ISO_CODE_SI || c == ISO_CODE_SO) |
|
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
7585 && ! inhibit_iso_escape_detection |
|
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
7586 && ! detect_info.checked) |
|
89974
2fef8edebd5c
(detect_coding_utf_16): Don't set detect_info->found if
Kenichi Handa <handa@m17n.org>
parents:
89933
diff
changeset
|
7587 { |
|
93595
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
7588 if (coding.head_ascii < 0) |
|
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
7589 coding.head_ascii = src - coding.source; |
|
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
7590 if (detect_coding_iso_2022 (&coding, &detect_info)) |
|
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
7591 { |
|
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
7592 /* We have scanned the whole data. */ |
|
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
7593 if (! (detect_info.rejected & CATEGORY_MASK_ISO_7_ELSE)) |
|
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
7594 /* We didn't find an 8-bit code. We may have |
|
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
7595 found a null-byte, but it's very rare that |
|
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
7596 a binary file confirm to ISO-2022. */ |
|
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
7597 src = src_end; |
|
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
7598 break; |
|
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
7599 } |
|
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
7600 } |
|
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
7601 else if (! c) |
|
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
7602 { |
|
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
7603 null_byte_found = 1; |
|
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
7604 if (eight_bit_found) |
|
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
7605 break; |
|
89974
2fef8edebd5c
(detect_coding_utf_16): Don't set detect_info->found if
Kenichi Handa <handa@m17n.org>
parents:
89933
diff
changeset
|
7606 } |
|
2fef8edebd5c
(detect_coding_utf_16): Don't set detect_info->found if
Kenichi Handa <handa@m17n.org>
parents:
89933
diff
changeset
|
7607 } |
| 17052 | 7608 } |
|
93595
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
7609 if (coding.head_ascii < 0) |
|
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
7610 coding.head_ascii = src - coding.source; |
|
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
7611 |
|
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
7612 if (null_byte_found || eight_bit_found |
|
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
7613 || coding.head_ascii < coding.src_bytes |
|
89974
2fef8edebd5c
(detect_coding_utf_16): Don't set detect_info->found if
Kenichi Handa <handa@m17n.org>
parents:
89933
diff
changeset
|
7614 || detect_info.found) |
|
2fef8edebd5c
(detect_coding_utf_16): Don't set detect_info->found if
Kenichi Handa <handa@m17n.org>
parents:
89933
diff
changeset
|
7615 { |
|
93595
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
7616 if (coding.head_ascii == coding.src_bytes) |
|
89974
2fef8edebd5c
(detect_coding_utf_16): Don't set detect_info->found if
Kenichi Handa <handa@m17n.org>
parents:
89933
diff
changeset
|
7617 /* As all bytes are 7-bit, we can ignore non-ISO-2022 codings. */ |
|
2fef8edebd5c
(detect_coding_utf_16): Don't set detect_info->found if
Kenichi Handa <handa@m17n.org>
parents:
89933
diff
changeset
|
7618 for (i = 0; i < coding_category_raw_text; i++) |
| 88365 | 7619 { |
|
89974
2fef8edebd5c
(detect_coding_utf_16): Don't set detect_info->found if
Kenichi Handa <handa@m17n.org>
parents:
89933
diff
changeset
|
7620 category = coding_priorities[i]; |
|
90594
a965377e6761
(detect_coding_system): Fix for handling off
Kenichi Handa <handa@m17n.org>
parents:
90587
diff
changeset
|
7621 this = coding_categories + category; |
|
89974
2fef8edebd5c
(detect_coding_utf_16): Don't set detect_info->found if
Kenichi Handa <handa@m17n.org>
parents:
89933
diff
changeset
|
7622 if (detect_info.found & (1 << category)) |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7623 break; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7624 } |
|
89974
2fef8edebd5c
(detect_coding_utf_16): Don't set detect_info->found if
Kenichi Handa <handa@m17n.org>
parents:
89933
diff
changeset
|
7625 else |
|
93595
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
7626 { |
|
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
7627 if (null_byte_found) |
|
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
7628 { |
|
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
7629 detect_info.checked |= ~CATEGORY_MASK_UTF_16; |
|
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
7630 detect_info.rejected |= ~CATEGORY_MASK_UTF_16; |
|
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
7631 } |
|
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
7632 for (i = 0; i < coding_category_raw_text; i++) |
|
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
7633 { |
|
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
7634 category = coding_priorities[i]; |
|
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
7635 this = coding_categories + category; |
|
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
7636 |
|
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
7637 if (this->id < 0) |
|
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
7638 { |
|
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
7639 /* No coding system of this category is defined. */ |
|
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
7640 detect_info.rejected |= (1 << category); |
|
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
7641 } |
|
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
7642 else if (category >= coding_category_raw_text) |
|
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
7643 continue; |
|
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
7644 else if (detect_info.checked & (1 << category)) |
|
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
7645 { |
|
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
7646 if (highest |
|
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
7647 && (detect_info.found & (1 << category))) |
|
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
7648 break; |
|
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
7649 } |
|
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
7650 else if ((*(this->detector)) (&coding, &detect_info) |
|
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
7651 && highest |
|
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
7652 && (detect_info.found & (1 << category))) |
|
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
7653 { |
|
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
7654 if (category == coding_category_utf_16_auto) |
|
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
7655 { |
|
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
7656 if (detect_info.found & CATEGORY_MASK_UTF_16_LE) |
|
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
7657 category = coding_category_utf_16_le; |
|
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
7658 else |
|
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
7659 category = coding_category_utf_16_be; |
|
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
7660 } |
|
89974
2fef8edebd5c
(detect_coding_utf_16): Don't set detect_info->found if
Kenichi Handa <handa@m17n.org>
parents:
89933
diff
changeset
|
7661 break; |
|
93595
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
7662 } |
|
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
7663 } |
|
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
7664 } |
|
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
7665 } |
|
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
7666 |
|
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
7667 if ((detect_info.rejected & CATEGORY_MASK_ANY) == CATEGORY_MASK_ANY) |
|
89193
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
7668 { |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7669 detect_info.found = CATEGORY_MASK_RAW_TEXT; |
|
89193
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
7670 id = coding_categories[coding_category_raw_text].id; |
|
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
7671 val = Fcons (make_number (id), Qnil); |
|
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
7672 } |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7673 else if (! detect_info.rejected && ! detect_info.found) |
|
89193
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
7674 { |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7675 detect_info.found = CATEGORY_MASK_ANY; |
|
89193
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
7676 id = coding_categories[coding_category_undecided].id; |
|
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
7677 val = Fcons (make_number (id), Qnil); |
|
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
7678 } |
|
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
7679 else if (highest) |
|
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
7680 { |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7681 if (detect_info.found) |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7682 { |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7683 detect_info.found = 1 << category; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7684 val = Fcons (make_number (this->id), Qnil); |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7685 } |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7686 else |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7687 for (i = 0; i < coding_category_raw_text; i++) |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7688 if (! (detect_info.rejected & (1 << coding_priorities[i]))) |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7689 { |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7690 detect_info.found = 1 << coding_priorities[i]; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7691 id = coding_categories[coding_priorities[i]].id; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7692 val = Fcons (make_number (id), Qnil); |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7693 break; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7694 } |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7695 } |
|
89193
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
7696 else |
|
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
7697 { |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7698 int mask = detect_info.rejected | detect_info.found; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7699 int found = 0; |
|
89193
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
7700 val = Qnil; |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7701 |
|
89193
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
7702 for (i = coding_category_raw_text - 1; i >= 0; i--) |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7703 { |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7704 category = coding_priorities[i]; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7705 if (! (mask & (1 << category))) |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7706 { |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7707 found |= 1 << category; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7708 id = coding_categories[category].id; |
|
90594
a965377e6761
(detect_coding_system): Fix for handling off
Kenichi Handa <handa@m17n.org>
parents:
90587
diff
changeset
|
7709 if (id >= 0) |
|
a965377e6761
(detect_coding_system): Fix for handling off
Kenichi Handa <handa@m17n.org>
parents:
90587
diff
changeset
|
7710 val = Fcons (make_number (id), val); |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7711 } |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7712 } |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7713 for (i = coding_category_raw_text - 1; i >= 0; i--) |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7714 { |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7715 category = coding_priorities[i]; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7716 if (detect_info.found & (1 << category)) |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7717 { |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7718 id = coding_categories[category].id; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7719 val = Fcons (make_number (id), val); |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7720 } |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7721 } |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7722 detect_info.found |= found; |
|
89193
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
7723 } |
|
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
7724 } |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
7725 else if (base_category == coding_category_utf_16_auto) |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
7726 { |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
7727 if (detect_coding_utf_16 (&coding, &detect_info)) |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
7728 { |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
7729 struct coding_system *this; |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
7730 |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
7731 if (detect_info.found & CATEGORY_MASK_UTF_16_LE) |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
7732 this = coding_categories + coding_category_utf_16_le; |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
7733 else if (detect_info.found & CATEGORY_MASK_UTF_16_BE) |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
7734 this = coding_categories + coding_category_utf_16_be; |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
7735 else if (detect_info.rejected & CATEGORY_MASK_UTF_16_LE_NOSIG) |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
7736 this = coding_categories + coding_category_utf_16_be_nosig; |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
7737 else |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
7738 this = coding_categories + coding_category_utf_16_le_nosig; |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
7739 val = Fcons (make_number (this->id), Qnil); |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
7740 } |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
7741 } |
| 88365 | 7742 else |
| 7743 { | |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7744 detect_info.found = 1 << XINT (CODING_ATTR_CATEGORY (attrs)); |
|
89193
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
7745 val = Fcons (make_number (coding.id), Qnil); |
|
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
7746 } |
|
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
7747 |
|
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
7748 /* Then, detect eol-format if necessary. */ |
| 88365 | 7749 { |
|
89193
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
7750 int normal_eol = -1, utf_16_be_eol = -1, utf_16_le_eol; |
| 88365 | 7751 Lisp_Object tail; |
| 7752 | |
|
89193
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
7753 if (VECTORP (eol_type)) |
|
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
7754 { |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7755 if (detect_info.found & ~CATEGORY_MASK_UTF_16) |
|
93595
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
7756 { |
|
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
7757 if (null_byte_found) |
|
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
7758 normal_eol = EOL_SEEN_LF; |
|
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
7759 else |
|
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
7760 normal_eol = detect_eol (coding.source, src_bytes, |
|
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
7761 coding_category_raw_text); |
|
ac4d127a841a
(CATEGORY_MASK_ANY): Add CATEGORY_MASK_UTF_16_AUTO.
Kenichi Handa <handa@m17n.org>
parents:
93323
diff
changeset
|
7762 } |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7763 if (detect_info.found & (CATEGORY_MASK_UTF_16_BE |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7764 | CATEGORY_MASK_UTF_16_BE_NOSIG)) |
|
89193
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
7765 utf_16_be_eol = detect_eol (coding.source, src_bytes, |
|
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
7766 coding_category_utf_16_be); |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7767 if (detect_info.found & (CATEGORY_MASK_UTF_16_LE |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7768 | CATEGORY_MASK_UTF_16_LE_NOSIG)) |
|
89193
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
7769 utf_16_le_eol = detect_eol (coding.source, src_bytes, |
|
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
7770 coding_category_utf_16_le); |
|
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
7771 } |
|
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
7772 else |
|
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
7773 { |
|
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
7774 if (EQ (eol_type, Qunix)) |
|
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
7775 normal_eol = utf_16_be_eol = utf_16_le_eol = EOL_SEEN_LF; |
|
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
7776 else if (EQ (eol_type, Qdos)) |
|
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
7777 normal_eol = utf_16_be_eol = utf_16_le_eol = EOL_SEEN_CRLF; |
|
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
7778 else |
|
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
7779 normal_eol = utf_16_be_eol = utf_16_le_eol = EOL_SEEN_CR; |
|
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
7780 } |
|
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
7781 |
| 88365 | 7782 for (tail = val; CONSP (tail); tail = XCDR (tail)) |
| 7783 { | |
|
89193
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
7784 enum coding_category category; |
| 88365 | 7785 int this_eol; |
|
89193
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
7786 |
|
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
7787 id = XINT (XCAR (tail)); |
|
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
7788 attrs = CODING_ID_ATTRS (id); |
|
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
7789 category = XINT (CODING_ATTR_CATEGORY (attrs)); |
|
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
7790 eol_type = CODING_ID_EOL_TYPE (id); |
| 88365 | 7791 if (VECTORP (eol_type)) |
| 7792 { | |
|
89193
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
7793 if (category == coding_category_utf_16_be |
|
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
7794 || category == coding_category_utf_16_be_nosig) |
|
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
7795 this_eol = utf_16_be_eol; |
|
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
7796 else if (category == coding_category_utf_16_le |
|
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
7797 || category == coding_category_utf_16_le_nosig) |
|
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
7798 this_eol = utf_16_le_eol; |
| 88365 | 7799 else |
|
89193
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
7800 this_eol = normal_eol; |
|
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
7801 |
| 88365 | 7802 if (this_eol == EOL_SEEN_LF) |
| 7803 XSETCAR (tail, AREF (eol_type, 0)); | |
| 7804 else if (this_eol == EOL_SEEN_CRLF) | |
| 7805 XSETCAR (tail, AREF (eol_type, 1)); | |
| 7806 else if (this_eol == EOL_SEEN_CR) | |
| 7807 XSETCAR (tail, AREF (eol_type, 2)); | |
|
89193
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
7808 else |
|
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
7809 XSETCAR (tail, CODING_ID_NAME (id)); |
| 88365 | 7810 } |
|
89193
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
7811 else |
|
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
7812 XSETCAR (tail, CODING_ID_NAME (id)); |
| 88365 | 7813 } |
| 7814 } | |
| 7815 | |
|
25662
0a7261c1d487
Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25370
diff
changeset
|
7816 return (highest ? XCAR (val) : val); |
|
42104
d69c2368e549
(DECODE_COMPOSITION_END): Fixed a typo in the last
Sam Steingold <sds@gnu.org>
parents:
42103
diff
changeset
|
7817 } |
|
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
7818 |
| 88365 | 7819 |
|
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
7820 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
|
7821 2, 3, 0, |
|
40713
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
7822 doc: /* Detect coding system of the text in the region between START and END. |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
7823 Return a list of possible coding systems ordered by priority. |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
7824 |
|
72552
6493d4697ad2
(Fdetect_coding_region, Fdetect_coding_string): Fix
Kenichi Handa <handa@m17n.org>
parents:
72395
diff
changeset
|
7825 If only ASCII characters are found (except for such ISO-2022 control |
|
6493d4697ad2
(Fdetect_coding_region, Fdetect_coding_string): Fix
Kenichi Handa <handa@m17n.org>
parents:
72395
diff
changeset
|
7826 characters ISO-2022 as ESC), it returns a list of single element |
|
40713
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
7827 `undecided' or its subsidiary coding system according to a detected |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
7828 end-of-line format. |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
7829 |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
7830 If optional argument HIGHEST is non-nil, return the coding system of |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
7831 highest priority. */) |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
7832 (start, end, highest) |
|
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
7833 Lisp_Object start, end, highest; |
| 17052 | 7834 { |
|
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
7835 int from, to; |
|
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
7836 int from_byte, to_byte; |
|
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
7837 |
|
40656
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Jan?k <Pavel@Janik.cz>
parents:
40461
diff
changeset
|
7838 CHECK_NUMBER_COERCE_MARKER (start); |
|
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Jan?k <Pavel@Janik.cz>
parents:
40461
diff
changeset
|
7839 CHECK_NUMBER_COERCE_MARKER (end); |
|
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
7840 |
|
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
7841 validate_region (&start, &end); |
|
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
7842 from = XINT (start), to = XINT (end); |
|
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
7843 from_byte = CHAR_TO_BYTE (from); |
|
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
7844 to_byte = CHAR_TO_BYTE (to); |
|
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
7845 |
|
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
7846 if (from < GPT && to >= GPT) |
|
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
7847 move_gap_both (to, to_byte); |
| 88365 | 7848 |
|
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
7849 return detect_coding_system (BYTE_POS_ADDR (from_byte), |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
7850 to - from, to_byte - from_byte, |
|
34531
37f85e931855
(ONE_MORE_BYTE_CHECK_MULTIBYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34197
diff
changeset
|
7851 !NILP (highest), |
|
37f85e931855
(ONE_MORE_BYTE_CHECK_MULTIBYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34197
diff
changeset
|
7852 !NILP (current_buffer |
| 88365 | 7853 ->enable_multibyte_characters), |
| 7854 Qnil); | |
|
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
7855 } |
|
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
7856 |
|
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
7857 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
|
7858 1, 2, 0, |
|
40713
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
7859 doc: /* Detect coding system of the text in STRING. |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
7860 Return a list of possible coding systems ordered by priority. |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
7861 |
|
72552
6493d4697ad2
(Fdetect_coding_region, Fdetect_coding_string): Fix
Kenichi Handa <handa@m17n.org>
parents:
72395
diff
changeset
|
7862 If only ASCII characters are found (except for such ISO-2022 control |
|
6493d4697ad2
(Fdetect_coding_region, Fdetect_coding_string): Fix
Kenichi Handa <handa@m17n.org>
parents:
72395
diff
changeset
|
7863 characters ISO-2022 as ESC), it returns a list of single element |
|
40713
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
7864 `undecided' or its subsidiary coding system according to a detected |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
7865 end-of-line format. |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
7866 |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
7867 If optional argument HIGHEST is non-nil, return the coding system of |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
7868 highest priority. */) |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
7869 (string, highest) |
|
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
7870 Lisp_Object string, highest; |
|
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
7871 { |
|
40656
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Jan?k <Pavel@Janik.cz>
parents:
40461
diff
changeset
|
7872 CHECK_STRING (string); |
|
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
7873 |
|
46370
40db0673e6f0
Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents:
46293
diff
changeset
|
7874 return detect_coding_system (SDATA (string), |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
7875 SCHARS (string), SBYTES (string), |
| 89483 | 7876 !NILP (highest), STRING_MULTIBYTE (string), |
| 88365 | 7877 Qnil); |
|
30487
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
7878 } |
|
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
7879 |
|
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
7880 |
| 88365 | 7881 static INLINE int |
| 7882 char_encodable_p (c, attrs) | |
| 7883 int c; | |
| 7884 Lisp_Object attrs; | |
|
30487
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
7885 { |
| 88365 | 7886 Lisp_Object tail; |
| 7887 struct charset *charset; | |
|
89732
8acde12aba89
(get_translation_table): New function.
Kenichi Handa <handa@m17n.org>
parents:
89730
diff
changeset
|
7888 Lisp_Object translation_table; |
|
8acde12aba89
(get_translation_table): New function.
Kenichi Handa <handa@m17n.org>
parents:
89730
diff
changeset
|
7889 |
|
8acde12aba89
(get_translation_table): New function.
Kenichi Handa <handa@m17n.org>
parents:
89730
diff
changeset
|
7890 translation_table = CODING_ATTR_TRANS_TBL (attrs); |
|
89759
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
7891 if (! NILP (translation_table)) |
|
89732
8acde12aba89
(get_translation_table): New function.
Kenichi Handa <handa@m17n.org>
parents:
89730
diff
changeset
|
7892 c = translate_char (translation_table, c); |
| 88365 | 7893 for (tail = CODING_ATTR_CHARSET_LIST (attrs); |
| 7894 CONSP (tail); tail = XCDR (tail)) | |
| 7895 { | |
| 7896 charset = CHARSET_FROM_ID (XINT (XCAR (tail))); | |
| 7897 if (CHAR_CHARSET_P (c, charset)) | |
| 7898 break; | |
| 7899 } | |
| 7900 return (! NILP (tail)); | |
|
30487
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
7901 } |
|
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
7902 |
|
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
7903 |
|
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
7904 /* Return a list of coding systems that safely encode the text between |
| 88365 | 7905 START and END. If EXCLUDE is non-nil, it is a list of coding |
| 7906 systems not to check. The returned list doesn't contain any such | |
|
88889
4548f224c603
(Ffind_coding_systems_region_internal): Detect an
Kenichi Handa <handa@m17n.org>
parents:
88876
diff
changeset
|
7907 coding systems. In any case, if the text contains only ASCII or is |
| 88365 | 7908 unibyte, return t. */ |
|
30487
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
7909 |
|
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
7910 DEFUN ("find-coding-systems-region-internal", |
|
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
7911 Ffind_coding_systems_region_internal, |
| 88365 | 7912 Sfind_coding_systems_region_internal, 2, 3, 0, |
|
40713
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
7913 doc: /* Internal use only. */) |
| 88365 | 7914 (start, end, exclude) |
| 7915 Lisp_Object start, end, exclude; | |
|
30487
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
7916 { |
| 88365 | 7917 Lisp_Object coding_attrs_list, safe_codings; |
| 7918 EMACS_INT start_byte, end_byte; | |
|
88876
af9012fdad56
(LEADING_CODE_PRIVATE_11, LEADING_CODE_PRIVATE_12,
Kenichi Handa <handa@m17n.org>
parents:
88862
diff
changeset
|
7919 const unsigned char *p, *pbeg, *pend; |
| 88365 | 7920 int c; |
| 7921 Lisp_Object tail, elt; | |
|
30487
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
7922 |
|
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
7923 if (STRINGP (start)) |
|
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
7924 { |
| 88365 | 7925 if (!STRING_MULTIBYTE (start) |
| 89483 | 7926 || SCHARS (start) == SBYTES (start)) |
|
30487
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
7927 return Qt; |
| 88365 | 7928 start_byte = 0; |
| 89483 | 7929 end_byte = SBYTES (start); |
|
30487
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
7930 } |
|
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
7931 else |
|
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
7932 { |
|
40656
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Jan?k <Pavel@Janik.cz>
parents:
40461
diff
changeset
|
7933 CHECK_NUMBER_COERCE_MARKER (start); |
|
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Jan?k <Pavel@Janik.cz>
parents:
40461
diff
changeset
|
7934 CHECK_NUMBER_COERCE_MARKER (end); |
|
30487
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
7935 if (XINT (start) < BEG || XINT (end) > Z || XINT (start) > XINT (end)) |
|
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
7936 args_out_of_range (start, end); |
|
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
7937 if (NILP (current_buffer->enable_multibyte_characters)) |
|
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
7938 return Qt; |
| 88365 | 7939 start_byte = CHAR_TO_BYTE (XINT (start)); |
| 7940 end_byte = CHAR_TO_BYTE (XINT (end)); | |
| 7941 if (XINT (end) - XINT (start) == end_byte - start_byte) | |
| 7942 return Qt; | |
| 7943 | |
|
89394
6ffca50f25b9
(Fcheck_coding_systems_region): Fix type errors.
Dave Love <fx@gnu.org>
parents:
89373
diff
changeset
|
7944 if (XINT (start) < GPT && XINT (end) > GPT) |
| 88365 | 7945 { |
|
89394
6ffca50f25b9
(Fcheck_coding_systems_region): Fix type errors.
Dave Love <fx@gnu.org>
parents:
89373
diff
changeset
|
7946 if ((GPT - XINT (start)) < (XINT (end) - GPT)) |
|
6ffca50f25b9
(Fcheck_coding_systems_region): Fix type errors.
Dave Love <fx@gnu.org>
parents:
89373
diff
changeset
|
7947 move_gap_both (XINT (start), start_byte); |
| 88365 | 7948 else |
|
89394
6ffca50f25b9
(Fcheck_coding_systems_region): Fix type errors.
Dave Love <fx@gnu.org>
parents:
89373
diff
changeset
|
7949 move_gap_both (XINT (end), end_byte); |
| 88365 | 7950 } |
| 7951 } | |
| 7952 | |
| 7953 coding_attrs_list = Qnil; | |
| 7954 for (tail = Vcoding_system_list; CONSP (tail); tail = XCDR (tail)) | |
| 7955 if (NILP (exclude) | |
| 7956 || NILP (Fmemq (XCAR (tail), exclude))) | |
| 7957 { | |
| 7958 Lisp_Object attrs; | |
| 7959 | |
| 7960 attrs = AREF (CODING_SYSTEM_SPEC (XCAR (tail)), 0); | |
| 7961 if (EQ (XCAR (tail), CODING_ATTR_BASE_NAME (attrs)) | |
| 7962 && ! EQ (CODING_ATTR_TYPE (attrs), Qundecided)) | |
|
89732
8acde12aba89
(get_translation_table): New function.
Kenichi Handa <handa@m17n.org>
parents:
89730
diff
changeset
|
7963 { |
|
8acde12aba89
(get_translation_table): New function.
Kenichi Handa <handa@m17n.org>
parents:
89730
diff
changeset
|
7964 ASET (attrs, coding_attr_trans_tbl, |
|
89861
7160ded23e55
(get_translation_table): Allow max_lookup to be NULL.
Kenichi Handa <handa@m17n.org>
parents:
89859
diff
changeset
|
7965 get_translation_table (attrs, 1, NULL)); |
|
89732
8acde12aba89
(get_translation_table): New function.
Kenichi Handa <handa@m17n.org>
parents:
89730
diff
changeset
|
7966 coding_attrs_list = Fcons (attrs, coding_attrs_list); |
|
8acde12aba89
(get_translation_table): New function.
Kenichi Handa <handa@m17n.org>
parents:
89730
diff
changeset
|
7967 } |
| 88365 | 7968 } |
| 7969 | |
| 7970 if (STRINGP (start)) | |
| 89483 | 7971 p = pbeg = SDATA (start); |
| 88365 | 7972 else |
| 7973 p = pbeg = BYTE_POS_ADDR (start_byte); | |
| 7974 pend = p + (end_byte - start_byte); | |
| 7975 | |
| 7976 while (p < pend && ASCII_BYTE_P (*p)) p++; | |
| 7977 while (p < pend && ASCII_BYTE_P (*(pend - 1))) pend--; | |
| 7978 | |
| 7979 while (p < pend) | |
| 7980 { | |
| 7981 if (ASCII_BYTE_P (*p)) | |
| 7982 p++; | |
|
30487
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
7983 else |
|
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
7984 { |
| 88365 | 7985 c = STRING_CHAR_ADVANCE (p); |
| 7986 | |
| 7987 charset_map_loaded = 0; | |
| 7988 for (tail = coding_attrs_list; CONSP (tail);) | |
| 7989 { | |
| 7990 elt = XCAR (tail); | |
| 7991 if (NILP (elt)) | |
| 7992 tail = XCDR (tail); | |
| 7993 else if (char_encodable_p (c, elt)) | |
| 7994 tail = XCDR (tail); | |
| 7995 else if (CONSP (XCDR (tail))) | |
| 7996 { | |
| 7997 XSETCAR (tail, XCAR (XCDR (tail))); | |
| 7998 XSETCDR (tail, XCDR (XCDR (tail))); | |
| 7999 } | |
| 8000 else | |
| 8001 { | |
| 8002 XSETCAR (tail, Qnil); | |
| 8003 tail = XCDR (tail); | |
| 8004 } | |
| 8005 } | |
| 8006 if (charset_map_loaded) | |
| 8007 { | |
| 8008 EMACS_INT p_offset = p - pbeg, pend_offset = pend - pbeg; | |
| 8009 | |
| 8010 if (STRINGP (start)) | |
| 89483 | 8011 pbeg = SDATA (start); |
| 88365 | 8012 else |
| 8013 pbeg = BYTE_POS_ADDR (start_byte); | |
| 8014 p = pbeg + p_offset; | |
| 8015 pend = pbeg + pend_offset; | |
| 8016 } | |
|
30487
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
8017 } |
|
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
8018 } |
|
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
8019 |
|
89905
37e044cc35f6
(Ffind_coding_systems_region_internal): Include raw-text and
Kenichi Handa <handa@m17n.org>
parents:
89892
diff
changeset
|
8020 safe_codings = list2 (Qraw_text, Qno_conversion); |
| 88365 | 8021 for (tail = coding_attrs_list; CONSP (tail); tail = XCDR (tail)) |
| 8022 if (! NILP (XCAR (tail))) | |
| 8023 safe_codings = Fcons (CODING_ATTR_BASE_NAME (XCAR (tail)), safe_codings); | |
|
49539
1ad5bfbb831a
(syms_of_coding): Add `...' for symbols in the docstring of
Kenichi Handa <handa@m17n.org>
parents:
48874
diff
changeset
|
8024 |
|
1ad5bfbb831a
(syms_of_coding): Add `...' for symbols in the docstring of
Kenichi Handa <handa@m17n.org>
parents:
48874
diff
changeset
|
8025 return safe_codings; |
|
1ad5bfbb831a
(syms_of_coding): Add `...' for symbols in the docstring of
Kenichi Handa <handa@m17n.org>
parents:
48874
diff
changeset
|
8026 } |
|
1ad5bfbb831a
(syms_of_coding): Add `...' for symbols in the docstring of
Kenichi Handa <handa@m17n.org>
parents:
48874
diff
changeset
|
8027 |
|
1ad5bfbb831a
(syms_of_coding): Add `...' for symbols in the docstring of
Kenichi Handa <handa@m17n.org>
parents:
48874
diff
changeset
|
8028 |
|
46859
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
8029 DEFUN ("unencodable-char-position", Funencodable_char_position, |
|
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
8030 Sunencodable_char_position, 3, 5, 0, |
|
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
8031 doc: /* |
|
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
8032 Return position of first un-encodable character in a region. |
|
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
8033 START and END specfiy the region and CODING-SYSTEM specifies the |
|
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
8034 encoding to check. Return nil if CODING-SYSTEM does encode the region. |
|
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
8035 |
|
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
8036 If optional 4th argument COUNT is non-nil, it specifies at most how |
|
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
8037 many un-encodable characters to search. In this case, the value is a |
|
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
8038 list of positions. |
|
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
8039 |
|
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
8040 If optional 5th argument STRING is non-nil, it is a string to search |
|
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
8041 for un-encodable characters. In that case, START and END are indexes |
|
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
8042 to the string. */) |
|
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
8043 (start, end, coding_system, count, string) |
|
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
8044 Lisp_Object start, end, coding_system, count, string; |
|
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
8045 { |
|
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
8046 int n; |
|
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
8047 struct coding_system coding; |
|
89732
8acde12aba89
(get_translation_table): New function.
Kenichi Handa <handa@m17n.org>
parents:
89730
diff
changeset
|
8048 Lisp_Object attrs, charset_list, translation_table; |
|
46859
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
8049 Lisp_Object positions; |
|
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
8050 int from, to; |
| 89483 | 8051 const unsigned char *p, *stop, *pend; |
| 8052 int ascii_compatible; | |
| 8053 | |
| 8054 setup_coding_system (Fcheck_coding_system (coding_system), &coding); | |
| 8055 attrs = CODING_ID_ATTRS (coding.id); | |
| 8056 if (EQ (CODING_ATTR_TYPE (attrs), Qraw_text)) | |
| 8057 return Qnil; | |
| 8058 ascii_compatible = ! NILP (CODING_ATTR_ASCII_COMPAT (attrs)); | |
| 8059 charset_list = CODING_ATTR_CHARSET_LIST (attrs); | |
|
89861
7160ded23e55
(get_translation_table): Allow max_lookup to be NULL.
Kenichi Handa <handa@m17n.org>
parents:
89859
diff
changeset
|
8060 translation_table = get_translation_table (attrs, 1, NULL); |
|
46859
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
8061 |
|
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
8062 if (NILP (string)) |
|
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
8063 { |
|
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
8064 validate_region (&start, &end); |
|
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
8065 from = XINT (start); |
|
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
8066 to = XINT (end); |
| 89483 | 8067 if (NILP (current_buffer->enable_multibyte_characters) |
| 8068 || (ascii_compatible | |
| 8069 && (to - from) == (CHAR_TO_BYTE (to) - (CHAR_TO_BYTE (from))))) | |
|
46859
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
8070 return Qnil; |
|
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
8071 p = CHAR_POS_ADDR (from); |
| 89483 | 8072 pend = CHAR_POS_ADDR (to); |
| 8073 if (from < GPT && to >= GPT) | |
| 8074 stop = GPT_ADDR; | |
|
48829
f6c59ca557c7
(Funencodable_char_position): Set pend correctly.
Kenichi Handa <handa@m17n.org>
parents:
48230
diff
changeset
|
8075 else |
| 89483 | 8076 stop = pend; |
|
46859
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
8077 } |
|
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
8078 else |
|
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
8079 { |
|
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
8080 CHECK_STRING (string); |
|
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
8081 CHECK_NATNUM (start); |
|
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
8082 CHECK_NATNUM (end); |
|
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
8083 from = XINT (start); |
|
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
8084 to = XINT (end); |
|
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
8085 if (from > to |
|
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
8086 || to > SCHARS (string)) |
|
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
8087 args_out_of_range_3 (string, start, end); |
|
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
8088 if (! STRING_MULTIBYTE (string)) |
|
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
8089 return Qnil; |
|
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
8090 p = SDATA (string) + string_char_to_byte (string, from); |
| 89483 | 8091 stop = pend = SDATA (string) + string_char_to_byte (string, to); |
| 8092 if (ascii_compatible && (to - from) == (pend - p)) | |
| 8093 return Qnil; | |
| 8094 } | |
|
46859
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
8095 |
|
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
8096 if (NILP (count)) |
|
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
8097 n = 1; |
|
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
8098 else |
|
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
8099 { |
|
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
8100 CHECK_NATNUM (count); |
|
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
8101 n = XINT (count); |
|
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
8102 } |
|
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
8103 |
| 89483 | 8104 positions = Qnil; |
| 8105 while (1) | |
| 8106 { | |
| 8107 int c; | |
| 8108 | |
| 8109 if (ascii_compatible) | |
| 8110 while (p < stop && ASCII_BYTE_P (*p)) | |
| 8111 p++, from++; | |
| 8112 if (p >= stop) | |
| 8113 { | |
| 8114 if (p >= pend) | |
| 8115 break; | |
| 8116 stop = pend; | |
| 8117 p = GAP_END_ADDR; | |
| 8118 } | |
| 8119 | |
| 8120 c = STRING_CHAR_ADVANCE (p); | |
| 8121 if (! (ASCII_CHAR_P (c) && ascii_compatible) | |
|
89732
8acde12aba89
(get_translation_table): New function.
Kenichi Handa <handa@m17n.org>
parents:
89730
diff
changeset
|
8122 && ! char_charset (translate_char (translation_table, c), |
|
8acde12aba89
(get_translation_table): New function.
Kenichi Handa <handa@m17n.org>
parents:
89730
diff
changeset
|
8123 charset_list, NULL)) |
| 89483 | 8124 { |
| 8125 positions = Fcons (make_number (from), positions); | |
| 8126 n--; | |
| 8127 if (n == 0) | |
| 8128 break; | |
| 8129 } | |
| 8130 | |
| 8131 from++; | |
| 8132 } | |
| 8133 | |
| 8134 return (NILP (count) ? Fcar (positions) : Fnreverse (positions)); | |
| 8135 } | |
| 8136 | |
| 8137 | |
| 88365 | 8138 DEFUN ("check-coding-systems-region", Fcheck_coding_systems_region, |
| 8139 Scheck_coding_systems_region, 3, 3, 0, | |
| 8140 doc: /* Check if the region is encodable by coding systems. | |
| 8141 | |
| 8142 START and END are buffer positions specifying the region. | |
| 8143 CODING-SYSTEM-LIST is a list of coding systems to check. | |
| 8144 | |
| 8145 The value is an alist ((CODING-SYSTEM POS0 POS1 ...) ...), where | |
| 8146 CODING-SYSTEM is a member of CODING-SYSTEM-LIst and can't encode the | |
| 8147 whole region, POS0, POS1, ... are buffer positions where non-encodable | |
| 8148 characters are found. | |
| 8149 | |
| 8150 If all coding systems in CODING-SYSTEM-LIST can encode the region, the | |
| 8151 value is nil. | |
| 8152 | |
| 8153 START may be a string. In that case, check if the string is | |
| 8154 encodable, and the value contains indices to the string instead of | |
| 8155 buffer positions. END is ignored. */) | |
| 8156 (start, end, coding_system_list) | |
| 8157 Lisp_Object start, end, coding_system_list; | |
| 8158 { | |
| 8159 Lisp_Object list; | |
| 8160 EMACS_INT start_byte, end_byte; | |
| 8161 int pos; | |
|
88876
af9012fdad56
(LEADING_CODE_PRIVATE_11, LEADING_CODE_PRIVATE_12,
Kenichi Handa <handa@m17n.org>
parents:
88862
diff
changeset
|
8162 const unsigned char *p, *pbeg, *pend; |
| 88365 | 8163 int c; |
|
89732
8acde12aba89
(get_translation_table): New function.
Kenichi Handa <handa@m17n.org>
parents:
89730
diff
changeset
|
8164 Lisp_Object tail, elt, attrs; |
| 88365 | 8165 |
| 8166 if (STRINGP (start)) | |
| 8167 { | |
| 8168 if (!STRING_MULTIBYTE (start) | |
| 89483 | 8169 && SCHARS (start) != SBYTES (start)) |
| 88365 | 8170 return Qnil; |
| 8171 start_byte = 0; | |
| 89483 | 8172 end_byte = SBYTES (start); |
| 88365 | 8173 pos = 0; |
|
30487
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
8174 } |
|
46859
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
8175 else |
|
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
8176 { |
| 88365 | 8177 CHECK_NUMBER_COERCE_MARKER (start); |
| 8178 CHECK_NUMBER_COERCE_MARKER (end); | |
| 8179 if (XINT (start) < BEG || XINT (end) > Z || XINT (start) > XINT (end)) | |
| 8180 args_out_of_range (start, end); | |
| 8181 if (NILP (current_buffer->enable_multibyte_characters)) | |
| 8182 return Qnil; | |
| 8183 start_byte = CHAR_TO_BYTE (XINT (start)); | |
| 8184 end_byte = CHAR_TO_BYTE (XINT (end)); | |
| 8185 if (XINT (end) - XINT (start) == end_byte - start_byte) | |
| 8186 return Qt; | |
| 8187 | |
|
89394
6ffca50f25b9
(Fcheck_coding_systems_region): Fix type errors.
Dave Love <fx@gnu.org>
parents:
89373
diff
changeset
|
8188 if (XINT (start) < GPT && XINT (end) > GPT) |
| 88365 | 8189 { |
|
89394
6ffca50f25b9
(Fcheck_coding_systems_region): Fix type errors.
Dave Love <fx@gnu.org>
parents:
89373
diff
changeset
|
8190 if ((GPT - XINT (start)) < (XINT (end) - GPT)) |
|
6ffca50f25b9
(Fcheck_coding_systems_region): Fix type errors.
Dave Love <fx@gnu.org>
parents:
89373
diff
changeset
|
8191 move_gap_both (XINT (start), start_byte); |
| 88365 | 8192 else |
|
89394
6ffca50f25b9
(Fcheck_coding_systems_region): Fix type errors.
Dave Love <fx@gnu.org>
parents:
89373
diff
changeset
|
8193 move_gap_both (XINT (end), end_byte); |
| 88365 | 8194 } |
|
89394
6ffca50f25b9
(Fcheck_coding_systems_region): Fix type errors.
Dave Love <fx@gnu.org>
parents:
89373
diff
changeset
|
8195 pos = XINT (start); |
| 88365 | 8196 } |
| 8197 | |
| 8198 list = Qnil; | |
| 8199 for (tail = coding_system_list; CONSP (tail); tail = XCDR (tail)) | |
| 8200 { | |
| 8201 elt = XCAR (tail); | |
|
89732
8acde12aba89
(get_translation_table): New function.
Kenichi Handa <handa@m17n.org>
parents:
89730
diff
changeset
|
8202 attrs = AREF (CODING_SYSTEM_SPEC (elt), 0); |
|
89861
7160ded23e55
(get_translation_table): Allow max_lookup to be NULL.
Kenichi Handa <handa@m17n.org>
parents:
89859
diff
changeset
|
8203 ASET (attrs, coding_attr_trans_tbl, |
|
7160ded23e55
(get_translation_table): Allow max_lookup to be NULL.
Kenichi Handa <handa@m17n.org>
parents:
89859
diff
changeset
|
8204 get_translation_table (attrs, 1, NULL)); |
|
89732
8acde12aba89
(get_translation_table): New function.
Kenichi Handa <handa@m17n.org>
parents:
89730
diff
changeset
|
8205 list = Fcons (Fcons (elt, Fcons (attrs, Qnil)), list); |
| 88365 | 8206 } |
| 8207 | |
| 8208 if (STRINGP (start)) | |
| 89483 | 8209 p = pbeg = SDATA (start); |
| 88365 | 8210 else |
| 8211 p = pbeg = BYTE_POS_ADDR (start_byte); | |
| 8212 pend = p + (end_byte - start_byte); | |
| 8213 | |
| 8214 while (p < pend && ASCII_BYTE_P (*p)) p++, pos++; | |
| 8215 while (p < pend && ASCII_BYTE_P (*(pend - 1))) pend--; | |
| 8216 | |
| 8217 while (p < pend) | |
| 8218 { | |
| 8219 if (ASCII_BYTE_P (*p)) | |
| 8220 p++; | |
|
46859
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
8221 else |
|
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
8222 { |
| 88365 | 8223 c = STRING_CHAR_ADVANCE (p); |
| 8224 | |
| 8225 charset_map_loaded = 0; | |
| 8226 for (tail = list; CONSP (tail); tail = XCDR (tail)) | |
| 8227 { | |
| 8228 elt = XCDR (XCAR (tail)); | |
| 8229 if (! char_encodable_p (c, XCAR (elt))) | |
| 8230 XSETCDR (elt, Fcons (make_number (pos), XCDR (elt))); | |
| 8231 } | |
| 8232 if (charset_map_loaded) | |
| 8233 { | |
| 8234 EMACS_INT p_offset = p - pbeg, pend_offset = pend - pbeg; | |
| 8235 | |
| 8236 if (STRINGP (start)) | |
| 89483 | 8237 pbeg = SDATA (start); |
| 88365 | 8238 else |
| 8239 pbeg = BYTE_POS_ADDR (start_byte); | |
| 8240 p = pbeg + p_offset; | |
| 8241 pend = pbeg + pend_offset; | |
| 8242 } | |
| 8243 } | |
| 8244 pos++; | |
| 8245 } | |
| 8246 | |
| 8247 tail = list; | |
| 8248 list = Qnil; | |
| 8249 for (; CONSP (tail); tail = XCDR (tail)) | |
| 8250 { | |
| 8251 elt = XCAR (tail); | |
| 8252 if (CONSP (XCDR (XCDR (elt)))) | |
| 8253 list = Fcons (Fcons (XCAR (elt), Fnreverse (XCDR (XCDR (elt)))), | |
| 8254 list); | |
| 8255 } | |
| 8256 | |
| 8257 return list; | |
|
46859
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
8258 } |
|
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
8259 |
|
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
8260 |
|
20803
0fa2183c587d
(ENCODE_ISO_CHARACTER): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
20794
diff
changeset
|
8261 Lisp_Object |
| 88365 | 8262 code_convert_region (start, end, coding_system, dst_object, encodep, norecord) |
| 8263 Lisp_Object start, end, coding_system, dst_object; | |
| 8264 int encodep, norecord; | |
|
20680
dd46027e8412
(code_convert_region): Always count chars inserted
Richard M. Stallman <rms@gnu.org>
parents:
20668
diff
changeset
|
8265 { |
|
dd46027e8412
(code_convert_region): Always count chars inserted
Richard M. Stallman <rms@gnu.org>
parents:
20668
diff
changeset
|
8266 struct coding_system coding; |
| 88365 | 8267 EMACS_INT from, from_byte, to, to_byte; |
| 8268 Lisp_Object src_object; | |
|
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
8269 |
|
40656
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Jan?k <Pavel@Janik.cz>
parents:
40461
diff
changeset
|
8270 CHECK_NUMBER_COERCE_MARKER (start); |
|
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Jan?k <Pavel@Janik.cz>
parents:
40461
diff
changeset
|
8271 CHECK_NUMBER_COERCE_MARKER (end); |
| 88365 | 8272 if (NILP (coding_system)) |
| 8273 coding_system = Qno_conversion; | |
| 8274 else | |
| 8275 CHECK_CODING_SYSTEM (coding_system); | |
| 8276 src_object = Fcurrent_buffer (); | |
| 8277 if (NILP (dst_object)) | |
| 8278 dst_object = src_object; | |
| 8279 else if (! EQ (dst_object, Qt)) | |
| 8280 CHECK_BUFFER (dst_object); | |
|
20680
dd46027e8412
(code_convert_region): Always count chars inserted
Richard M. Stallman <rms@gnu.org>
parents:
20668
diff
changeset
|
8281 |
|
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
8282 validate_region (&start, &end); |
|
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
8283 from = XFASTINT (start); |
| 88365 | 8284 from_byte = CHAR_TO_BYTE (from); |
|
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
8285 to = XFASTINT (end); |
| 88365 | 8286 to_byte = CHAR_TO_BYTE (to); |
| 8287 | |
| 8288 setup_coding_system (coding_system, &coding); | |
|
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
8289 coding.mode |= CODING_MODE_LAST_BLOCK; |
| 88365 | 8290 |
| 8291 if (encodep) | |
| 8292 encode_coding_object (&coding, src_object, from, from_byte, to, to_byte, | |
| 8293 dst_object); | |
| 8294 else | |
| 8295 decode_coding_object (&coding, src_object, from, from_byte, to, to_byte, | |
| 8296 dst_object); | |
| 8297 if (! norecord) | |
| 8298 Vlast_coding_system_used = CODING_ID_NAME (coding.id); | |
| 8299 | |
| 8300 return (BUFFERP (dst_object) | |
| 8301 ? make_number (coding.produced_char) | |
| 8302 : coding.dst_object); | |
|
20803
0fa2183c587d
(ENCODE_ISO_CHARACTER): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
20794
diff
changeset
|
8303 } |
|
0fa2183c587d
(ENCODE_ISO_CHARACTER): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
20794
diff
changeset
|
8304 |
|
0fa2183c587d
(ENCODE_ISO_CHARACTER): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
20794
diff
changeset
|
8305 |
|
0fa2183c587d
(ENCODE_ISO_CHARACTER): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
20794
diff
changeset
|
8306 DEFUN ("decode-coding-region", Fdecode_coding_region, Sdecode_coding_region, |
| 88365 | 8307 3, 4, "r\nzCoding system: ", |
|
40713
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
8308 doc: /* Decode the current region from the specified coding system. |
| 88365 | 8309 When called from a program, takes four arguments: |
| 8310 START, END, CODING-SYSTEM, and DESTINATION. | |
| 8311 START and END are buffer positions. | |
| 8312 | |
| 8313 Optional 4th arguments DESTINATION specifies where the decoded text goes. | |
|
91083
ff87badce376
(Fdecode_coding_region): Fix typo in docstring.
Kenichi Handa <handa@m17n.org>
parents:
91056
diff
changeset
|
8314 If nil, the region between START and END is replaced by the decoded text. |
| 88365 | 8315 If buffer, the decoded text is inserted in the buffer. |
| 8316 If t, the decoded text is returned. | |
| 8317 | |
|
40713
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
8318 This function sets `last-coding-system-used' to the precise coding system |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
8319 used (which may be different from CODING-SYSTEM if CODING-SYSTEM is |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
8320 not fully specified.) |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
8321 It returns the length of the decoded text. */) |
| 88365 | 8322 (start, end, coding_system, destination) |
| 8323 Lisp_Object start, end, coding_system, destination; | |
|
20803
0fa2183c587d
(ENCODE_ISO_CHARACTER): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
20794
diff
changeset
|
8324 { |
| 88365 | 8325 return code_convert_region (start, end, coding_system, destination, 0, 0); |
|
20680
dd46027e8412
(code_convert_region): Always count chars inserted
Richard M. Stallman <rms@gnu.org>
parents:
20668
diff
changeset
|
8326 } |
|
dd46027e8412
(code_convert_region): Always count chars inserted
Richard M. Stallman <rms@gnu.org>
parents:
20668
diff
changeset
|
8327 |
|
dd46027e8412
(code_convert_region): Always count chars inserted
Richard M. Stallman <rms@gnu.org>
parents:
20668
diff
changeset
|
8328 DEFUN ("encode-coding-region", Fencode_coding_region, Sencode_coding_region, |
| 88365 | 8329 3, 4, "r\nzCoding system: ", |
| 8330 doc: /* Encode the current region by specified coding system. | |
|
40713
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
8331 When called from a program, takes three arguments: |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
8332 START, END, and CODING-SYSTEM. START and END are buffer positions. |
| 88365 | 8333 |
| 8334 Optional 4th arguments DESTINATION specifies where the encoded text goes. | |
| 8335 If nil, the region between START and END is replace by the encoded text. | |
| 8336 If buffer, the encoded text is inserted in the buffer. | |
| 8337 If t, the encoded text is returned. | |
| 8338 | |
|
40713
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
8339 This function sets `last-coding-system-used' to the precise coding system |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
8340 used (which may be different from CODING-SYSTEM if CODING-SYSTEM is |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
8341 not fully specified.) |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
8342 It returns the length of the encoded text. */) |
| 88365 | 8343 (start, end, coding_system, destination) |
| 8344 Lisp_Object start, end, coding_system, destination; | |
|
20680
dd46027e8412
(code_convert_region): Always count chars inserted
Richard M. Stallman <rms@gnu.org>
parents:
20668
diff
changeset
|
8345 { |
| 88365 | 8346 return code_convert_region (start, end, coding_system, destination, 1, 0); |
| 17052 | 8347 } |
| 8348 | |
|
20803
0fa2183c587d
(ENCODE_ISO_CHARACTER): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
20794
diff
changeset
|
8349 Lisp_Object |
| 88365 | 8350 code_convert_string (string, coding_system, dst_object, |
| 8351 encodep, nocopy, norecord) | |
| 8352 Lisp_Object string, coding_system, dst_object; | |
| 8353 int encodep, nocopy, norecord; | |
| 17052 | 8354 { |
| 8355 struct coding_system coding; | |
| 88365 | 8356 EMACS_INT chars, bytes; |
| 17052 | 8357 |
|
40656
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Jan?k <Pavel@Janik.cz>
parents:
40461
diff
changeset
|
8358 CHECK_STRING (string); |
| 88365 | 8359 if (NILP (coding_system)) |
| 8360 { | |
| 8361 if (! norecord) | |
| 8362 Vlast_coding_system_used = Qno_conversion; | |
| 8363 if (NILP (dst_object)) | |
| 8364 return (nocopy ? Fcopy_sequence (string) : string); | |
| 8365 } | |
| 17052 | 8366 |
|
70520
b6740a317343
(setup_coding_system): For invalid coding-system, set
Kenichi Handa <handa@m17n.org>
parents:
69995
diff
changeset
|
8367 if (NILP (coding_system)) |
| 88365 | 8368 coding_system = Qno_conversion; |
| 8369 else | |
| 8370 CHECK_CODING_SYSTEM (coding_system); | |
| 8371 if (NILP (dst_object)) | |
| 8372 dst_object = Qt; | |
| 8373 else if (! EQ (dst_object, Qt)) | |
| 8374 CHECK_BUFFER (dst_object); | |
| 8375 | |
| 8376 setup_coding_system (coding_system, &coding); | |
|
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
8377 coding.mode |= CODING_MODE_LAST_BLOCK; |
| 89483 | 8378 chars = SCHARS (string); |
| 8379 bytes = SBYTES (string); | |
| 88365 | 8380 if (encodep) |
| 8381 encode_coding_object (&coding, string, 0, 0, chars, bytes, dst_object); | |
| 8382 else | |
| 8383 decode_coding_object (&coding, string, 0, 0, chars, bytes, dst_object); | |
| 8384 if (! norecord) | |
| 8385 Vlast_coding_system_used = CODING_ID_NAME (coding.id); | |
| 8386 | |
| 8387 return (BUFFERP (dst_object) | |
| 8388 ? make_number (coding.produced_char) | |
| 8389 : coding.dst_object); | |
|
20803
0fa2183c587d
(ENCODE_ISO_CHARACTER): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
20794
diff
changeset
|
8390 } |
|
0fa2183c587d
(ENCODE_ISO_CHARACTER): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
20794
diff
changeset
|
8391 |
|
0fa2183c587d
(ENCODE_ISO_CHARACTER): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
20794
diff
changeset
|
8392 |
|
22341
572ba933a4bf
(code_convert_string_norecord): New function.
Karl Heuer <kwzh@gnu.org>
parents:
22329
diff
changeset
|
8393 /* Encode or decode STRING according to CODING_SYSTEM. |
| 26847 | 8394 Do not set Vlast_coding_system_used. |
| 8395 | |
| 8396 This function is called only from macros DECODE_FILE and | |
| 8397 ENCODE_FILE, thus we ignore character composition. */ | |
|
22341
572ba933a4bf
(code_convert_string_norecord): New function.
Karl Heuer <kwzh@gnu.org>
parents:
22329
diff
changeset
|
8398 |
|
572ba933a4bf
(code_convert_string_norecord): New function.
Karl Heuer <kwzh@gnu.org>
parents:
22329
diff
changeset
|
8399 Lisp_Object |
|
572ba933a4bf
(code_convert_string_norecord): New function.
Karl Heuer <kwzh@gnu.org>
parents:
22329
diff
changeset
|
8400 code_convert_string_norecord (string, coding_system, encodep) |
|
572ba933a4bf
(code_convert_string_norecord): New function.
Karl Heuer <kwzh@gnu.org>
parents:
22329
diff
changeset
|
8401 Lisp_Object string, coding_system; |
|
572ba933a4bf
(code_convert_string_norecord): New function.
Karl Heuer <kwzh@gnu.org>
parents:
22329
diff
changeset
|
8402 int encodep; |
|
572ba933a4bf
(code_convert_string_norecord): New function.
Karl Heuer <kwzh@gnu.org>
parents:
22329
diff
changeset
|
8403 { |
|
88430
6418a272b97e
* coding.c: Delete unused variables.
Kenichi Handa <handa@m17n.org>
parents:
88365
diff
changeset
|
8404 return code_convert_string (string, coding_system, Qt, encodep, 0, 1); |
|
22341
572ba933a4bf
(code_convert_string_norecord): New function.
Karl Heuer <kwzh@gnu.org>
parents:
22329
diff
changeset
|
8405 } |
| 88365 | 8406 |
| 8407 | |
| 8408 DEFUN ("decode-coding-string", Fdecode_coding_string, Sdecode_coding_string, | |
| 8409 2, 4, 0, | |
| 8410 doc: /* Decode STRING which is encoded in CODING-SYSTEM, and return the result. | |
| 8411 | |
| 8412 Optional third arg NOCOPY non-nil means it is OK to return STRING itself | |
| 8413 if the decoding operation is trivial. | |
| 8414 | |
| 8415 Optional fourth arg BUFFER non-nil meant that the decoded text is | |
|
88845
64b8f6168269
(Fset_coding_system_priority): Allow null arg list.
Dave Love <fx@gnu.org>
parents:
88771
diff
changeset
|
8416 inserted in BUFFER instead of returned as a string. In this case, |
| 88365 | 8417 the return value is BUFFER. |
| 8418 | |
| 8419 This function sets `last-coding-system-used' to the precise coding system | |
| 8420 used (which may be different from CODING-SYSTEM if CODING-SYSTEM is | |
| 8421 not fully specified. */) | |
| 8422 (string, coding_system, nocopy, buffer) | |
| 8423 Lisp_Object string, coding_system, nocopy, buffer; | |
| 8424 { | |
| 8425 return code_convert_string (string, coding_system, buffer, | |
| 8426 0, ! NILP (nocopy), 0); | |
| 8427 } | |
| 8428 | |
| 8429 DEFUN ("encode-coding-string", Fencode_coding_string, Sencode_coding_string, | |
| 8430 2, 4, 0, | |
| 8431 doc: /* Encode STRING to CODING-SYSTEM, and return the result. | |
| 8432 | |
| 8433 Optional third arg NOCOPY non-nil means it is OK to return STRING | |
| 8434 itself if the encoding operation is trivial. | |
| 8435 | |
| 8436 Optional fourth arg BUFFER non-nil meant that the encoded text is | |
|
88845
64b8f6168269
(Fset_coding_system_priority): Allow null arg list.
Dave Love <fx@gnu.org>
parents:
88771
diff
changeset
|
8437 inserted in BUFFER instead of returned as a string. In this case, |
| 88365 | 8438 the return value is BUFFER. |
| 8439 | |
| 8440 This function sets `last-coding-system-used' to the precise coding system | |
| 8441 used (which may be different from CODING-SYSTEM if CODING-SYSTEM is | |
| 8442 not fully specified.) */) | |
| 8443 (string, coding_system, nocopy, buffer) | |
| 8444 Lisp_Object string, coding_system, nocopy, buffer; | |
| 8445 { | |
| 8446 return code_convert_string (string, coding_system, buffer, | |
| 88856 | 8447 1, ! NILP (nocopy), 1); |
| 88365 | 8448 } |
| 8449 | |
|
20680
dd46027e8412
(code_convert_region): Always count chars inserted
Richard M. Stallman <rms@gnu.org>
parents:
20668
diff
changeset
|
8450 |
| 17052 | 8451 DEFUN ("decode-sjis-char", Fdecode_sjis_char, Sdecode_sjis_char, 1, 1, 0, |
|
40713
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
8452 doc: /* Decode a Japanese character which has CODE in shift_jis encoding. |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
8453 Return the corresponding character. */) |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
8454 (code) |
| 17052 | 8455 Lisp_Object code; |
| 8456 { | |
| 88365 | 8457 Lisp_Object spec, attrs, val; |
| 8458 struct charset *charset_roman, *charset_kanji, *charset_kana, *charset; | |
| 8459 int c; | |
| 8460 | |
| 8461 CHECK_NATNUM (code); | |
| 8462 c = XFASTINT (code); | |
| 8463 CHECK_CODING_SYSTEM_GET_SPEC (Vsjis_coding_system, spec); | |
| 8464 attrs = AREF (spec, 0); | |
| 8465 | |
| 8466 if (ASCII_BYTE_P (c) | |
| 8467 && ! NILP (CODING_ATTR_ASCII_COMPAT (attrs))) | |
| 8468 return code; | |
| 8469 | |
| 8470 val = CODING_ATTR_CHARSET_LIST (attrs); | |
| 8471 charset_roman = CHARSET_FROM_ID (XINT (XCAR (val))), val = XCDR (val); | |
|
88497
d2b9e0d4c2f6
(Fdecode_sjis_char): Fix typo (0x7F->0xFF). Fix the
Kenichi Handa <handa@m17n.org>
parents:
88485
diff
changeset
|
8472 charset_kana = CHARSET_FROM_ID (XINT (XCAR (val))), val = XCDR (val); |
|
d2b9e0d4c2f6
(Fdecode_sjis_char): Fix typo (0x7F->0xFF). Fix the
Kenichi Handa <handa@m17n.org>
parents:
88485
diff
changeset
|
8473 charset_kanji = CHARSET_FROM_ID (XINT (XCAR (val))); |
| 88365 | 8474 |
| 8475 if (c <= 0x7F) | |
| 8476 charset = charset_roman; | |
| 8477 else if (c >= 0xA0 && c < 0xDF) | |
| 8478 { | |
| 8479 charset = charset_kana; | |
| 8480 c -= 0x80; | |
|
24065
7e291dea6141
(Fdecode_sjis_char): Decode Japanese Katakana character
Kenichi Handa <handa@m17n.org>
parents:
24056
diff
changeset
|
8481 } |
|
7e291dea6141
(Fdecode_sjis_char): Decode Japanese Katakana character
Kenichi Handa <handa@m17n.org>
parents:
24056
diff
changeset
|
8482 else |
|
7e291dea6141
(Fdecode_sjis_char): Decode Japanese Katakana character
Kenichi Handa <handa@m17n.org>
parents:
24056
diff
changeset
|
8483 { |
|
88497
d2b9e0d4c2f6
(Fdecode_sjis_char): Fix typo (0x7F->0xFF). Fix the
Kenichi Handa <handa@m17n.org>
parents:
88485
diff
changeset
|
8484 int s1 = c >> 8, s2 = c & 0xFF; |
| 88365 | 8485 |
| 8486 if (s1 < 0x81 || (s1 > 0x9F && s1 < 0xE0) || s1 > 0xEF | |
| 8487 || s2 < 0x40 || s2 == 0x7F || s2 > 0xFC) | |
| 8488 error ("Invalid code: %d", code); | |
| 8489 SJIS_TO_JIS (c); | |
| 8490 charset = charset_kanji; | |
| 8491 } | |
| 8492 c = DECODE_CHAR (charset, c); | |
| 8493 if (c < 0) | |
| 8494 error ("Invalid code: %d", code); | |
| 8495 return make_number (c); | |
| 17052 | 8496 } |
| 8497 | |
| 8498 | |
| 8499 DEFUN ("encode-sjis-char", Fencode_sjis_char, Sencode_sjis_char, 1, 1, 0, | |
|
73949
0d1207b43a5b
(Fencode_sjis_char, Fencode_big5_char): Improve argument/docstring consistency.
Juanma Barranquero <lekktu@gmail.com>
parents:
72552
diff
changeset
|
8500 doc: /* Encode a Japanese character CH to shift_jis encoding. |
|
40713
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
8501 Return the corresponding code in SJIS. */) |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
8502 (ch) |
| 88365 | 8503 Lisp_Object ch; |
| 17052 | 8504 { |
| 88365 | 8505 Lisp_Object spec, attrs, charset_list; |
| 8506 int c; | |
| 8507 struct charset *charset; | |
| 8508 unsigned code; | |
| 8509 | |
| 8510 CHECK_CHARACTER (ch); | |
| 8511 c = XFASTINT (ch); | |
| 8512 CHECK_CODING_SYSTEM_GET_SPEC (Vsjis_coding_system, spec); | |
| 8513 attrs = AREF (spec, 0); | |
| 8514 | |
| 8515 if (ASCII_CHAR_P (c) | |
| 8516 && ! NILP (CODING_ATTR_ASCII_COMPAT (attrs))) | |
| 8517 return ch; | |
| 8518 | |
| 8519 charset_list = CODING_ATTR_CHARSET_LIST (attrs); | |
| 8520 charset = char_charset (c, charset_list, &code); | |
| 8521 if (code == CHARSET_INVALID_CODE (charset)) | |
| 8522 error ("Can't encode by shift_jis encoding: %d", c); | |
| 8523 JIS_TO_SJIS (code); | |
| 8524 | |
| 8525 return make_number (code); | |
| 17052 | 8526 } |
| 8527 | |
| 8528 DEFUN ("decode-big5-char", Fdecode_big5_char, Sdecode_big5_char, 1, 1, 0, | |
|
40713
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
8529 doc: /* Decode a Big5 character which has CODE in BIG5 coding system. |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
8530 Return the corresponding character. */) |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
8531 (code) |
| 17052 | 8532 Lisp_Object code; |
| 8533 { | |
| 88365 | 8534 Lisp_Object spec, attrs, val; |
| 8535 struct charset *charset_roman, *charset_big5, *charset; | |
| 8536 int c; | |
| 8537 | |
| 8538 CHECK_NATNUM (code); | |
| 8539 c = XFASTINT (code); | |
| 8540 CHECK_CODING_SYSTEM_GET_SPEC (Vbig5_coding_system, spec); | |
| 8541 attrs = AREF (spec, 0); | |
| 8542 | |
| 8543 if (ASCII_BYTE_P (c) | |
| 8544 && ! NILP (CODING_ATTR_ASCII_COMPAT (attrs))) | |
| 8545 return code; | |
| 8546 | |
| 8547 val = CODING_ATTR_CHARSET_LIST (attrs); | |
| 8548 charset_roman = CHARSET_FROM_ID (XINT (XCAR (val))), val = XCDR (val); | |
| 8549 charset_big5 = CHARSET_FROM_ID (XINT (XCAR (val))); | |
| 8550 | |
| 8551 if (c <= 0x7F) | |
| 8552 charset = charset_roman; | |
|
24324
2eec590faf26
(Fdecode_sjis_char, Fencode_sjis_char): Hanlde
Kenichi Handa <handa@m17n.org>
parents:
24316
diff
changeset
|
8553 else |
|
2eec590faf26
(Fdecode_sjis_char, Fencode_sjis_char): Hanlde
Kenichi Handa <handa@m17n.org>
parents:
24316
diff
changeset
|
8554 { |
| 88365 | 8555 int b1 = c >> 8, b2 = c & 0x7F; |
| 8556 if (b1 < 0xA1 || b1 > 0xFE | |
| 8557 || b2 < 0x40 || (b2 > 0x7E && b2 < 0xA1) || b2 > 0xFE) | |
| 8558 error ("Invalid code: %d", code); | |
| 8559 charset = charset_big5; | |
| 8560 } | |
| 8561 c = DECODE_CHAR (charset, (unsigned )c); | |
| 8562 if (c < 0) | |
| 8563 error ("Invalid code: %d", code); | |
| 8564 return make_number (c); | |
| 17052 | 8565 } |
| 8566 | |
| 8567 DEFUN ("encode-big5-char", Fencode_big5_char, Sencode_big5_char, 1, 1, 0, | |
|
73949
0d1207b43a5b
(Fencode_sjis_char, Fencode_big5_char): Improve argument/docstring consistency.
Juanma Barranquero <lekktu@gmail.com>
parents:
72552
diff
changeset
|
8568 doc: /* Encode the Big5 character CH to BIG5 coding system. |
|
40713
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
8569 Return the corresponding character code in Big5. */) |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
8570 (ch) |
| 17052 | 8571 Lisp_Object ch; |
| 8572 { | |
| 88365 | 8573 Lisp_Object spec, attrs, charset_list; |
| 8574 struct charset *charset; | |
| 8575 int c; | |
| 8576 unsigned code; | |
| 8577 | |
| 8578 CHECK_CHARACTER (ch); | |
| 8579 c = XFASTINT (ch); | |
| 8580 CHECK_CODING_SYSTEM_GET_SPEC (Vbig5_coding_system, spec); | |
| 8581 attrs = AREF (spec, 0); | |
| 8582 if (ASCII_CHAR_P (c) | |
| 8583 && ! NILP (CODING_ATTR_ASCII_COMPAT (attrs))) | |
| 8584 return ch; | |
| 8585 | |
| 8586 charset_list = CODING_ATTR_CHARSET_LIST (attrs); | |
| 8587 charset = char_charset (c, charset_list, &code); | |
| 8588 if (code == CHARSET_INVALID_CODE (charset)) | |
| 8589 error ("Can't encode by Big5 encoding: %d", c); | |
| 8590 | |
| 8591 return make_number (code); | |
| 17052 | 8592 } |
| 88365 | 8593 |
|
20680
dd46027e8412
(code_convert_region): Always count chars inserted
Richard M. Stallman <rms@gnu.org>
parents:
20668
diff
changeset
|
8594 |
|
48182
9474e269efd1
Reformat some DEFUNs so that etags works.
Dave Love <fx@gnu.org>
parents:
48125
diff
changeset
|
8595 DEFUN ("set-terminal-coding-system-internal", Fset_terminal_coding_system_internal, |
|
83298
ed09a89e2b25
Fix UTF-8 tty input when first frame is an X frame. Steps towards multiple tty locale support.
Karoly Lorentey <lorentey@elte.hu>
parents:
83292
diff
changeset
|
8596 Sset_terminal_coding_system_internal, 1, 2, 0, |
|
40713
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
8597 doc: /* Internal use only. */) |
|
83431
76396de7f50a
Rename `struct device' to `struct terminal'. Rename some terminal-related functions similarly.
Karoly Lorentey <lorentey@elte.hu>
parents:
83423
diff
changeset
|
8598 (coding_system, terminal) |
| 17052 | 8599 Lisp_Object coding_system; |
|
83431
76396de7f50a
Rename `struct device' to `struct terminal'. Rename some terminal-related functions similarly.
Karoly Lorentey <lorentey@elte.hu>
parents:
83423
diff
changeset
|
8600 Lisp_Object terminal; |
| 17052 | 8601 { |
|
83431
76396de7f50a
Rename `struct device' to `struct terminal'. Rename some terminal-related functions similarly.
Karoly Lorentey <lorentey@elte.hu>
parents:
83423
diff
changeset
|
8602 struct coding_system *terminal_coding = TERMINAL_TERMINAL_CODING (get_terminal (terminal, 1)); |
|
40656
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Jan?k <Pavel@Janik.cz>
parents:
40461
diff
changeset
|
8603 CHECK_SYMBOL (coding_system); |
|
83127
5182815e0ee1
Make terminal_coding and keyboard_coding display-local.
Karoly Lorentey <lorentey@elte.hu>
parents:
54320
diff
changeset
|
8604 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
|
8605 /* We had better not send unsafe characters to terminal. */ |
| 91041 | 8606 terminal_coding->mode |= CODING_MODE_SAFE_ENCODING; |
| 88365 | 8607 /* Characer composition should be disabled. */ |
| 91041 | 8608 terminal_coding->common_flags &= ~CODING_ANNOTATE_COMPOSITION_MASK; |
|
83127
5182815e0ee1
Make terminal_coding and keyboard_coding display-local.
Karoly Lorentey <lorentey@elte.hu>
parents:
54320
diff
changeset
|
8609 terminal_coding->src_multibyte = 1; |
|
5182815e0ee1
Make terminal_coding and keyboard_coding display-local.
Karoly Lorentey <lorentey@elte.hu>
parents:
54320
diff
changeset
|
8610 terminal_coding->dst_multibyte = 0; |
| 17052 | 8611 return Qnil; |
| 8612 } | |
| 8613 | |
|
19280
e755044718ee
(ENCODE_ISO_CHARACTER_DIMENSION1): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
19193
diff
changeset
|
8614 DEFUN ("set-safe-terminal-coding-system-internal", |
|
e755044718ee
(ENCODE_ISO_CHARACTER_DIMENSION1): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
19193
diff
changeset
|
8615 Fset_safe_terminal_coding_system_internal, |
|
40713
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
8616 Sset_safe_terminal_coding_system_internal, 1, 1, 0, |
| 41006 | 8617 doc: /* Internal use only. */) |
|
40713
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
8618 (coding_system) |
|
19280
e755044718ee
(ENCODE_ISO_CHARACTER_DIMENSION1): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
19193
diff
changeset
|
8619 Lisp_Object coding_system; |
|
e755044718ee
(ENCODE_ISO_CHARACTER_DIMENSION1): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
19193
diff
changeset
|
8620 { |
|
40656
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Jan?k <Pavel@Janik.cz>
parents:
40461
diff
changeset
|
8621 CHECK_SYMBOL (coding_system); |
|
19280
e755044718ee
(ENCODE_ISO_CHARACTER_DIMENSION1): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
19193
diff
changeset
|
8622 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
|
8623 &safe_terminal_coding); |
| 88365 | 8624 /* Characer composition should be disabled. */ |
| 8625 safe_terminal_coding.common_flags &= ~CODING_ANNOTATE_COMPOSITION_MASK; | |
|
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
8626 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
|
8627 safe_terminal_coding.dst_multibyte = 0; |
|
19280
e755044718ee
(ENCODE_ISO_CHARACTER_DIMENSION1): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
19193
diff
changeset
|
8628 return Qnil; |
|
e755044718ee
(ENCODE_ISO_CHARACTER_DIMENSION1): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
19193
diff
changeset
|
8629 } |
|
e755044718ee
(ENCODE_ISO_CHARACTER_DIMENSION1): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
19193
diff
changeset
|
8630 |
|
48182
9474e269efd1
Reformat some DEFUNs so that etags works.
Dave Love <fx@gnu.org>
parents:
48125
diff
changeset
|
8631 DEFUN ("terminal-coding-system", Fterminal_coding_system, |
|
83298
ed09a89e2b25
Fix UTF-8 tty input when first frame is an X frame. Steps towards multiple tty locale support.
Karoly Lorentey <lorentey@elte.hu>
parents:
83292
diff
changeset
|
8632 Sterminal_coding_system, 0, 1, 0, |
|
83431
76396de7f50a
Rename `struct device' to `struct terminal'. Rename some terminal-related functions similarly.
Karoly Lorentey <lorentey@elte.hu>
parents:
83423
diff
changeset
|
8633 doc: /* Return coding system specified for terminal output on the given terminal. |
|
76396de7f50a
Rename `struct device' to `struct terminal'. Rename some terminal-related functions similarly.
Karoly Lorentey <lorentey@elte.hu>
parents:
83423
diff
changeset
|
8634 TERMINAL may be a terminal id, a frame, or nil for the selected |
|
76396de7f50a
Rename `struct device' to `struct terminal'. Rename some terminal-related functions similarly.
Karoly Lorentey <lorentey@elte.hu>
parents:
83423
diff
changeset
|
8635 frame's terminal device. */) |
|
76396de7f50a
Rename `struct device' to `struct terminal'. Rename some terminal-related functions similarly.
Karoly Lorentey <lorentey@elte.hu>
parents:
83423
diff
changeset
|
8636 (terminal) |
|
76396de7f50a
Rename `struct device' to `struct terminal'. Rename some terminal-related functions similarly.
Karoly Lorentey <lorentey@elte.hu>
parents:
83423
diff
changeset
|
8637 Lisp_Object terminal; |
| 17052 | 8638 { |
| 91046 | 8639 struct coding_system *terminal_coding |
| 8640 = TERMINAL_TERMINAL_CODING (get_terminal (terminal, 1)); | |
| 8641 Lisp_Object coding_system = CODING_ID_NAME (terminal_coding->id); | |
| 8642 | |
|
90011
26cef35a1562
(setup_coding_system): If coding_system is nil, use
Kenichi Handa <handa@m17n.org>
parents:
89976
diff
changeset
|
8643 /* For backward compatibility, return nil if it is `undecided'. */ |
|
90359
041f75914d0c
(produce_composition): Compare charbuf[i] instead of
Kenichi Handa <handa@m17n.org>
parents:
90354
diff
changeset
|
8644 return (! EQ (coding_system, Qundecided) ? coding_system : Qnil); |
| 17052 | 8645 } |
| 8646 | |
|
48182
9474e269efd1
Reformat some DEFUNs so that etags works.
Dave Love <fx@gnu.org>
parents:
48125
diff
changeset
|
8647 DEFUN ("set-keyboard-coding-system-internal", Fset_keyboard_coding_system_internal, |
|
83298
ed09a89e2b25
Fix UTF-8 tty input when first frame is an X frame. Steps towards multiple tty locale support.
Karoly Lorentey <lorentey@elte.hu>
parents:
83292
diff
changeset
|
8648 Sset_keyboard_coding_system_internal, 1, 2, 0, |
|
40713
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
8649 doc: /* Internal use only. */) |
|
83431
76396de7f50a
Rename `struct device' to `struct terminal'. Rename some terminal-related functions similarly.
Karoly Lorentey <lorentey@elte.hu>
parents:
83423
diff
changeset
|
8650 (coding_system, terminal) |
| 17052 | 8651 Lisp_Object coding_system; |
|
83431
76396de7f50a
Rename `struct device' to `struct terminal'. Rename some terminal-related functions similarly.
Karoly Lorentey <lorentey@elte.hu>
parents:
83423
diff
changeset
|
8652 Lisp_Object terminal; |
| 17052 | 8653 { |
|
83431
76396de7f50a
Rename `struct device' to `struct terminal'. Rename some terminal-related functions similarly.
Karoly Lorentey <lorentey@elte.hu>
parents:
83423
diff
changeset
|
8654 struct terminal *t = get_terminal (terminal, 1); |
|
40656
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Jan?k <Pavel@Janik.cz>
parents:
40461
diff
changeset
|
8655 CHECK_SYMBOL (coding_system); |
|
83127
5182815e0ee1
Make terminal_coding and keyboard_coding display-local.
Karoly Lorentey <lorentey@elte.hu>
parents:
54320
diff
changeset
|
8656 setup_coding_system (Fcheck_coding_system (coding_system), |
| 91041 | 8657 TERMINAL_KEYBOARD_CODING (t)); |
| 88365 | 8658 /* Characer composition should be disabled. */ |
| 91041 | 8659 TERMINAL_KEYBOARD_CODING (t)->common_flags |
| 8660 &= ~CODING_ANNOTATE_COMPOSITION_MASK; | |
| 17052 | 8661 return Qnil; |
| 8662 } | |
| 8663 | |
| 8664 DEFUN ("keyboard-coding-system", | |
| 91046 | 8665 Fkeyboard_coding_system, Skeyboard_coding_system, 0, 1, 0, |
|
40713
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
8666 doc: /* Return coding system specified for decoding keyboard input. */) |
|
83431
76396de7f50a
Rename `struct device' to `struct terminal'. Rename some terminal-related functions similarly.
Karoly Lorentey <lorentey@elte.hu>
parents:
83423
diff
changeset
|
8667 (terminal) |
|
76396de7f50a
Rename `struct device' to `struct terminal'. Rename some terminal-related functions similarly.
Karoly Lorentey <lorentey@elte.hu>
parents:
83423
diff
changeset
|
8668 Lisp_Object terminal; |
| 17052 | 8669 { |
| 91046 | 8670 return CODING_ID_NAME (TERMINAL_KEYBOARD_CODING |
| 8671 (get_terminal (terminal, 1))->id); | |
| 17052 | 8672 } |
| 8673 | |
| 8674 | |
|
18536
69c0e220b626
(Vstandard_character_unification_table_for_decode):
Kenichi Handa <handa@m17n.org>
parents:
18523
diff
changeset
|
8675 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
|
8676 Sfind_operation_coding_system, 1, MANY, 0, |
|
40713
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
8677 doc: /* Choose a coding system for an operation based on the target name. |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
8678 The value names a pair of coding systems: (DECODING-SYSTEM . ENCODING-SYSTEM). |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
8679 DECODING-SYSTEM is the coding system to use for decoding |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
8680 \(in case OPERATION does decoding), and ENCODING-SYSTEM is the coding system |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
8681 for encoding (in case OPERATION does encoding). |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
8682 |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
8683 The first argument OPERATION specifies an I/O primitive: |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
8684 For file I/O, `insert-file-contents' or `write-region'. |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
8685 For process I/O, `call-process', `call-process-region', or `start-process'. |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
8686 For network I/O, `open-network-stream'. |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
8687 |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
8688 The remaining arguments should be the same arguments that were passed |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
8689 to the primitive. Depending on which primitive, one of those arguments |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
8690 is selected as the TARGET. For example, if OPERATION does file I/O, |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
8691 whichever argument specifies the file name is TARGET. |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
8692 |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
8693 TARGET has a meaning which depends on OPERATION: |
|
70948
7ea8b1c11d80
(Ffind_operation_coding_system): Allow (FILENAME . BUFFER) in TARGET.
Kenichi Handa <handa@m17n.org>
parents:
70704
diff
changeset
|
8694 For file I/O, TARGET is a file name (except for the special case below). |
|
40713
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
8695 For process I/O, TARGET is a process name. |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
8696 For network I/O, TARGET is a service name or a port number |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
8697 |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
8698 This function looks up what specified for TARGET in, |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
8699 `file-coding-system-alist', `process-coding-system-alist', |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
8700 or `network-coding-system-alist' depending on OPERATION. |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
8701 They may specify a coding system, a cons of coding systems, |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
8702 or a function symbol to call. |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
8703 In the last case, we call the function with one argument, |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
8704 which is a list of all the arguments given to this function. |
|
81611
ae42ad5f89e6
(Ffind_operation_coding_system): Docstring improved.
Kenichi Handa <handa@m17n.org>
parents:
75348
diff
changeset
|
8705 If the function can't decide a coding system, it can return |
|
ae42ad5f89e6
(Ffind_operation_coding_system): Docstring improved.
Kenichi Handa <handa@m17n.org>
parents:
75348
diff
changeset
|
8706 `undecided' so that the normal code-detection is performed. |
|
40713
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
8707 |
|
70948
7ea8b1c11d80
(Ffind_operation_coding_system): Allow (FILENAME . BUFFER) in TARGET.
Kenichi Handa <handa@m17n.org>
parents:
70704
diff
changeset
|
8708 If OPERATION is `insert-file-contents', the argument corresponding to |
|
7ea8b1c11d80
(Ffind_operation_coding_system): Allow (FILENAME . BUFFER) in TARGET.
Kenichi Handa <handa@m17n.org>
parents:
70704
diff
changeset
|
8709 TARGET may be a cons (FILENAME . BUFFER). In that case, FILENAME is a |
|
71084
ccef92f2f7f8
(Ffind_operation_coding_system): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
71070
diff
changeset
|
8710 file name to look up, and BUFFER is a buffer that contains the file's |
|
ccef92f2f7f8
(Ffind_operation_coding_system): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
71070
diff
changeset
|
8711 contents (not yet decoded). If `file-coding-system-alist' specifies a |
|
71070
0c8ac7192244
(Ffind_operation_coding_system): Doc fix.
Eli Zaretskii <eliz@gnu.org>
parents:
71039
diff
changeset
|
8712 function to call for FILENAME, that function should examine the |
|
0c8ac7192244
(Ffind_operation_coding_system): Doc fix.
Eli Zaretskii <eliz@gnu.org>
parents:
71039
diff
changeset
|
8713 contents of BUFFER instead of reading the file. |
|
70948
7ea8b1c11d80
(Ffind_operation_coding_system): Allow (FILENAME . BUFFER) in TARGET.
Kenichi Handa <handa@m17n.org>
parents:
70704
diff
changeset
|
8714 |
|
78152
5e5f359984e5
(Ffind_operation_coding_system): Doc fix.
Juanma Barranquero <lekktu@gmail.com>
parents:
75348
diff
changeset
|
8715 usage: (find-operation-coding-system OPERATION ARGUMENTS...) */) |
|
40713
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
8716 (nargs, args) |
| 17052 | 8717 int nargs; |
| 8718 Lisp_Object *args; | |
| 8719 { | |
| 8720 Lisp_Object operation, target_idx, target, val; | |
| 8721 register Lisp_Object chain; | |
| 8722 | |
| 8723 if (nargs < 2) | |
| 8724 error ("Too few arguments"); | |
| 8725 operation = args[0]; | |
| 8726 if (!SYMBOLP (operation) | |
| 8727 || !INTEGERP (target_idx = Fget (operation, Qtarget_idx))) | |
|
93877
62d97ebb13a9
* coding.c (detect_coding_emacs_mule)
Michael Albinus <michael.albinus@gmx.de>
parents:
93595
diff
changeset
|
8728 error ("Invalid first argument"); |
| 17052 | 8729 if (nargs < 1 + XINT (target_idx)) |
| 8730 error ("Too few arguments for operation: %s", | |
|
46370
40db0673e6f0
Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents:
46293
diff
changeset
|
8731 SDATA (SYMBOL_NAME (operation))); |
| 17052 | 8732 target = args[XINT (target_idx) + 1]; |
| 8733 if (!(STRINGP (target) | |
|
70948
7ea8b1c11d80
(Ffind_operation_coding_system): Allow (FILENAME . BUFFER) in TARGET.
Kenichi Handa <handa@m17n.org>
parents:
70704
diff
changeset
|
8734 || (EQ (operation, Qinsert_file_contents) && CONSP (target) |
|
7ea8b1c11d80
(Ffind_operation_coding_system): Allow (FILENAME . BUFFER) in TARGET.
Kenichi Handa <handa@m17n.org>
parents:
70704
diff
changeset
|
8735 && STRINGP (XCAR (target)) && BUFFERP (XCDR (target))) |
| 17052 | 8736 || (EQ (operation, Qopen_network_stream) && INTEGERP (target)))) |
| 88365 | 8737 error ("Invalid %dth argument", XINT (target_idx) + 1); |
|
70948
7ea8b1c11d80
(Ffind_operation_coding_system): Allow (FILENAME . BUFFER) in TARGET.
Kenichi Handa <handa@m17n.org>
parents:
70704
diff
changeset
|
8738 if (CONSP (target)) |
|
7ea8b1c11d80
(Ffind_operation_coding_system): Allow (FILENAME . BUFFER) in TARGET.
Kenichi Handa <handa@m17n.org>
parents:
70704
diff
changeset
|
8739 target = XCAR (target); |
| 17052 | 8740 |
|
18613
614b916ff5bf
Fix bugs with inappropriate mixing of Lisp_Object with int.
Richard M. Stallman <rms@gnu.org>
parents:
18536
diff
changeset
|
8741 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
|
8742 || EQ (operation, Qwrite_region)) |
|
18180
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
8743 ? 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
|
8744 : (EQ (operation, Qopen_network_stream) |
|
18180
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
8745 ? Vnetwork_coding_system_alist |
|
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
8746 : Vprocess_coding_system_alist)); |
| 17052 | 8747 if (NILP (chain)) |
| 8748 return Qnil; | |
| 8749 | |
|
25662
0a7261c1d487
Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25370
diff
changeset
|
8750 for (; CONSP (chain); chain = XCDR (chain)) |
| 17052 | 8751 { |
|
19747
bed06df9cbc5
(setup_coding_system, Ffind_operation_coding_system)
Richard M. Stallman <rms@gnu.org>
parents:
19743
diff
changeset
|
8752 Lisp_Object elt; |
| 88365 | 8753 |
|
25662
0a7261c1d487
Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25370
diff
changeset
|
8754 elt = XCAR (chain); |
| 17052 | 8755 if (CONSP (elt) |
| 8756 && ((STRINGP (target) | |
|
25662
0a7261c1d487
Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25370
diff
changeset
|
8757 && STRINGP (XCAR (elt)) |
|
0a7261c1d487
Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25370
diff
changeset
|
8758 && 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
|
8759 || (INTEGERP (target) && EQ (target, XCAR (elt))))) |
|
18180
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
8760 { |
|
25662
0a7261c1d487
Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25370
diff
changeset
|
8761 val = XCDR (elt); |
|
19763
ab2fd2c85986
(Ffind_operation_coding_system): If a function in
Kenichi Handa <handa@m17n.org>
parents:
19758
diff
changeset
|
8762 /* 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
|
8763 function symbol, we return VAL as a coding system. */ |
|
18180
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
8764 if (CONSP (val)) |
|
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
8765 return val; |
|
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
8766 if (! SYMBOLP (val)) |
|
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
8767 return Qnil; |
|
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
8768 if (! NILP (Fcoding_system_p (val))) |
|
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
8769 return Fcons (val, val); |
|
19763
ab2fd2c85986
(Ffind_operation_coding_system): If a function in
Kenichi Handa <handa@m17n.org>
parents:
19758
diff
changeset
|
8770 if (! NILP (Ffboundp (val))) |
|
ab2fd2c85986
(Ffind_operation_coding_system): If a function in
Kenichi Handa <handa@m17n.org>
parents:
19758
diff
changeset
|
8771 { |
| 72188 | 8772 /* We use call1 rather than safe_call1 |
| 8773 so as to get bug reports about functions called here | |
| 8774 which don't handle the current interface. */ | |
|
72180
f3bc55b96df5
(Ffind_operation_coding_system): Revert the change from 2006-05-29.
Eli Zaretskii <eliz@gnu.org>
parents:
71972
diff
changeset
|
8775 val = call1 (val, Flist (nargs, args)); |
|
19763
ab2fd2c85986
(Ffind_operation_coding_system): If a function in
Kenichi Handa <handa@m17n.org>
parents:
19758
diff
changeset
|
8776 if (CONSP (val)) |
|
ab2fd2c85986
(Ffind_operation_coding_system): If a function in
Kenichi Handa <handa@m17n.org>
parents:
19758
diff
changeset
|
8777 return val; |
|
ab2fd2c85986
(Ffind_operation_coding_system): If a function in
Kenichi Handa <handa@m17n.org>
parents:
19758
diff
changeset
|
8778 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
|
8779 return Fcons (val, val); |
|
ab2fd2c85986
(Ffind_operation_coding_system): If a function in
Kenichi Handa <handa@m17n.org>
parents:
19758
diff
changeset
|
8780 } |
|
18180
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
8781 return Qnil; |
|
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
8782 } |
| 17052 | 8783 } |
| 8784 return Qnil; | |
| 8785 } | |
| 8786 | |
| 88365 | 8787 DEFUN ("set-coding-system-priority", Fset_coding_system_priority, |
|
88845
64b8f6168269
(Fset_coding_system_priority): Allow null arg list.
Dave Love <fx@gnu.org>
parents:
88771
diff
changeset
|
8788 Sset_coding_system_priority, 0, MANY, 0, |
| 88645 | 8789 doc: /* Assign higher priority to the coding systems given as arguments. |
|
89467
e911ca706166
(Fset_coding_system_priority): Doc fix. Update values
Kenichi Handa <handa@m17n.org>
parents:
89462
diff
changeset
|
8790 If multiple coding systems belongs to the same category, |
|
89519
040a08a2a879
(Fread_coding_system): Fix arg of XSETSTRING.
Dave Love <fx@gnu.org>
parents:
89483
diff
changeset
|
8791 all but the first one are ignored. |
|
040a08a2a879
(Fread_coding_system): Fix arg of XSETSTRING.
Dave Love <fx@gnu.org>
parents:
89483
diff
changeset
|
8792 |
|
040a08a2a879
(Fread_coding_system): Fix arg of XSETSTRING.
Dave Love <fx@gnu.org>
parents:
89483
diff
changeset
|
8793 usage: (set-coding-system-priority ...) */) |
| 88365 | 8794 (nargs, args) |
| 8795 int nargs; | |
| 8796 Lisp_Object *args; | |
| 8797 { | |
| 8798 int i, j; | |
| 8799 int changed[coding_category_max]; | |
| 8800 enum coding_category priorities[coding_category_max]; | |
| 8801 | |
| 8802 bzero (changed, sizeof changed); | |
| 8803 | |
| 8804 for (i = j = 0; i < nargs; i++) | |
| 8805 { | |
| 8806 enum coding_category category; | |
| 8807 Lisp_Object spec, attrs; | |
| 8808 | |
| 8809 CHECK_CODING_SYSTEM_GET_SPEC (args[i], spec); | |
| 8810 attrs = AREF (spec, 0); | |
| 8811 category = XINT (CODING_ATTR_CATEGORY (attrs)); | |
| 8812 if (changed[category]) | |
| 8813 /* Ignore this coding system because a coding system of the | |
| 8814 same category already had a higher priority. */ | |
| 8815 continue; | |
| 8816 changed[category] = 1; | |
| 8817 priorities[j++] = category; | |
| 8818 if (coding_categories[category].id >= 0 | |
| 8819 && ! EQ (args[i], CODING_ID_NAME (coding_categories[category].id))) | |
| 8820 setup_coding_system (args[i], &coding_categories[category]); | |
|
89467
e911ca706166
(Fset_coding_system_priority): Doc fix. Update values
Kenichi Handa <handa@m17n.org>
parents:
89462
diff
changeset
|
8821 Fset (AREF (Vcoding_category_table, category), args[i]); |
| 88365 | 8822 } |
| 8823 | |
| 8824 /* Now we have decided top J priorities. Reflect the order of the | |
| 8825 original priorities to the remaining priorities. */ | |
| 8826 | |
| 8827 for (i = j, j = 0; i < coding_category_max; i++, j++) | |
| 8828 { | |
| 8829 while (j < coding_category_max | |
| 8830 && changed[coding_priorities[j]]) | |
| 8831 j++; | |
| 8832 if (j == coding_category_max) | |
| 8833 abort (); | |
| 8834 priorities[i] = coding_priorities[j]; | |
| 8835 } | |
| 8836 | |
| 8837 bcopy (priorities, coding_priorities, sizeof priorities); | |
|
89467
e911ca706166
(Fset_coding_system_priority): Doc fix. Update values
Kenichi Handa <handa@m17n.org>
parents:
89462
diff
changeset
|
8838 |
|
e911ca706166
(Fset_coding_system_priority): Doc fix. Update values
Kenichi Handa <handa@m17n.org>
parents:
89462
diff
changeset
|
8839 /* Update `coding-category-list'. */ |
|
e911ca706166
(Fset_coding_system_priority): Doc fix. Update values
Kenichi Handa <handa@m17n.org>
parents:
89462
diff
changeset
|
8840 Vcoding_category_list = Qnil; |
|
e911ca706166
(Fset_coding_system_priority): Doc fix. Update values
Kenichi Handa <handa@m17n.org>
parents:
89462
diff
changeset
|
8841 for (i = coding_category_max - 1; i >= 0; i--) |
|
e911ca706166
(Fset_coding_system_priority): Doc fix. Update values
Kenichi Handa <handa@m17n.org>
parents:
89462
diff
changeset
|
8842 Vcoding_category_list |
|
e911ca706166
(Fset_coding_system_priority): Doc fix. Update values
Kenichi Handa <handa@m17n.org>
parents:
89462
diff
changeset
|
8843 = Fcons (AREF (Vcoding_category_table, priorities[i]), |
|
e911ca706166
(Fset_coding_system_priority): Doc fix. Update values
Kenichi Handa <handa@m17n.org>
parents:
89462
diff
changeset
|
8844 Vcoding_category_list); |
|
22874
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
8845 |
|
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
8846 return Qnil; |
|
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
8847 } |
|
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
8848 |
| 88365 | 8849 DEFUN ("coding-system-priority-list", Fcoding_system_priority_list, |
| 8850 Scoding_system_priority_list, 0, 1, 0, | |
| 88645 | 8851 doc: /* Return a list of coding systems ordered by their priorities. |
| 8852 HIGHESTP non-nil means just return the highest priority one. */) | |
| 88365 | 8853 (highestp) |
| 8854 Lisp_Object highestp; | |
|
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
8855 { |
|
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
8856 int i; |
|
22954
928b337d953b
Avoid using initializers for Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents:
22874
diff
changeset
|
8857 Lisp_Object val; |
|
928b337d953b
Avoid using initializers for Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents:
22874
diff
changeset
|
8858 |
| 88365 | 8859 for (i = 0, val = Qnil; i < coding_category_max; i++) |
| 8860 { | |
| 8861 enum coding_category category = coding_priorities[i]; | |
| 8862 int id = coding_categories[category].id; | |
| 8863 Lisp_Object attrs; | |
| 8864 | |
| 8865 if (id < 0) | |
| 8866 continue; | |
| 8867 attrs = CODING_ID_ATTRS (id); | |
| 8868 if (! NILP (highestp)) | |
| 8869 return CODING_ATTR_BASE_NAME (attrs); | |
| 8870 val = Fcons (CODING_ATTR_BASE_NAME (attrs), val); | |
| 8871 } | |
| 8872 return Fnreverse (val); | |
| 8873 } | |
| 8874 | |
|
88631
780b91d4a7e5
(setup_iso_safe_charsets): Fix arg decl for K&R.
Dave Love <fx@gnu.org>
parents:
88607
diff
changeset
|
8875 static char *suffixes[] = { "-unix", "-dos", "-mac" }; |
|
780b91d4a7e5
(setup_iso_safe_charsets): Fix arg decl for K&R.
Dave Love <fx@gnu.org>
parents:
88607
diff
changeset
|
8876 |
| 88365 | 8877 static Lisp_Object |
| 8878 make_subsidiaries (base) | |
| 8879 Lisp_Object base; | |
| 8880 { | |
| 8881 Lisp_Object subsidiaries; | |
| 89483 | 8882 int base_name_len = SBYTES (SYMBOL_NAME (base)); |
| 88365 | 8883 char *buf = (char *) alloca (base_name_len + 6); |
| 8884 int i; | |
| 89483 | 8885 |
| 8886 bcopy (SDATA (SYMBOL_NAME (base)), buf, base_name_len); | |
| 88365 | 8887 subsidiaries = Fmake_vector (make_number (3), Qnil); |
| 8888 for (i = 0; i < 3; i++) | |
| 8889 { | |
| 8890 bcopy (suffixes[i], buf + base_name_len, strlen (suffixes[i]) + 1); | |
| 8891 ASET (subsidiaries, i, intern (buf)); | |
| 8892 } | |
| 8893 return subsidiaries; | |
| 8894 } | |
| 8895 | |
|
22226
557fac086b1b
(ascii_skip_code): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22186
diff
changeset
|
8896 |
|
49539
1ad5bfbb831a
(syms_of_coding): Add `...' for symbols in the docstring of
Kenichi Handa <handa@m17n.org>
parents:
48874
diff
changeset
|
8897 DEFUN ("define-coding-system-internal", Fdefine_coding_system_internal, |
| 88365 | 8898 Sdefine_coding_system_internal, coding_arg_max, MANY, 0, |
|
88544
f464d728344c
(Vchar_coding_system_table, Qchar_coding_system):
Dave Love <fx@gnu.org>
parents:
88510
diff
changeset
|
8899 doc: /* For internal use only. |
|
f464d728344c
(Vchar_coding_system_table, Qchar_coding_system):
Dave Love <fx@gnu.org>
parents:
88510
diff
changeset
|
8900 usage: (define-coding-system-internal ...) */) |
| 88365 | 8901 (nargs, args) |
| 8902 int nargs; | |
| 8903 Lisp_Object *args; | |
| 8904 { | |
| 8905 Lisp_Object name; | |
| 8906 Lisp_Object spec_vec; /* [ ATTRS ALIASE EOL_TYPE ] */ | |
| 8907 Lisp_Object attrs; /* Vector of attributes. */ | |
| 8908 Lisp_Object eol_type; | |
| 8909 Lisp_Object aliases; | |
| 8910 Lisp_Object coding_type, charset_list, safe_charsets; | |
| 8911 enum coding_category category; | |
| 8912 Lisp_Object tail, val; | |
| 8913 int max_charset_id = 0; | |
| 8914 int i; | |
| 8915 | |
| 8916 if (nargs < coding_arg_max) | |
| 8917 goto short_args; | |
| 8918 | |
| 8919 attrs = Fmake_vector (make_number (coding_attr_last_index), Qnil); | |
| 8920 | |
| 8921 name = args[coding_arg_name]; | |
| 8922 CHECK_SYMBOL (name); | |
| 8923 CODING_ATTR_BASE_NAME (attrs) = name; | |
| 8924 | |
| 8925 val = args[coding_arg_mnemonic]; | |
| 8926 if (! STRINGP (val)) | |
| 8927 CHECK_CHARACTER (val); | |
| 8928 CODING_ATTR_MNEMONIC (attrs) = val; | |
| 8929 | |
| 8930 coding_type = args[coding_arg_coding_type]; | |
| 8931 CHECK_SYMBOL (coding_type); | |
| 8932 CODING_ATTR_TYPE (attrs) = coding_type; | |
| 8933 | |
| 8934 charset_list = args[coding_arg_charset_list]; | |
| 8935 if (SYMBOLP (charset_list)) | |
| 8936 { | |
| 8937 if (EQ (charset_list, Qiso_2022)) | |
| 8938 { | |
| 8939 if (! EQ (coding_type, Qiso_2022)) | |
| 8940 error ("Invalid charset-list"); | |
| 8941 charset_list = Viso_2022_charset_list; | |
| 8942 } | |
| 8943 else if (EQ (charset_list, Qemacs_mule)) | |
| 8944 { | |
| 8945 if (! EQ (coding_type, Qemacs_mule)) | |
| 8946 error ("Invalid charset-list"); | |
| 8947 charset_list = Vemacs_mule_charset_list; | |
| 8948 } | |
| 8949 for (tail = charset_list; CONSP (tail); tail = XCDR (tail)) | |
| 8950 if (max_charset_id < XFASTINT (XCAR (tail))) | |
| 8951 max_charset_id = XFASTINT (XCAR (tail)); | |
| 8952 } | |
| 8953 else | |
| 8954 { | |
| 8955 charset_list = Fcopy_sequence (charset_list); | |
| 91046 | 8956 for (tail = charset_list; CONSP (tail); tail = XCDR (tail)) |
| 88365 | 8957 { |
| 8958 struct charset *charset; | |
| 8959 | |
| 91046 | 8960 val = XCAR (tail); |
| 88365 | 8961 CHECK_CHARSET_GET_CHARSET (val, charset); |
| 8962 if (EQ (coding_type, Qiso_2022) | |
| 8963 ? CHARSET_ISO_FINAL (charset) < 0 | |
| 8964 : EQ (coding_type, Qemacs_mule) | |
| 8965 ? CHARSET_EMACS_MULE_ID (charset) < 0 | |
| 8966 : 0) | |
| 8967 error ("Can't handle charset `%s'", | |
| 89483 | 8968 SDATA (SYMBOL_NAME (CHARSET_NAME (charset)))); |
| 8969 | |
| 8970 XSETCAR (tail, make_number (charset->id)); | |
| 88365 | 8971 if (max_charset_id < charset->id) |
| 8972 max_charset_id = charset->id; | |
| 8973 } | |
| 8974 } | |
| 8975 CODING_ATTR_CHARSET_LIST (attrs) = charset_list; | |
| 8976 | |
| 8977 safe_charsets = Fmake_string (make_number (max_charset_id + 1), | |
| 8978 make_number (255)); | |
| 8979 for (tail = charset_list; CONSP (tail); tail = XCDR (tail)) | |
| 89483 | 8980 SSET (safe_charsets, XFASTINT (XCAR (tail)), 0); |
| 88365 | 8981 CODING_ATTR_SAFE_CHARSETS (attrs) = safe_charsets; |
| 8982 | |
|
89225
32058afc72e2
(detect_coding_charset): If only ASCII bytes are found, return 0.
Kenichi Handa <handa@m17n.org>
parents:
89221
diff
changeset
|
8983 CODING_ATTR_ASCII_COMPAT (attrs) = args[coding_arg_ascii_compatible_p]; |
|
32058afc72e2
(detect_coding_charset): If only ASCII bytes are found, return 0.
Kenichi Handa <handa@m17n.org>
parents:
89221
diff
changeset
|
8984 |
| 88365 | 8985 val = args[coding_arg_decode_translation_table]; |
|
89759
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
8986 if (! CHAR_TABLE_P (val) && ! CONSP (val)) |
|
89732
8acde12aba89
(get_translation_table): New function.
Kenichi Handa <handa@m17n.org>
parents:
89730
diff
changeset
|
8987 CHECK_SYMBOL (val); |
| 88365 | 8988 CODING_ATTR_DECODE_TBL (attrs) = val; |
| 8989 | |
| 8990 val = args[coding_arg_encode_translation_table]; | |
|
89759
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
8991 if (! CHAR_TABLE_P (val) && ! CONSP (val)) |
|
89732
8acde12aba89
(get_translation_table): New function.
Kenichi Handa <handa@m17n.org>
parents:
89730
diff
changeset
|
8992 CHECK_SYMBOL (val); |
| 88365 | 8993 CODING_ATTR_ENCODE_TBL (attrs) = val; |
| 8994 | |
| 8995 val = args[coding_arg_post_read_conversion]; | |
| 8996 CHECK_SYMBOL (val); | |
| 8997 CODING_ATTR_POST_READ (attrs) = val; | |
| 8998 | |
| 8999 val = args[coding_arg_pre_write_conversion]; | |
| 9000 CHECK_SYMBOL (val); | |
| 9001 CODING_ATTR_PRE_WRITE (attrs) = val; | |
| 9002 | |
| 9003 val = args[coding_arg_default_char]; | |
| 9004 if (NILP (val)) | |
| 9005 CODING_ATTR_DEFAULT_CHAR (attrs) = make_number (' '); | |
| 9006 else | |
| 9007 { | |
| 89483 | 9008 CHECK_CHARACTER (val); |
| 88365 | 9009 CODING_ATTR_DEFAULT_CHAR (attrs) = val; |
| 9010 } | |
| 9011 | |
| 89483 | 9012 val = args[coding_arg_for_unibyte]; |
| 9013 CODING_ATTR_FOR_UNIBYTE (attrs) = NILP (val) ? Qnil : Qt; | |
| 9014 | |
| 88365 | 9015 val = args[coding_arg_plist]; |
| 9016 CHECK_LIST (val); | |
| 9017 CODING_ATTR_PLIST (attrs) = val; | |
| 9018 | |
| 9019 if (EQ (coding_type, Qcharset)) | |
| 9020 { | |
|
88597
74b74f59bc09
(decode_coding_charset): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
88587
diff
changeset
|
9021 /* Generate a lisp vector of 256 elements. Each element is nil, |
|
74b74f59bc09
(decode_coding_charset): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
88587
diff
changeset
|
9022 integer, or a list of charset IDs. |
|
74b74f59bc09
(decode_coding_charset): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
88587
diff
changeset
|
9023 |
|
74b74f59bc09
(decode_coding_charset): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
88587
diff
changeset
|
9024 If Nth element is nil, the byte code N is invalid in this |
|
74b74f59bc09
(decode_coding_charset): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
88587
diff
changeset
|
9025 coding system. |
|
74b74f59bc09
(decode_coding_charset): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
88587
diff
changeset
|
9026 |
|
74b74f59bc09
(decode_coding_charset): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
88587
diff
changeset
|
9027 If Nth element is a number NUM, N is the first byte of a |
|
74b74f59bc09
(decode_coding_charset): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
88587
diff
changeset
|
9028 charset whose ID is NUM. |
|
74b74f59bc09
(decode_coding_charset): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
88587
diff
changeset
|
9029 |
|
74b74f59bc09
(decode_coding_charset): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
88587
diff
changeset
|
9030 If Nth element is a list of charset IDs, N is the first byte |
|
74b74f59bc09
(decode_coding_charset): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
88587
diff
changeset
|
9031 of one of them. The list is sorted by dimensions of the |
|
89648
d5641a606e08
(Fdefine_coding_system_internal): Fix checking of ascii compatibility.
Kenichi Handa <handa@m17n.org>
parents:
89644
diff
changeset
|
9032 charsets. A charset of smaller dimension comes firtst. */ |
| 88365 | 9033 val = Fmake_vector (make_number (256), Qnil); |
| 9034 | |
|
89653
cbaa9fd1aa5c
(Fdefine_coding_system_internal): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89648
diff
changeset
|
9035 for (tail = charset_list; CONSP (tail); tail = XCDR (tail)) |
| 88365 | 9036 { |
|
88597
74b74f59bc09
(decode_coding_charset): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
88587
diff
changeset
|
9037 struct charset *charset = CHARSET_FROM_ID (XFASTINT (XCAR (tail))); |
|
74b74f59bc09
(decode_coding_charset): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
88587
diff
changeset
|
9038 int dim = CHARSET_DIMENSION (charset); |
|
74b74f59bc09
(decode_coding_charset): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
88587
diff
changeset
|
9039 int idx = (dim - 1) * 4; |
| 89483 | 9040 |
|
89653
cbaa9fd1aa5c
(Fdefine_coding_system_internal): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89648
diff
changeset
|
9041 if (CHARSET_ASCII_COMPATIBLE_P (charset)) |
|
89225
32058afc72e2
(detect_coding_charset): If only ASCII bytes are found, return 0.
Kenichi Handa <handa@m17n.org>
parents:
89221
diff
changeset
|
9042 CODING_ATTR_ASCII_COMPAT (attrs) = Qt; |
|
32058afc72e2
(detect_coding_charset): If only ASCII bytes are found, return 0.
Kenichi Handa <handa@m17n.org>
parents:
89221
diff
changeset
|
9043 |
|
88477
5f974cbba7b3
(coding_set_source): Delete the local variable beg_byte.
Kenichi Handa <handa@m17n.org>
parents:
88473
diff
changeset
|
9044 for (i = charset->code_space[idx]; |
|
5f974cbba7b3
(coding_set_source): Delete the local variable beg_byte.
Kenichi Handa <handa@m17n.org>
parents:
88473
diff
changeset
|
9045 i <= charset->code_space[idx + 1]; i++) |
|
5f974cbba7b3
(coding_set_source): Delete the local variable beg_byte.
Kenichi Handa <handa@m17n.org>
parents:
88473
diff
changeset
|
9046 { |
|
88597
74b74f59bc09
(decode_coding_charset): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
88587
diff
changeset
|
9047 Lisp_Object tmp, tmp2; |
|
74b74f59bc09
(decode_coding_charset): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
88587
diff
changeset
|
9048 int dim2; |
|
74b74f59bc09
(decode_coding_charset): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
88587
diff
changeset
|
9049 |
|
74b74f59bc09
(decode_coding_charset): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
88587
diff
changeset
|
9050 tmp = AREF (val, i); |
|
74b74f59bc09
(decode_coding_charset): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
88587
diff
changeset
|
9051 if (NILP (tmp)) |
|
74b74f59bc09
(decode_coding_charset): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
88587
diff
changeset
|
9052 tmp = XCAR (tail); |
|
74b74f59bc09
(decode_coding_charset): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
88587
diff
changeset
|
9053 else if (NUMBERP (tmp)) |
|
74b74f59bc09
(decode_coding_charset): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
88587
diff
changeset
|
9054 { |
|
74b74f59bc09
(decode_coding_charset): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
88587
diff
changeset
|
9055 dim2 = CHARSET_DIMENSION (CHARSET_FROM_ID (XFASTINT (tmp))); |
|
74b74f59bc09
(decode_coding_charset): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
88587
diff
changeset
|
9056 if (dim < dim2) |
|
88607
18436bf3d6dd
(Fdefine_coding_system_internal): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
88598
diff
changeset
|
9057 tmp = Fcons (XCAR (tail), Fcons (tmp, Qnil)); |
|
88597
74b74f59bc09
(decode_coding_charset): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
88587
diff
changeset
|
9058 else |
|
88607
18436bf3d6dd
(Fdefine_coding_system_internal): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
88598
diff
changeset
|
9059 tmp = Fcons (tmp, Fcons (XCAR (tail), Qnil)); |
|
88597
74b74f59bc09
(decode_coding_charset): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
88587
diff
changeset
|
9060 } |
|
88477
5f974cbba7b3
(coding_set_source): Delete the local variable beg_byte.
Kenichi Handa <handa@m17n.org>
parents:
88473
diff
changeset
|
9061 else |
|
88597
74b74f59bc09
(decode_coding_charset): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
88587
diff
changeset
|
9062 { |
|
74b74f59bc09
(decode_coding_charset): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
88587
diff
changeset
|
9063 for (tmp2 = tmp; CONSP (tmp2); tmp2 = XCDR (tmp2)) |
|
74b74f59bc09
(decode_coding_charset): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
88587
diff
changeset
|
9064 { |
|
74b74f59bc09
(decode_coding_charset): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
88587
diff
changeset
|
9065 dim2 = CHARSET_DIMENSION (CHARSET_FROM_ID (XFASTINT (XCAR (tmp2)))); |
|
74b74f59bc09
(decode_coding_charset): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
88587
diff
changeset
|
9066 if (dim < dim2) |
|
74b74f59bc09
(decode_coding_charset): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
88587
diff
changeset
|
9067 break; |
|
74b74f59bc09
(decode_coding_charset): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
88587
diff
changeset
|
9068 } |
|
74b74f59bc09
(decode_coding_charset): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
88587
diff
changeset
|
9069 if (NILP (tmp2)) |
|
74b74f59bc09
(decode_coding_charset): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
88587
diff
changeset
|
9070 tmp = nconc2 (tmp, Fcons (XCAR (tail), Qnil)); |
|
74b74f59bc09
(decode_coding_charset): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
88587
diff
changeset
|
9071 else |
|
74b74f59bc09
(decode_coding_charset): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
88587
diff
changeset
|
9072 { |
|
74b74f59bc09
(decode_coding_charset): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
88587
diff
changeset
|
9073 XSETCDR (tmp2, Fcons (XCAR (tmp2), XCDR (tmp2))); |
|
74b74f59bc09
(decode_coding_charset): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
88587
diff
changeset
|
9074 XSETCAR (tmp2, XCAR (tail)); |
|
74b74f59bc09
(decode_coding_charset): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
88587
diff
changeset
|
9075 } |
|
74b74f59bc09
(decode_coding_charset): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
88587
diff
changeset
|
9076 } |
|
74b74f59bc09
(decode_coding_charset): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
88587
diff
changeset
|
9077 ASET (val, i, tmp); |
|
88477
5f974cbba7b3
(coding_set_source): Delete the local variable beg_byte.
Kenichi Handa <handa@m17n.org>
parents:
88473
diff
changeset
|
9078 } |
| 88365 | 9079 } |
| 9080 ASET (attrs, coding_attr_charset_valids, val); | |
| 9081 category = coding_category_charset; | |
| 9082 } | |
| 9083 else if (EQ (coding_type, Qccl)) | |
| 9084 { | |
| 9085 Lisp_Object valids; | |
| 89483 | 9086 |
| 88365 | 9087 if (nargs < coding_arg_ccl_max) |
| 9088 goto short_args; | |
| 9089 | |
| 9090 val = args[coding_arg_ccl_decoder]; | |
| 9091 CHECK_CCL_PROGRAM (val); | |
| 9092 if (VECTORP (val)) | |
| 9093 val = Fcopy_sequence (val); | |
| 9094 ASET (attrs, coding_attr_ccl_decoder, val); | |
| 9095 | |
| 9096 val = args[coding_arg_ccl_encoder]; | |
| 9097 CHECK_CCL_PROGRAM (val); | |
| 9098 if (VECTORP (val)) | |
| 9099 val = Fcopy_sequence (val); | |
| 9100 ASET (attrs, coding_attr_ccl_encoder, val); | |
| 9101 | |
| 9102 val = args[coding_arg_ccl_valids]; | |
| 9103 valids = Fmake_string (make_number (256), make_number (0)); | |
| 9104 for (tail = val; !NILP (tail); tail = Fcdr (tail)) | |
| 9105 { | |
|
89373
4cc9e57fcabc
(decode_coding_ccl, encode_coding_ccl): Call ccl_driver
Kenichi Handa <handa@m17n.org>
parents:
89331
diff
changeset
|
9106 int from, to; |
|
4cc9e57fcabc
(decode_coding_ccl, encode_coding_ccl): Call ccl_driver
Kenichi Handa <handa@m17n.org>
parents:
89331
diff
changeset
|
9107 |
| 88365 | 9108 val = Fcar (tail); |
| 9109 if (INTEGERP (val)) | |
|
89373
4cc9e57fcabc
(decode_coding_ccl, encode_coding_ccl): Call ccl_driver
Kenichi Handa <handa@m17n.org>
parents:
89331
diff
changeset
|
9110 { |
|
4cc9e57fcabc
(decode_coding_ccl, encode_coding_ccl): Call ccl_driver
Kenichi Handa <handa@m17n.org>
parents:
89331
diff
changeset
|
9111 from = to = XINT (val); |
|
4cc9e57fcabc
(decode_coding_ccl, encode_coding_ccl): Call ccl_driver
Kenichi Handa <handa@m17n.org>
parents:
89331
diff
changeset
|
9112 if (from < 0 || from > 255) |
|
4cc9e57fcabc
(decode_coding_ccl, encode_coding_ccl): Call ccl_driver
Kenichi Handa <handa@m17n.org>
parents:
89331
diff
changeset
|
9113 args_out_of_range_3 (val, make_number (0), make_number (255)); |
|
4cc9e57fcabc
(decode_coding_ccl, encode_coding_ccl): Call ccl_driver
Kenichi Handa <handa@m17n.org>
parents:
89331
diff
changeset
|
9114 } |
| 88365 | 9115 else |
| 9116 { | |
| 9117 CHECK_CONS (val); | |
| 89483 | 9118 CHECK_NATNUM_CAR (val); |
| 9119 CHECK_NATNUM_CDR (val); | |
| 88365 | 9120 from = XINT (XCAR (val)); |
| 89483 | 9121 if (from > 255) |
|
89373
4cc9e57fcabc
(decode_coding_ccl, encode_coding_ccl): Call ccl_driver
Kenichi Handa <handa@m17n.org>
parents:
89331
diff
changeset
|
9122 args_out_of_range_3 (XCAR (val), |
|
4cc9e57fcabc
(decode_coding_ccl, encode_coding_ccl): Call ccl_driver
Kenichi Handa <handa@m17n.org>
parents:
89331
diff
changeset
|
9123 make_number (0), make_number (255)); |
| 88365 | 9124 to = XINT (XCDR (val)); |
|
89373
4cc9e57fcabc
(decode_coding_ccl, encode_coding_ccl): Call ccl_driver
Kenichi Handa <handa@m17n.org>
parents:
89331
diff
changeset
|
9125 if (to < from || to > 255) |
|
4cc9e57fcabc
(decode_coding_ccl, encode_coding_ccl): Call ccl_driver
Kenichi Handa <handa@m17n.org>
parents:
89331
diff
changeset
|
9126 args_out_of_range_3 (XCDR (val), |
|
4cc9e57fcabc
(decode_coding_ccl, encode_coding_ccl): Call ccl_driver
Kenichi Handa <handa@m17n.org>
parents:
89331
diff
changeset
|
9127 XCAR (val), make_number (255)); |
| 88365 | 9128 } |
|
89373
4cc9e57fcabc
(decode_coding_ccl, encode_coding_ccl): Call ccl_driver
Kenichi Handa <handa@m17n.org>
parents:
89331
diff
changeset
|
9129 for (i = from; i <= to; i++) |
| 89483 | 9130 SSET (valids, i, 1); |
| 88365 | 9131 } |
| 9132 ASET (attrs, coding_attr_ccl_valids, valids); | |
| 89483 | 9133 |
| 88365 | 9134 category = coding_category_ccl; |
| 9135 } | |
| 9136 else if (EQ (coding_type, Qutf_16)) | |
| 9137 { | |
| 9138 Lisp_Object bom, endian; | |
| 9139 | |
|
89225
32058afc72e2
(detect_coding_charset): If only ASCII bytes are found, return 0.
Kenichi Handa <handa@m17n.org>
parents:
89221
diff
changeset
|
9140 CODING_ATTR_ASCII_COMPAT (attrs) = Qnil; |
|
32058afc72e2
(detect_coding_charset): If only ASCII bytes are found, return 0.
Kenichi Handa <handa@m17n.org>
parents:
89221
diff
changeset
|
9141 |
| 88365 | 9142 if (nargs < coding_arg_utf16_max) |
| 9143 goto short_args; | |
| 9144 | |
| 9145 bom = args[coding_arg_utf16_bom]; | |
| 9146 if (! NILP (bom) && ! EQ (bom, Qt)) | |
|
22874
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
9147 { |
| 88365 | 9148 CHECK_CONS (bom); |
| 89483 | 9149 val = XCAR (bom); |
| 9150 CHECK_CODING_SYSTEM (val); | |
| 9151 val = XCDR (bom); | |
| 9152 CHECK_CODING_SYSTEM (val); | |
| 88365 | 9153 } |
| 9154 ASET (attrs, coding_attr_utf_16_bom, bom); | |
| 9155 | |
| 9156 endian = args[coding_arg_utf16_endian]; | |
|
89420
c3e67ce6ee0f
(Qsignature, Qendian): Delete these variables.
Kenichi Handa <handa@m17n.org>
parents:
89418
diff
changeset
|
9157 CHECK_SYMBOL (endian); |
|
c3e67ce6ee0f
(Qsignature, Qendian): Delete these variables.
Kenichi Handa <handa@m17n.org>
parents:
89418
diff
changeset
|
9158 if (NILP (endian)) |
|
c3e67ce6ee0f
(Qsignature, Qendian): Delete these variables.
Kenichi Handa <handa@m17n.org>
parents:
89418
diff
changeset
|
9159 endian = Qbig; |
|
c3e67ce6ee0f
(Qsignature, Qendian): Delete these variables.
Kenichi Handa <handa@m17n.org>
parents:
89418
diff
changeset
|
9160 else if (! EQ (endian, Qbig) && ! EQ (endian, Qlittle)) |
| 89483 | 9161 error ("Invalid endian: %s", SDATA (SYMBOL_NAME (endian))); |
| 88365 | 9162 ASET (attrs, coding_attr_utf_16_endian, endian); |
| 9163 | |
| 9164 category = (CONSP (bom) | |
| 9165 ? coding_category_utf_16_auto | |
| 9166 : NILP (bom) | |
|
89420
c3e67ce6ee0f
(Qsignature, Qendian): Delete these variables.
Kenichi Handa <handa@m17n.org>
parents:
89418
diff
changeset
|
9167 ? (EQ (endian, Qbig) |
| 88365 | 9168 ? coding_category_utf_16_be_nosig |
| 9169 : coding_category_utf_16_le_nosig) | |
|
89420
c3e67ce6ee0f
(Qsignature, Qendian): Delete these variables.
Kenichi Handa <handa@m17n.org>
parents:
89418
diff
changeset
|
9170 : (EQ (endian, Qbig) |
| 88365 | 9171 ? coding_category_utf_16_be |
| 9172 : coding_category_utf_16_le)); | |
| 9173 } | |
| 9174 else if (EQ (coding_type, Qiso_2022)) | |
| 9175 { | |
| 9176 Lisp_Object initial, reg_usage, request, flags; | |
|
89442
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
9177 int i; |
| 88365 | 9178 |
| 9179 if (nargs < coding_arg_iso2022_max) | |
| 9180 goto short_args; | |
| 9181 | |
| 9182 initial = Fcopy_sequence (args[coding_arg_iso2022_initial]); | |
| 9183 CHECK_VECTOR (initial); | |
| 9184 for (i = 0; i < 4; i++) | |
| 9185 { | |
| 9186 val = Faref (initial, make_number (i)); | |
| 9187 if (! NILP (val)) | |
| 9188 { | |
|
89225
32058afc72e2
(detect_coding_charset): If only ASCII bytes are found, return 0.
Kenichi Handa <handa@m17n.org>
parents:
89221
diff
changeset
|
9189 struct charset *charset; |
|
32058afc72e2
(detect_coding_charset): If only ASCII bytes are found, return 0.
Kenichi Handa <handa@m17n.org>
parents:
89221
diff
changeset
|
9190 |
|
32058afc72e2
(detect_coding_charset): If only ASCII bytes are found, return 0.
Kenichi Handa <handa@m17n.org>
parents:
89221
diff
changeset
|
9191 CHECK_CHARSET_GET_CHARSET (val, charset); |
|
32058afc72e2
(detect_coding_charset): If only ASCII bytes are found, return 0.
Kenichi Handa <handa@m17n.org>
parents:
89221
diff
changeset
|
9192 ASET (initial, i, make_number (CHARSET_ID (charset))); |
|
32058afc72e2
(detect_coding_charset): If only ASCII bytes are found, return 0.
Kenichi Handa <handa@m17n.org>
parents:
89221
diff
changeset
|
9193 if (i == 0 && CHARSET_ASCII_COMPATIBLE_P (charset)) |
|
32058afc72e2
(detect_coding_charset): If only ASCII bytes are found, return 0.
Kenichi Handa <handa@m17n.org>
parents:
89221
diff
changeset
|
9194 CODING_ATTR_ASCII_COMPAT (attrs) = Qt; |
| 88365 | 9195 } |
| 9196 else | |
| 9197 ASET (initial, i, make_number (-1)); | |
| 9198 } | |
| 9199 | |
| 9200 reg_usage = args[coding_arg_iso2022_reg_usage]; | |
| 9201 CHECK_CONS (reg_usage); | |
| 89483 | 9202 CHECK_NUMBER_CAR (reg_usage); |
| 9203 CHECK_NUMBER_CDR (reg_usage); | |
| 88365 | 9204 |
| 9205 request = Fcopy_sequence (args[coding_arg_iso2022_request]); | |
| 9206 for (tail = request; ! NILP (tail); tail = Fcdr (tail)) | |
| 9207 { | |
| 9208 int id; | |
| 89483 | 9209 Lisp_Object tmp; |
| 88365 | 9210 |
| 9211 val = Fcar (tail); | |
| 9212 CHECK_CONS (val); | |
| 89483 | 9213 tmp = XCAR (val); |
| 9214 CHECK_CHARSET_GET_ID (tmp, id); | |
| 9215 CHECK_NATNUM_CDR (val); | |
| 88365 | 9216 if (XINT (XCDR (val)) >= 4) |
| 9217 error ("Invalid graphic register number: %d", XINT (XCDR (val))); | |
| 89483 | 9218 XSETCAR (val, make_number (id)); |
| 88365 | 9219 } |
| 9220 | |
| 9221 flags = args[coding_arg_iso2022_flags]; | |
| 9222 CHECK_NATNUM (flags); | |
| 9223 i = XINT (flags); | |
| 9224 if (EQ (args[coding_arg_charset_list], Qiso_2022)) | |
| 9225 flags = make_number (i | CODING_ISO_FLAG_FULL_SUPPORT); | |
| 9226 | |
| 9227 ASET (attrs, coding_attr_iso_initial, initial); | |
| 9228 ASET (attrs, coding_attr_iso_usage, reg_usage); | |
| 9229 ASET (attrs, coding_attr_iso_request, request); | |
| 9230 ASET (attrs, coding_attr_iso_flags, flags); | |
| 9231 setup_iso_safe_charsets (attrs); | |
| 9232 | |
| 9233 if (i & CODING_ISO_FLAG_SEVEN_BITS) | |
| 9234 category = ((i & (CODING_ISO_FLAG_LOCKING_SHIFT | |
| 9235 | CODING_ISO_FLAG_SINGLE_SHIFT)) | |
| 9236 ? coding_category_iso_7_else | |
| 9237 : EQ (args[coding_arg_charset_list], Qiso_2022) | |
| 9238 ? coding_category_iso_7 | |
| 9239 : coding_category_iso_7_tight); | |
| 9240 else | |
| 9241 { | |
| 9242 int id = XINT (AREF (initial, 1)); | |
| 9243 | |
|
88977
3b05c02eebf2
(Fdefine_coding_system_internal): Fix category setting
Kenichi Handa <handa@m17n.org>
parents:
88950
diff
changeset
|
9244 category = (((i & CODING_ISO_FLAG_LOCKING_SHIFT) |
| 88365 | 9245 || EQ (args[coding_arg_charset_list], Qiso_2022) |
| 9246 || id < 0) | |
| 9247 ? coding_category_iso_8_else | |
| 9248 : (CHARSET_DIMENSION (CHARSET_FROM_ID (id)) == 1) | |
| 9249 ? coding_category_iso_8_1 | |
| 9250 : coding_category_iso_8_2); | |
|
22874
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
9251 } |
|
89227
101ee928c088
(Fdefine_coding_system_internal): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89225
diff
changeset
|
9252 if (category != coding_category_iso_8_1 |
|
101ee928c088
(Fdefine_coding_system_internal): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89225
diff
changeset
|
9253 && category != coding_category_iso_8_2) |
|
101ee928c088
(Fdefine_coding_system_internal): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89225
diff
changeset
|
9254 CODING_ATTR_ASCII_COMPAT (attrs) = Qnil; |
| 88365 | 9255 } |
| 9256 else if (EQ (coding_type, Qemacs_mule)) | |
| 9257 { | |
| 9258 if (EQ (args[coding_arg_charset_list], Qemacs_mule)) | |
| 9259 ASET (attrs, coding_attr_emacs_mule_full, Qt); | |
|
89225
32058afc72e2
(detect_coding_charset): If only ASCII bytes are found, return 0.
Kenichi Handa <handa@m17n.org>
parents:
89221
diff
changeset
|
9260 CODING_ATTR_ASCII_COMPAT (attrs) = Qt; |
| 88365 | 9261 category = coding_category_emacs_mule; |
| 9262 } | |
| 9263 else if (EQ (coding_type, Qshift_jis)) | |
| 9264 { | |
| 9265 | |
| 9266 struct charset *charset; | |
| 9267 | |
|
89732
8acde12aba89
(get_translation_table): New function.
Kenichi Handa <handa@m17n.org>
parents:
89730
diff
changeset
|
9268 if (XINT (Flength (charset_list)) != 3 |
|
89739
293c9235be3f
(Fdefine_coding_system_internal): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89732
diff
changeset
|
9269 && XINT (Flength (charset_list)) != 4) |
|
89732
8acde12aba89
(get_translation_table): New function.
Kenichi Handa <handa@m17n.org>
parents:
89730
diff
changeset
|
9270 error ("There should be three or four charsets"); |
| 88365 | 9271 |
| 9272 charset = CHARSET_FROM_ID (XINT (XCAR (charset_list))); | |
| 9273 if (CHARSET_DIMENSION (charset) != 1) | |
| 9274 error ("Dimension of charset %s is not one", | |
| 89483 | 9275 SDATA (SYMBOL_NAME (CHARSET_NAME (charset)))); |
|
89225
32058afc72e2
(detect_coding_charset): If only ASCII bytes are found, return 0.
Kenichi Handa <handa@m17n.org>
parents:
89221
diff
changeset
|
9276 if (CHARSET_ASCII_COMPATIBLE_P (charset)) |
|
32058afc72e2
(detect_coding_charset): If only ASCII bytes are found, return 0.
Kenichi Handa <handa@m17n.org>
parents:
89221
diff
changeset
|
9277 CODING_ATTR_ASCII_COMPAT (attrs) = Qt; |
| 88365 | 9278 |
| 9279 charset_list = XCDR (charset_list); | |
| 9280 charset = CHARSET_FROM_ID (XINT (XCAR (charset_list))); | |
| 9281 if (CHARSET_DIMENSION (charset) != 1) | |
| 9282 error ("Dimension of charset %s is not one", | |
| 89483 | 9283 SDATA (SYMBOL_NAME (CHARSET_NAME (charset)))); |
| 88365 | 9284 |
| 9285 charset_list = XCDR (charset_list); | |
| 9286 charset = CHARSET_FROM_ID (XINT (XCAR (charset_list))); | |
| 9287 if (CHARSET_DIMENSION (charset) != 2) | |
| 9288 error ("Dimension of charset %s is not two", | |
| 89483 | 9289 SDATA (SYMBOL_NAME (CHARSET_NAME (charset)))); |
| 88365 | 9290 |
|
89732
8acde12aba89
(get_translation_table): New function.
Kenichi Handa <handa@m17n.org>
parents:
89730
diff
changeset
|
9291 charset_list = XCDR (charset_list); |
|
89740
78c1fd14ed42
(Fdefine_coding_system_internal): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89739
diff
changeset
|
9292 if (! NILP (charset_list)) |
|
78c1fd14ed42
(Fdefine_coding_system_internal): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89739
diff
changeset
|
9293 { |
|
78c1fd14ed42
(Fdefine_coding_system_internal): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89739
diff
changeset
|
9294 charset = CHARSET_FROM_ID (XINT (XCAR (charset_list))); |
|
78c1fd14ed42
(Fdefine_coding_system_internal): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89739
diff
changeset
|
9295 if (CHARSET_DIMENSION (charset) != 2) |
|
78c1fd14ed42
(Fdefine_coding_system_internal): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89739
diff
changeset
|
9296 error ("Dimension of charset %s is not two", |
|
78c1fd14ed42
(Fdefine_coding_system_internal): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89739
diff
changeset
|
9297 SDATA (SYMBOL_NAME (CHARSET_NAME (charset)))); |
|
78c1fd14ed42
(Fdefine_coding_system_internal): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89739
diff
changeset
|
9298 } |
|
89732
8acde12aba89
(get_translation_table): New function.
Kenichi Handa <handa@m17n.org>
parents:
89730
diff
changeset
|
9299 |
| 88365 | 9300 category = coding_category_sjis; |
| 9301 Vsjis_coding_system = name; | |
| 9302 } | |
| 9303 else if (EQ (coding_type, Qbig5)) | |
| 9304 { | |
| 9305 struct charset *charset; | |
| 9306 | |
| 9307 if (XINT (Flength (charset_list)) != 2) | |
| 9308 error ("There should be just two charsets"); | |
| 9309 | |
| 9310 charset = CHARSET_FROM_ID (XINT (XCAR (charset_list))); | |
| 9311 if (CHARSET_DIMENSION (charset) != 1) | |
| 9312 error ("Dimension of charset %s is not one", | |
| 89483 | 9313 SDATA (SYMBOL_NAME (CHARSET_NAME (charset)))); |
|
89225
32058afc72e2
(detect_coding_charset): If only ASCII bytes are found, return 0.
Kenichi Handa <handa@m17n.org>
parents:
89221
diff
changeset
|
9314 if (CHARSET_ASCII_COMPATIBLE_P (charset)) |
|
32058afc72e2
(detect_coding_charset): If only ASCII bytes are found, return 0.
Kenichi Handa <handa@m17n.org>
parents:
89221
diff
changeset
|
9315 CODING_ATTR_ASCII_COMPAT (attrs) = Qt; |
| 88365 | 9316 |
| 9317 charset_list = XCDR (charset_list); | |
| 9318 charset = CHARSET_FROM_ID (XINT (XCAR (charset_list))); | |
| 9319 if (CHARSET_DIMENSION (charset) != 2) | |
| 9320 error ("Dimension of charset %s is not two", | |
| 89483 | 9321 SDATA (SYMBOL_NAME (CHARSET_NAME (charset)))); |
| 88365 | 9322 |
| 9323 category = coding_category_big5; | |
| 9324 Vbig5_coding_system = name; | |
| 9325 } | |
| 9326 else if (EQ (coding_type, Qraw_text)) | |
|
89225
32058afc72e2
(detect_coding_charset): If only ASCII bytes are found, return 0.
Kenichi Handa <handa@m17n.org>
parents:
89221
diff
changeset
|
9327 { |
|
32058afc72e2
(detect_coding_charset): If only ASCII bytes are found, return 0.
Kenichi Handa <handa@m17n.org>
parents:
89221
diff
changeset
|
9328 category = coding_category_raw_text; |
|
32058afc72e2
(detect_coding_charset): If only ASCII bytes are found, return 0.
Kenichi Handa <handa@m17n.org>
parents:
89221
diff
changeset
|
9329 CODING_ATTR_ASCII_COMPAT (attrs) = Qt; |
|
32058afc72e2
(detect_coding_charset): If only ASCII bytes are found, return 0.
Kenichi Handa <handa@m17n.org>
parents:
89221
diff
changeset
|
9330 } |
| 88365 | 9331 else if (EQ (coding_type, Qutf_8)) |
|
89225
32058afc72e2
(detect_coding_charset): If only ASCII bytes are found, return 0.
Kenichi Handa <handa@m17n.org>
parents:
89221
diff
changeset
|
9332 { |
|
32058afc72e2
(detect_coding_charset): If only ASCII bytes are found, return 0.
Kenichi Handa <handa@m17n.org>
parents:
89221
diff
changeset
|
9333 category = coding_category_utf_8; |
|
32058afc72e2
(detect_coding_charset): If only ASCII bytes are found, return 0.
Kenichi Handa <handa@m17n.org>
parents:
89221
diff
changeset
|
9334 CODING_ATTR_ASCII_COMPAT (attrs) = Qt; |
|
32058afc72e2
(detect_coding_charset): If only ASCII bytes are found, return 0.
Kenichi Handa <handa@m17n.org>
parents:
89221
diff
changeset
|
9335 } |
| 88365 | 9336 else if (EQ (coding_type, Qundecided)) |
| 9337 category = coding_category_undecided; | |
| 9338 else | |
| 9339 error ("Invalid coding system type: %s", | |
| 89483 | 9340 SDATA (SYMBOL_NAME (coding_type))); |
| 88365 | 9341 |
| 9342 CODING_ATTR_CATEGORY (attrs) = make_number (category); | |
|
89468
7dbbe692f70c
* coding.c (QCcategory): New variable.
Kenichi Handa <handa@m17n.org>
parents:
89467
diff
changeset
|
9343 CODING_ATTR_PLIST (attrs) |
|
7dbbe692f70c
* coding.c (QCcategory): New variable.
Kenichi Handa <handa@m17n.org>
parents:
89467
diff
changeset
|
9344 = Fcons (QCcategory, Fcons (AREF (Vcoding_category_table, category), |
|
7dbbe692f70c
* coding.c (QCcategory): New variable.
Kenichi Handa <handa@m17n.org>
parents:
89467
diff
changeset
|
9345 CODING_ATTR_PLIST (attrs))); |
|
90214
460ee00505d5
(QCascii_compatible_p): New variable.
Kenichi Handa <handa@m17n.org>
parents:
90201
diff
changeset
|
9346 CODING_ATTR_PLIST (attrs) |
|
93877
62d97ebb13a9
* coding.c (detect_coding_emacs_mule)
Michael Albinus <michael.albinus@gmx.de>
parents:
93595
diff
changeset
|
9347 = Fcons (QCascii_compatible_p, |
|
90214
460ee00505d5
(QCascii_compatible_p): New variable.
Kenichi Handa <handa@m17n.org>
parents:
90201
diff
changeset
|
9348 Fcons (CODING_ATTR_ASCII_COMPAT (attrs), |
|
460ee00505d5
(QCascii_compatible_p): New variable.
Kenichi Handa <handa@m17n.org>
parents:
90201
diff
changeset
|
9349 CODING_ATTR_PLIST (attrs))); |
| 88365 | 9350 |
| 9351 eol_type = args[coding_arg_eol_type]; | |
| 9352 if (! NILP (eol_type) | |
| 9353 && ! EQ (eol_type, Qunix) | |
| 9354 && ! EQ (eol_type, Qdos) | |
| 9355 && ! EQ (eol_type, Qmac)) | |
| 9356 error ("Invalid eol-type"); | |
| 9357 | |
| 9358 aliases = Fcons (name, Qnil); | |
| 9359 | |
| 9360 if (NILP (eol_type)) | |
| 9361 { | |
| 9362 eol_type = make_subsidiaries (name); | |
| 9363 for (i = 0; i < 3; i++) | |
|
22874
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
9364 { |
| 88365 | 9365 Lisp_Object this_spec, this_name, this_aliases, this_eol_type; |
| 9366 | |
| 9367 this_name = AREF (eol_type, i); | |
| 9368 this_aliases = Fcons (this_name, Qnil); | |
| 9369 this_eol_type = (i == 0 ? Qunix : i == 1 ? Qdos : Qmac); | |
| 9370 this_spec = Fmake_vector (make_number (3), attrs); | |
| 9371 ASET (this_spec, 1, this_aliases); | |
| 9372 ASET (this_spec, 2, this_eol_type); | |
| 9373 Fputhash (this_name, this_spec, Vcoding_system_hash_table); | |
| 9374 Vcoding_system_list = Fcons (this_name, Vcoding_system_list); | |
|
90289
72d8a45f6c9f
(Fdefine_coding_system_internal): Avoid a duplicated
Kenichi Handa <handa@m17n.org>
parents:
90272
diff
changeset
|
9375 val = Fassoc (Fsymbol_name (this_name), Vcoding_system_alist); |
|
72d8a45f6c9f
(Fdefine_coding_system_internal): Avoid a duplicated
Kenichi Handa <handa@m17n.org>
parents:
90272
diff
changeset
|
9376 if (NILP (val)) |
|
72d8a45f6c9f
(Fdefine_coding_system_internal): Avoid a duplicated
Kenichi Handa <handa@m17n.org>
parents:
90272
diff
changeset
|
9377 Vcoding_system_alist |
|
72d8a45f6c9f
(Fdefine_coding_system_internal): Avoid a duplicated
Kenichi Handa <handa@m17n.org>
parents:
90272
diff
changeset
|
9378 = Fcons (Fcons (Fsymbol_name (this_name), Qnil), |
|
72d8a45f6c9f
(Fdefine_coding_system_internal): Avoid a duplicated
Kenichi Handa <handa@m17n.org>
parents:
90272
diff
changeset
|
9379 Vcoding_system_alist); |
|
22874
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
9380 } |
|
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
9381 } |
|
22874
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
9382 |
| 88365 | 9383 spec_vec = Fmake_vector (make_number (3), attrs); |
| 9384 ASET (spec_vec, 1, aliases); | |
| 9385 ASET (spec_vec, 2, eol_type); | |
| 9386 | |
| 9387 Fputhash (name, spec_vec, Vcoding_system_hash_table); | |
| 9388 Vcoding_system_list = Fcons (name, Vcoding_system_list); | |
|
90289
72d8a45f6c9f
(Fdefine_coding_system_internal): Avoid a duplicated
Kenichi Handa <handa@m17n.org>
parents:
90272
diff
changeset
|
9389 val = Fassoc (Fsymbol_name (name), Vcoding_system_alist); |
|
72d8a45f6c9f
(Fdefine_coding_system_internal): Avoid a duplicated
Kenichi Handa <handa@m17n.org>
parents:
90272
diff
changeset
|
9390 if (NILP (val)) |
|
72d8a45f6c9f
(Fdefine_coding_system_internal): Avoid a duplicated
Kenichi Handa <handa@m17n.org>
parents:
90272
diff
changeset
|
9391 Vcoding_system_alist = Fcons (Fcons (Fsymbol_name (name), Qnil), |
|
72d8a45f6c9f
(Fdefine_coding_system_internal): Avoid a duplicated
Kenichi Handa <handa@m17n.org>
parents:
90272
diff
changeset
|
9392 Vcoding_system_alist); |
| 88365 | 9393 |
| 9394 { | |
| 9395 int id = coding_categories[category].id; | |
| 9396 | |
| 9397 if (id < 0 || EQ (name, CODING_ID_NAME (id))) | |
| 9398 setup_coding_system (name, &coding_categories[category]); | |
| 9399 } | |
| 9400 | |
| 9401 return Qnil; | |
| 9402 | |
| 9403 short_args: | |
| 9404 return Fsignal (Qwrong_number_of_arguments, | |
| 9405 Fcons (intern ("define-coding-system-internal"), | |
| 9406 make_number (nargs))); | |
| 9407 } | |
| 9408 | |
|
89571
242f2cc0134b
(Fdefine_coding_system_alias): Update Vcoding_system_list.
Kenichi Handa <handa@m17n.org>
parents:
89562
diff
changeset
|
9409 |
|
89759
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
9410 DEFUN ("coding-system-put", Fcoding_system_put, Scoding_system_put, |
|
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
9411 3, 3, 0, |
|
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
9412 doc: /* Change value in CODING-SYSTEM's property list PROP to VAL. */) |
|
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
9413 (coding_system, prop, val) |
|
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
9414 Lisp_Object coding_system, prop, val; |
|
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
9415 { |
|
89924
7d0f6da3ea6e
(detect_coding): Delete unused variables.
Kenichi Handa <handa@m17n.org>
parents:
89917
diff
changeset
|
9416 Lisp_Object spec, attrs; |
|
89759
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
9417 |
|
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
9418 CHECK_CODING_SYSTEM_GET_SPEC (coding_system, spec); |
|
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
9419 attrs = AREF (spec, 0); |
|
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
9420 if (EQ (prop, QCmnemonic)) |
|
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
9421 { |
|
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
9422 if (! STRINGP (val)) |
|
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
9423 CHECK_CHARACTER (val); |
|
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
9424 CODING_ATTR_MNEMONIC (attrs) = val; |
|
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
9425 } |
|
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
9426 else if (EQ (prop, QCdefalut_char)) |
|
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
9427 { |
|
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
9428 if (NILP (val)) |
|
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
9429 val = make_number (' '); |
|
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
9430 else |
|
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
9431 CHECK_CHARACTER (val); |
|
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
9432 CODING_ATTR_DEFAULT_CHAR (attrs) = val; |
|
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
9433 } |
|
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
9434 else if (EQ (prop, QCdecode_translation_table)) |
|
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
9435 { |
|
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
9436 if (! CHAR_TABLE_P (val) && ! CONSP (val)) |
|
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
9437 CHECK_SYMBOL (val); |
|
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
9438 CODING_ATTR_DECODE_TBL (attrs) = val; |
|
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
9439 } |
|
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
9440 else if (EQ (prop, QCencode_translation_table)) |
|
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
9441 { |
|
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
9442 if (! CHAR_TABLE_P (val) && ! CONSP (val)) |
|
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
9443 CHECK_SYMBOL (val); |
|
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
9444 CODING_ATTR_ENCODE_TBL (attrs) = val; |
|
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
9445 } |
|
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
9446 else if (EQ (prop, QCpost_read_conversion)) |
|
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
9447 { |
|
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
9448 CHECK_SYMBOL (val); |
|
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
9449 CODING_ATTR_POST_READ (attrs) = val; |
|
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
9450 } |
|
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
9451 else if (EQ (prop, QCpre_write_conversion)) |
|
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
9452 { |
|
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
9453 CHECK_SYMBOL (val); |
|
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
9454 CODING_ATTR_PRE_WRITE (attrs) = val; |
|
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
9455 } |
|
90214
460ee00505d5
(QCascii_compatible_p): New variable.
Kenichi Handa <handa@m17n.org>
parents:
90201
diff
changeset
|
9456 else if (EQ (prop, QCascii_compatible_p)) |
|
460ee00505d5
(QCascii_compatible_p): New variable.
Kenichi Handa <handa@m17n.org>
parents:
90201
diff
changeset
|
9457 { |
|
460ee00505d5
(QCascii_compatible_p): New variable.
Kenichi Handa <handa@m17n.org>
parents:
90201
diff
changeset
|
9458 CODING_ATTR_ASCII_COMPAT (attrs) = val; |
|
460ee00505d5
(QCascii_compatible_p): New variable.
Kenichi Handa <handa@m17n.org>
parents:
90201
diff
changeset
|
9459 } |
|
89759
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
9460 |
|
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
9461 CODING_ATTR_PLIST (attrs) |
|
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
9462 = Fplist_put (CODING_ATTR_PLIST (attrs), prop, val); |
|
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
9463 return val; |
|
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
9464 } |
|
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
9465 |
|
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
9466 |
| 88365 | 9467 DEFUN ("define-coding-system-alias", Fdefine_coding_system_alias, |
| 9468 Sdefine_coding_system_alias, 2, 2, 0, | |
| 9469 doc: /* Define ALIAS as an alias for CODING-SYSTEM. */) | |
| 9470 (alias, coding_system) | |
| 9471 Lisp_Object alias, coding_system; | |
| 9472 { | |
|
90289
72d8a45f6c9f
(Fdefine_coding_system_internal): Avoid a duplicated
Kenichi Handa <handa@m17n.org>
parents:
90272
diff
changeset
|
9473 Lisp_Object spec, aliases, eol_type, val; |
| 88365 | 9474 |
| 9475 CHECK_SYMBOL (alias); | |
| 9476 CHECK_CODING_SYSTEM_GET_SPEC (coding_system, spec); | |
| 9477 aliases = AREF (spec, 1); | |
|
89571
242f2cc0134b
(Fdefine_coding_system_alias): Update Vcoding_system_list.
Kenichi Handa <handa@m17n.org>
parents:
89562
diff
changeset
|
9478 /* ALISES should be a list of length more than zero, and the first |
|
242f2cc0134b
(Fdefine_coding_system_alias): Update Vcoding_system_list.
Kenichi Handa <handa@m17n.org>
parents:
89562
diff
changeset
|
9479 element is a base coding system. Append ALIAS at the tail of the |
|
242f2cc0134b
(Fdefine_coding_system_alias): Update Vcoding_system_list.
Kenichi Handa <handa@m17n.org>
parents:
89562
diff
changeset
|
9480 list. */ |
| 88365 | 9481 while (!NILP (XCDR (aliases))) |
| 9482 aliases = XCDR (aliases); | |
| 89483 | 9483 XSETCDR (aliases, Fcons (alias, Qnil)); |
| 88365 | 9484 |
| 9485 eol_type = AREF (spec, 2); | |
| 9486 if (VECTORP (eol_type)) | |
| 9487 { | |
| 9488 Lisp_Object subsidiaries; | |
| 9489 int i; | |
| 9490 | |
| 9491 subsidiaries = make_subsidiaries (alias); | |
| 9492 for (i = 0; i < 3; i++) | |
| 9493 Fdefine_coding_system_alias (AREF (subsidiaries, i), | |
| 9494 AREF (eol_type, i)); | |
| 9495 } | |
| 9496 | |
| 9497 Fputhash (alias, spec, Vcoding_system_hash_table); | |
|
89571
242f2cc0134b
(Fdefine_coding_system_alias): Update Vcoding_system_list.
Kenichi Handa <handa@m17n.org>
parents:
89562
diff
changeset
|
9498 Vcoding_system_list = Fcons (alias, Vcoding_system_list); |
|
90289
72d8a45f6c9f
(Fdefine_coding_system_internal): Avoid a duplicated
Kenichi Handa <handa@m17n.org>
parents:
90272
diff
changeset
|
9499 val = Fassoc (Fsymbol_name (alias), Vcoding_system_alist); |
|
72d8a45f6c9f
(Fdefine_coding_system_internal): Avoid a duplicated
Kenichi Handa <handa@m17n.org>
parents:
90272
diff
changeset
|
9500 if (NILP (val)) |
|
72d8a45f6c9f
(Fdefine_coding_system_internal): Avoid a duplicated
Kenichi Handa <handa@m17n.org>
parents:
90272
diff
changeset
|
9501 Vcoding_system_alist = Fcons (Fcons (Fsymbol_name (alias), Qnil), |
|
72d8a45f6c9f
(Fdefine_coding_system_internal): Avoid a duplicated
Kenichi Handa <handa@m17n.org>
parents:
90272
diff
changeset
|
9502 Vcoding_system_alist); |
| 88365 | 9503 |
|
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
9504 return Qnil; |
|
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
9505 } |
|
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
9506 |
| 88365 | 9507 DEFUN ("coding-system-base", Fcoding_system_base, Scoding_system_base, |
| 9508 1, 1, 0, | |
| 9509 doc: /* Return the base of CODING-SYSTEM. | |
| 88645 | 9510 Any alias or subsidiary coding system is not a base coding system. */) |
| 88365 | 9511 (coding_system) |
| 9512 Lisp_Object coding_system; | |
| 9513 { | |
| 9514 Lisp_Object spec, attrs; | |
| 9515 | |
| 9516 if (NILP (coding_system)) | |
| 9517 return (Qno_conversion); | |
| 9518 CHECK_CODING_SYSTEM_GET_SPEC (coding_system, spec); | |
| 9519 attrs = AREF (spec, 0); | |
| 9520 return CODING_ATTR_BASE_NAME (attrs); | |
| 9521 } | |
| 9522 | |
| 9523 DEFUN ("coding-system-plist", Fcoding_system_plist, Scoding_system_plist, | |
| 9524 1, 1, 0, | |
| 9525 doc: "Return the property list of CODING-SYSTEM.") | |
|
49539
1ad5bfbb831a
(syms_of_coding): Add `...' for symbols in the docstring of
Kenichi Handa <handa@m17n.org>
parents:
48874
diff
changeset
|
9526 (coding_system) |
|
1ad5bfbb831a
(syms_of_coding): Add `...' for symbols in the docstring of
Kenichi Handa <handa@m17n.org>
parents:
48874
diff
changeset
|
9527 Lisp_Object coding_system; |
|
1ad5bfbb831a
(syms_of_coding): Add `...' for symbols in the docstring of
Kenichi Handa <handa@m17n.org>
parents:
48874
diff
changeset
|
9528 { |
| 88365 | 9529 Lisp_Object spec, attrs; |
| 9530 | |
| 9531 if (NILP (coding_system)) | |
| 9532 coding_system = Qno_conversion; | |
| 9533 CHECK_CODING_SYSTEM_GET_SPEC (coding_system, spec); | |
| 9534 attrs = AREF (spec, 0); | |
| 9535 return CODING_ATTR_PLIST (attrs); | |
| 9536 } | |
| 9537 | |
| 9538 | |
| 9539 DEFUN ("coding-system-aliases", Fcoding_system_aliases, Scoding_system_aliases, | |
| 9540 1, 1, 0, | |
| 88645 | 9541 doc: /* Return the list of aliases of CODING-SYSTEM. */) |
| 88365 | 9542 (coding_system) |
| 9543 Lisp_Object coding_system; | |
| 9544 { | |
| 9545 Lisp_Object spec; | |
| 9546 | |
| 9547 if (NILP (coding_system)) | |
| 9548 coding_system = Qno_conversion; | |
| 9549 CHECK_CODING_SYSTEM_GET_SPEC (coding_system, spec); | |
| 88645 | 9550 return AREF (spec, 1); |
| 88365 | 9551 } |
| 9552 | |
| 9553 DEFUN ("coding-system-eol-type", Fcoding_system_eol_type, | |
| 9554 Scoding_system_eol_type, 1, 1, 0, | |
| 9555 doc: /* Return eol-type of CODING-SYSTEM. | |
| 9556 An eol-type is integer 0, 1, 2, or a vector of coding systems. | |
| 9557 | |
| 9558 Integer values 0, 1, and 2 indicate a format of end-of-line; LF, CRLF, | |
| 9559 and CR respectively. | |
| 9560 | |
| 9561 A vector value indicates that a format of end-of-line should be | |
| 9562 detected automatically. Nth element of the vector is the subsidiary | |
| 9563 coding system whose eol-type is N. */) | |
| 9564 (coding_system) | |
| 9565 Lisp_Object coding_system; | |
| 9566 { | |
| 9567 Lisp_Object spec, eol_type; | |
| 9568 int n; | |
| 9569 | |
| 9570 if (NILP (coding_system)) | |
| 9571 coding_system = Qno_conversion; | |
| 9572 if (! CODING_SYSTEM_P (coding_system)) | |
| 9573 return Qnil; | |
| 9574 spec = CODING_SYSTEM_SPEC (coding_system); | |
| 9575 eol_type = AREF (spec, 2); | |
| 9576 if (VECTORP (eol_type)) | |
| 9577 return Fcopy_sequence (eol_type); | |
| 9578 n = EQ (eol_type, Qunix) ? 0 : EQ (eol_type, Qdos) ? 1 : 2; | |
| 9579 return make_number (n); | |
|
49539
1ad5bfbb831a
(syms_of_coding): Add `...' for symbols in the docstring of
Kenichi Handa <handa@m17n.org>
parents:
48874
diff
changeset
|
9580 } |
|
1ad5bfbb831a
(syms_of_coding): Add `...' for symbols in the docstring of
Kenichi Handa <handa@m17n.org>
parents:
48874
diff
changeset
|
9581 |
| 17052 | 9582 #endif /* emacs */ |
| 9583 | |
| 9584 | |
|
22874
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
9585 /*** 9. Post-amble ***/ |
| 17052 | 9586 |
| 21514 | 9587 void |
| 17052 | 9588 init_coding_once () |
| 9589 { | |
| 9590 int i; | |
| 9591 | |
| 88365 | 9592 for (i = 0; i < coding_category_max; i++) |
| 9593 { | |
| 9594 coding_categories[i].id = -1; | |
| 9595 coding_priorities[i] = i; | |
| 9596 } | |
| 17052 | 9597 |
| 9598 /* ISO2022 specific initialize routine. */ | |
| 9599 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
|
9600 iso_code_class[i] = ISO_control_0; |
| 17052 | 9601 for (i = 0x21; i < 0x7F; i++) |
| 9602 iso_code_class[i] = ISO_graphic_plane_0; | |
| 9603 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
|
9604 iso_code_class[i] = ISO_control_1; |
| 17052 | 9605 for (i = 0xA1; i < 0xFF; i++) |
| 9606 iso_code_class[i] = ISO_graphic_plane_1; | |
| 9607 iso_code_class[0x20] = iso_code_class[0x7F] = ISO_0x20_or_0x7F; | |
| 9608 iso_code_class[0xA0] = iso_code_class[0xFF] = ISO_0xA0_or_0xFF; | |
| 9609 iso_code_class[ISO_CODE_SO] = ISO_shift_out; | |
| 9610 iso_code_class[ISO_CODE_SI] = ISO_shift_in; | |
| 9611 iso_code_class[ISO_CODE_SS2_7] = ISO_single_shift_2_7; | |
| 9612 iso_code_class[ISO_CODE_ESC] = ISO_escape; | |
| 9613 iso_code_class[ISO_CODE_SS2] = ISO_single_shift_2; | |
| 9614 iso_code_class[ISO_CODE_SS3] = ISO_single_shift_3; | |
| 9615 iso_code_class[ISO_CODE_CSI] = ISO_control_sequence_introducer; | |
| 9616 | |
| 88365 | 9617 for (i = 0; i < 256; i++) |
| 9618 { | |
| 9619 emacs_mule_bytes[i] = 1; | |
| 9620 } | |
|
88876
af9012fdad56
(LEADING_CODE_PRIVATE_11, LEADING_CODE_PRIVATE_12,
Kenichi Handa <handa@m17n.org>
parents:
88862
diff
changeset
|
9621 emacs_mule_bytes[EMACS_MULE_LEADING_CODE_PRIVATE_11] = 3; |
|
af9012fdad56
(LEADING_CODE_PRIVATE_11, LEADING_CODE_PRIVATE_12,
Kenichi Handa <handa@m17n.org>
parents:
88862
diff
changeset
|
9622 emacs_mule_bytes[EMACS_MULE_LEADING_CODE_PRIVATE_12] = 3; |
|
af9012fdad56
(LEADING_CODE_PRIVATE_11, LEADING_CODE_PRIVATE_12,
Kenichi Handa <handa@m17n.org>
parents:
88862
diff
changeset
|
9623 emacs_mule_bytes[EMACS_MULE_LEADING_CODE_PRIVATE_21] = 4; |
|
af9012fdad56
(LEADING_CODE_PRIVATE_11, LEADING_CODE_PRIVATE_12,
Kenichi Handa <handa@m17n.org>
parents:
88862
diff
changeset
|
9624 emacs_mule_bytes[EMACS_MULE_LEADING_CODE_PRIVATE_22] = 4; |
|
17119
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
9625 } |
|
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
9626 |
|
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
9627 #ifdef emacs |
|
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
9628 |
| 21514 | 9629 void |
|
17119
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
9630 syms_of_coding () |
|
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
9631 { |
| 88365 | 9632 staticpro (&Vcoding_system_hash_table); |
| 89483 | 9633 { |
| 9634 Lisp_Object args[2]; | |
| 9635 args[0] = QCtest; | |
| 9636 args[1] = Qeq; | |
| 9637 Vcoding_system_hash_table = Fmake_hash_table (2, args); | |
| 9638 } | |
| 88365 | 9639 |
| 9640 staticpro (&Vsjis_coding_system); | |
| 9641 Vsjis_coding_system = Qnil; | |
| 9642 | |
| 9643 staticpro (&Vbig5_coding_system); | |
| 9644 Vbig5_coding_system = Qnil; | |
| 9645 | |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
9646 staticpro (&Vcode_conversion_reused_workbuf); |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
9647 Vcode_conversion_reused_workbuf = Qnil; |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
9648 |
|
58637
ff8a37b5299b
(Vcode_conversion_workbuf_name): New variable.
Kenichi Handa <handa@m17n.org>
parents:
58502
diff
changeset
|
9649 staticpro (&Vcode_conversion_workbuf_name); |
|
ff8a37b5299b
(Vcode_conversion_workbuf_name): New variable.
Kenichi Handa <handa@m17n.org>
parents:
58502
diff
changeset
|
9650 Vcode_conversion_workbuf_name = build_string (" *code-conversion-work*"); |
|
ff8a37b5299b
(Vcode_conversion_workbuf_name): New variable.
Kenichi Handa <handa@m17n.org>
parents:
58502
diff
changeset
|
9651 |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
9652 reused_workbuf_in_use = 0; |
| 88365 | 9653 |
| 9654 DEFSYM (Qcharset, "charset"); | |
| 9655 DEFSYM (Qtarget_idx, "target-idx"); | |
| 9656 DEFSYM (Qcoding_system_history, "coding-system-history"); | |
|
19750
95e4e1cba6ac
(Qcoding_system_history): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
19747
diff
changeset
|
9657 Fset (Qcoding_system_history, Qnil); |
|
95e4e1cba6ac
(Qcoding_system_history): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
19747
diff
changeset
|
9658 |
|
18650
aa3f2820e2ac
(Qemacs_mule, inhibit_eol_conversion): New variables.
Kenichi Handa <handa@m17n.org>
parents:
18613
diff
changeset
|
9659 /* 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
|
9660 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
|
9661 /* 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
|
9662 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
|
9663 |
| 88365 | 9664 DEFSYM (Qcall_process, "call-process"); |
|
18650
aa3f2820e2ac
(Qemacs_mule, inhibit_eol_conversion): New variables.
Kenichi Handa <handa@m17n.org>
parents:
18613
diff
changeset
|
9665 /* 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
|
9666 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
|
9667 |
| 88365 | 9668 DEFSYM (Qcall_process_region, "call-process-region"); |
|
18650
aa3f2820e2ac
(Qemacs_mule, inhibit_eol_conversion): New variables.
Kenichi Handa <handa@m17n.org>
parents:
18613
diff
changeset
|
9669 /* 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
|
9670 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
|
9671 |
| 88365 | 9672 DEFSYM (Qstart_process, "start-process"); |
|
18650
aa3f2820e2ac
(Qemacs_mule, inhibit_eol_conversion): New variables.
Kenichi Handa <handa@m17n.org>
parents:
18613
diff
changeset
|
9673 /* 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
|
9674 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
|
9675 |
| 88365 | 9676 DEFSYM (Qopen_network_stream, "open-network-stream"); |
|
18650
aa3f2820e2ac
(Qemacs_mule, inhibit_eol_conversion): New variables.
Kenichi Handa <handa@m17n.org>
parents:
18613
diff
changeset
|
9677 /* 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
|
9678 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
|
9679 |
| 88365 | 9680 DEFSYM (Qcoding_system, "coding-system"); |
| 9681 DEFSYM (Qcoding_aliases, "coding-aliases"); | |
| 9682 | |
| 9683 DEFSYM (Qeol_type, "eol-type"); | |
| 9684 DEFSYM (Qunix, "unix"); | |
| 9685 DEFSYM (Qdos, "dos"); | |
| 9686 | |
| 9687 DEFSYM (Qbuffer_file_coding_system, "buffer-file-coding-system"); | |
| 9688 DEFSYM (Qpost_read_conversion, "post-read-conversion"); | |
| 9689 DEFSYM (Qpre_write_conversion, "pre-write-conversion"); | |
| 9690 DEFSYM (Qdefault_char, "default-char"); | |
| 9691 DEFSYM (Qundecided, "undecided"); | |
| 9692 DEFSYM (Qno_conversion, "no-conversion"); | |
| 9693 DEFSYM (Qraw_text, "raw-text"); | |
| 9694 | |
| 9695 DEFSYM (Qiso_2022, "iso-2022"); | |
| 9696 | |
| 9697 DEFSYM (Qutf_8, "utf-8"); | |
| 89483 | 9698 DEFSYM (Qutf_8_emacs, "utf-8-emacs"); |
| 88365 | 9699 |
| 9700 DEFSYM (Qutf_16, "utf-16"); | |
| 9701 DEFSYM (Qbig, "big"); | |
| 9702 DEFSYM (Qlittle, "little"); | |
| 9703 | |
| 9704 DEFSYM (Qshift_jis, "shift-jis"); | |
| 9705 DEFSYM (Qbig5, "big5"); | |
| 9706 | |
| 9707 DEFSYM (Qcoding_system_p, "coding-system-p"); | |
| 9708 | |
| 9709 DEFSYM (Qcoding_system_error, "coding-system-error"); | |
| 17052 | 9710 Fput (Qcoding_system_error, Qerror_conditions, |
| 9711 Fcons (Qcoding_system_error, Fcons (Qerror, Qnil))); | |
| 9712 Fput (Qcoding_system_error, Qerror_message, | |
|
18650
aa3f2820e2ac
(Qemacs_mule, inhibit_eol_conversion): New variables.
Kenichi Handa <handa@m17n.org>
parents:
18613
diff
changeset
|
9713 build_string ("Invalid coding system")); |
| 17052 | 9714 |
|
30487
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
9715 /* Intern this now in case it isn't already done. |
|
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
9716 Setting this variable twice is harmless. |
|
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
9717 But don't staticpro it here--that is done in alloc.c. */ |
|
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
9718 Qchar_table_extra_slots = intern ("char-table-extra-slots"); |
| 88365 | 9719 |
| 9720 DEFSYM (Qtranslation_table, "translation-table"); | |
|
89856
18b52da60a76
(get_translation): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89852
diff
changeset
|
9721 Fput (Qtranslation_table, Qchar_table_extra_slots, make_number (2)); |
| 88365 | 9722 DEFSYM (Qtranslation_table_id, "translation-table-id"); |
| 9723 DEFSYM (Qtranslation_table_for_decode, "translation-table-for-decode"); | |
| 9724 DEFSYM (Qtranslation_table_for_encode, "translation-table-for-encode"); | |
| 9725 | |
| 9726 DEFSYM (Qvalid_codes, "valid-codes"); | |
| 9727 | |
| 9728 DEFSYM (Qemacs_mule, "emacs-mule"); | |
| 9729 | |
|
89468
7dbbe692f70c
* coding.c (QCcategory): New variable.
Kenichi Handa <handa@m17n.org>
parents:
89467
diff
changeset
|
9730 DEFSYM (QCcategory, ":category"); |
|
89759
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
9731 DEFSYM (QCmnemonic, ":mnemonic"); |
|
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
9732 DEFSYM (QCdefalut_char, ":default-char"); |
|
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
9733 DEFSYM (QCdecode_translation_table, ":decode-translation-table"); |
|
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
9734 DEFSYM (QCencode_translation_table, ":encode-translation-table"); |
|
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
9735 DEFSYM (QCpost_read_conversion, ":post-read-conversion"); |
|
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
9736 DEFSYM (QCpre_write_conversion, ":pre-write-conversion"); |
|
90214
460ee00505d5
(QCascii_compatible_p): New variable.
Kenichi Handa <handa@m17n.org>
parents:
90201
diff
changeset
|
9737 DEFSYM (QCascii_compatible_p, ":ascii-compatible-p"); |
|
89468
7dbbe692f70c
* coding.c (QCcategory): New variable.
Kenichi Handa <handa@m17n.org>
parents:
89467
diff
changeset
|
9738 |
| 88365 | 9739 Vcoding_category_table |
| 9740 = Fmake_vector (make_number (coding_category_max), Qnil); | |
| 9741 staticpro (&Vcoding_category_table); | |
| 9742 /* Followings are target of code detection. */ | |
| 9743 ASET (Vcoding_category_table, coding_category_iso_7, | |
| 9744 intern ("coding-category-iso-7")); | |
| 9745 ASET (Vcoding_category_table, coding_category_iso_7_tight, | |
| 9746 intern ("coding-category-iso-7-tight")); | |
| 9747 ASET (Vcoding_category_table, coding_category_iso_8_1, | |
| 9748 intern ("coding-category-iso-8-1")); | |
| 9749 ASET (Vcoding_category_table, coding_category_iso_8_2, | |
| 9750 intern ("coding-category-iso-8-2")); | |
| 9751 ASET (Vcoding_category_table, coding_category_iso_7_else, | |
| 9752 intern ("coding-category-iso-7-else")); | |
| 9753 ASET (Vcoding_category_table, coding_category_iso_8_else, | |
| 9754 intern ("coding-category-iso-8-else")); | |
| 9755 ASET (Vcoding_category_table, coding_category_utf_8, | |
| 9756 intern ("coding-category-utf-8")); | |
| 9757 ASET (Vcoding_category_table, coding_category_utf_16_be, | |
| 9758 intern ("coding-category-utf-16-be")); | |
|
89467
e911ca706166
(Fset_coding_system_priority): Doc fix. Update values
Kenichi Handa <handa@m17n.org>
parents:
89462
diff
changeset
|
9759 ASET (Vcoding_category_table, coding_category_utf_16_auto, |
|
e911ca706166
(Fset_coding_system_priority): Doc fix. Update values
Kenichi Handa <handa@m17n.org>
parents:
89462
diff
changeset
|
9760 intern ("coding-category-utf-16-auto")); |
| 88365 | 9761 ASET (Vcoding_category_table, coding_category_utf_16_le, |
| 9762 intern ("coding-category-utf-16-le")); | |
| 9763 ASET (Vcoding_category_table, coding_category_utf_16_be_nosig, | |
| 9764 intern ("coding-category-utf-16-be-nosig")); | |
| 9765 ASET (Vcoding_category_table, coding_category_utf_16_le_nosig, | |
| 9766 intern ("coding-category-utf-16-le-nosig")); | |
| 9767 ASET (Vcoding_category_table, coding_category_charset, | |
| 9768 intern ("coding-category-charset")); | |
| 9769 ASET (Vcoding_category_table, coding_category_sjis, | |
| 9770 intern ("coding-category-sjis")); | |
| 9771 ASET (Vcoding_category_table, coding_category_big5, | |
| 9772 intern ("coding-category-big5")); | |
| 9773 ASET (Vcoding_category_table, coding_category_ccl, | |
| 9774 intern ("coding-category-ccl")); | |
| 9775 ASET (Vcoding_category_table, coding_category_emacs_mule, | |
| 9776 intern ("coding-category-emacs-mule")); | |
| 9777 /* Followings are NOT target of code detection. */ | |
| 9778 ASET (Vcoding_category_table, coding_category_raw_text, | |
| 9779 intern ("coding-category-raw-text")); | |
| 9780 ASET (Vcoding_category_table, coding_category_undecided, | |
| 9781 intern ("coding-category-undecided")); | |
| 9782 | |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
9783 DEFSYM (Qinsufficient_source, "insufficient-source"); |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
9784 DEFSYM (Qinconsistent_eol, "inconsistent-eol"); |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
9785 DEFSYM (Qinvalid_source, "invalid-source"); |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
9786 DEFSYM (Qinterrupted, "interrupted"); |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
9787 DEFSYM (Qinsufficient_memory, "insufficient-memory"); |
|
90272
f1df126ec7de
Sync to HEAD for handling autoload-coding-system.
Kenichi Handa <handa@m17n.org>
parents:
90263
diff
changeset
|
9788 DEFSYM (Qcoding_system_define_form, "coding-system-define-form"); |
|
52794
f4d906e31662
(Qcoding_system_define_form): New variable.
Kenichi Handa <handa@m17n.org>
parents:
52401
diff
changeset
|
9789 |
| 17052 | 9790 defsubr (&Scoding_system_p); |
| 9791 defsubr (&Sread_coding_system); | |
| 9792 defsubr (&Sread_non_nil_coding_system); | |
| 9793 defsubr (&Scheck_coding_system); | |
| 9794 defsubr (&Sdetect_coding_region); | |
|
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
9795 defsubr (&Sdetect_coding_string); |
|
30487
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
9796 defsubr (&Sfind_coding_systems_region_internal); |
|
46859
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
9797 defsubr (&Sunencodable_char_position); |
| 88365 | 9798 defsubr (&Scheck_coding_systems_region); |
| 17052 | 9799 defsubr (&Sdecode_coding_region); |
| 9800 defsubr (&Sencode_coding_region); | |
| 9801 defsubr (&Sdecode_coding_string); | |
| 9802 defsubr (&Sencode_coding_string); | |
| 9803 defsubr (&Sdecode_sjis_char); | |
| 9804 defsubr (&Sencode_sjis_char); | |
| 9805 defsubr (&Sdecode_big5_char); | |
| 9806 defsubr (&Sencode_big5_char); | |
|
18002
a14261786239
(encode_invocation_designation): Use macro
Kenichi Handa <handa@m17n.org>
parents:
17835
diff
changeset
|
9807 defsubr (&Sset_terminal_coding_system_internal); |
|
19280
e755044718ee
(ENCODE_ISO_CHARACTER_DIMENSION1): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
19193
diff
changeset
|
9808 defsubr (&Sset_safe_terminal_coding_system_internal); |
| 17052 | 9809 defsubr (&Sterminal_coding_system); |
|
18002
a14261786239
(encode_invocation_designation): Use macro
Kenichi Handa <handa@m17n.org>
parents:
17835
diff
changeset
|
9810 defsubr (&Sset_keyboard_coding_system_internal); |
| 17052 | 9811 defsubr (&Skeyboard_coding_system); |
|
18536
69c0e220b626
(Vstandard_character_unification_table_for_decode):
Kenichi Handa <handa@m17n.org>
parents:
18523
diff
changeset
|
9812 defsubr (&Sfind_operation_coding_system); |
| 88365 | 9813 defsubr (&Sset_coding_system_priority); |
|
49539
1ad5bfbb831a
(syms_of_coding): Add `...' for symbols in the docstring of
Kenichi Handa <handa@m17n.org>
parents:
48874
diff
changeset
|
9814 defsubr (&Sdefine_coding_system_internal); |
| 88365 | 9815 defsubr (&Sdefine_coding_system_alias); |
|
89759
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
9816 defsubr (&Scoding_system_put); |
| 88365 | 9817 defsubr (&Scoding_system_base); |
| 9818 defsubr (&Scoding_system_plist); | |
| 9819 defsubr (&Scoding_system_aliases); | |
| 9820 defsubr (&Scoding_system_eol_type); | |
| 9821 defsubr (&Scoding_system_priority_list); | |
| 17052 | 9822 |
|
20105
c017642863c2
(Qcoding_system_spec): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
19824
diff
changeset
|
9823 DEFVAR_LISP ("coding-system-list", &Vcoding_system_list, |
|
40713
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
9824 doc: /* List of coding systems. |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
9825 |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
9826 Do not alter the value of this variable manually. This variable should be |
| 88365 | 9827 updated by the functions `define-coding-system' and |
|
40713
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
9828 `define-coding-system-alias'. */); |
|
20105
c017642863c2
(Qcoding_system_spec): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
19824
diff
changeset
|
9829 Vcoding_system_list = Qnil; |
|
c017642863c2
(Qcoding_system_spec): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
19824
diff
changeset
|
9830 |
|
c017642863c2
(Qcoding_system_spec): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
19824
diff
changeset
|
9831 DEFVAR_LISP ("coding-system-alist", &Vcoding_system_alist, |
|
40713
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
9832 doc: /* Alist of coding system names. |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
9833 Each element is one element list of coding system name. |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
9834 This variable is given to `completing-read' as TABLE argument. |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
9835 |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
9836 Do not alter the value of this variable manually. This variable should be |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
9837 updated by the functions `make-coding-system' and |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
9838 `define-coding-system-alias'. */); |
|
20105
c017642863c2
(Qcoding_system_spec): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
19824
diff
changeset
|
9839 Vcoding_system_alist = Qnil; |
|
c017642863c2
(Qcoding_system_spec): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
19824
diff
changeset
|
9840 |
| 17052 | 9841 DEFVAR_LISP ("coding-category-list", &Vcoding_category_list, |
|
40713
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
9842 doc: /* List of coding-categories (symbols) ordered by priority. |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
9843 |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
9844 On detecting a coding system, Emacs tries code detection algorithms |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
9845 associated with each coding-category one by one in this order. When |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
9846 one algorithm agrees with a byte sequence of source text, the coding |
|
60608
4b80e9c28e8f
(syms_of_coding): Docstring of coding-category-list fixed.
Kenichi Handa <handa@m17n.org>
parents:
60031
diff
changeset
|
9847 system bound to the corresponding coding-category is selected. |
|
4b80e9c28e8f
(syms_of_coding): Docstring of coding-category-list fixed.
Kenichi Handa <handa@m17n.org>
parents:
60031
diff
changeset
|
9848 |
|
61166
e3a6dd630fdf
(Vcoding_category_list): Docstring fix.
Kenichi Handa <handa@m17n.org>
parents:
60907
diff
changeset
|
9849 Don't modify this variable directly, but use `set-coding-priority'. */); |
| 17052 | 9850 { |
| 9851 int i; | |
| 9852 | |
| 9853 Vcoding_category_list = Qnil; | |
| 88365 | 9854 for (i = coding_category_max - 1; i >= 0; i--) |
| 17052 | 9855 Vcoding_category_list |
|
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
9856 = Fcons (XVECTOR (Vcoding_category_table)->contents[i], |
|
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
9857 Vcoding_category_list); |
| 17052 | 9858 } |
| 9859 | |
| 9860 DEFVAR_LISP ("coding-system-for-read", &Vcoding_system_for_read, | |
|
40713
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
9861 doc: /* Specify the coding system for read operations. |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
9862 It is useful to bind this variable with `let', but do not set it globally. |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
9863 If the value is a coding system, it is used for decoding on read operation. |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
9864 If not, an appropriate element is used from one of the coding system alists: |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
9865 There are three such tables, `file-coding-system-alist', |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
9866 `process-coding-system-alist', and `network-coding-system-alist'. */); |
| 17052 | 9867 Vcoding_system_for_read = Qnil; |
| 9868 | |
| 9869 DEFVAR_LISP ("coding-system-for-write", &Vcoding_system_for_write, | |
|
40713
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
9870 doc: /* Specify the coding system for write operations. |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
9871 Programs bind this variable with `let', but you should not set it globally. |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
9872 If the value is a coding system, it is used for encoding of output, |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
9873 when writing it to a file and when sending it to a file or subprocess. |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
9874 |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
9875 If this does not specify a coding system, an appropriate element |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
9876 is used from one of the coding system alists: |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
9877 There are three such tables, `file-coding-system-alist', |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
9878 `process-coding-system-alist', and `network-coding-system-alist'. |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
9879 For output to files, if the above procedure does not specify a coding system, |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
9880 the value of `buffer-file-coding-system' is used. */); |
| 17052 | 9881 Vcoding_system_for_write = Qnil; |
| 9882 | |
| 9883 DEFVAR_LISP ("last-coding-system-used", &Vlast_coding_system_used, | |
| 88365 | 9884 doc: /* |
| 9885 Coding system used in the latest file or process I/O. */); | |
| 17052 | 9886 Vlast_coding_system_used = Qnil; |
| 9887 | |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
9888 DEFVAR_LISP ("last-code-conversion-error", &Vlast_code_conversion_error, |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
9889 doc: /* |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
9890 Error status of the last code conversion. |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
9891 |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
9892 When an error was detected in the last code conversion, this variable |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
9893 is set to one of the following symbols. |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
9894 `insufficient-source' |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
9895 `inconsistent-eol' |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
9896 `invalid-source' |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
9897 `interrupted' |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
9898 `insufficient-memory' |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
9899 When no error was detected, the value doesn't change. So, to check |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
9900 the error status of a code conversion by this variable, you must |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
9901 explicitly set this variable to nil before performing code |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
9902 conversion. */); |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
9903 Vlast_code_conversion_error = Qnil; |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
9904 |
|
18650
aa3f2820e2ac
(Qemacs_mule, inhibit_eol_conversion): New variables.
Kenichi Handa <handa@m17n.org>
parents:
18613
diff
changeset
|
9905 DEFVAR_BOOL ("inhibit-eol-conversion", &inhibit_eol_conversion, |
| 88365 | 9906 doc: /* |
| 9907 *Non-nil means always inhibit code conversion of end-of-line format. | |
|
40713
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
9908 See info node `Coding Systems' and info node `Text and Binary' concerning |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
9909 such conversion. */); |
|
18650
aa3f2820e2ac
(Qemacs_mule, inhibit_eol_conversion): New variables.
Kenichi Handa <handa@m17n.org>
parents:
18613
diff
changeset
|
9910 inhibit_eol_conversion = 0; |
|
aa3f2820e2ac
(Qemacs_mule, inhibit_eol_conversion): New variables.
Kenichi Handa <handa@m17n.org>
parents:
18613
diff
changeset
|
9911 |
|
21574
30394e3ae7f8
(syms_of_coding): Declare and define inherit-process-coding-system.
Eli Zaretskii <eliz@gnu.org>
parents:
21520
diff
changeset
|
9912 DEFVAR_BOOL ("inherit-process-coding-system", &inherit_process_coding_system, |
| 88365 | 9913 doc: /* |
| 9914 Non-nil means process buffer inherits coding system of process output. | |
|
40713
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
9915 Bind it to t if the process output is to be treated as if it were a file |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
9916 read from some filesystem. */); |
|
21574
30394e3ae7f8
(syms_of_coding): Declare and define inherit-process-coding-system.
Eli Zaretskii <eliz@gnu.org>
parents:
21520
diff
changeset
|
9917 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
|
9918 |
|
18180
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
9919 DEFVAR_LISP ("file-coding-system-alist", &Vfile_coding_system_alist, |
| 88365 | 9920 doc: /* |
| 9921 Alist to decide a coding system to use for a file I/O operation. | |
|
40713
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
9922 The format is ((PATTERN . VAL) ...), |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
9923 where PATTERN is a regular expression matching a file name, |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
9924 VAL is a coding system, a cons of coding systems, or a function symbol. |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
9925 If VAL is a coding system, it is used for both decoding and encoding |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
9926 the file contents. |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
9927 If VAL is a cons of coding systems, the car part is used for decoding, |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
9928 and the cdr part is used for encoding. |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
9929 If VAL is a function symbol, the function must return a coding system |
|
72323
af796bc81ff0
(syms_of_coding): Improve the docstring
Kenichi Handa <handa@m17n.org>
parents:
72188
diff
changeset
|
9930 or a cons of coding systems which are used as above. The function is |
|
af796bc81ff0
(syms_of_coding): Improve the docstring
Kenichi Handa <handa@m17n.org>
parents:
72188
diff
changeset
|
9931 called with an argument that is a list of the arguments with which |
|
81611
ae42ad5f89e6
(Ffind_operation_coding_system): Docstring improved.
Kenichi Handa <handa@m17n.org>
parents:
75348
diff
changeset
|
9932 `find-operation-coding-system' was called. If the function can't decide |
|
ae42ad5f89e6
(Ffind_operation_coding_system): Docstring improved.
Kenichi Handa <handa@m17n.org>
parents:
75348
diff
changeset
|
9933 a coding system, it can return `undecided' so that the normal |
|
ae42ad5f89e6
(Ffind_operation_coding_system): Docstring improved.
Kenichi Handa <handa@m17n.org>
parents:
75348
diff
changeset
|
9934 code-detection is performed. |
|
40713
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
9935 |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
9936 See also the function `find-operation-coding-system' |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
9937 and the variable `auto-coding-alist'. */); |
|
18180
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
9938 Vfile_coding_system_alist = Qnil; |
|
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
9939 |
|
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
9940 DEFVAR_LISP ("process-coding-system-alist", &Vprocess_coding_system_alist, |
| 88365 | 9941 doc: /* |
| 9942 Alist to decide a coding system to use for a process I/O operation. | |
|
40713
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
9943 The format is ((PATTERN . VAL) ...), |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
9944 where PATTERN is a regular expression matching a program name, |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
9945 VAL is a coding system, a cons of coding systems, or a function symbol. |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
9946 If VAL is a coding system, it is used for both decoding what received |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
9947 from the program and encoding what sent to the program. |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
9948 If VAL is a cons of coding systems, the car part is used for decoding, |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
9949 and the cdr part is used for encoding. |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
9950 If VAL is a function symbol, the function must return a coding system |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
9951 or a cons of coding systems which are used as above. |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
9952 |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
9953 See also the function `find-operation-coding-system'. */); |
|
18180
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
9954 Vprocess_coding_system_alist = Qnil; |
|
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
9955 |
|
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
9956 DEFVAR_LISP ("network-coding-system-alist", &Vnetwork_coding_system_alist, |
| 88365 | 9957 doc: /* |
| 9958 Alist to decide a coding system to use for a network I/O operation. | |
|
40713
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
9959 The format is ((PATTERN . VAL) ...), |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
9960 where PATTERN is a regular expression matching a network service name |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
9961 or is a port number to connect to, |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
9962 VAL is a coding system, a cons of coding systems, or a function symbol. |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
9963 If VAL is a coding system, it is used for both decoding what received |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
9964 from the network stream and encoding what sent to the network stream. |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
9965 If VAL is a cons of coding systems, the car part is used for decoding, |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
9966 and the cdr part is used for encoding. |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
9967 If VAL is a function symbol, the function must return a coding system |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
9968 or a cons of coding systems which are used as above. |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
9969 |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
9970 See also the function `find-operation-coding-system'. */); |
|
18180
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
9971 Vnetwork_coding_system_alist = Qnil; |
| 17052 | 9972 |
|
26088
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
26067
diff
changeset
|
9973 DEFVAR_LISP ("locale-coding-system", &Vlocale_coding_system, |
|
41026
6f20449b7e12
(syms_of_coding): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
41006
diff
changeset
|
9974 doc: /* Coding system to use with system messages. |
|
6f20449b7e12
(syms_of_coding): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
41006
diff
changeset
|
9975 Also used for decoding keyboard input on X Window system. */); |
|
26088
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
26067
diff
changeset
|
9976 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
|
9977 |
|
29182
1d1c27067af4
(encode_eol): Add null statement after label.
Dave Love <fx@gnu.org>
parents:
29172
diff
changeset
|
9978 /* 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
|
9979 DEFVAR_LISP ("eol-mnemonic-unix", &eol_mnemonic_unix, |
| 88365 | 9980 doc: /* |
| 9981 *String displayed in mode line for UNIX-like (LF) end-of-line format. */); | |
|
24200
b9d9fccad516
(syms_of_coding): eol-mnemonic-* variables are now
Eli Zaretskii <eliz@gnu.org>
parents:
24178
diff
changeset
|
9982 eol_mnemonic_unix = build_string (":"); |
|
b9d9fccad516
(syms_of_coding): eol-mnemonic-* variables are now
Eli Zaretskii <eliz@gnu.org>
parents:
24178
diff
changeset
|
9983 |
|
b9d9fccad516
(syms_of_coding): eol-mnemonic-* variables are now
Eli Zaretskii <eliz@gnu.org>
parents:
24178
diff
changeset
|
9984 DEFVAR_LISP ("eol-mnemonic-dos", &eol_mnemonic_dos, |
| 88365 | 9985 doc: /* |
| 9986 *String displayed in mode line for DOS-like (CRLF) end-of-line format. */); | |
|
24200
b9d9fccad516
(syms_of_coding): eol-mnemonic-* variables are now
Eli Zaretskii <eliz@gnu.org>
parents:
24178
diff
changeset
|
9987 eol_mnemonic_dos = build_string ("\\"); |
|
b9d9fccad516
(syms_of_coding): eol-mnemonic-* variables are now
Eli Zaretskii <eliz@gnu.org>
parents:
24178
diff
changeset
|
9988 |
|
b9d9fccad516
(syms_of_coding): eol-mnemonic-* variables are now
Eli Zaretskii <eliz@gnu.org>
parents:
24178
diff
changeset
|
9989 DEFVAR_LISP ("eol-mnemonic-mac", &eol_mnemonic_mac, |
| 88365 | 9990 doc: /* |
| 9991 *String displayed in mode line for MAC-like (CR) end-of-line format. */); | |
|
24200
b9d9fccad516
(syms_of_coding): eol-mnemonic-* variables are now
Eli Zaretskii <eliz@gnu.org>
parents:
24178
diff
changeset
|
9992 eol_mnemonic_mac = build_string ("/"); |
|
b9d9fccad516
(syms_of_coding): eol-mnemonic-* variables are now
Eli Zaretskii <eliz@gnu.org>
parents:
24178
diff
changeset
|
9993 |
|
b9d9fccad516
(syms_of_coding): eol-mnemonic-* variables are now
Eli Zaretskii <eliz@gnu.org>
parents:
24178
diff
changeset
|
9994 DEFVAR_LISP ("eol-mnemonic-undecided", &eol_mnemonic_undecided, |
| 88365 | 9995 doc: /* |
| 9996 *String displayed in mode line when end-of-line format is not yet determined. */); | |
|
24200
b9d9fccad516
(syms_of_coding): eol-mnemonic-* variables are now
Eli Zaretskii <eliz@gnu.org>
parents:
24178
diff
changeset
|
9997 eol_mnemonic_undecided = build_string (":"); |
| 17052 | 9998 |
|
22119
592bb8b9bcfd
Change terms unify/unification to
Kenichi Handa <handa@m17n.org>
parents:
22020
diff
changeset
|
9999 DEFVAR_LISP ("enable-character-translation", &Venable_character_translation, |
| 88365 | 10000 doc: /* |
| 10001 *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
|
10002 Venable_character_translation = Qt; |
|
592bb8b9bcfd
Change terms unify/unification to
Kenichi Handa <handa@m17n.org>
parents:
22020
diff
changeset
|
10003 |
|
22186
fc4aaf1b1772
Change term "character translation table" to "translation table".
Kenichi Handa <handa@m17n.org>
parents:
22166
diff
changeset
|
10004 DEFVAR_LISP ("standard-translation-table-for-decode", |
|
40713
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
10005 &Vstandard_translation_table_for_decode, |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
10006 doc: /* Table for translating characters while decoding. */); |
|
22186
fc4aaf1b1772
Change term "character translation table" to "translation table".
Kenichi Handa <handa@m17n.org>
parents:
22166
diff
changeset
|
10007 Vstandard_translation_table_for_decode = Qnil; |
|
fc4aaf1b1772
Change term "character translation table" to "translation table".
Kenichi Handa <handa@m17n.org>
parents:
22166
diff
changeset
|
10008 |
|
fc4aaf1b1772
Change term "character translation table" to "translation table".
Kenichi Handa <handa@m17n.org>
parents:
22166
diff
changeset
|
10009 DEFVAR_LISP ("standard-translation-table-for-encode", |
|
40713
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
10010 &Vstandard_translation_table_for_encode, |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
10011 doc: /* Table for translating characters while encoding. */); |
|
22186
fc4aaf1b1772
Change term "character translation table" to "translation table".
Kenichi Handa <handa@m17n.org>
parents:
22166
diff
changeset
|
10012 Vstandard_translation_table_for_encode = Qnil; |
| 17052 | 10013 |
| 88365 | 10014 DEFVAR_LISP ("charset-revision-table", &Vcharset_revision_table, |
|
40713
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
10015 doc: /* Alist of charsets vs revision numbers. |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
10016 While encoding, if a charset (car part of an element) is found, |
| 88365 | 10017 designate it with the escape sequence identifying revision (cdr part |
| 10018 of the element). */); | |
| 10019 Vcharset_revision_table = Qnil; | |
|
18180
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
10020 |
|
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
10021 DEFVAR_LISP ("default-process-coding-system", |
|
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
10022 &Vdefault_process_coding_system, |
|
40713
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
10023 doc: /* Cons of coding systems used for process I/O by default. |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
10024 The car part is used for decoding a process output, |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
10025 the cdr part is used for encoding a text to be sent to a process. */); |
|
18180
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
10026 Vdefault_process_coding_system = Qnil; |
|
19280
e755044718ee
(ENCODE_ISO_CHARACTER_DIMENSION1): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
19193
diff
changeset
|
10027 |
|
19365
d9374f5ebd3a
(CODING_FLAG_ISO_LATIN_EXTRA): New macro.
Kenichi Handa <handa@m17n.org>
parents:
19285
diff
changeset
|
10028 DEFVAR_LISP ("latin-extra-code-table", &Vlatin_extra_code_table, |
| 88365 | 10029 doc: /* |
| 10030 Table of extra Latin codes in the range 128..159 (inclusive). | |
|
40713
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
10031 This is a vector of length 256. |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
10032 If Nth element is non-nil, the existence of code N in a file |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
10033 \(or output of subprocess) doesn't prevent it to be detected as |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
10034 a coding system of ISO 2022 variant which has a flag |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
10035 `accept-latin-extra-code' t (e.g. iso-latin-1) on reading a file |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
10036 or reading output of a subprocess. |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
10037 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
|
10038 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
|
10039 |
|
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
10040 DEFVAR_LISP ("select-safe-coding-system-function", |
|
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
10041 &Vselect_safe_coding_system_function, |
| 88365 | 10042 doc: /* |
| 10043 Function to call to select safe coding system for encoding a text. | |
|
40713
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
10044 |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
10045 If set, this function is called to force a user to select a proper |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
10046 coding system which can encode the text in the case that a default |
|
87778
0ec6f8d26078
(select-safe-coding-system-function): Doc fix.
Glenn Morris <rgm@gnu.org>
parents:
87710
diff
changeset
|
10047 coding system used in each operation can't encode the text. The |
|
0ec6f8d26078
(select-safe-coding-system-function): Doc fix.
Glenn Morris <rgm@gnu.org>
parents:
87710
diff
changeset
|
10048 function should take care that the buffer is not modified while |
|
0ec6f8d26078
(select-safe-coding-system-function): Doc fix.
Glenn Morris <rgm@gnu.org>
parents:
87710
diff
changeset
|
10049 the coding system is being selected. |
|
40713
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
10050 |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
10051 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
|
10052 Vselect_safe_coding_system_function = Qnil; |
|
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
10053 |
|
48874
3002a87cc629
(coding_system_require_warning): New variable.
Kenichi Handa <handa@m17n.org>
parents:
48829
diff
changeset
|
10054 DEFVAR_BOOL ("coding-system-require-warning", |
|
3002a87cc629
(coding_system_require_warning): New variable.
Kenichi Handa <handa@m17n.org>
parents:
48829
diff
changeset
|
10055 &coding_system_require_warning, |
|
3002a87cc629
(coding_system_require_warning): New variable.
Kenichi Handa <handa@m17n.org>
parents:
48829
diff
changeset
|
10056 doc: /* Internal use only. |
|
49539
1ad5bfbb831a
(syms_of_coding): Add `...' for symbols in the docstring of
Kenichi Handa <handa@m17n.org>
parents:
48874
diff
changeset
|
10057 If non-nil, on writing a file, `select-safe-coding-system-function' is |
|
1ad5bfbb831a
(syms_of_coding): Add `...' for symbols in the docstring of
Kenichi Handa <handa@m17n.org>
parents:
48874
diff
changeset
|
10058 called even if `coding-system-for-write' is non-nil. The command |
|
1ad5bfbb831a
(syms_of_coding): Add `...' for symbols in the docstring of
Kenichi Handa <handa@m17n.org>
parents:
48874
diff
changeset
|
10059 `universal-coding-system-argument' binds this variable to t temporarily. */); |
|
48874
3002a87cc629
(coding_system_require_warning): New variable.
Kenichi Handa <handa@m17n.org>
parents:
48829
diff
changeset
|
10060 coding_system_require_warning = 0; |
|
3002a87cc629
(coding_system_require_warning): New variable.
Kenichi Handa <handa@m17n.org>
parents:
48829
diff
changeset
|
10061 |
|
3002a87cc629
(coding_system_require_warning): New variable.
Kenichi Handa <handa@m17n.org>
parents:
48829
diff
changeset
|
10062 |
|
30292
14a9937df1f5
(syms_of_coding): Fix typo in spelling of variable
Gerd Moellmann <gerd@gnu.org>
parents:
30263
diff
changeset
|
10063 DEFVAR_BOOL ("inhibit-iso-escape-detection", |
|
30204
35aec8514228
(inhibit_iso_escape_detection): New variable.
Kenichi Handa <handa@m17n.org>
parents:
29985
diff
changeset
|
10064 &inhibit_iso_escape_detection, |
| 88365 | 10065 doc: /* |
| 10066 If non-nil, Emacs ignores ISO2022's escape sequence on code detection. | |
|
40713
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
10067 |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
10068 By default, on reading a file, Emacs tries to detect how the text is |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
10069 encoded. This code detection is sensitive to escape sequences. If |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
10070 the sequence is valid as ISO2022, the code is determined as one of |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
10071 the ISO2022 encodings, and the file is decoded by the corresponding |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
10072 coding system (e.g. `iso-2022-7bit'). |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
10073 |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
10074 However, there may be a case that you want to read escape sequences in |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
10075 a file as is. In such a case, you can set this variable to non-nil. |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
10076 Then, as the code detection ignores any escape sequences, no file is |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
10077 detected as encoded in some ISO2022 encoding. The result is that all |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
10078 escape sequences become visible in a buffer. |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
10079 |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
10080 The default value is nil, and it is strongly recommended not to change |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
10081 it. That is because many Emacs Lisp source files that contain |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
10082 non-ASCII characters are encoded by the coding system `iso-2022-7bit' |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
10083 in Emacs's distribution, and they won't be decoded correctly on |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
10084 reading if you suppress escape sequence detection. |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
10085 |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
10086 The other way to read escape sequences in a file without decoding is |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
10087 to explicitly specify some coding system that doesn't use ISO2022's |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
10088 escape sequence (e.g `latin-1') on reading by \\[universal-coding-system-argument]. */); |
|
30204
35aec8514228
(inhibit_iso_escape_detection): New variable.
Kenichi Handa <handa@m17n.org>
parents:
29985
diff
changeset
|
10089 inhibit_iso_escape_detection = 0; |
|
48182
9474e269efd1
Reformat some DEFUNs so that etags works.
Dave Love <fx@gnu.org>
parents:
48125
diff
changeset
|
10090 |
|
9474e269efd1
Reformat some DEFUNs so that etags works.
Dave Love <fx@gnu.org>
parents:
48125
diff
changeset
|
10091 DEFVAR_LISP ("translation-table-for-input", &Vtranslation_table_for_input, |
|
48230
c2ce8280fb97
(Vtranslation_table_for_input): New.
Dave Love <fx@gnu.org>
parents:
48182
diff
changeset
|
10092 doc: /* Char table for translating self-inserting characters. |
|
c2ce8280fb97
(Vtranslation_table_for_input): New.
Dave Love <fx@gnu.org>
parents:
48182
diff
changeset
|
10093 This is applied to the result of input methods, not their input. See also |
|
c2ce8280fb97
(Vtranslation_table_for_input): New.
Dave Love <fx@gnu.org>
parents:
48182
diff
changeset
|
10094 `keyboard-translate-table'. */); |
|
48182
9474e269efd1
Reformat some DEFUNs so that etags works.
Dave Love <fx@gnu.org>
parents:
48125
diff
changeset
|
10095 Vtranslation_table_for_input = Qnil; |
| 89483 | 10096 |
|
88456
a7b309f72920
(coding_alloc_by_making_gap): Check the case that the
Kenichi Handa <handa@m17n.org>
parents:
88443
diff
changeset
|
10097 { |
|
a7b309f72920
(coding_alloc_by_making_gap): Check the case that the
Kenichi Handa <handa@m17n.org>
parents:
88443
diff
changeset
|
10098 Lisp_Object args[coding_arg_max]; |
| 89483 | 10099 Lisp_Object plist[16]; |
|
88456
a7b309f72920
(coding_alloc_by_making_gap): Check the case that the
Kenichi Handa <handa@m17n.org>
parents:
88443
diff
changeset
|
10100 int i; |
|
a7b309f72920
(coding_alloc_by_making_gap): Check the case that the
Kenichi Handa <handa@m17n.org>
parents:
88443
diff
changeset
|
10101 |
|
a7b309f72920
(coding_alloc_by_making_gap): Check the case that the
Kenichi Handa <handa@m17n.org>
parents:
88443
diff
changeset
|
10102 for (i = 0; i < coding_arg_max; i++) |
|
a7b309f72920
(coding_alloc_by_making_gap): Check the case that the
Kenichi Handa <handa@m17n.org>
parents:
88443
diff
changeset
|
10103 args[i] = Qnil; |
|
a7b309f72920
(coding_alloc_by_making_gap): Check the case that the
Kenichi Handa <handa@m17n.org>
parents:
88443
diff
changeset
|
10104 |
|
a7b309f72920
(coding_alloc_by_making_gap): Check the case that the
Kenichi Handa <handa@m17n.org>
parents:
88443
diff
changeset
|
10105 plist[0] = intern (":name"); |
|
a7b309f72920
(coding_alloc_by_making_gap): Check the case that the
Kenichi Handa <handa@m17n.org>
parents:
88443
diff
changeset
|
10106 plist[1] = args[coding_arg_name] = Qno_conversion; |
|
a7b309f72920
(coding_alloc_by_making_gap): Check the case that the
Kenichi Handa <handa@m17n.org>
parents:
88443
diff
changeset
|
10107 plist[2] = intern (":mnemonic"); |
|
a7b309f72920
(coding_alloc_by_making_gap): Check the case that the
Kenichi Handa <handa@m17n.org>
parents:
88443
diff
changeset
|
10108 plist[3] = args[coding_arg_mnemonic] = make_number ('='); |
|
a7b309f72920
(coding_alloc_by_making_gap): Check the case that the
Kenichi Handa <handa@m17n.org>
parents:
88443
diff
changeset
|
10109 plist[4] = intern (":coding-type"); |
|
a7b309f72920
(coding_alloc_by_making_gap): Check the case that the
Kenichi Handa <handa@m17n.org>
parents:
88443
diff
changeset
|
10110 plist[5] = args[coding_arg_coding_type] = Qraw_text; |
|
a7b309f72920
(coding_alloc_by_making_gap): Check the case that the
Kenichi Handa <handa@m17n.org>
parents:
88443
diff
changeset
|
10111 plist[6] = intern (":ascii-compatible-p"); |
|
a7b309f72920
(coding_alloc_by_making_gap): Check the case that the
Kenichi Handa <handa@m17n.org>
parents:
88443
diff
changeset
|
10112 plist[7] = args[coding_arg_ascii_compatible_p] = Qt; |
|
a7b309f72920
(coding_alloc_by_making_gap): Check the case that the
Kenichi Handa <handa@m17n.org>
parents:
88443
diff
changeset
|
10113 plist[8] = intern (":default-char"); |
|
a7b309f72920
(coding_alloc_by_making_gap): Check the case that the
Kenichi Handa <handa@m17n.org>
parents:
88443
diff
changeset
|
10114 plist[9] = args[coding_arg_default_char] = make_number (0); |
| 89483 | 10115 plist[10] = intern (":for-unibyte"); |
| 10116 plist[11] = args[coding_arg_for_unibyte] = Qt; | |
| 10117 plist[12] = intern (":docstring"); | |
| 10118 plist[13] = build_string ("Do no conversion.\n\ | |
|
88456
a7b309f72920
(coding_alloc_by_making_gap): Check the case that the
Kenichi Handa <handa@m17n.org>
parents:
88443
diff
changeset
|
10119 \n\ |
|
a7b309f72920
(coding_alloc_by_making_gap): Check the case that the
Kenichi Handa <handa@m17n.org>
parents:
88443
diff
changeset
|
10120 When you visit a file with this coding, the file is read into a\n\ |
|
a7b309f72920
(coding_alloc_by_making_gap): Check the case that the
Kenichi Handa <handa@m17n.org>
parents:
88443
diff
changeset
|
10121 unibyte buffer as is, thus each byte of a file is treated as a\n\ |
|
a7b309f72920
(coding_alloc_by_making_gap): Check the case that the
Kenichi Handa <handa@m17n.org>
parents:
88443
diff
changeset
|
10122 character."); |
| 89483 | 10123 plist[14] = intern (":eol-type"); |
| 10124 plist[15] = args[coding_arg_eol_type] = Qunix; | |
| 10125 args[coding_arg_plist] = Flist (16, plist); | |
|
88456
a7b309f72920
(coding_alloc_by_making_gap): Check the case that the
Kenichi Handa <handa@m17n.org>
parents:
88443
diff
changeset
|
10126 Fdefine_coding_system_internal (coding_arg_max, args); |
|
90011
26cef35a1562
(setup_coding_system): If coding_system is nil, use
Kenichi Handa <handa@m17n.org>
parents:
89976
diff
changeset
|
10127 |
|
26cef35a1562
(setup_coding_system): If coding_system is nil, use
Kenichi Handa <handa@m17n.org>
parents:
89976
diff
changeset
|
10128 plist[1] = args[coding_arg_name] = Qundecided; |
|
26cef35a1562
(setup_coding_system): If coding_system is nil, use
Kenichi Handa <handa@m17n.org>
parents:
89976
diff
changeset
|
10129 plist[3] = args[coding_arg_mnemonic] = make_number ('-'); |
|
26cef35a1562
(setup_coding_system): If coding_system is nil, use
Kenichi Handa <handa@m17n.org>
parents:
89976
diff
changeset
|
10130 plist[5] = args[coding_arg_coding_type] = Qundecided; |
|
26cef35a1562
(setup_coding_system): If coding_system is nil, use
Kenichi Handa <handa@m17n.org>
parents:
89976
diff
changeset
|
10131 /* This is already set. |
|
90214
460ee00505d5
(QCascii_compatible_p): New variable.
Kenichi Handa <handa@m17n.org>
parents:
90201
diff
changeset
|
10132 plist[7] = args[coding_arg_ascii_compatible_p] = Qt; */ |
|
90011
26cef35a1562
(setup_coding_system): If coding_system is nil, use
Kenichi Handa <handa@m17n.org>
parents:
89976
diff
changeset
|
10133 plist[8] = intern (":charset-list"); |
|
26cef35a1562
(setup_coding_system): If coding_system is nil, use
Kenichi Handa <handa@m17n.org>
parents:
89976
diff
changeset
|
10134 plist[9] = args[coding_arg_charset_list] = Fcons (Qascii, Qnil); |
|
26cef35a1562
(setup_coding_system): If coding_system is nil, use
Kenichi Handa <handa@m17n.org>
parents:
89976
diff
changeset
|
10135 plist[11] = args[coding_arg_for_unibyte] = Qnil; |
|
26cef35a1562
(setup_coding_system): If coding_system is nil, use
Kenichi Handa <handa@m17n.org>
parents:
89976
diff
changeset
|
10136 plist[13] = build_string ("No conversion on encoding, automatic conversion on decoding."); |
|
26cef35a1562
(setup_coding_system): If coding_system is nil, use
Kenichi Handa <handa@m17n.org>
parents:
89976
diff
changeset
|
10137 plist[15] = args[coding_arg_eol_type] = Qnil; |
|
26cef35a1562
(setup_coding_system): If coding_system is nil, use
Kenichi Handa <handa@m17n.org>
parents:
89976
diff
changeset
|
10138 args[coding_arg_plist] = Flist (16, plist); |
|
26cef35a1562
(setup_coding_system): If coding_system is nil, use
Kenichi Handa <handa@m17n.org>
parents:
89976
diff
changeset
|
10139 Fdefine_coding_system_internal (coding_arg_max, args); |
|
88456
a7b309f72920
(coding_alloc_by_making_gap): Check the case that the
Kenichi Handa <handa@m17n.org>
parents:
88443
diff
changeset
|
10140 } |
|
a7b309f72920
(coding_alloc_by_making_gap): Check the case that the
Kenichi Handa <handa@m17n.org>
parents:
88443
diff
changeset
|
10141 |
|
a7b309f72920
(coding_alloc_by_making_gap): Check the case that the
Kenichi Handa <handa@m17n.org>
parents:
88443
diff
changeset
|
10142 setup_coding_system (Qno_conversion, &safe_terminal_coding); |
|
89467
e911ca706166
(Fset_coding_system_priority): Doc fix. Update values
Kenichi Handa <handa@m17n.org>
parents:
89462
diff
changeset
|
10143 |
|
e911ca706166
(Fset_coding_system_priority): Doc fix. Update values
Kenichi Handa <handa@m17n.org>
parents:
89462
diff
changeset
|
10144 { |
|
e911ca706166
(Fset_coding_system_priority): Doc fix. Update values
Kenichi Handa <handa@m17n.org>
parents:
89462
diff
changeset
|
10145 int i; |
|
e911ca706166
(Fset_coding_system_priority): Doc fix. Update values
Kenichi Handa <handa@m17n.org>
parents:
89462
diff
changeset
|
10146 |
|
e911ca706166
(Fset_coding_system_priority): Doc fix. Update values
Kenichi Handa <handa@m17n.org>
parents:
89462
diff
changeset
|
10147 for (i = 0; i < coding_category_max; i++) |
|
e911ca706166
(Fset_coding_system_priority): Doc fix. Update values
Kenichi Handa <handa@m17n.org>
parents:
89462
diff
changeset
|
10148 Fset (AREF (Vcoding_category_table, i), Qno_conversion); |
|
e911ca706166
(Fset_coding_system_priority): Doc fix. Update values
Kenichi Handa <handa@m17n.org>
parents:
89462
diff
changeset
|
10149 } |
|
90394
263867fe7b55
(system_eol_type): Sync with HEAD.
Kenichi Handa <handa@m17n.org>
parents:
90380
diff
changeset
|
10150 #if defined (MSDOS) || defined (WINDOWSNT) |
|
263867fe7b55
(system_eol_type): Sync with HEAD.
Kenichi Handa <handa@m17n.org>
parents:
90380
diff
changeset
|
10151 system_eol_type = Qdos; |
|
263867fe7b55
(system_eol_type): Sync with HEAD.
Kenichi Handa <handa@m17n.org>
parents:
90380
diff
changeset
|
10152 #else |
|
263867fe7b55
(system_eol_type): Sync with HEAD.
Kenichi Handa <handa@m17n.org>
parents:
90380
diff
changeset
|
10153 system_eol_type = Qunix; |
|
263867fe7b55
(system_eol_type): Sync with HEAD.
Kenichi Handa <handa@m17n.org>
parents:
90380
diff
changeset
|
10154 #endif |
|
263867fe7b55
(system_eol_type): Sync with HEAD.
Kenichi Handa <handa@m17n.org>
parents:
90380
diff
changeset
|
10155 staticpro (&system_eol_type); |
| 17052 | 10156 } |
| 10157 | |
|
26088
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
26067
diff
changeset
|
10158 char * |
|
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
26067
diff
changeset
|
10159 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
|
10160 int error_number; |
|
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
26067
diff
changeset
|
10161 { |
|
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
26067
diff
changeset
|
10162 char *str; |
|
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
26067
diff
changeset
|
10163 |
|
26526
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26240
diff
changeset
|
10164 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
|
10165 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
|
10166 |
|
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
26067
diff
changeset
|
10167 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
|
10168 { |
|
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
26067
diff
changeset
|
10169 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
|
10170 Vlocale_coding_system, |
|
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
26067
diff
changeset
|
10171 0); |
|
46370
40db0673e6f0
Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents:
46293
diff
changeset
|
10172 str = (char *) SDATA (dec); |
|
26088
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
26067
diff
changeset
|
10173 } |
|
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
26067
diff
changeset
|
10174 |
|
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
26067
diff
changeset
|
10175 return str; |
|
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
26067
diff
changeset
|
10176 } |
|
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
26067
diff
changeset
|
10177 |
| 17052 | 10178 #endif /* emacs */ |
| 29184 | 10179 |
| 52401 | 10180 /* arch-tag: 3a3a2b01-5ff6-4071-9afe-f5b808d9229d |
| 10181 (do not change this comment) */ |
