Mercurial > emacs
annotate src/coding.c @ 89859:b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
(LOOKUP_TRANSLATION_TABLE): Pay attention that table may be a list.
| author | Kenichi Handa <handa@m17n.org> |
|---|---|
| date | Thu, 11 Mar 2004 07:07:41 +0000 |
| parents | 23cb9ed79225 |
| children | 7160ded23e55 |
| rev | line source |
|---|---|
| 88936 | 1 /* Coding system handler (conversion, detection, etc). |
| 20708 | 2 Copyright (C) 1995, 1997, 1998 Electrotechnical Laboratory, JAPAN. |
| 89483 | 3 Licensed to the Free Software Foundation. |
|
88862
108e2535280d
(adjust_coding_eol_type): Fix eol_type/eol_seen mixup.
Dave Love <fx@gnu.org>
parents:
88856
diff
changeset
|
4 Copyright (C) 2001, 2002 Free Software Foundation, Inc. |
| 89483 | 5 Copyright (C) 2003 |
| 88365 | 6 National Institute of Advanced Industrial Science and Technology (AIST) |
| 7 Registration Number H13PRO009 | |
| 17052 | 8 |
| 17071 | 9 This file is part of GNU Emacs. |
| 10 | |
| 11 GNU Emacs is free software; you can redistribute it and/or modify | |
| 12 it under the terms of the GNU General Public License as published by | |
| 13 the Free Software Foundation; either version 2, or (at your option) | |
| 14 any later version. | |
| 15 | |
| 16 GNU Emacs is distributed in the hope that it will be useful, | |
| 17 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 19 GNU General Public License for more details. | |
| 20 | |
| 21 You should have received a copy of the GNU General Public License | |
| 22 along with GNU Emacs; see the file COPYING. If not, write to | |
| 23 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
| 24 Boston, MA 02111-1307, USA. */ | |
| 17052 | 25 |
| 26 /*** TABLE OF CONTENTS *** | |
| 27 | |
|
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
28 0. General comments |
| 17052 | 29 1. Preamble |
| 88365 | 30 2. Emacs' internal format (emacs-utf-8) handlers |
| 31 3. UTF-8 handlers | |
| 32 4. UTF-16 handlers | |
| 33 5. Charset-base coding systems handlers | |
| 34 6. emacs-mule (old Emacs' internal format) handlers | |
| 35 7. ISO2022 handlers | |
| 36 8. Shift-JIS and BIG5 handlers | |
| 37 9. CCL handlers | |
| 38 10. C library functions | |
| 39 11. Emacs Lisp library functions | |
| 40 12. Postamble | |
| 17052 | 41 |
| 42 */ | |
| 43 | |
| 88365 | 44 /*** 0. General comments *** |
| 45 | |
| 46 | |
| 47 CODING SYSTEM | |
| 48 | |
| 88485 | 49 A coding system is an object for an encoding mechanism that contains |
| 50 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
|
51 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
|
52 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
|
53 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
|
54 `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
|
55 character sequence of emacs-utf-8 to a byte sequence of a specific |
|
3a34b722dd71
(encode_coding_utf_8): Initialize produced_chars to 0.
Kenichi Handa <handa@m17n.org>
parents:
88430
diff
changeset
|
56 coding system. |
|
3a34b722dd71
(encode_coding_utf_8): Initialize produced_chars to 0.
Kenichi Handa <handa@m17n.org>
parents:
88430
diff
changeset
|
57 |
|
3a34b722dd71
(encode_coding_utf_8): Initialize produced_chars to 0.
Kenichi Handa <handa@m17n.org>
parents:
88430
diff
changeset
|
58 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
|
59 C level, a coding system is represented by a vector of attributes |
| 88485 | 60 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
|
61 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
|
62 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
|
63 |
|
3a34b722dd71
(encode_coding_utf_8): Initialize produced_chars to 0.
Kenichi Handa <handa@m17n.org>
parents:
88430
diff
changeset
|
64 Coding systems are classified into the following types depending on |
| 88485 | 65 the encoding mechanism. Here's a brief description of the types. |
| 88365 | 66 |
| 67 o UTF-8 | |
| 68 | |
| 69 o UTF-16 | |
| 70 | |
| 71 o Charset-base coding system | |
| 72 | |
| 73 A coding system defined by one or more (coded) character sets. | |
| 88485 | 74 Decoding and encoding are done by a code converter defined for each |
| 88365 | 75 character set. |
| 76 | |
| 88485 | 77 o Old Emacs internal format (emacs-mule) |
| 78 | |
| 79 The coding system adopted by old versions of Emacs (20 and 21). | |
| 88365 | 80 |
| 81 o ISO2022-base coding system | |
| 17052 | 82 |
| 83 The most famous coding system for multiple character sets. X's | |
| 88365 | 84 Compound Text, various EUCs (Extended Unix Code), and coding systems |
| 85 used in the Internet communication such as ISO-2022-JP are all | |
| 86 variants of ISO2022. | |
| 87 | |
| 88 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
|
89 |
| 17052 | 90 A coding system to encode character sets: ASCII, JISX0201, and |
| 91 JISX0208. Widely used for PC's in Japan. Details are described in | |
| 88365 | 92 section 8. |
| 93 | |
| 94 o BIG5 | |
| 95 | |
| 96 A coding system to encode character sets: ASCII and Big5. Widely | |
| 88771 | 97 used for Chinese (mainly in Taiwan and Hong Kong). Details are |
| 88365 | 98 described in section 8. In this file, when we write "big5" (all |
| 99 lowercase), we mean the coding system, and when we write "Big5" | |
| 100 (capitalized), we mean the character set. | |
| 101 | |
| 102 o CCL | |
| 103 | |
| 88485 | 104 If a user wants to decode/encode text encoded in a coding system |
| 88365 | 105 not listed above, he can supply a decoder and an encoder for it in |
| 106 CCL (Code Conversion Language) programs. Emacs executes the CCL | |
| 107 program while decoding/encoding. | |
| 108 | |
| 109 o Raw-text | |
| 110 | |
| 88771 | 111 A coding system for text containing raw eight-bit data. Emacs |
| 88485 | 112 treats each byte of source text as a character (except for |
| 88365 | 113 end-of-line conversion). |
| 114 | |
| 115 o No-conversion | |
| 116 | |
| 117 Like raw text, but don't do end-of-line conversion. | |
| 118 | |
| 119 | |
| 120 END-OF-LINE FORMAT | |
| 121 | |
| 88485 | 122 How text end-of-line is encoded depends on operating system. For |
| 88365 | 123 instance, Unix's format is just one byte of LF (line-feed) code, |
| 18766 | 124 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
|
125 `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
|
126 `carriage-return'. |
| 17052 | 127 |
| 88485 | 128 Since text character encoding and end-of-line encoding are |
| 88365 | 129 independent, any coding system described above can take any format |
| 130 of end-of-line (except for no-conversion). | |
| 17052 | 131 |
|
88438
3a34b722dd71
(encode_coding_utf_8): Initialize produced_chars to 0.
Kenichi Handa <handa@m17n.org>
parents:
88430
diff
changeset
|
132 STRUCT CODING_SYSTEM |
|
3a34b722dd71
(encode_coding_utf_8): Initialize produced_chars to 0.
Kenichi Handa <handa@m17n.org>
parents:
88430
diff
changeset
|
133 |
|
3a34b722dd71
(encode_coding_utf_8): Initialize produced_chars to 0.
Kenichi Handa <handa@m17n.org>
parents:
88430
diff
changeset
|
134 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
|
135 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
|
136 This structure keeps various information about a specific code |
| 88485 | 137 conversion (e.g. the location of source and destination data). |
|
88438
3a34b722dd71
(encode_coding_utf_8): Initialize produced_chars to 0.
Kenichi Handa <handa@m17n.org>
parents:
88430
diff
changeset
|
138 |
| 17052 | 139 */ |
| 140 | |
| 88365 | 141 /* COMMON MACROS */ |
| 142 | |
| 143 | |
| 17052 | 144 /*** GENERAL NOTES on `detect_coding_XXX ()' functions *** |
| 145 | |
| 88365 | 146 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
|
147 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
|
148 DETECT_INFO. |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
149 |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
150 Return 1 if the byte sequence conforms to XXX, otherwise return 0. |
| 88365 | 151 |
| 152 Below is the template of these functions. */ | |
| 153 | |
| 17052 | 154 #if 0 |
| 88365 | 155 static int |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
156 detect_coding_XXX (coding, detect_info) |
| 88365 | 157 struct coding_system *coding; |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
158 struct coding_detection_info *detect_info; |
| 17052 | 159 { |
| 88365 | 160 unsigned char *src = coding->source; |
| 161 unsigned char *src_end = coding->source + coding->src_bytes; | |
| 162 int multibytep = coding->src_multibyte; | |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
163 int consumed_chars = 0; |
| 88365 | 164 int found = 0; |
| 165 ...; | |
| 166 | |
| 167 while (1) | |
| 168 { | |
| 169 /* Get one byte from the source. If the souce is exausted, jump | |
| 170 to no_more_source:. */ | |
| 171 ONE_MORE_BYTE (c); | |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
172 |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
173 if (! __C_conforms_to_XXX___ (c)) |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
174 break; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
175 if (! __C_strongly_suggests_XXX__ (c)) |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
176 found = CATEGORY_MASK_XXX; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
177 } |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
178 /* The byte sequence is invalid for XXX. */ |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
179 detect_info->rejected |= CATEGORY_MASK_XXX; |
| 88365 | 180 return 0; |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
181 |
| 88365 | 182 no_more_source: |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
183 /* The source exausted successfully. */ |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
184 detect_info->found |= found; |
| 88365 | 185 return 1; |
| 17052 | 186 } |
| 187 #endif | |
| 188 | |
| 189 /*** GENERAL NOTES on `decode_coding_XXX ()' functions *** | |
| 190 | |
| 88365 | 191 These functions decode a byte sequence specified as a source by |
| 192 CODING. The resulting multibyte text goes to a place pointed to by | |
| 193 CODING->charbuf, the length of which should not exceed | |
| 194 CODING->charbuf_size; | |
| 195 | |
| 196 These functions set the information of original and decoded texts in | |
| 197 CODING->consumed, CODING->consumed_char, and CODING->charbuf_used. | |
| 198 They also set CODING->result to one of CODING_RESULT_XXX indicating | |
| 199 how the decoding is finished. | |
| 200 | |
| 201 Below is the template of these functions. */ | |
| 202 | |
| 17052 | 203 #if 0 |
|
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
204 static void |
| 88365 | 205 decode_coding_XXXX (coding) |
| 17052 | 206 struct coding_system *coding; |
| 207 { | |
| 88365 | 208 unsigned char *src = coding->source + coding->consumed; |
| 209 unsigned char *src_end = coding->source + coding->src_bytes; | |
| 210 /* SRC_BASE remembers the start position in source in each loop. | |
| 211 The loop will be exited when there's not enough source code, or | |
| 212 when there's no room in CHARBUF for a decoded character. */ | |
| 213 unsigned char *src_base; | |
| 214 /* 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
|
215 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
|
216 int *charbuf_end = coding->charbuf + coding->charbuf_size; |
| 88365 | 217 int multibytep = coding->src_multibyte; |
| 218 | |
| 219 while (1) | |
| 220 { | |
| 221 src_base = src; | |
| 222 if (charbuf < charbuf_end) | |
| 223 /* No more room to produce a decoded character. */ | |
| 224 break; | |
| 225 ONE_MORE_BYTE (c); | |
| 226 /* Decode it. */ | |
| 227 } | |
| 228 | |
| 229 no_more_source: | |
| 230 if (src_base < src_end | |
| 231 && coding->mode & CODING_MODE_LAST_BLOCK) | |
| 232 /* If the source ends by partial bytes to construct a character, | |
| 233 treat them as eight-bit raw data. */ | |
| 234 while (src_base < src_end && charbuf < charbuf_end) | |
| 235 *charbuf++ = *src_base++; | |
| 236 /* Remember how many bytes and characters we consumed. If the | |
| 237 source is multibyte, the bytes and chars are not identical. */ | |
| 238 coding->consumed = coding->consumed_char = src_base - coding->source; | |
| 239 /* Remember how many characters we produced. */ | |
| 240 coding->charbuf_used = charbuf - coding->charbuf; | |
| 17052 | 241 } |
| 242 #endif | |
| 243 | |
| 244 /*** GENERAL NOTES on `encode_coding_XXX ()' functions *** | |
| 245 | |
| 88365 | 246 These functions encode SRC_BYTES length text at SOURCE of Emacs' |
| 247 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
|
248 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
|
249 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
|
250 |
| 88365 | 251 These functions set the information of original and encoded texts in |
| 252 the members produced, produced_char, consumed, and consumed_char of | |
| 253 the structure *CODING. They also set the member result to one of | |
| 254 CODING_RESULT_XXX indicating how the encoding finished. | |
| 255 | |
| 256 DST_BYTES zero means that source area and destination area are | |
| 257 overlapped, which means that we can produce a encoded text until it | |
| 258 reaches at the head of not-yet-encoded source text. | |
| 259 | |
| 260 Below is a template of these functions. */ | |
| 17052 | 261 #if 0 |
|
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
262 static void |
| 88365 | 263 encode_coding_XXX (coding) |
| 17052 | 264 struct coding_system *coding; |
| 265 { | |
| 88365 | 266 int multibytep = coding->dst_multibyte; |
| 267 int *charbuf = coding->charbuf; | |
| 268 int *charbuf_end = charbuf->charbuf + coding->charbuf_used; | |
| 269 unsigned char *dst = coding->destination + coding->produced; | |
| 270 unsigned char *dst_end = coding->destination + coding->dst_bytes; | |
| 271 unsigned char *adjusted_dst_end = dst_end - _MAX_BYTES_PRODUCED_IN_LOOP_; | |
| 272 int produced_chars = 0; | |
| 273 | |
| 274 for (; charbuf < charbuf_end && dst < adjusted_dst_end; charbuf++) | |
| 275 { | |
| 276 int c = *charbuf; | |
| 277 /* Encode C into DST, and increment DST. */ | |
| 278 } | |
| 279 label_no_more_destination: | |
| 280 /* How many chars and bytes we produced. */ | |
| 281 coding->produced_char += produced_chars; | |
| 282 coding->produced = dst - coding->destination; | |
| 17052 | 283 } |
| 284 #endif | |
| 285 | |
| 286 | |
| 287 /*** 1. Preamble ***/ | |
| 288 | |
|
26088
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
26067
diff
changeset
|
289 #include <config.h> |
| 17052 | 290 #include <stdio.h> |
| 291 | |
| 292 #include "lisp.h" | |
| 293 #include "buffer.h" | |
| 88365 | 294 #include "character.h" |
| 17052 | 295 #include "charset.h" |
| 88365 | 296 #include "ccl.h" |
| 26847 | 297 #include "composite.h" |
| 17052 | 298 #include "coding.h" |
| 299 #include "window.h" | |
| 300 | |
| 88365 | 301 Lisp_Object Vcoding_system_hash_table; |
| 302 | |
| 303 Lisp_Object Qcoding_system, Qcoding_aliases, Qeol_type; | |
|
88646
d3b1f30e2267
(Qmac): Remove (duplicated) definition.
Dave Love <fx@gnu.org>
parents:
88645
diff
changeset
|
304 Lisp_Object Qunix, Qdos; |
|
d3b1f30e2267
(Qmac): Remove (duplicated) definition.
Dave Love <fx@gnu.org>
parents:
88645
diff
changeset
|
305 extern Lisp_Object Qmac; /* frame.c */ |
| 17052 | 306 Lisp_Object Qbuffer_file_coding_system; |
| 307 Lisp_Object Qpost_read_conversion, Qpre_write_conversion; | |
| 88365 | 308 Lisp_Object Qdefault_char; |
|
19612
783efd6c7c1e
(Qno_conversion, Qundecided): New variables.
Kenichi Handa <handa@m17n.org>
parents:
19546
diff
changeset
|
309 Lisp_Object Qno_conversion, Qundecided; |
| 88365 | 310 Lisp_Object Qcharset, Qiso_2022, Qutf_8, Qutf_16, Qshift_jis, Qbig5; |
|
89420
c3e67ce6ee0f
(Qsignature, Qendian): Delete these variables.
Kenichi Handa <handa@m17n.org>
parents:
89418
diff
changeset
|
311 Lisp_Object Qbig, Qlittle; |
|
19750
95e4e1cba6ac
(Qcoding_system_history): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
19747
diff
changeset
|
312 Lisp_Object Qcoding_system_history; |
|
22874
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
313 Lisp_Object Qvalid_codes; |
|
89759
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
314 Lisp_Object QCcategory, QCmnemonic, QCdefalut_char; |
|
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
315 Lisp_Object QCdecode_translation_table, QCencode_translation_table; |
|
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
316 Lisp_Object QCpost_read_conversion, QCpre_write_conversion; |
| 17052 | 317 |
| 318 extern Lisp_Object Qinsert_file_contents, Qwrite_region; | |
| 319 Lisp_Object Qcall_process, Qcall_process_region, Qprocess_argument; | |
| 320 Lisp_Object Qstart_process, Qopen_network_stream; | |
| 321 Lisp_Object Qtarget_idx; | |
| 322 | |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
323 Lisp_Object Qinsufficient_source, Qinconsistent_eol, Qinvalid_source; |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
324 Lisp_Object Qinterrupted, Qinsufficient_memory; |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
325 |
| 89483 | 326 int coding_system_require_warning; |
| 327 | |
|
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
328 Lisp_Object Vselect_safe_coding_system_function; |
|
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
329 |
|
24200
b9d9fccad516
(syms_of_coding): eol-mnemonic-* variables are now
Eli Zaretskii <eliz@gnu.org>
parents:
24178
diff
changeset
|
330 /* 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
|
331 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
|
332 /* Mnemonic string to indicate format of end-of-line is not yet |
| 17052 | 333 decided. */ |
|
24200
b9d9fccad516
(syms_of_coding): eol-mnemonic-* variables are now
Eli Zaretskii <eliz@gnu.org>
parents:
24178
diff
changeset
|
334 Lisp_Object eol_mnemonic_undecided; |
| 17052 | 335 |
| 336 #ifdef emacs | |
| 337 | |
|
20105
c017642863c2
(Qcoding_system_spec): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
19824
diff
changeset
|
338 Lisp_Object Vcoding_system_list, Vcoding_system_alist; |
|
c017642863c2
(Qcoding_system_spec): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
19824
diff
changeset
|
339 |
|
c017642863c2
(Qcoding_system_spec): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
19824
diff
changeset
|
340 Lisp_Object Qcoding_system_p, Qcoding_system_error; |
| 17052 | 341 |
|
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
342 /* 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
|
343 end-of-line format. */ |
|
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
344 Lisp_Object Qemacs_mule, Qraw_text; |
| 89483 | 345 Lisp_Object Qutf_8_emacs; |
|
18650
aa3f2820e2ac
(Qemacs_mule, inhibit_eol_conversion): New variables.
Kenichi Handa <handa@m17n.org>
parents:
18613
diff
changeset
|
346 |
| 17052 | 347 /* Coding-systems are handed between Emacs Lisp programs and C internal |
| 348 routines by the following three variables. */ | |
| 349 /* Coding-system for reading files and receiving data from process. */ | |
| 350 Lisp_Object Vcoding_system_for_read; | |
| 351 /* Coding-system for writing files and sending data to process. */ | |
| 352 Lisp_Object Vcoding_system_for_write; | |
| 353 /* Coding-system actually used in the latest I/O. */ | |
| 354 Lisp_Object Vlast_coding_system_used; | |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
355 /* 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
|
356 Lisp_Object Vlast_code_conversion_error; |
|
19280
e755044718ee
(ENCODE_ISO_CHARACTER_DIMENSION1): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
19193
diff
changeset
|
357 /* A vector of length 256 which contains information about special |
| 22529 | 358 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
|
359 Lisp_Object Vlatin_extra_code_table; |
|
19280
e755044718ee
(ENCODE_ISO_CHARACTER_DIMENSION1): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
19193
diff
changeset
|
360 |
|
18650
aa3f2820e2ac
(Qemacs_mule, inhibit_eol_conversion): New variables.
Kenichi Handa <handa@m17n.org>
parents:
18613
diff
changeset
|
361 /* 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
|
362 int inhibit_eol_conversion; |
|
aa3f2820e2ac
(Qemacs_mule, inhibit_eol_conversion): New variables.
Kenichi Handa <handa@m17n.org>
parents:
18613
diff
changeset
|
363 |
|
30204
35aec8514228
(inhibit_iso_escape_detection): New variable.
Kenichi Handa <handa@m17n.org>
parents:
29985
diff
changeset
|
364 /* Flag to inhibit ISO2022 escape sequence detection. */ |
|
35aec8514228
(inhibit_iso_escape_detection): New variable.
Kenichi Handa <handa@m17n.org>
parents:
29985
diff
changeset
|
365 int inhibit_iso_escape_detection; |
|
35aec8514228
(inhibit_iso_escape_detection): New variable.
Kenichi Handa <handa@m17n.org>
parents:
29985
diff
changeset
|
366 |
|
21574
30394e3ae7f8
(syms_of_coding): Declare and define inherit-process-coding-system.
Eli Zaretskii <eliz@gnu.org>
parents:
21520
diff
changeset
|
367 /* 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
|
368 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
|
369 |
|
19280
e755044718ee
(ENCODE_ISO_CHARACTER_DIMENSION1): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
19193
diff
changeset
|
370 /* Coding system to be used to encode text for terminal display. */ |
| 17052 | 371 struct coding_system terminal_coding; |
| 372 | |
|
19280
e755044718ee
(ENCODE_ISO_CHARACTER_DIMENSION1): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
19193
diff
changeset
|
373 /* 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
|
374 terminal coding system is nil. */ |
|
e755044718ee
(ENCODE_ISO_CHARACTER_DIMENSION1): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
19193
diff
changeset
|
375 struct coding_system safe_terminal_coding; |
|
e755044718ee
(ENCODE_ISO_CHARACTER_DIMENSION1): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
19193
diff
changeset
|
376 |
|
e755044718ee
(ENCODE_ISO_CHARACTER_DIMENSION1): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
19193
diff
changeset
|
377 /* Coding system of what is sent from terminal keyboard. */ |
| 17052 | 378 struct coding_system keyboard_coding; |
| 379 | |
|
18180
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
380 Lisp_Object Vfile_coding_system_alist; |
|
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
381 Lisp_Object Vprocess_coding_system_alist; |
|
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
382 Lisp_Object Vnetwork_coding_system_alist; |
| 17052 | 383 |
|
26088
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
26067
diff
changeset
|
384 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
|
385 |
| 17052 | 386 #endif /* emacs */ |
| 387 | |
|
22186
fc4aaf1b1772
Change term "character translation table" to "translation table".
Kenichi Handa <handa@m17n.org>
parents:
22166
diff
changeset
|
388 /* 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
|
389 conversion. */ |
|
22119
592bb8b9bcfd
Change terms unify/unification to
Kenichi Handa <handa@m17n.org>
parents:
22020
diff
changeset
|
390 Lisp_Object Venable_character_translation; |
|
22186
fc4aaf1b1772
Change term "character translation table" to "translation table".
Kenichi Handa <handa@m17n.org>
parents:
22166
diff
changeset
|
391 /* 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
|
392 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
|
393 /* 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
|
394 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
|
395 |
|
fc4aaf1b1772
Change term "character translation table" to "translation table".
Kenichi Handa <handa@m17n.org>
parents:
22166
diff
changeset
|
396 Lisp_Object Qtranslation_table; |
|
fc4aaf1b1772
Change term "character translation table" to "translation table".
Kenichi Handa <handa@m17n.org>
parents:
22166
diff
changeset
|
397 Lisp_Object Qtranslation_table_id; |
|
fc4aaf1b1772
Change term "character translation table" to "translation table".
Kenichi Handa <handa@m17n.org>
parents:
22166
diff
changeset
|
398 Lisp_Object Qtranslation_table_for_decode; |
|
fc4aaf1b1772
Change term "character translation table" to "translation table".
Kenichi Handa <handa@m17n.org>
parents:
22166
diff
changeset
|
399 Lisp_Object Qtranslation_table_for_encode; |
| 17052 | 400 |
| 401 /* Alist of charsets vs revision number. */ | |
| 88365 | 402 static Lisp_Object Vcharset_revision_table; |
| 17052 | 403 |
|
18180
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
404 /* Default coding systems used for process I/O. */ |
|
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
405 Lisp_Object Vdefault_process_coding_system; |
|
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
406 |
|
48182
9474e269efd1
Reformat some DEFUNs so that etags works.
Dave Love <fx@gnu.org>
parents:
48125
diff
changeset
|
407 /* 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
|
408 Lisp_Object Vtranslation_table_for_input; |
|
9474e269efd1
Reformat some DEFUNs so that etags works.
Dave Love <fx@gnu.org>
parents:
48125
diff
changeset
|
409 |
| 88365 | 410 /* Two special coding systems. */ |
| 411 Lisp_Object Vsjis_coding_system; | |
| 412 Lisp_Object Vbig5_coding_system; | |
| 413 | |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
414 static void record_conversion_result (struct coding_system *coding, |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
415 enum coding_result_code result); |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
416 static int detect_coding_utf_8 P_ ((struct coding_system *, |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
417 struct coding_detection_info *info)); |
| 88365 | 418 static void decode_coding_utf_8 P_ ((struct coding_system *)); |
| 419 static int encode_coding_utf_8 P_ ((struct coding_system *)); | |
| 420 | |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
421 static int detect_coding_utf_16 P_ ((struct coding_system *, |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
422 struct coding_detection_info *info)); |
| 88365 | 423 static void decode_coding_utf_16 P_ ((struct coding_system *)); |
| 424 static int encode_coding_utf_16 P_ ((struct coding_system *)); | |
| 425 | |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
426 static int detect_coding_iso_2022 P_ ((struct coding_system *, |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
427 struct coding_detection_info *info)); |
| 88365 | 428 static void decode_coding_iso_2022 P_ ((struct coding_system *)); |
| 429 static int encode_coding_iso_2022 P_ ((struct coding_system *)); | |
| 430 | |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
431 static int detect_coding_emacs_mule P_ ((struct coding_system *, |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
432 struct coding_detection_info *info)); |
| 88365 | 433 static void decode_coding_emacs_mule P_ ((struct coding_system *)); |
| 434 static int encode_coding_emacs_mule P_ ((struct coding_system *)); | |
| 435 | |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
436 static int detect_coding_sjis P_ ((struct coding_system *, |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
437 struct coding_detection_info *info)); |
| 88365 | 438 static void decode_coding_sjis P_ ((struct coding_system *)); |
| 439 static int encode_coding_sjis P_ ((struct coding_system *)); | |
| 440 | |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
441 static int detect_coding_big5 P_ ((struct coding_system *, |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
442 struct coding_detection_info *info)); |
| 88365 | 443 static void decode_coding_big5 P_ ((struct coding_system *)); |
| 444 static int encode_coding_big5 P_ ((struct coding_system *)); | |
| 445 | |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
446 static int detect_coding_ccl P_ ((struct coding_system *, |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
447 struct coding_detection_info *info)); |
| 88365 | 448 static void decode_coding_ccl P_ ((struct coding_system *)); |
| 449 static int encode_coding_ccl P_ ((struct coding_system *)); | |
| 450 | |
| 451 static void decode_coding_raw_text P_ ((struct coding_system *)); | |
| 452 static int encode_coding_raw_text P_ ((struct coding_system *)); | |
| 453 | |
| 454 | |
| 455 /* ISO2022 section */ | |
| 456 | |
| 457 #define CODING_ISO_INITIAL(coding, reg) \ | |
| 458 (XINT (AREF (AREF (CODING_ID_ATTRS ((coding)->id), \ | |
| 459 coding_attr_iso_initial), \ | |
| 460 reg))) | |
| 461 | |
| 462 | |
| 463 #define CODING_ISO_REQUEST(coding, charset_id) \ | |
| 464 ((charset_id <= (coding)->max_charset_id \ | |
| 465 ? (coding)->safe_charsets[charset_id] \ | |
| 466 : -1)) | |
| 467 | |
| 468 | |
| 469 #define CODING_ISO_FLAGS(coding) \ | |
| 470 ((coding)->spec.iso_2022.flags) | |
| 471 #define CODING_ISO_DESIGNATION(coding, reg) \ | |
| 472 ((coding)->spec.iso_2022.current_designation[reg]) | |
| 473 #define CODING_ISO_INVOCATION(coding, plane) \ | |
| 474 ((coding)->spec.iso_2022.current_invocation[plane]) | |
| 475 #define CODING_ISO_SINGLE_SHIFTING(coding) \ | |
| 476 ((coding)->spec.iso_2022.single_shifting) | |
| 477 #define CODING_ISO_BOL(coding) \ | |
| 478 ((coding)->spec.iso_2022.bol) | |
| 479 #define CODING_ISO_INVOKED_CHARSET(coding, plane) \ | |
| 480 CODING_ISO_DESIGNATION ((coding), CODING_ISO_INVOCATION ((coding), (plane))) | |
| 481 | |
| 482 /* Control characters of ISO2022. */ | |
| 483 /* code */ /* function */ | |
| 484 #define ISO_CODE_LF 0x0A /* line-feed */ | |
| 485 #define ISO_CODE_CR 0x0D /* carriage-return */ | |
| 486 #define ISO_CODE_SO 0x0E /* shift-out */ | |
| 487 #define ISO_CODE_SI 0x0F /* shift-in */ | |
| 488 #define ISO_CODE_SS2_7 0x19 /* single-shift-2 for 7-bit code */ | |
| 489 #define ISO_CODE_ESC 0x1B /* escape */ | |
| 490 #define ISO_CODE_SS2 0x8E /* single-shift-2 */ | |
| 491 #define ISO_CODE_SS3 0x8F /* single-shift-3 */ | |
| 492 #define ISO_CODE_CSI 0x9B /* control-sequence-introducer */ | |
| 493 | |
| 494 /* All code (1-byte) of ISO2022 is classified into one of the | |
| 495 followings. */ | |
| 496 enum iso_code_class_type | |
| 497 { | |
| 498 ISO_control_0, /* Control codes in the range | |
| 499 0x00..0x1F and 0x7F, except for the | |
| 500 following 5 codes. */ | |
| 501 ISO_shift_out, /* ISO_CODE_SO (0x0E) */ | |
| 502 ISO_shift_in, /* ISO_CODE_SI (0x0F) */ | |
| 503 ISO_single_shift_2_7, /* ISO_CODE_SS2_7 (0x19) */ | |
| 504 ISO_escape, /* ISO_CODE_SO (0x1B) */ | |
| 505 ISO_control_1, /* Control codes in the range | |
| 506 0x80..0x9F, except for the | |
| 507 following 3 codes. */ | |
| 508 ISO_single_shift_2, /* ISO_CODE_SS2 (0x8E) */ | |
| 509 ISO_single_shift_3, /* ISO_CODE_SS3 (0x8F) */ | |
| 510 ISO_control_sequence_introducer, /* ISO_CODE_CSI (0x9B) */ | |
| 511 ISO_0x20_or_0x7F, /* Codes of the values 0x20 or 0x7F. */ | |
| 512 ISO_graphic_plane_0, /* Graphic codes in the range 0x21..0x7E. */ | |
| 513 ISO_0xA0_or_0xFF, /* Codes of the values 0xA0 or 0xFF. */ | |
| 514 ISO_graphic_plane_1 /* Graphic codes in the range 0xA1..0xFE. */ | |
| 515 }; | |
| 516 | |
| 517 /** The macros CODING_ISO_FLAG_XXX defines a flag bit of the | |
| 518 `iso-flags' attribute of an iso2022 coding system. */ | |
| 519 | |
| 520 /* If set, produce long-form designation sequence (e.g. ESC $ ( A) | |
| 521 instead of the correct short-form sequence (e.g. ESC $ A). */ | |
| 522 #define CODING_ISO_FLAG_LONG_FORM 0x0001 | |
| 523 | |
| 524 /* If set, reset graphic planes and registers at end-of-line to the | |
| 525 initial state. */ | |
| 526 #define CODING_ISO_FLAG_RESET_AT_EOL 0x0002 | |
| 527 | |
| 528 /* If set, reset graphic planes and registers before any control | |
| 529 characters to the initial state. */ | |
| 530 #define CODING_ISO_FLAG_RESET_AT_CNTL 0x0004 | |
| 531 | |
| 532 /* If set, encode by 7-bit environment. */ | |
| 533 #define CODING_ISO_FLAG_SEVEN_BITS 0x0008 | |
| 534 | |
| 535 /* If set, use locking-shift function. */ | |
| 536 #define CODING_ISO_FLAG_LOCKING_SHIFT 0x0010 | |
| 537 | |
| 538 /* If set, use single-shift function. Overwrite | |
| 539 CODING_ISO_FLAG_LOCKING_SHIFT. */ | |
| 540 #define CODING_ISO_FLAG_SINGLE_SHIFT 0x0020 | |
| 541 | |
| 542 /* If set, use designation escape sequence. */ | |
| 543 #define CODING_ISO_FLAG_DESIGNATION 0x0040 | |
| 544 | |
| 545 /* If set, produce revision number sequence. */ | |
| 546 #define CODING_ISO_FLAG_REVISION 0x0080 | |
| 547 | |
| 548 /* If set, produce ISO6429's direction specifying sequence. */ | |
| 549 #define CODING_ISO_FLAG_DIRECTION 0x0100 | |
| 550 | |
| 551 /* If set, assume designation states are reset at beginning of line on | |
| 552 output. */ | |
| 553 #define CODING_ISO_FLAG_INIT_AT_BOL 0x0200 | |
| 554 | |
| 555 /* If set, designation sequence should be placed at beginning of line | |
| 556 on output. */ | |
| 557 #define CODING_ISO_FLAG_DESIGNATE_AT_BOL 0x0400 | |
| 558 | |
| 559 /* If set, do not encode unsafe charactes on output. */ | |
| 560 #define CODING_ISO_FLAG_SAFE 0x0800 | |
| 561 | |
| 562 /* If set, extra latin codes (128..159) are accepted as a valid code | |
| 563 on input. */ | |
| 564 #define CODING_ISO_FLAG_LATIN_EXTRA 0x1000 | |
| 565 | |
| 566 #define CODING_ISO_FLAG_COMPOSITION 0x2000 | |
| 567 | |
| 568 #define CODING_ISO_FLAG_EUC_TW_SHIFT 0x4000 | |
| 569 | |
|
88681
2cdfbffa8a0d
(CODING_ISO_FLAG_USE_ROMAN): New macro
Kenichi Handa <handa@m17n.org>
parents:
88669
diff
changeset
|
570 #define CODING_ISO_FLAG_USE_ROMAN 0x8000 |
|
2cdfbffa8a0d
(CODING_ISO_FLAG_USE_ROMAN): New macro
Kenichi Handa <handa@m17n.org>
parents:
88669
diff
changeset
|
571 |
|
2cdfbffa8a0d
(CODING_ISO_FLAG_USE_ROMAN): New macro
Kenichi Handa <handa@m17n.org>
parents:
88669
diff
changeset
|
572 #define CODING_ISO_FLAG_USE_OLDJIS 0x10000 |
|
2cdfbffa8a0d
(CODING_ISO_FLAG_USE_ROMAN): New macro
Kenichi Handa <handa@m17n.org>
parents:
88669
diff
changeset
|
573 |
|
2cdfbffa8a0d
(CODING_ISO_FLAG_USE_ROMAN): New macro
Kenichi Handa <handa@m17n.org>
parents:
88669
diff
changeset
|
574 #define CODING_ISO_FLAG_FULL_SUPPORT 0x100000 |
| 88365 | 575 |
| 576 /* A character to be produced on output if encoding of the original | |
| 577 character is prohibited by CODING_ISO_FLAG_SAFE. */ | |
| 578 #define CODING_INHIBIT_CHARACTER_SUBSTITUTION '?' | |
| 579 | |
| 580 | |
| 581 /* UTF-16 section */ | |
| 582 #define CODING_UTF_16_BOM(coding) \ | |
| 583 ((coding)->spec.utf_16.bom) | |
| 584 | |
| 585 #define CODING_UTF_16_ENDIAN(coding) \ | |
| 586 ((coding)->spec.utf_16.endian) | |
| 587 | |
| 588 #define CODING_UTF_16_SURROGATE(coding) \ | |
| 589 ((coding)->spec.utf_16.surrogate) | |
| 590 | |
| 591 | |
| 592 /* CCL section */ | |
| 593 #define CODING_CCL_DECODER(coding) \ | |
| 594 AREF (CODING_ID_ATTRS ((coding)->id), coding_attr_ccl_decoder) | |
| 595 #define CODING_CCL_ENCODER(coding) \ | |
| 596 AREF (CODING_ID_ATTRS ((coding)->id), coding_attr_ccl_encoder) | |
| 597 #define CODING_CCL_VALIDS(coding) \ | |
| 89483 | 598 (SDATA (AREF (CODING_ID_ATTRS ((coding)->id), coding_attr_ccl_valids))) |
| 88365 | 599 |
| 88771 | 600 /* Index for each coding category in `coding_categories' */ |
| 88365 | 601 |
| 602 enum coding_category | |
| 603 { | |
| 604 coding_category_iso_7, | |
| 605 coding_category_iso_7_tight, | |
| 606 coding_category_iso_8_1, | |
| 607 coding_category_iso_8_2, | |
| 608 coding_category_iso_7_else, | |
| 609 coding_category_iso_8_else, | |
| 610 coding_category_utf_8, | |
| 611 coding_category_utf_16_auto, | |
| 612 coding_category_utf_16_be, | |
| 613 coding_category_utf_16_le, | |
| 614 coding_category_utf_16_be_nosig, | |
| 615 coding_category_utf_16_le_nosig, | |
| 616 coding_category_charset, | |
| 617 coding_category_sjis, | |
| 618 coding_category_big5, | |
| 619 coding_category_ccl, | |
| 620 coding_category_emacs_mule, | |
| 621 /* All above are targets of code detection. */ | |
| 622 coding_category_raw_text, | |
| 623 coding_category_undecided, | |
| 624 coding_category_max | |
| 625 }; | |
| 626 | |
| 627 /* Definitions of flag bits used in detect_coding_XXXX. */ | |
| 628 #define CATEGORY_MASK_ISO_7 (1 << coding_category_iso_7) | |
| 629 #define CATEGORY_MASK_ISO_7_TIGHT (1 << coding_category_iso_7_tight) | |
| 630 #define CATEGORY_MASK_ISO_8_1 (1 << coding_category_iso_8_1) | |
| 631 #define CATEGORY_MASK_ISO_8_2 (1 << coding_category_iso_8_2) | |
| 632 #define CATEGORY_MASK_ISO_7_ELSE (1 << coding_category_iso_7_else) | |
| 633 #define CATEGORY_MASK_ISO_8_ELSE (1 << coding_category_iso_8_else) | |
| 634 #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
|
635 #define CATEGORY_MASK_UTF_16_AUTO (1 << coding_category_utf_16_auto) |
| 88365 | 636 #define CATEGORY_MASK_UTF_16_BE (1 << coding_category_utf_16_be) |
| 637 #define CATEGORY_MASK_UTF_16_LE (1 << coding_category_utf_16_le) | |
| 638 #define CATEGORY_MASK_UTF_16_BE_NOSIG (1 << coding_category_utf_16_be_nosig) | |
| 639 #define CATEGORY_MASK_UTF_16_LE_NOSIG (1 << coding_category_utf_16_le_nosig) | |
| 640 #define CATEGORY_MASK_CHARSET (1 << coding_category_charset) | |
| 641 #define CATEGORY_MASK_SJIS (1 << coding_category_sjis) | |
| 642 #define CATEGORY_MASK_BIG5 (1 << coding_category_big5) | |
| 643 #define CATEGORY_MASK_CCL (1 << coding_category_ccl) | |
| 644 #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
|
645 #define CATEGORY_MASK_RAW_TEXT (1 << coding_category_raw_text) |
| 88365 | 646 |
| 647 /* This value is returned if detect_coding_mask () find nothing other | |
| 648 than ASCII characters. */ | |
| 649 #define CATEGORY_MASK_ANY \ | |
| 650 (CATEGORY_MASK_ISO_7 \ | |
| 651 | CATEGORY_MASK_ISO_7_TIGHT \ | |
| 652 | CATEGORY_MASK_ISO_8_1 \ | |
| 653 | CATEGORY_MASK_ISO_8_2 \ | |
| 654 | CATEGORY_MASK_ISO_7_ELSE \ | |
| 655 | CATEGORY_MASK_ISO_8_ELSE \ | |
| 656 | CATEGORY_MASK_UTF_8 \ | |
| 657 | CATEGORY_MASK_UTF_16_BE \ | |
| 658 | CATEGORY_MASK_UTF_16_LE \ | |
| 659 | CATEGORY_MASK_UTF_16_BE_NOSIG \ | |
| 660 | CATEGORY_MASK_UTF_16_LE_NOSIG \ | |
| 661 | CATEGORY_MASK_CHARSET \ | |
| 662 | CATEGORY_MASK_SJIS \ | |
| 663 | CATEGORY_MASK_BIG5 \ | |
| 664 | CATEGORY_MASK_CCL \ | |
| 665 | CATEGORY_MASK_EMACS_MULE) | |
| 666 | |
| 667 | |
| 668 #define CATEGORY_MASK_ISO_7BIT \ | |
| 669 (CATEGORY_MASK_ISO_7 | CATEGORY_MASK_ISO_7_TIGHT) | |
| 670 | |
| 671 #define CATEGORY_MASK_ISO_8BIT \ | |
| 672 (CATEGORY_MASK_ISO_8_1 | CATEGORY_MASK_ISO_8_2) | |
| 673 | |
| 674 #define CATEGORY_MASK_ISO_ELSE \ | |
| 675 (CATEGORY_MASK_ISO_7_ELSE | CATEGORY_MASK_ISO_8_ELSE) | |
| 676 | |
| 677 #define CATEGORY_MASK_ISO_ESCAPE \ | |
| 678 (CATEGORY_MASK_ISO_7 \ | |
| 679 | CATEGORY_MASK_ISO_7_TIGHT \ | |
| 680 | CATEGORY_MASK_ISO_7_ELSE \ | |
| 681 | CATEGORY_MASK_ISO_8_ELSE) | |
| 682 | |
| 683 #define CATEGORY_MASK_ISO \ | |
| 684 ( CATEGORY_MASK_ISO_7BIT \ | |
| 685 | CATEGORY_MASK_ISO_8BIT \ | |
| 686 | CATEGORY_MASK_ISO_ELSE) | |
| 687 | |
| 688 #define CATEGORY_MASK_UTF_16 \ | |
| 689 (CATEGORY_MASK_UTF_16_BE \ | |
| 690 | CATEGORY_MASK_UTF_16_LE \ | |
| 691 | CATEGORY_MASK_UTF_16_BE_NOSIG \ | |
| 692 | CATEGORY_MASK_UTF_16_LE_NOSIG) | |
| 693 | |
| 694 | |
| 695 /* List of symbols `coding-category-xxx' ordered by priority. This | |
| 696 variable is exposed to Emacs Lisp. */ | |
| 697 static Lisp_Object Vcoding_category_list; | |
| 698 | |
| 699 /* Table of coding categories (Lisp symbols). This variable is for | |
| 700 internal use oly. */ | |
| 701 static Lisp_Object Vcoding_category_table; | |
| 702 | |
| 703 /* Table of coding-categories ordered by priority. */ | |
| 704 static enum coding_category coding_priorities[coding_category_max]; | |
| 705 | |
| 706 /* Nth element is a coding context for the coding system bound to the | |
| 707 Nth coding category. */ | |
| 708 static struct coding_system coding_categories[coding_category_max]; | |
| 709 | |
| 710 /*** Commonly used macros and functions ***/ | |
| 711 | |
| 712 #ifndef min | |
| 713 #define min(a, b) ((a) < (b) ? (a) : (b)) | |
| 714 #endif | |
| 715 #ifndef max | |
| 716 #define max(a, b) ((a) > (b) ? (a) : (b)) | |
| 717 #endif | |
| 718 | |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
719 #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
|
720 do { \ |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
721 (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
|
722 (charset_list) = CODING_ATTR_CHARSET_LIST (attrs); \ |
| 88365 | 723 } while (0) |
| 724 | |
| 725 | |
| 726 /* Safely get one byte from the source text pointed by SRC which ends | |
| 727 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
|
728 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
|
729 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
|
730 negative value of the character code. The caller should declare |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
731 and set these variables appropriately in advance: |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
732 src, src_end, multibytep */ |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
733 |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
734 #define ONE_MORE_BYTE(c) \ |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
735 do { \ |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
736 if (src == src_end) \ |
|
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 (src_base < src) \ |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
739 record_conversion_result \ |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
740 (coding, CODING_RESULT_INSUFFICIENT_SRC); \ |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
741 goto no_more_source; \ |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
742 } \ |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
743 c = *src++; \ |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
744 if (multibytep && (c & 0x80)) \ |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
745 { \ |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
746 if ((c & 0xFE) == 0xC0) \ |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
747 c = ((c & 1) << 6) | *src++; \ |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
748 else \ |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
749 { \ |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
750 c = - string_char (--src, &src, NULL); \ |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
751 record_conversion_result \ |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
752 (coding, CODING_RESULT_INVALID_SRC); \ |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
753 } \ |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
754 } \ |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
755 consumed_chars++; \ |
| 88365 | 756 } while (0) |
| 757 | |
| 758 | |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
759 #define ONE_MORE_BYTE_NO_CHECK(c) \ |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
760 do { \ |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
761 c = *src++; \ |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
762 if (multibytep && (c & 0x80)) \ |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
763 { \ |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
764 if ((c & 0xFE) == 0xC0) \ |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
765 c = ((c & 1) << 6) | *src++; \ |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
766 else \ |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
767 { \ |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
768 c = - string_char (--src, &src, NULL); \ |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
769 record_conversion_result \ |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
770 (coding, CODING_RESULT_INVALID_SRC); \ |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
771 } \ |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
772 } \ |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
773 consumed_chars++; \ |
| 88365 | 774 } while (0) |
| 775 | |
| 776 | |
| 777 /* Store a byte C in the place pointed by DST and increment DST to the | |
| 778 next free point, and increment PRODUCED_CHARS. The caller should | |
| 779 assure that C is 0..127, and declare and set the variable `dst' | |
| 780 appropriately in advance. | |
| 781 */ | |
| 782 | |
| 783 | |
| 784 #define EMIT_ONE_ASCII_BYTE(c) \ | |
| 785 do { \ | |
| 786 produced_chars++; \ | |
| 787 *dst++ = (c); \ | |
| 788 } while (0) | |
| 789 | |
| 790 | |
| 791 /* Like EMIT_ONE_ASCII_BYTE byt store two bytes; C1 and C2. */ | |
| 792 | |
| 793 #define EMIT_TWO_ASCII_BYTES(c1, c2) \ | |
| 794 do { \ | |
| 795 produced_chars += 2; \ | |
| 796 *dst++ = (c1), *dst++ = (c2); \ | |
| 797 } while (0) | |
| 798 | |
| 799 | |
| 800 /* Store a byte C in the place pointed by DST and increment DST to the | |
| 801 next free point, and increment PRODUCED_CHARS. If MULTIBYTEP is | |
| 802 nonzero, store in an appropriate multibyte from. The caller should | |
| 803 declare and set the variables `dst' and `multibytep' appropriately | |
| 804 in advance. */ | |
| 805 | |
| 806 #define EMIT_ONE_BYTE(c) \ | |
| 807 do { \ | |
| 808 produced_chars++; \ | |
| 809 if (multibytep) \ | |
| 810 { \ | |
| 811 int ch = (c); \ | |
| 812 if (ch >= 0x80) \ | |
| 813 ch = BYTE8_TO_CHAR (ch); \ | |
| 814 CHAR_STRING_ADVANCE (ch, dst); \ | |
| 815 } \ | |
| 816 else \ | |
| 817 *dst++ = (c); \ | |
| 818 } while (0) | |
| 819 | |
| 820 | |
| 821 /* Like EMIT_ONE_BYTE, but emit two bytes; C1 and C2. */ | |
| 822 | |
|
88438
3a34b722dd71
(encode_coding_utf_8): Initialize produced_chars to 0.
Kenichi Handa <handa@m17n.org>
parents:
88430
diff
changeset
|
823 #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
|
824 do { \ |
|
3a34b722dd71
(encode_coding_utf_8): Initialize produced_chars to 0.
Kenichi Handa <handa@m17n.org>
parents:
88430
diff
changeset
|
825 produced_chars += 2; \ |
|
3a34b722dd71
(encode_coding_utf_8): Initialize produced_chars to 0.
Kenichi Handa <handa@m17n.org>
parents:
88430
diff
changeset
|
826 if (multibytep) \ |
|
3a34b722dd71
(encode_coding_utf_8): Initialize produced_chars to 0.
Kenichi Handa <handa@m17n.org>
parents:
88430
diff
changeset
|
827 { \ |
|
3a34b722dd71
(encode_coding_utf_8): Initialize produced_chars to 0.
Kenichi Handa <handa@m17n.org>
parents:
88430
diff
changeset
|
828 int ch; \ |
|
3a34b722dd71
(encode_coding_utf_8): Initialize produced_chars to 0.
Kenichi Handa <handa@m17n.org>
parents:
88430
diff
changeset
|
829 \ |
|
3a34b722dd71
(encode_coding_utf_8): Initialize produced_chars to 0.
Kenichi Handa <handa@m17n.org>
parents:
88430
diff
changeset
|
830 ch = (c1); \ |
|
3a34b722dd71
(encode_coding_utf_8): Initialize produced_chars to 0.
Kenichi Handa <handa@m17n.org>
parents:
88430
diff
changeset
|
831 if (ch >= 0x80) \ |
|
3a34b722dd71
(encode_coding_utf_8): Initialize produced_chars to 0.
Kenichi Handa <handa@m17n.org>
parents:
88430
diff
changeset
|
832 ch = BYTE8_TO_CHAR (ch); \ |
|
3a34b722dd71
(encode_coding_utf_8): Initialize produced_chars to 0.
Kenichi Handa <handa@m17n.org>
parents:
88430
diff
changeset
|
833 CHAR_STRING_ADVANCE (ch, dst); \ |
|
3a34b722dd71
(encode_coding_utf_8): Initialize produced_chars to 0.
Kenichi Handa <handa@m17n.org>
parents:
88430
diff
changeset
|
834 ch = (c2); \ |
|
3a34b722dd71
(encode_coding_utf_8): Initialize produced_chars to 0.
Kenichi Handa <handa@m17n.org>
parents:
88430
diff
changeset
|
835 if (ch >= 0x80) \ |
|
3a34b722dd71
(encode_coding_utf_8): Initialize produced_chars to 0.
Kenichi Handa <handa@m17n.org>
parents:
88430
diff
changeset
|
836 ch = BYTE8_TO_CHAR (ch); \ |
|
3a34b722dd71
(encode_coding_utf_8): Initialize produced_chars to 0.
Kenichi Handa <handa@m17n.org>
parents:
88430
diff
changeset
|
837 CHAR_STRING_ADVANCE (ch, dst); \ |
|
3a34b722dd71
(encode_coding_utf_8): Initialize produced_chars to 0.
Kenichi Handa <handa@m17n.org>
parents:
88430
diff
changeset
|
838 } \ |
|
3a34b722dd71
(encode_coding_utf_8): Initialize produced_chars to 0.
Kenichi Handa <handa@m17n.org>
parents:
88430
diff
changeset
|
839 else \ |
|
3a34b722dd71
(encode_coding_utf_8): Initialize produced_chars to 0.
Kenichi Handa <handa@m17n.org>
parents:
88430
diff
changeset
|
840 { \ |
|
3a34b722dd71
(encode_coding_utf_8): Initialize produced_chars to 0.
Kenichi Handa <handa@m17n.org>
parents:
88430
diff
changeset
|
841 *dst++ = (c1); \ |
|
3a34b722dd71
(encode_coding_utf_8): Initialize produced_chars to 0.
Kenichi Handa <handa@m17n.org>
parents:
88430
diff
changeset
|
842 *dst++ = (c2); \ |
|
3a34b722dd71
(encode_coding_utf_8): Initialize produced_chars to 0.
Kenichi Handa <handa@m17n.org>
parents:
88430
diff
changeset
|
843 } \ |
| 88365 | 844 } while (0) |
| 845 | |
| 846 | |
| 847 #define EMIT_THREE_BYTES(c1, c2, c3) \ | |
| 848 do { \ | |
| 849 EMIT_ONE_BYTE (c1); \ | |
| 850 EMIT_TWO_BYTES (c2, c3); \ | |
| 851 } while (0) | |
| 852 | |
| 853 | |
| 854 #define EMIT_FOUR_BYTES(c1, c2, c3, c4) \ | |
| 855 do { \ | |
| 856 EMIT_TWO_BYTES (c1, c2); \ | |
| 857 EMIT_TWO_BYTES (c3, c4); \ | |
| 858 } while (0) | |
| 859 | |
| 860 | |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
861 static void |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
862 record_conversion_result (struct coding_system *coding, |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
863 enum coding_result_code result) |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
864 { |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
865 coding->result = result; |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
866 switch (result) |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
867 { |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
868 case CODING_RESULT_INSUFFICIENT_SRC: |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
869 Vlast_code_conversion_error = Qinsufficient_source; |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
870 break; |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
871 case CODING_RESULT_INCONSISTENT_EOL: |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
872 Vlast_code_conversion_error = Qinconsistent_eol; |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
873 break; |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
874 case CODING_RESULT_INVALID_SRC: |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
875 Vlast_code_conversion_error = Qinvalid_source; |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
876 break; |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
877 case CODING_RESULT_INTERRUPT: |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
878 Vlast_code_conversion_error = Qinterrupted; |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
879 break; |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
880 case CODING_RESULT_INSUFFICIENT_MEM: |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
881 Vlast_code_conversion_error = Qinsufficient_memory; |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
882 break; |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
883 } |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
884 } |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
885 |
| 88365 | 886 #define CODING_DECODE_CHAR(coding, src, src_base, src_end, charset, code, c) \ |
| 887 do { \ | |
| 888 charset_map_loaded = 0; \ | |
| 889 c = DECODE_CHAR (charset, code); \ | |
| 890 if (charset_map_loaded) \ | |
| 891 { \ | |
| 89483 | 892 const unsigned char *orig = coding->source; \ |
| 88365 | 893 EMACS_INT offset; \ |
| 894 \ | |
| 895 coding_set_source (coding); \ | |
| 896 offset = coding->source - orig; \ | |
| 897 src += offset; \ | |
| 898 src_base += offset; \ | |
| 899 src_end += offset; \ | |
| 900 } \ | |
| 901 } while (0) | |
| 902 | |
| 903 | |
| 904 #define ASSURE_DESTINATION(bytes) \ | |
| 905 do { \ | |
| 906 if (dst + (bytes) >= dst_end) \ | |
| 907 { \ | |
| 908 int more_bytes = charbuf_end - charbuf + (bytes); \ | |
| 909 \ | |
| 910 dst = alloc_destination (coding, more_bytes, dst); \ | |
| 911 dst_end = coding->destination + coding->dst_bytes; \ | |
| 912 } \ | |
| 913 } while (0) | |
| 914 | |
| 915 | |
| 916 | |
| 917 static void | |
| 918 coding_set_source (coding) | |
| 919 struct coding_system *coding; | |
| 920 { | |
| 921 if (BUFFERP (coding->src_object)) | |
| 922 { | |
|
89418
a9c2b3712863
(coding_set_source): Fix for the case that the current
Kenichi Handa <handa@m17n.org>
parents:
89404
diff
changeset
|
923 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
|
924 |
| 88365 | 925 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
|
926 coding->source = BUF_GAP_END_ADDR (buf) + coding->src_pos_byte; |
| 88365 | 927 else |
|
89418
a9c2b3712863
(coding_set_source): Fix for the case that the current
Kenichi Handa <handa@m17n.org>
parents:
89404
diff
changeset
|
928 coding->source = BUF_BYTE_ADDRESS (buf, coding->src_pos_byte); |
| 88365 | 929 } |
| 930 else if (STRINGP (coding->src_object)) | |
| 931 { | |
| 89483 | 932 coding->source = SDATA (coding->src_object) + coding->src_pos_byte; |
| 88365 | 933 } |
| 934 else | |
| 935 /* Otherwise, the source is C string and is never relocated | |
| 936 automatically. Thus we don't have to update anything. */ | |
| 937 ; | |
| 938 } | |
| 939 | |
| 940 static void | |
| 941 coding_set_destination (coding) | |
|
30487
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
942 struct coding_system *coding; |
|
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
943 { |
| 88365 | 944 if (BUFFERP (coding->dst_object)) |
| 945 { | |
| 946 if (coding->src_pos < 0) | |
|
89042
2b9f8973f240
(coding_set_destination): Fix coding->destination for
Kenichi Handa <handa@m17n.org>
parents:
88977
diff
changeset
|
947 { |
|
2b9f8973f240
(coding_set_destination): Fix coding->destination for
Kenichi Handa <handa@m17n.org>
parents:
88977
diff
changeset
|
948 coding->destination = BEG_ADDR + coding->dst_pos_byte - 1; |
|
2b9f8973f240
(coding_set_destination): Fix coding->destination for
Kenichi Handa <handa@m17n.org>
parents:
88977
diff
changeset
|
949 coding->dst_bytes = (GAP_END_ADDR |
|
2b9f8973f240
(coding_set_destination): Fix coding->destination for
Kenichi Handa <handa@m17n.org>
parents:
88977
diff
changeset
|
950 - (coding->src_bytes - coding->consumed) |
|
2b9f8973f240
(coding_set_destination): Fix coding->destination for
Kenichi Handa <handa@m17n.org>
parents:
88977
diff
changeset
|
951 - coding->destination); |
|
2b9f8973f240
(coding_set_destination): Fix coding->destination for
Kenichi Handa <handa@m17n.org>
parents:
88977
diff
changeset
|
952 } |
| 88365 | 953 else |
|
89042
2b9f8973f240
(coding_set_destination): Fix coding->destination for
Kenichi Handa <handa@m17n.org>
parents:
88977
diff
changeset
|
954 { |
|
2b9f8973f240
(coding_set_destination): Fix coding->destination for
Kenichi Handa <handa@m17n.org>
parents:
88977
diff
changeset
|
955 /* 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
|
956 of the buffer. */ |
|
2b9f8973f240
(coding_set_destination): Fix coding->destination for
Kenichi Handa <handa@m17n.org>
parents:
88977
diff
changeset
|
957 coding->destination = (BUF_BEG_ADDR (XBUFFER (coding->dst_object)) |
|
2b9f8973f240
(coding_set_destination): Fix coding->destination for
Kenichi Handa <handa@m17n.org>
parents:
88977
diff
changeset
|
958 + coding->dst_pos_byte - 1); |
|
2b9f8973f240
(coding_set_destination): Fix coding->destination for
Kenichi Handa <handa@m17n.org>
parents:
88977
diff
changeset
|
959 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
|
960 - coding->destination); |
|
2b9f8973f240
(coding_set_destination): Fix coding->destination for
Kenichi Handa <handa@m17n.org>
parents:
88977
diff
changeset
|
961 } |
| 88365 | 962 } |
| 963 else | |
| 964 /* Otherwise, the destination is C string and is never relocated | |
| 965 automatically. Thus we don't have to update anything. */ | |
| 966 ; | |
| 967 } | |
| 968 | |
| 969 | |
| 970 static void | |
| 971 coding_alloc_by_realloc (coding, bytes) | |
| 972 struct coding_system *coding; | |
| 973 EMACS_INT bytes; | |
| 974 { | |
| 975 coding->destination = (unsigned char *) xrealloc (coding->destination, | |
| 976 coding->dst_bytes + bytes); | |
| 977 coding->dst_bytes += bytes; | |
|
30487
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
978 } |
|
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
979 |
| 88365 | 980 static void |
| 981 coding_alloc_by_making_gap (coding, bytes) | |
| 982 struct coding_system *coding; | |
| 983 EMACS_INT bytes; | |
| 984 { | |
|
88456
a7b309f72920
(coding_alloc_by_making_gap): Check the case that the
Kenichi Handa <handa@m17n.org>
parents:
88443
diff
changeset
|
985 if (BUFFERP (coding->dst_object) |
|
a7b309f72920
(coding_alloc_by_making_gap): Check the case that the
Kenichi Handa <handa@m17n.org>
parents:
88443
diff
changeset
|
986 && EQ (coding->src_object, coding->dst_object)) |
| 88365 | 987 { |
| 988 EMACS_INT add = coding->src_bytes - coding->consumed; | |
| 989 | |
| 990 GAP_SIZE -= add; ZV += add; Z += add; ZV_BYTE += add; Z_BYTE += add; | |
| 991 make_gap (bytes); | |
| 992 GAP_SIZE += add; ZV -= add; Z -= add; ZV_BYTE -= add; Z_BYTE -= add; | |
| 993 } | |
| 994 else | |
| 995 { | |
|
88456
a7b309f72920
(coding_alloc_by_making_gap): Check the case that the
Kenichi Handa <handa@m17n.org>
parents:
88443
diff
changeset
|
996 Lisp_Object this_buffer; |
|
a7b309f72920
(coding_alloc_by_making_gap): Check the case that the
Kenichi Handa <handa@m17n.org>
parents:
88443
diff
changeset
|
997 |
|
a7b309f72920
(coding_alloc_by_making_gap): Check the case that the
Kenichi Handa <handa@m17n.org>
parents:
88443
diff
changeset
|
998 this_buffer = Fcurrent_buffer (); |
| 88365 | 999 set_buffer_internal (XBUFFER (coding->dst_object)); |
| 1000 make_gap (bytes); | |
| 1001 set_buffer_internal (XBUFFER (this_buffer)); | |
| 1002 } | |
| 1003 } | |
| 89483 | 1004 |
| 88365 | 1005 |
| 1006 static unsigned char * | |
| 1007 alloc_destination (coding, nbytes, dst) | |
| 1008 struct coding_system *coding; | |
|
89545
4f394eed6ff2
(inhibit_pre_post_conversion): Removed (unused).
Dave Love <fx@gnu.org>
parents:
89519
diff
changeset
|
1009 EMACS_INT nbytes; |
| 88365 | 1010 unsigned char *dst; |
| 1011 { | |
| 1012 EMACS_INT offset = dst - coding->destination; | |
| 1013 | |
| 1014 if (BUFFERP (coding->dst_object)) | |
| 1015 coding_alloc_by_making_gap (coding, nbytes); | |
| 1016 else | |
| 1017 coding_alloc_by_realloc (coding, nbytes); | |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1018 record_conversion_result (coding, CODING_RESULT_SUCCESS); |
| 88365 | 1019 coding_set_destination (coding); |
| 1020 dst = coding->destination + offset; | |
| 1021 return dst; | |
| 1022 } | |
| 1023 | |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1024 /** Macros for annotations. */ |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1025 |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1026 /* 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
|
1027 composition and charset). */ |
|
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
1028 #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
|
1029 |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1030 /* 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
|
1031 format: |
|
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
1032 [ -LENGTH ANNOTATION_MASK NCHARS ... ] |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1033 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
|
1034 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
|
1035 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
|
1036 |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1037 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
|
1038 |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1039 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
|
1040 follows: |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1041 ... METHOD [ COMPOSITION-COMPONENTS ... ] |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1042 METHOD is one of enum composition_method. |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1043 Optionnal COMPOSITION-COMPONENTS are characters and composition |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1044 rules. |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1045 |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1046 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
|
1047 follows. */ |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1048 |
|
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
1049 #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
|
1050 do { \ |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1051 *(buf)++ = -(len); \ |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1052 *(buf)++ = (mask); \ |
|
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
1053 *(buf)++ = (nchars); \ |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1054 coding->annotated = 1; \ |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1055 } while (0); |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1056 |
|
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
1057 #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
|
1058 do { \ |
|
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
1059 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
|
1060 *buf++ = method; \ |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1061 } while (0) |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1062 |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1063 |
|
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
1064 #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
|
1065 do { \ |
|
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
1066 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
|
1067 *buf++ = id; \ |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1068 } while (0) |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1069 |
| 88365 | 1070 |
| 1071 /*** 2. Emacs' internal format (emacs-utf-8) ***/ | |
| 1072 | |
| 1073 | |
|
30487
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
1074 |
| 17052 | 1075 |
| 88365 | 1076 /*** 3. UTF-8 ***/ |
| 1077 | |
| 1078 /* 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
|
1079 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
|
1080 return 0. */ |
| 88365 | 1081 |
| 1082 #define UTF_8_1_OCTET_P(c) ((c) < 0x80) | |
| 1083 #define UTF_8_EXTRA_OCTET_P(c) (((c) & 0xC0) == 0x80) | |
| 1084 #define UTF_8_2_OCTET_LEADING_P(c) (((c) & 0xE0) == 0xC0) | |
| 1085 #define UTF_8_3_OCTET_LEADING_P(c) (((c) & 0xF0) == 0xE0) | |
| 1086 #define UTF_8_4_OCTET_LEADING_P(c) (((c) & 0xF8) == 0xF0) | |
| 1087 #define UTF_8_5_OCTET_LEADING_P(c) (((c) & 0xFC) == 0xF8) | |
| 1088 | |
| 1089 static int | |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1090 detect_coding_utf_8 (coding, detect_info) |
| 88365 | 1091 struct coding_system *coding; |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1092 struct coding_detection_info *detect_info; |
| 88365 | 1093 { |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1094 const unsigned char *src = coding->source, *src_base; |
| 89483 | 1095 const unsigned char *src_end = coding->source + coding->src_bytes; |
| 88365 | 1096 int multibytep = coding->src_multibyte; |
| 1097 int consumed_chars = 0; | |
| 1098 int found = 0; | |
| 1099 | |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1100 detect_info->checked |= CATEGORY_MASK_UTF_8; |
| 88365 | 1101 /* A coding system of this category is always ASCII compatible. */ |
| 1102 src += coding->head_ascii; | |
| 1103 | |
| 1104 while (1) | |
| 1105 { | |
| 1106 int c, c1, c2, c3, c4; | |
| 1107 | |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1108 src_base = src; |
| 88365 | 1109 ONE_MORE_BYTE (c); |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1110 if (c < 0 || UTF_8_1_OCTET_P (c)) |
| 88365 | 1111 continue; |
| 1112 ONE_MORE_BYTE (c1); | |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1113 if (c1 < 0 || ! UTF_8_EXTRA_OCTET_P (c1)) |
| 88365 | 1114 break; |
| 1115 if (UTF_8_2_OCTET_LEADING_P (c)) | |
| 1116 { | |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1117 found = CATEGORY_MASK_UTF_8; |
| 88365 | 1118 continue; |
| 1119 } | |
| 1120 ONE_MORE_BYTE (c2); | |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1121 if (c2 < 0 || ! UTF_8_EXTRA_OCTET_P (c2)) |
| 88365 | 1122 break; |
| 1123 if (UTF_8_3_OCTET_LEADING_P (c)) | |
| 1124 { | |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1125 found = CATEGORY_MASK_UTF_8; |
| 88365 | 1126 continue; |
| 1127 } | |
| 1128 ONE_MORE_BYTE (c3); | |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1129 if (c3 < 0 || ! UTF_8_EXTRA_OCTET_P (c3)) |
| 88365 | 1130 break; |
| 1131 if (UTF_8_4_OCTET_LEADING_P (c)) | |
| 1132 { | |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1133 found = CATEGORY_MASK_UTF_8; |
| 88365 | 1134 continue; |
| 1135 } | |
| 1136 ONE_MORE_BYTE (c4); | |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1137 if (c4 < 0 || ! UTF_8_EXTRA_OCTET_P (c4)) |
| 88365 | 1138 break; |
| 1139 if (UTF_8_5_OCTET_LEADING_P (c)) | |
| 1140 { | |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1141 found = CATEGORY_MASK_UTF_8; |
| 88365 | 1142 continue; |
| 1143 } | |
| 1144 break; | |
| 1145 } | |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1146 detect_info->rejected |= CATEGORY_MASK_UTF_8; |
| 88365 | 1147 return 0; |
| 1148 | |
| 1149 no_more_source: | |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1150 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
|
1151 { |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1152 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
|
1153 return 0; |
|
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
1154 } |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1155 detect_info->found |= found; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1156 return 1; |
| 88365 | 1157 } |
| 1158 | |
| 1159 | |
| 1160 static void | |
| 1161 decode_coding_utf_8 (coding) | |
| 1162 struct coding_system *coding; | |
| 1163 { | |
| 89483 | 1164 const unsigned char *src = coding->source + coding->consumed; |
| 1165 const unsigned char *src_end = coding->source + coding->src_bytes; | |
| 1166 const unsigned char *src_base; | |
|
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
1167 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
|
1168 int *charbuf_end = coding->charbuf + coding->charbuf_size; |
| 88365 | 1169 int consumed_chars = 0, consumed_chars_base; |
| 1170 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
|
1171 Lisp_Object attr, charset_list; |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
1172 |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
1173 CODING_GET_INFO (coding, attr, charset_list); |
| 88365 | 1174 |
| 1175 while (1) | |
| 1176 { | |
| 1177 int c, c1, c2, c3, c4, c5; | |
| 1178 | |
| 1179 src_base = src; | |
| 1180 consumed_chars_base = consumed_chars; | |
| 1181 | |
| 1182 if (charbuf >= charbuf_end) | |
| 1183 break; | |
| 1184 | |
| 1185 ONE_MORE_BYTE (c1); | |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1186 if (c1 < 0) |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1187 { |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1188 c = - c1; |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1189 } |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1190 else if (UTF_8_1_OCTET_P(c1)) |
| 88365 | 1191 { |
| 1192 c = c1; | |
| 1193 } | |
| 1194 else | |
| 1195 { | |
| 1196 ONE_MORE_BYTE (c2); | |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1197 if (c2 < 0 || ! UTF_8_EXTRA_OCTET_P (c2)) |
| 88365 | 1198 goto invalid_code; |
| 1199 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
|
1200 { |
|
0bc5868f9f61
(decode_coding_utf_8): Reject overlong sequences.
Dave Love <fx@gnu.org>
parents:
88646
diff
changeset
|
1201 c = ((c1 & 0x1F) << 6) | (c2 & 0x3F); |
|
0bc5868f9f61
(decode_coding_utf_8): Reject overlong sequences.
Dave Love <fx@gnu.org>
parents:
88646
diff
changeset
|
1202 /* Reject overlong sequences here and below. Encoders |
|
0bc5868f9f61
(decode_coding_utf_8): Reject overlong sequences.
Dave Love <fx@gnu.org>
parents:
88646
diff
changeset
|
1203 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
|
1204 and they mess up read/write invariance. */ |
|
0bc5868f9f61
(decode_coding_utf_8): Reject overlong sequences.
Dave Love <fx@gnu.org>
parents:
88646
diff
changeset
|
1205 if (c < 128) |
|
0bc5868f9f61
(decode_coding_utf_8): Reject overlong sequences.
Dave Love <fx@gnu.org>
parents:
88646
diff
changeset
|
1206 goto invalid_code; |
|
0bc5868f9f61
(decode_coding_utf_8): Reject overlong sequences.
Dave Love <fx@gnu.org>
parents:
88646
diff
changeset
|
1207 } |
| 88365 | 1208 else |
| 1209 { | |
| 1210 ONE_MORE_BYTE (c3); | |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1211 if (c3 < 0 || ! UTF_8_EXTRA_OCTET_P (c3)) |
| 88365 | 1212 goto invalid_code; |
| 1213 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
|
1214 { |
|
0bc5868f9f61
(decode_coding_utf_8): Reject overlong sequences.
Dave Love <fx@gnu.org>
parents:
88646
diff
changeset
|
1215 c = (((c1 & 0xF) << 12) |
|
0bc5868f9f61
(decode_coding_utf_8): Reject overlong sequences.
Dave Love <fx@gnu.org>
parents:
88646
diff
changeset
|
1216 | ((c2 & 0x3F) << 6) | (c3 & 0x3F)); |
|
89184
88a9e962e183
(decode_coding_utf_8): Treat surrogates as invalid.
Dave Love <fx@gnu.org>
parents:
89042
diff
changeset
|
1217 if (c < 0x800 |
|
88a9e962e183
(decode_coding_utf_8): Treat surrogates as invalid.
Dave Love <fx@gnu.org>
parents:
89042
diff
changeset
|
1218 || (c >= 0xd800 && c < 0xe000)) /* surrogates (invalid) */ |
|
88669
0bc5868f9f61
(decode_coding_utf_8): Reject overlong sequences.
Dave Love <fx@gnu.org>
parents:
88646
diff
changeset
|
1219 goto invalid_code; |
|
0bc5868f9f61
(decode_coding_utf_8): Reject overlong sequences.
Dave Love <fx@gnu.org>
parents:
88646
diff
changeset
|
1220 } |
| 88365 | 1221 else |
| 1222 { | |
| 1223 ONE_MORE_BYTE (c4); | |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1224 if (c4 < 0 || ! UTF_8_EXTRA_OCTET_P (c4)) |
| 88365 | 1225 goto invalid_code; |
| 1226 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
|
1227 { |
| 88365 | 1228 c = (((c1 & 0x7) << 18) | ((c2 & 0x3F) << 12) |
| 1229 | ((c3 & 0x3F) << 6) | (c4 & 0x3F)); | |
|
88669
0bc5868f9f61
(decode_coding_utf_8): Reject overlong sequences.
Dave Love <fx@gnu.org>
parents:
88646
diff
changeset
|
1230 if (c < 0x10000) |
|
0bc5868f9f61
(decode_coding_utf_8): Reject overlong sequences.
Dave Love <fx@gnu.org>
parents:
88646
diff
changeset
|
1231 goto invalid_code; |
|
0bc5868f9f61
(decode_coding_utf_8): Reject overlong sequences.
Dave Love <fx@gnu.org>
parents:
88646
diff
changeset
|
1232 } |
| 88365 | 1233 else |
| 1234 { | |
| 1235 ONE_MORE_BYTE (c5); | |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1236 if (c5 < 0 || ! UTF_8_EXTRA_OCTET_P (c5)) |
| 88365 | 1237 goto invalid_code; |
| 1238 if (UTF_8_5_OCTET_LEADING_P (c1)) | |
| 1239 { | |
| 1240 c = (((c1 & 0x3) << 24) | ((c2 & 0x3F) << 18) | |
| 1241 | ((c3 & 0x3F) << 12) | ((c4 & 0x3F) << 6) | |
| 1242 | (c5 & 0x3F)); | |
|
88669
0bc5868f9f61
(decode_coding_utf_8): Reject overlong sequences.
Dave Love <fx@gnu.org>
parents:
88646
diff
changeset
|
1243 if ((c > MAX_CHAR) || (c < 0x200000)) |
| 88365 | 1244 goto invalid_code; |
| 1245 } | |
| 1246 else | |
| 1247 goto invalid_code; | |
| 1248 } | |
| 1249 } | |
| 1250 } | |
| 1251 } | |
| 1252 | |
| 1253 *charbuf++ = c; | |
| 1254 continue; | |
| 1255 | |
| 1256 invalid_code: | |
| 1257 src = src_base; | |
| 1258 consumed_chars = consumed_chars_base; | |
| 1259 ONE_MORE_BYTE (c); | |
| 1260 *charbuf++ = ASCII_BYTE_P (c) ? c : BYTE8_TO_CHAR (c); | |
| 1261 coding->errors++; | |
| 1262 } | |
| 1263 | |
| 1264 no_more_source: | |
| 1265 coding->consumed_char += consumed_chars_base; | |
| 1266 coding->consumed = src_base - coding->source; | |
| 1267 coding->charbuf_used = charbuf - coding->charbuf; | |
| 1268 } | |
| 1269 | |
| 1270 | |
| 1271 static int | |
| 1272 encode_coding_utf_8 (coding) | |
| 1273 struct coding_system *coding; | |
| 1274 { | |
| 1275 int multibytep = coding->dst_multibyte; | |
| 1276 int *charbuf = coding->charbuf; | |
| 1277 int *charbuf_end = charbuf + coding->charbuf_used; | |
| 1278 unsigned char *dst = coding->destination + coding->produced; | |
| 1279 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
|
1280 int produced_chars = 0; |
| 88365 | 1281 int c; |
| 1282 | |
| 1283 if (multibytep) | |
| 1284 { | |
| 1285 int safe_room = MAX_MULTIBYTE_LENGTH * 2; | |
| 1286 | |
| 1287 while (charbuf < charbuf_end) | |
| 1288 { | |
| 1289 unsigned char str[MAX_MULTIBYTE_LENGTH], *p, *pend = str; | |
| 89483 | 1290 |
| 88365 | 1291 ASSURE_DESTINATION (safe_room); |
| 1292 c = *charbuf++; | |
|
89042
2b9f8973f240
(coding_set_destination): Fix coding->destination for
Kenichi Handa <handa@m17n.org>
parents:
88977
diff
changeset
|
1293 if (CHAR_BYTE8_P (c)) |
|
2b9f8973f240
(coding_set_destination): Fix coding->destination for
Kenichi Handa <handa@m17n.org>
parents:
88977
diff
changeset
|
1294 { |
|
2b9f8973f240
(coding_set_destination): Fix coding->destination for
Kenichi Handa <handa@m17n.org>
parents:
88977
diff
changeset
|
1295 c = CHAR_TO_BYTE8 (c); |
|
2b9f8973f240
(coding_set_destination): Fix coding->destination for
Kenichi Handa <handa@m17n.org>
parents:
88977
diff
changeset
|
1296 EMIT_ONE_BYTE (c); |
|
2b9f8973f240
(coding_set_destination): Fix coding->destination for
Kenichi Handa <handa@m17n.org>
parents:
88977
diff
changeset
|
1297 } |
|
2b9f8973f240
(coding_set_destination): Fix coding->destination for
Kenichi Handa <handa@m17n.org>
parents:
88977
diff
changeset
|
1298 else |
|
2b9f8973f240
(coding_set_destination): Fix coding->destination for
Kenichi Handa <handa@m17n.org>
parents:
88977
diff
changeset
|
1299 { |
|
2b9f8973f240
(coding_set_destination): Fix coding->destination for
Kenichi Handa <handa@m17n.org>
parents:
88977
diff
changeset
|
1300 CHAR_STRING_ADVANCE (c, pend); |
|
2b9f8973f240
(coding_set_destination): Fix coding->destination for
Kenichi Handa <handa@m17n.org>
parents:
88977
diff
changeset
|
1301 for (p = str; p < pend; p++) |
|
2b9f8973f240
(coding_set_destination): Fix coding->destination for
Kenichi Handa <handa@m17n.org>
parents:
88977
diff
changeset
|
1302 EMIT_ONE_BYTE (*p); |
|
2b9f8973f240
(coding_set_destination): Fix coding->destination for
Kenichi Handa <handa@m17n.org>
parents:
88977
diff
changeset
|
1303 } |
| 88365 | 1304 } |
| 1305 } | |
| 1306 else | |
| 1307 { | |
| 1308 int safe_room = MAX_MULTIBYTE_LENGTH; | |
| 1309 | |
| 1310 while (charbuf < charbuf_end) | |
| 1311 { | |
| 1312 ASSURE_DESTINATION (safe_room); | |
| 1313 c = *charbuf++; | |
| 1314 dst += CHAR_STRING (c, dst); | |
| 1315 produced_chars++; | |
| 1316 } | |
| 1317 } | |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1318 record_conversion_result (coding, CODING_RESULT_SUCCESS); |
| 88365 | 1319 coding->produced_char += produced_chars; |
| 1320 coding->produced = dst - coding->destination; | |
| 1321 return 0; | |
| 1322 } | |
| 1323 | |
| 1324 | |
| 1325 /* 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
|
1326 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
|
1327 If it is, return 1, else return 0. */ |
| 88365 | 1328 |
| 1329 #define UTF_16_HIGH_SURROGATE_P(val) \ | |
| 1330 (((val) & 0xFC00) == 0xD800) | |
| 1331 | |
| 1332 #define UTF_16_LOW_SURROGATE_P(val) \ | |
| 1333 (((val) & 0xFC00) == 0xDC00) | |
| 1334 | |
| 1335 #define UTF_16_INVALID_P(val) \ | |
| 1336 (((val) == 0xFFFE) \ | |
| 1337 || ((val) == 0xFFFF) \ | |
| 1338 || UTF_16_LOW_SURROGATE_P (val)) | |
| 1339 | |
| 1340 | |
| 1341 static int | |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1342 detect_coding_utf_16 (coding, detect_info) |
| 88365 | 1343 struct coding_system *coding; |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1344 struct coding_detection_info *detect_info; |
| 88365 | 1345 { |
| 89483 | 1346 const unsigned char *src = coding->source, *src_base = src; |
| 1347 const unsigned char *src_end = coding->source + coding->src_bytes; | |
| 88365 | 1348 int multibytep = coding->src_multibyte; |
| 1349 int consumed_chars = 0; | |
| 1350 int c1, c2; | |
| 1351 | |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1352 detect_info->checked |= CATEGORY_MASK_UTF_16; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1353 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
|
1354 && (coding->src_chars & 1)) |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1355 { |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1356 detect_info->rejected |= CATEGORY_MASK_UTF_16; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1357 return 0; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1358 } |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
1359 |
| 88365 | 1360 ONE_MORE_BYTE (c1); |
| 1361 ONE_MORE_BYTE (c2); | |
| 1362 if ((c1 == 0xFF) && (c2 == 0xFE)) | |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1363 { |
|
89420
c3e67ce6ee0f
(Qsignature, Qendian): Delete these variables.
Kenichi Handa <handa@m17n.org>
parents:
89418
diff
changeset
|
1364 detect_info->found |= (CATEGORY_MASK_UTF_16_LE |
|
c3e67ce6ee0f
(Qsignature, Qendian): Delete these variables.
Kenichi Handa <handa@m17n.org>
parents:
89418
diff
changeset
|
1365 | 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
|
1366 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
|
1367 | 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
|
1368 | CATEGORY_MASK_UTF_16_LE_NOSIG); |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1369 } |
| 88365 | 1370 else if ((c1 == 0xFE) && (c2 == 0xFF)) |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1371 { |
|
89420
c3e67ce6ee0f
(Qsignature, Qendian): Delete these variables.
Kenichi Handa <handa@m17n.org>
parents:
89418
diff
changeset
|
1372 detect_info->found |= (CATEGORY_MASK_UTF_16_BE |
|
c3e67ce6ee0f
(Qsignature, Qendian): Delete these variables.
Kenichi Handa <handa@m17n.org>
parents:
89418
diff
changeset
|
1373 | 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
|
1374 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
|
1375 | 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
|
1376 | 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
|
1377 } |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1378 else if (c1 >= 0 && c2 >= 0) |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
1379 { |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
1380 unsigned char b1[256], b2[256]; |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
1381 int b1_variants = 1, b2_variants = 1; |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
1382 int n; |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
1383 |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
1384 bzero (b1, 256), bzero (b2, 256); |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
1385 b1[c1]++, b2[c2]++; |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
1386 for (n = 0; n < 256 && src < src_end; n++) |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
1387 { |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1388 src_base = src; |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
1389 ONE_MORE_BYTE (c1); |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
1390 ONE_MORE_BYTE (c2); |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1391 if (c1 < 0 || c2 < 0) |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1392 break; |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
1393 if (! b1[c1++]) b1_variants++; |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
1394 if (! b2[c2++]) b2_variants++; |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
1395 } |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
1396 if (b1_variants < b2_variants) |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
1397 detect_info->found |= 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
|
1398 else |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
1399 detect_info->found |= 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
|
1400 detect_info->rejected |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
1401 |= (CATEGORY_MASK_UTF_16_BE | CATEGORY_MASK_UTF_16_LE); |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1402 } |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1403 no_more_source: |
|
89193
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
1404 return 1; |
| 88365 | 1405 } |
| 1406 | |
| 1407 static void | |
| 1408 decode_coding_utf_16 (coding) | |
| 1409 struct coding_system *coding; | |
| 1410 { | |
| 89483 | 1411 const unsigned char *src = coding->source + coding->consumed; |
| 1412 const unsigned char *src_end = coding->source + coding->src_bytes; | |
| 1413 const unsigned char *src_base; | |
|
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
1414 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
|
1415 int *charbuf_end = coding->charbuf + coding->charbuf_size; |
| 88365 | 1416 int consumed_chars = 0, consumed_chars_base; |
| 1417 int multibytep = coding->src_multibyte; | |
| 1418 enum utf_16_bom_type bom = CODING_UTF_16_BOM (coding); | |
| 1419 enum utf_16_endian_type endian = CODING_UTF_16_ENDIAN (coding); | |
| 1420 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
|
1421 Lisp_Object attr, charset_list; |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
1422 |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
1423 CODING_GET_INFO (coding, attr, charset_list); |
| 88365 | 1424 |
|
89420
c3e67ce6ee0f
(Qsignature, Qendian): Delete these variables.
Kenichi Handa <handa@m17n.org>
parents:
89418
diff
changeset
|
1425 if (bom == utf_16_with_bom) |
| 88365 | 1426 { |
| 1427 int c, c1, c2; | |
| 1428 | |
| 1429 src_base = src; | |
| 1430 ONE_MORE_BYTE (c1); | |
| 1431 ONE_MORE_BYTE (c2); | |
|
88438
3a34b722dd71
(encode_coding_utf_8): Initialize produced_chars to 0.
Kenichi Handa <handa@m17n.org>
parents:
88430
diff
changeset
|
1432 c = (c1 << 8) | c2; |
|
89420
c3e67ce6ee0f
(Qsignature, Qendian): Delete these variables.
Kenichi Handa <handa@m17n.org>
parents:
89418
diff
changeset
|
1433 |
|
c3e67ce6ee0f
(Qsignature, Qendian): Delete these variables.
Kenichi Handa <handa@m17n.org>
parents:
89418
diff
changeset
|
1434 if (endian == utf_16_big_endian |
|
c3e67ce6ee0f
(Qsignature, Qendian): Delete these variables.
Kenichi Handa <handa@m17n.org>
parents:
89418
diff
changeset
|
1435 ? c != 0xFEFF : c != 0xFFFE) |
| 88365 | 1436 { |
|
89420
c3e67ce6ee0f
(Qsignature, Qendian): Delete these variables.
Kenichi Handa <handa@m17n.org>
parents:
89418
diff
changeset
|
1437 /* 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
|
1438 for a normal character. */ |
|
c3e67ce6ee0f
(Qsignature, Qendian): Delete these variables.
Kenichi Handa <handa@m17n.org>
parents:
89418
diff
changeset
|
1439 src = src_base; |
|
c3e67ce6ee0f
(Qsignature, Qendian): Delete these variables.
Kenichi Handa <handa@m17n.org>
parents:
89418
diff
changeset
|
1440 coding->errors++; |
| 88365 | 1441 } |
|
89420
c3e67ce6ee0f
(Qsignature, Qendian): Delete these variables.
Kenichi Handa <handa@m17n.org>
parents:
89418
diff
changeset
|
1442 CODING_UTF_16_BOM (coding) = utf_16_without_bom; |
|
c3e67ce6ee0f
(Qsignature, Qendian): Delete these variables.
Kenichi Handa <handa@m17n.org>
parents:
89418
diff
changeset
|
1443 } |
|
c3e67ce6ee0f
(Qsignature, Qendian): Delete these variables.
Kenichi Handa <handa@m17n.org>
parents:
89418
diff
changeset
|
1444 else if (bom == utf_16_detect_bom) |
|
c3e67ce6ee0f
(Qsignature, Qendian): Delete these variables.
Kenichi Handa <handa@m17n.org>
parents:
89418
diff
changeset
|
1445 { |
|
c3e67ce6ee0f
(Qsignature, Qendian): Delete these variables.
Kenichi Handa <handa@m17n.org>
parents:
89418
diff
changeset
|
1446 /* 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
|
1447 detect_coding. */ |
|
c3e67ce6ee0f
(Qsignature, Qendian): Delete these variables.
Kenichi Handa <handa@m17n.org>
parents:
89418
diff
changeset
|
1448 CODING_UTF_16_BOM (coding) = utf_16_without_bom; |
| 88365 | 1449 } |
| 1450 | |
| 1451 while (1) | |
| 1452 { | |
| 1453 int c, c1, c2; | |
| 1454 | |
| 1455 src_base = src; | |
| 1456 consumed_chars_base = consumed_chars; | |
| 1457 | |
| 1458 if (charbuf + 2 >= charbuf_end) | |
| 1459 break; | |
| 1460 | |
| 1461 ONE_MORE_BYTE (c1); | |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1462 if (c1 < 0) |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1463 { |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1464 *charbuf++ = -c1; |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1465 continue; |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1466 } |
| 88365 | 1467 ONE_MORE_BYTE (c2); |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1468 if (c2 < 0) |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1469 { |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1470 *charbuf++ = ASCII_BYTE_P (c1) ? c1 : BYTE8_TO_CHAR (c1); |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1471 *charbuf++ = -c2; |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1472 continue; |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1473 } |
| 88365 | 1474 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
|
1475 ? ((c1 << 8) | c2) : ((c2 << 8) | c1)); |
| 88365 | 1476 if (surrogate) |
| 1477 { | |
| 1478 if (! UTF_16_LOW_SURROGATE_P (c)) | |
| 1479 { | |
| 1480 if (endian == utf_16_big_endian) | |
| 1481 c1 = surrogate >> 8, c2 = surrogate & 0xFF; | |
| 1482 else | |
| 1483 c1 = surrogate & 0xFF, c2 = surrogate >> 8; | |
| 1484 *charbuf++ = c1; | |
| 1485 *charbuf++ = c2; | |
| 1486 coding->errors++; | |
| 1487 if (UTF_16_HIGH_SURROGATE_P (c)) | |
| 1488 CODING_UTF_16_SURROGATE (coding) = surrogate = c; | |
| 1489 else | |
| 1490 *charbuf++ = c; | |
| 1491 } | |
| 1492 else | |
| 1493 { | |
| 1494 c = ((surrogate - 0xD800) << 10) | (c - 0xDC00); | |
| 1495 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
|
1496 *charbuf++ = 0x10000 + c; |
| 88365 | 1497 } |
| 1498 } | |
| 1499 else | |
| 1500 { | |
| 1501 if (UTF_16_HIGH_SURROGATE_P (c)) | |
| 1502 CODING_UTF_16_SURROGATE (coding) = surrogate = c; | |
| 1503 else | |
| 1504 *charbuf++ = c; | |
| 89483 | 1505 } |
| 88365 | 1506 } |
| 1507 | |
| 1508 no_more_source: | |
| 1509 coding->consumed_char += consumed_chars_base; | |
| 1510 coding->consumed = src_base - coding->source; | |
| 1511 coding->charbuf_used = charbuf - coding->charbuf; | |
| 1512 } | |
| 1513 | |
| 1514 static int | |
| 1515 encode_coding_utf_16 (coding) | |
| 1516 struct coding_system *coding; | |
| 1517 { | |
| 1518 int multibytep = coding->dst_multibyte; | |
| 1519 int *charbuf = coding->charbuf; | |
| 1520 int *charbuf_end = charbuf + coding->charbuf_used; | |
| 1521 unsigned char *dst = coding->destination + coding->produced; | |
| 1522 unsigned char *dst_end = coding->destination + coding->dst_bytes; | |
| 1523 int safe_room = 8; | |
| 1524 enum utf_16_bom_type bom = CODING_UTF_16_BOM (coding); | |
| 1525 int big_endian = CODING_UTF_16_ENDIAN (coding) == utf_16_big_endian; | |
| 1526 int produced_chars = 0; | |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
1527 Lisp_Object attrs, charset_list; |
| 88365 | 1528 int c; |
| 1529 | |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
1530 CODING_GET_INFO (coding, attrs, charset_list); |
| 88365 | 1531 |
|
89420
c3e67ce6ee0f
(Qsignature, Qendian): Delete these variables.
Kenichi Handa <handa@m17n.org>
parents:
89418
diff
changeset
|
1532 if (bom != utf_16_without_bom) |
| 88365 | 1533 { |
| 1534 ASSURE_DESTINATION (safe_room); | |
| 1535 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
|
1536 EMIT_TWO_BYTES (0xFE, 0xFF); |
| 88365 | 1537 else |
|
89404
3e1d187b52c3
(Qutf_16_be_nosig, Qutf_16_be, Qutf_16_le_nosig)
Kenichi Handa <handa@m17n.org>
parents:
89394
diff
changeset
|
1538 EMIT_TWO_BYTES (0xFF, 0xFE); |
| 88365 | 1539 CODING_UTF_16_BOM (coding) = utf_16_without_bom; |
| 1540 } | |
| 1541 | |
| 1542 while (charbuf < charbuf_end) | |
| 1543 { | |
| 1544 ASSURE_DESTINATION (safe_room); | |
| 1545 c = *charbuf++; | |
|
88438
3a34b722dd71
(encode_coding_utf_8): Initialize produced_chars to 0.
Kenichi Handa <handa@m17n.org>
parents:
88430
diff
changeset
|
1546 if (c >= MAX_UNICODE_CHAR) |
|
3a34b722dd71
(encode_coding_utf_8): Initialize produced_chars to 0.
Kenichi Handa <handa@m17n.org>
parents:
88430
diff
changeset
|
1547 c = coding->default_char; |
| 88365 | 1548 |
| 1549 if (c < 0x10000) | |
| 1550 { | |
| 1551 if (big_endian) | |
| 1552 EMIT_TWO_BYTES (c >> 8, c & 0xFF); | |
| 1553 else | |
| 1554 EMIT_TWO_BYTES (c & 0xFF, c >> 8); | |
| 1555 } | |
| 1556 else | |
| 1557 { | |
| 1558 int c1, c2; | |
| 1559 | |
| 1560 c -= 0x10000; | |
| 1561 c1 = (c >> 10) + 0xD800; | |
| 1562 c2 = (c & 0x3FF) + 0xDC00; | |
| 1563 if (big_endian) | |
| 1564 EMIT_FOUR_BYTES (c1 >> 8, c1 & 0xFF, c2 >> 8, c2 & 0xFF); | |
| 1565 else | |
| 1566 EMIT_FOUR_BYTES (c1 & 0xFF, c1 >> 8, c2 & 0xFF, c2 >> 8); | |
| 1567 } | |
| 1568 } | |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1569 record_conversion_result (coding, CODING_RESULT_SUCCESS); |
| 88365 | 1570 coding->produced = dst - coding->destination; |
| 1571 coding->produced_char += produced_chars; | |
| 1572 return 0; | |
| 1573 } | |
| 1574 | |
| 1575 | |
| 1576 /*** 6. Old Emacs' internal format (emacs-mule) ***/ | |
| 17052 | 1577 |
|
34888
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1578 /* Emacs' internal format for representation of multiple character |
|
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1579 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
|
1580 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
|
1581 |
|
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1582 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
|
1583 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
|
1584 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
|
1585 |
|
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1586 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
|
1587 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
|
1588 code + 0x20). |
|
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1589 |
|
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1590 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
|
1591 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
|
1592 |
|
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1593 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
|
1594 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
|
1595 `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
|
1596 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
|
1597 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
|
1598 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
|
1599 and position-code. |
| 18766 | 1600 |
| 17052 | 1601 --- 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
|
1602 character set range |
|
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1603 ------------- ----- |
|
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1604 ascii 0x00..0x7F |
|
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1605 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
|
1606 eight-bit-graphic 0xA0..0xBF |
|
34888
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1607 ELSE 0x81..0x9D + [0xA0..0xFF]+ |
| 17052 | 1608 --------------------------------------------- |
| 1609 | |
|
34888
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1610 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
|
1611 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
|
1612 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
|
1613 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
|
1614 |
|
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1615 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
|
1616 form. |
|
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1617 |
| 88365 | 1618 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
|
1619 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
|
1620 |
|
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1621 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
|
1622 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
|
1623 where, |
|
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1624 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
|
1625 composition_method), |
|
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1626 |
| 88365 | 1627 BYTES is 0xA0 plus a byte length of this composition data, |
| 1628 | |
| 1629 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
|
1630 data, |
|
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1631 |
| 88365 | 1632 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
|
1633 rules encoded by two-byte of ASCII codes. |
|
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1634 |
|
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1635 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
|
1636 also recognized as composition data on decoding. |
|
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1637 |
|
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1638 0x80 MSEQ ... |
|
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1639 0x80 0xFF MSEQ RULE MSEQ RULE ... MSEQ |
|
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1640 |
|
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1641 Here, |
|
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1642 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
|
1643 ASCII: 0xA0 ASCII_CODE+0x80, |
|
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1644 other: LEADING_CODE+0x20 FOLLOWING-BYTE ..., |
|
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1645 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
|
1646 represents a composition rule. |
| 17052 | 1647 */ |
| 1648 | |
| 88365 | 1649 char emacs_mule_bytes[256]; |
| 1650 | |
| 1651 int | |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1652 emacs_mule_char (coding, src, nbytes, nchars, id) |
| 88365 | 1653 struct coding_system *coding; |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1654 const unsigned char *src; |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1655 int *nbytes, *nchars, *id; |
| 88365 | 1656 { |
| 89483 | 1657 const unsigned char *src_end = coding->source + coding->src_bytes; |
| 1658 const unsigned char *src_base = src; | |
| 88365 | 1659 int multibytep = coding->src_multibyte; |
| 1660 struct charset *charset; | |
| 1661 unsigned code; | |
| 1662 int c; | |
| 1663 int consumed_chars = 0; | |
| 1664 | |
| 1665 ONE_MORE_BYTE (c); | |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1666 if (c < 0) |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1667 { |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1668 c = -c; |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1669 charset = emacs_mule_charset[0]; |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1670 } |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1671 else |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1672 { |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1673 switch (emacs_mule_bytes[c]) |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1674 { |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1675 case 2: |
| 88365 | 1676 if (! (charset = emacs_mule_charset[c])) |
| 1677 goto invalid_code; | |
| 1678 ONE_MORE_BYTE (c); | |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1679 if (c < 0) |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1680 goto invalid_code; |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1681 code = c & 0x7F; |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1682 break; |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1683 |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1684 case 3: |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1685 if (c == EMACS_MULE_LEADING_CODE_PRIVATE_11 |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1686 || c == EMACS_MULE_LEADING_CODE_PRIVATE_12) |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1687 { |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1688 ONE_MORE_BYTE (c); |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1689 if (c < 0 || ! (charset = emacs_mule_charset[c])) |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1690 goto invalid_code; |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1691 ONE_MORE_BYTE (c); |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1692 if (c < 0) |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1693 goto invalid_code; |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1694 code = c & 0x7F; |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1695 } |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1696 else |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1697 { |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1698 if (! (charset = emacs_mule_charset[c])) |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1699 goto invalid_code; |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1700 ONE_MORE_BYTE (c); |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1701 if (c < 0) |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1702 goto invalid_code; |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1703 code = (c & 0x7F) << 8; |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1704 ONE_MORE_BYTE (c); |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1705 if (c < 0) |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1706 goto invalid_code; |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1707 code |= c & 0x7F; |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1708 } |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1709 break; |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1710 |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1711 case 4: |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1712 ONE_MORE_BYTE (c); |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1713 if (c < 0 || ! (charset = emacs_mule_charset[c])) |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1714 goto invalid_code; |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1715 ONE_MORE_BYTE (c); |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1716 if (c < 0) |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1717 goto invalid_code; |
|
88585
c7772f702227
(ONE_MORE_BYTE_NO_CHECK): Increment consumed_chars.
Kenichi Handa <handa@m17n.org>
parents:
88573
diff
changeset
|
1718 code = (c & 0x7F) << 8; |
| 88365 | 1719 ONE_MORE_BYTE (c); |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1720 if (c < 0) |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1721 goto invalid_code; |
| 88365 | 1722 code |= c & 0x7F; |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1723 break; |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1724 |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1725 case 1: |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1726 code = c; |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1727 charset = CHARSET_FROM_ID (ASCII_BYTE_P (code) |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1728 ? charset_ascii : charset_eight_bit); |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1729 break; |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1730 |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1731 default: |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1732 abort (); |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1733 } |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1734 c = DECODE_CHAR (charset, code); |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1735 if (c < 0) |
| 88365 | 1736 goto invalid_code; |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1737 } |
| 88365 | 1738 *nbytes = src - src_base; |
| 1739 *nchars = consumed_chars; | |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1740 if (id) |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1741 *id = charset->id; |
| 88365 | 1742 return c; |
| 1743 | |
| 1744 no_more_source: | |
| 1745 return -2; | |
| 1746 | |
| 1747 invalid_code: | |
| 1748 return -1; | |
| 1749 } | |
| 1750 | |
| 17052 | 1751 |
| 1752 /* 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
|
1753 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
|
1754 else return 0. */ |
| 17052 | 1755 |
|
34531
37f85e931855
(ONE_MORE_BYTE_CHECK_MULTIBYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34197
diff
changeset
|
1756 static int |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1757 detect_coding_emacs_mule (coding, detect_info) |
| 88365 | 1758 struct coding_system *coding; |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1759 struct coding_detection_info *detect_info; |
| 17052 | 1760 { |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1761 const unsigned char *src = coding->source, *src_base; |
| 89483 | 1762 const unsigned char *src_end = coding->source + coding->src_bytes; |
| 88365 | 1763 int multibytep = coding->src_multibyte; |
| 1764 int consumed_chars = 0; | |
| 1765 int c; | |
| 1766 int found = 0; | |
| 1767 | |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1768 detect_info->checked |= CATEGORY_MASK_EMACS_MULE; |
| 88365 | 1769 /* A coding system of this category is always ASCII compatible. */ |
| 1770 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
|
1771 |
|
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1772 while (1) |
| 17052 | 1773 { |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1774 src_base = src; |
| 88365 | 1775 ONE_MORE_BYTE (c); |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1776 if (c < 0) |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1777 continue; |
| 88365 | 1778 if (c == 0x80) |
| 17052 | 1779 { |
| 88365 | 1780 /* Perhaps the start of composite character. We simple skip |
| 1781 it because analyzing it is too heavy for detecting. But, | |
| 1782 at least, we check that the composite character | |
| 1783 constitues of more than 4 bytes. */ | |
| 89483 | 1784 const unsigned char *src_base; |
| 88365 | 1785 |
| 1786 repeat: | |
| 1787 src_base = src; | |
| 1788 do | |
| 1789 { | |
| 1790 ONE_MORE_BYTE (c); | |
| 1791 } | |
| 1792 while (c >= 0xA0); | |
| 1793 | |
| 1794 if (src - src_base <= 4) | |
| 1795 break; | |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1796 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
|
1797 if (c == 0x80) |
| 88365 | 1798 goto repeat; |
|
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1799 } |
| 88365 | 1800 |
| 1801 if (c < 0x80) | |
| 1802 { | |
| 1803 if (c < 0x20 | |
| 1804 && (c == ISO_CODE_ESC || c == ISO_CODE_SI || c == ISO_CODE_SO)) | |
| 1805 break; | |
| 1806 } | |
| 1807 else | |
| 1808 { | |
|
89848
3edfa038a435
(detect_coding_emacs_mule): Fix counting of encoded
Kenichi Handa <handa@m17n.org>
parents:
89842
diff
changeset
|
1809 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
|
1810 |
|
3edfa038a435
(detect_coding_emacs_mule): Fix counting of encoded
Kenichi Handa <handa@m17n.org>
parents:
89842
diff
changeset
|
1811 while (more_bytes > 0) |
| 88365 | 1812 { |
| 1813 ONE_MORE_BYTE (c); | |
|
89848
3edfa038a435
(detect_coding_emacs_mule): Fix counting of encoded
Kenichi Handa <handa@m17n.org>
parents:
89842
diff
changeset
|
1814 if (c < 0xA0) |
|
3edfa038a435
(detect_coding_emacs_mule): Fix counting of encoded
Kenichi Handa <handa@m17n.org>
parents:
89842
diff
changeset
|
1815 { |
|
3edfa038a435
(detect_coding_emacs_mule): Fix counting of encoded
Kenichi Handa <handa@m17n.org>
parents:
89842
diff
changeset
|
1816 src--; /* Unread the last byte. */ |
|
3edfa038a435
(detect_coding_emacs_mule): Fix counting of encoded
Kenichi Handa <handa@m17n.org>
parents:
89842
diff
changeset
|
1817 break; |
|
3edfa038a435
(detect_coding_emacs_mule): Fix counting of encoded
Kenichi Handa <handa@m17n.org>
parents:
89842
diff
changeset
|
1818 } |
|
3edfa038a435
(detect_coding_emacs_mule): Fix counting of encoded
Kenichi Handa <handa@m17n.org>
parents:
89842
diff
changeset
|
1819 more_bytes--; |
| 88365 | 1820 } |
|
89848
3edfa038a435
(detect_coding_emacs_mule): Fix counting of encoded
Kenichi Handa <handa@m17n.org>
parents:
89842
diff
changeset
|
1821 if (more_bytes != 0) |
| 88365 | 1822 break; |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1823 found = CATEGORY_MASK_EMACS_MULE; |
| 88365 | 1824 } |
| 1825 } | |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1826 detect_info->rejected |= CATEGORY_MASK_EMACS_MULE; |
| 88365 | 1827 return 0; |
| 1828 | |
| 1829 no_more_source: | |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1830 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
|
1831 { |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1832 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
|
1833 return 0; |
|
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
1834 } |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1835 detect_info->found |= found; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1836 return 1; |
|
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1837 } |
|
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1838 |
|
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1839 |
| 88365 | 1840 /* 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
|
1841 |
|
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1842 /* Decode a character represented as a component of composition |
| 88365 | 1843 sequence of Emacs 20/21 style at SRC. Set C to that character and |
| 1844 update SRC to the head of next character (or an encoded composition | |
| 1845 rule). If SRC doesn't points a composition component, set C to -1. | |
| 1846 If SRC points an invalid byte sequence, global exit by a return | |
| 1847 value 0. */ | |
| 1848 | |
| 1849 #define DECODE_EMACS_MULE_COMPOSITION_CHAR(buf) \ | |
| 1850 if (1) \ | |
| 1851 { \ | |
| 1852 int c; \ | |
| 1853 int nbytes, nchars; \ | |
|
34888
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1854 \ |
| 88365 | 1855 if (src == src_end) \ |
| 1856 break; \ | |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1857 c = emacs_mule_char (coding, src, &nbytes, &nchars, NULL);\ |
| 88365 | 1858 if (c < 0) \ |
| 1859 { \ | |
| 1860 if (c == -2) \ | |
| 1861 break; \ | |
| 1862 goto invalid_code; \ | |
| 1863 } \ | |
| 1864 *buf++ = c; \ | |
| 1865 src += nbytes; \ | |
| 1866 consumed_chars += nchars; \ | |
| 1867 } \ | |
| 1868 else | |
|
34888
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1869 |
|
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1870 |
|
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1871 /* 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
|
1872 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
|
1873 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
|
1874 to -1. */ |
|
c7772f702227
(ONE_MORE_BYTE_NO_CHECK): Increment consumed_chars.
Kenichi Handa <handa@m17n.org>
parents:
88573
diff
changeset
|
1875 |
|
c7772f702227
(ONE_MORE_BYTE_NO_CHECK): Increment consumed_chars.
Kenichi Handa <handa@m17n.org>
parents:
88573
diff
changeset
|
1876 #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
|
1877 do { \ |
| 88365 | 1878 int c, gref, nref; \ |
| 1879 \ | |
|
88585
c7772f702227
(ONE_MORE_BYTE_NO_CHECK): Increment consumed_chars.
Kenichi Handa <handa@m17n.org>
parents:
88573
diff
changeset
|
1880 if (src >= src_end) \ |
| 88365 | 1881 goto invalid_code; \ |
| 1882 ONE_MORE_BYTE_NO_CHECK (c); \ | |
|
88585
c7772f702227
(ONE_MORE_BYTE_NO_CHECK): Increment consumed_chars.
Kenichi Handa <handa@m17n.org>
parents:
88573
diff
changeset
|
1883 c -= 0x20; \ |
|
34888
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1884 if (c < 0 || c >= 81) \ |
| 88365 | 1885 goto invalid_code; \ |
| 1886 \ | |
| 1887 gref = c / 9, nref = c % 9; \ | |
| 1888 *buf++ = COMPOSITION_ENCODE_RULE (gref, nref); \ | |
| 1889 } while (0) | |
| 1890 | |
| 1891 | |
|
88585
c7772f702227
(ONE_MORE_BYTE_NO_CHECK): Increment consumed_chars.
Kenichi Handa <handa@m17n.org>
parents:
88573
diff
changeset
|
1892 /* Decode a composition rule represented as a component of composition |
|
c7772f702227
(ONE_MORE_BYTE_NO_CHECK): Increment consumed_chars.
Kenichi Handa <handa@m17n.org>
parents:
88573
diff
changeset
|
1893 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
|
1894 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
|
1895 to -1. */ |
|
c7772f702227
(ONE_MORE_BYTE_NO_CHECK): Increment consumed_chars.
Kenichi Handa <handa@m17n.org>
parents:
88573
diff
changeset
|
1896 |
|
c7772f702227
(ONE_MORE_BYTE_NO_CHECK): Increment consumed_chars.
Kenichi Handa <handa@m17n.org>
parents:
88573
diff
changeset
|
1897 #define DECODE_EMACS_MULE_COMPOSITION_RULE_21(buf) \ |
|
c7772f702227
(ONE_MORE_BYTE_NO_CHECK): Increment consumed_chars.
Kenichi Handa <handa@m17n.org>
parents:
88573
diff
changeset
|
1898 do { \ |
|
c7772f702227
(ONE_MORE_BYTE_NO_CHECK): Increment consumed_chars.
Kenichi Handa <handa@m17n.org>
parents:
88573
diff
changeset
|
1899 int gref, nref; \ |
|
c7772f702227
(ONE_MORE_BYTE_NO_CHECK): Increment consumed_chars.
Kenichi Handa <handa@m17n.org>
parents:
88573
diff
changeset
|
1900 \ |
|
c7772f702227
(ONE_MORE_BYTE_NO_CHECK): Increment consumed_chars.
Kenichi Handa <handa@m17n.org>
parents:
88573
diff
changeset
|
1901 if (src + 1>= src_end) \ |
|
c7772f702227
(ONE_MORE_BYTE_NO_CHECK): Increment consumed_chars.
Kenichi Handa <handa@m17n.org>
parents:
88573
diff
changeset
|
1902 goto invalid_code; \ |
|
c7772f702227
(ONE_MORE_BYTE_NO_CHECK): Increment consumed_chars.
Kenichi Handa <handa@m17n.org>
parents:
88573
diff
changeset
|
1903 ONE_MORE_BYTE_NO_CHECK (gref); \ |
|
c7772f702227
(ONE_MORE_BYTE_NO_CHECK): Increment consumed_chars.
Kenichi Handa <handa@m17n.org>
parents:
88573
diff
changeset
|
1904 gref -= 0x20; \ |
|
c7772f702227
(ONE_MORE_BYTE_NO_CHECK): Increment consumed_chars.
Kenichi Handa <handa@m17n.org>
parents:
88573
diff
changeset
|
1905 ONE_MORE_BYTE_NO_CHECK (nref); \ |
|
c7772f702227
(ONE_MORE_BYTE_NO_CHECK): Increment consumed_chars.
Kenichi Handa <handa@m17n.org>
parents:
88573
diff
changeset
|
1906 nref -= 0x20; \ |
|
c7772f702227
(ONE_MORE_BYTE_NO_CHECK): Increment consumed_chars.
Kenichi Handa <handa@m17n.org>
parents:
88573
diff
changeset
|
1907 if (gref < 0 || gref >= 81 \ |
|
c7772f702227
(ONE_MORE_BYTE_NO_CHECK): Increment consumed_chars.
Kenichi Handa <handa@m17n.org>
parents:
88573
diff
changeset
|
1908 || nref < 0 || nref >= 81) \ |
|
c7772f702227
(ONE_MORE_BYTE_NO_CHECK): Increment consumed_chars.
Kenichi Handa <handa@m17n.org>
parents:
88573
diff
changeset
|
1909 goto invalid_code; \ |
|
c7772f702227
(ONE_MORE_BYTE_NO_CHECK): Increment consumed_chars.
Kenichi Handa <handa@m17n.org>
parents:
88573
diff
changeset
|
1910 *buf++ = COMPOSITION_ENCODE_RULE (gref, nref); \ |
|
c7772f702227
(ONE_MORE_BYTE_NO_CHECK): Increment consumed_chars.
Kenichi Handa <handa@m17n.org>
parents:
88573
diff
changeset
|
1911 } while (0) |
|
c7772f702227
(ONE_MORE_BYTE_NO_CHECK): Increment consumed_chars.
Kenichi Handa <handa@m17n.org>
parents:
88573
diff
changeset
|
1912 |
|
c7772f702227
(ONE_MORE_BYTE_NO_CHECK): Increment consumed_chars.
Kenichi Handa <handa@m17n.org>
parents:
88573
diff
changeset
|
1913 |
| 88365 | 1914 #define DECODE_EMACS_MULE_21_COMPOSITION(c) \ |
| 1915 do { \ | |
| 1916 /* 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
|
1917 (METHOD - 0xF2), (BYTES - 0xA0), (CHARS - 0xA0), where BYTES is \ |
| 88365 | 1918 the byte length of this composition information, CHARS is the \ |
| 1919 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
|
1920 enum composition_method method = c - 0xF2; \ |
|
c7772f702227
(ONE_MORE_BYTE_NO_CHECK): Increment consumed_chars.
Kenichi Handa <handa@m17n.org>
parents:
88573
diff
changeset
|
1921 int *charbuf_base = charbuf; \ |
| 88365 | 1922 int consumed_chars_limit; \ |
| 1923 int nbytes, nchars; \ | |
| 1924 \ | |
| 1925 ONE_MORE_BYTE (c); \ | |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1926 if (c < 0) \ |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1927 goto invalid_code; \ |
| 88365 | 1928 nbytes = c - 0xA0; \ |
| 1929 if (nbytes < 3) \ | |
| 1930 goto invalid_code; \ | |
| 1931 ONE_MORE_BYTE (c); \ | |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1932 if (c < 0) \ |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1933 goto invalid_code; \ |
| 88365 | 1934 nchars = c - 0xA0; \ |
|
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
1935 ADD_COMPOSITION_DATA (charbuf, nchars, method); \ |
| 88365 | 1936 consumed_chars_limit = consumed_chars_base + nbytes; \ |
| 1937 if (method != COMPOSITION_RELATIVE) \ | |
| 1938 { \ | |
| 1939 int i = 0; \ | |
| 1940 while (consumed_chars < consumed_chars_limit) \ | |
| 1941 { \ | |
| 1942 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
|
1943 DECODE_EMACS_MULE_COMPOSITION_RULE_21 (charbuf); \ |
| 88365 | 1944 else \ |
| 1945 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
|
1946 i++; \ |
| 88365 | 1947 } \ |
| 1948 if (consumed_chars < consumed_chars_limit) \ | |
| 1949 goto invalid_code; \ | |
|
88585
c7772f702227
(ONE_MORE_BYTE_NO_CHECK): Increment consumed_chars.
Kenichi Handa <handa@m17n.org>
parents:
88573
diff
changeset
|
1950 charbuf_base[0] -= i; \ |
| 88365 | 1951 } \ |
| 1952 } while (0) | |
| 1953 | |
| 1954 | |
| 1955 #define DECODE_EMACS_MULE_20_RELATIVE_COMPOSITION(c) \ | |
| 1956 do { \ | |
| 1957 /* Emacs 20 style format for relative composition. */ \ | |
| 1958 /* 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
|
1959 enum composition_method method = COMPOSITION_RELATIVE; \ |
| 88365 | 1960 int components[MAX_COMPOSITION_COMPONENTS * 2 - 1]; \ |
| 1961 int *buf = components; \ | |
| 1962 int i, j; \ | |
| 1963 \ | |
| 1964 src = src_base; \ | |
| 1965 ONE_MORE_BYTE (c); /* skip 0x80 */ \ | |
| 1966 for (i = 0; i < MAX_COMPOSITION_COMPONENTS; i++) \ | |
| 1967 DECODE_EMACS_MULE_COMPOSITION_CHAR (buf); \ | |
| 1968 if (i < 2) \ | |
| 1969 goto invalid_code; \ | |
|
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
1970 ADD_COMPOSITION_DATA (charbuf, i, method); \ |
| 88365 | 1971 for (j = 0; j < i; j++) \ |
| 1972 *charbuf++ = components[j]; \ | |
| 1973 } while (0) | |
| 1974 | |
| 1975 | |
| 1976 #define DECODE_EMACS_MULE_20_RULEBASE_COMPOSITION(c) \ | |
| 1977 do { \ | |
| 1978 /* Emacs 20 style format for rule-base composition. */ \ | |
| 1979 /* 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
|
1980 enum composition_method method = COMPOSITION_WITH_RULE; \ |
| 88365 | 1981 int components[MAX_COMPOSITION_COMPONENTS * 2 - 1]; \ |
| 1982 int *buf = components; \ | |
| 1983 int i, j; \ | |
| 1984 \ | |
| 1985 DECODE_EMACS_MULE_COMPOSITION_CHAR (buf); \ | |
| 1986 for (i = 0; i < MAX_COMPOSITION_COMPONENTS; i++) \ | |
| 1987 { \ | |
|
88585
c7772f702227
(ONE_MORE_BYTE_NO_CHECK): Increment consumed_chars.
Kenichi Handa <handa@m17n.org>
parents:
88573
diff
changeset
|
1988 DECODE_EMACS_MULE_COMPOSITION_RULE_20 (buf); \ |
| 88365 | 1989 DECODE_EMACS_MULE_COMPOSITION_CHAR (buf); \ |
| 1990 } \ | |
| 1991 if (i < 1 || (buf - components) % 2 == 0) \ | |
| 1992 goto invalid_code; \ | |
| 1993 if (charbuf + i + (i / 2) + 1 < charbuf_end) \ | |
| 1994 goto no_more_source; \ | |
|
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
1995 ADD_COMPOSITION_DATA (buf, i, method); \ |
| 88365 | 1996 for (j = 0; j < i; j++) \ |
| 1997 *charbuf++ = components[j]; \ | |
| 1998 for (j = 0; j < i; j += 2) \ | |
| 1999 *charbuf++ = components[j]; \ | |
| 2000 } while (0) | |
| 2001 | |
|
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2002 |
|
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2003 static void |
| 88365 | 2004 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
|
2005 struct coding_system *coding; |
|
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2006 { |
| 89483 | 2007 const unsigned char *src = coding->source + coding->consumed; |
| 2008 const unsigned char *src_end = coding->source + coding->src_bytes; | |
| 2009 const unsigned char *src_base; | |
|
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
2010 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
|
2011 int *charbuf_end |
|
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
2012 = coding->charbuf + coding->charbuf_size - MAX_ANNOTATION_LENGTH; |
| 88365 | 2013 int consumed_chars = 0, consumed_chars_base; |
| 2014 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
|
2015 Lisp_Object attrs, charset_list; |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2016 int char_offset = coding->produced_char; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2017 int last_offset = char_offset; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2018 int last_id = charset_ascii; |
| 88365 | 2019 |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
2020 CODING_GET_INFO (coding, attrs, charset_list); |
| 88365 | 2021 |
| 2022 while (1) | |
| 2023 { | |
| 2024 int c; | |
| 2025 | |
| 2026 src_base = src; | |
| 2027 consumed_chars_base = consumed_chars; | |
| 2028 | |
| 2029 if (charbuf >= charbuf_end) | |
| 2030 break; | |
| 2031 | |
| 2032 ONE_MORE_BYTE (c); | |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
2033 if (c < 0) |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
2034 { |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
2035 *charbuf++ = -c; |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
2036 char_offset++; |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
2037 } |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
2038 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
|
2039 { |
| 88365 | 2040 *charbuf++ = c; |
| 2041 char_offset++; | |
|
32806
9502d0a5b2ad
(decode_coding_emacs_mule): If coding->eol_type is CR
Eli Zaretskii <eliz@gnu.org>
parents:
32745
diff
changeset
|
2042 } |
| 88365 | 2043 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
|
2044 { |
| 88365 | 2045 ONE_MORE_BYTE (c); |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
2046 if (c < 0) |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
2047 goto invalid_code; |
|
88585
c7772f702227
(ONE_MORE_BYTE_NO_CHECK): Increment consumed_chars.
Kenichi Handa <handa@m17n.org>
parents:
88573
diff
changeset
|
2048 if (c - 0xF2 >= COMPOSITION_RELATIVE |
|
c7772f702227
(ONE_MORE_BYTE_NO_CHECK): Increment consumed_chars.
Kenichi Handa <handa@m17n.org>
parents:
88573
diff
changeset
|
2049 && c - 0xF2 <= COMPOSITION_WITH_RULE_ALTCHARS) |
| 88365 | 2050 DECODE_EMACS_MULE_21_COMPOSITION (c); |
| 2051 else if (c < 0xC0) | |
| 2052 DECODE_EMACS_MULE_20_RELATIVE_COMPOSITION (c); | |
| 2053 else if (c == 0xFF) | |
| 2054 DECODE_EMACS_MULE_20_RULEBASE_COMPOSITION (c); | |
| 2055 else | |
| 2056 goto invalid_code; | |
|
32806
9502d0a5b2ad
(decode_coding_emacs_mule): If coding->eol_type is CR
Eli Zaretskii <eliz@gnu.org>
parents:
32745
diff
changeset
|
2057 } |
| 88365 | 2058 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
|
2059 { |
| 88365 | 2060 int nbytes, nchars; |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2061 int id; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2062 |
|
88585
c7772f702227
(ONE_MORE_BYTE_NO_CHECK): Increment consumed_chars.
Kenichi Handa <handa@m17n.org>
parents:
88573
diff
changeset
|
2063 src = src_base; |
|
c7772f702227
(ONE_MORE_BYTE_NO_CHECK): Increment consumed_chars.
Kenichi Handa <handa@m17n.org>
parents:
88573
diff
changeset
|
2064 consumed_chars = consumed_chars_base; |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2065 c = emacs_mule_char (coding, src, &nbytes, &nchars, &id); |
| 88365 | 2066 if (c < 0) |
|
34888
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
2067 { |
| 88365 | 2068 if (c == -2) |
| 2069 break; | |
| 2070 goto invalid_code; | |
|
34888
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
2071 } |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2072 if (last_id != id) |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2073 { |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2074 if (last_id != charset_ascii) |
|
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
2075 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
|
2076 last_id = id; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2077 last_offset = char_offset; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2078 } |
| 88365 | 2079 *charbuf++ = c; |
|
88585
c7772f702227
(ONE_MORE_BYTE_NO_CHECK): Increment consumed_chars.
Kenichi Handa <handa@m17n.org>
parents:
88573
diff
changeset
|
2080 src += nbytes; |
|
c7772f702227
(ONE_MORE_BYTE_NO_CHECK): Increment consumed_chars.
Kenichi Handa <handa@m17n.org>
parents:
88573
diff
changeset
|
2081 consumed_chars += nchars; |
| 88365 | 2082 char_offset++; |
|
34888
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
2083 } |
| 88365 | 2084 continue; |
| 2085 | |
| 2086 invalid_code: | |
| 2087 src = src_base; | |
| 2088 consumed_chars = consumed_chars_base; | |
| 2089 ONE_MORE_BYTE (c); | |
| 2090 *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
|
2091 char_offset++; |
| 88365 | 2092 coding->errors++; |
| 2093 } | |
| 2094 | |
| 2095 no_more_source: | |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2096 if (last_id != charset_ascii) |
|
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
2097 ADD_CHARSET_DATA (charbuf, char_offset - last_offset, last_id); |
| 88365 | 2098 coding->consumed_char += consumed_chars_base; |
| 2099 coding->consumed = src_base - coding->source; | |
| 2100 coding->charbuf_used = charbuf - coding->charbuf; | |
| 2101 } | |
| 2102 | |
| 2103 | |
| 2104 #define EMACS_MULE_LEADING_CODES(id, codes) \ | |
| 2105 do { \ | |
| 2106 if (id < 0xA0) \ | |
| 2107 codes[0] = id, codes[1] = 0; \ | |
| 2108 else if (id < 0xE0) \ | |
| 2109 codes[0] = 0x9A, codes[1] = id; \ | |
| 2110 else if (id < 0xF0) \ | |
| 2111 codes[0] = 0x9B, codes[1] = id; \ | |
| 2112 else if (id < 0xF5) \ | |
| 2113 codes[0] = 0x9C, codes[1] = id; \ | |
| 2114 else \ | |
| 2115 codes[0] = 0x9D, codes[1] = id; \ | |
| 2116 } while (0); | |
| 2117 | |
| 2118 | |
| 2119 static int | |
| 2120 encode_coding_emacs_mule (coding) | |
| 2121 struct coding_system *coding; | |
| 2122 { | |
| 2123 int multibytep = coding->dst_multibyte; | |
| 2124 int *charbuf = coding->charbuf; | |
| 2125 int *charbuf_end = charbuf + coding->charbuf_used; | |
| 2126 unsigned char *dst = coding->destination + coding->produced; | |
| 2127 unsigned char *dst_end = coding->destination + coding->dst_bytes; | |
| 2128 int safe_room = 8; | |
| 2129 int produced_chars = 0; | |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
2130 Lisp_Object attrs, charset_list; |
| 88365 | 2131 int c; |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2132 int preferred_charset_id = -1; |
| 88365 | 2133 |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
2134 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
|
2135 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
|
2136 { |
|
fc9cda144ffc
(encode_coding_emacs_mule): Resync charset_list to
Kenichi Handa <handa@m17n.org>
parents:
89642
diff
changeset
|
2137 CODING_ATTR_CHARSET_LIST (attrs) |
|
fc9cda144ffc
(encode_coding_emacs_mule): Resync charset_list to
Kenichi Handa <handa@m17n.org>
parents:
89642
diff
changeset
|
2138 = charset_list = Vemacs_mule_charset_list; |
|
fc9cda144ffc
(encode_coding_emacs_mule): Resync charset_list to
Kenichi Handa <handa@m17n.org>
parents:
89642
diff
changeset
|
2139 } |
| 88365 | 2140 |
| 2141 while (charbuf < charbuf_end) | |
| 2142 { | |
| 2143 ASSURE_DESTINATION (safe_room); | |
| 2144 c = *charbuf++; | |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2145 |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2146 if (c < 0) |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2147 { |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2148 /* Handle an annotation. */ |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2149 switch (*charbuf) |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2150 { |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2151 case CODING_ANNOTATE_COMPOSITION_MASK: |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2152 /* Not yet implemented. */ |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2153 break; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2154 case CODING_ANNOTATE_CHARSET_MASK: |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2155 preferred_charset_id = charbuf[3]; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2156 if (preferred_charset_id >= 0 |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2157 && NILP (Fmemq (make_number (preferred_charset_id), |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2158 charset_list))) |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2159 preferred_charset_id = -1; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2160 break; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2161 default: |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2162 abort (); |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2163 } |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2164 charbuf += -c - 1; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2165 continue; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2166 } |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2167 |
| 88365 | 2168 if (ASCII_CHAR_P (c)) |
| 2169 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
|
2170 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
|
2171 { |
|
7f284ac55b07
(encode_coding_emacs_mule): Pay attention to raw-8-bit chars.
Kenichi Handa <handa@m17n.org>
parents:
88681
diff
changeset
|
2172 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
|
2173 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
|
2174 } |
|
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2175 else |
|
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2176 { |
| 88365 | 2177 struct charset *charset; |
| 2178 unsigned code; | |
| 2179 int dimension; | |
| 2180 int emacs_mule_id; | |
| 2181 unsigned char leading_codes[2]; | |
| 2182 | |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2183 if (preferred_charset_id >= 0) |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2184 { |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2185 charset = CHARSET_FROM_ID (preferred_charset_id); |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2186 if (! CHAR_CHARSET_P (c, charset)) |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2187 charset = char_charset (c, charset_list, NULL); |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2188 } |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2189 else |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2190 charset = char_charset (c, charset_list, &code); |
| 88365 | 2191 if (! charset) |
| 2192 { | |
| 2193 c = coding->default_char; | |
| 2194 if (ASCII_CHAR_P (c)) | |
| 2195 { | |
| 2196 EMIT_ONE_ASCII_BYTE (c); | |
| 2197 continue; | |
| 2198 } | |
| 2199 charset = char_charset (c, charset_list, &code); | |
| 2200 } | |
| 2201 dimension = CHARSET_DIMENSION (charset); | |
| 2202 emacs_mule_id = CHARSET_EMACS_MULE_ID (charset); | |
| 2203 EMACS_MULE_LEADING_CODES (emacs_mule_id, leading_codes); | |
| 2204 EMIT_ONE_BYTE (leading_codes[0]); | |
| 2205 if (leading_codes[1]) | |
| 2206 EMIT_ONE_BYTE (leading_codes[1]); | |
| 2207 if (dimension == 1) | |
|
89642
e97441b6244b
(encode_coding_emacs_mule): Emit bytes with MSB.
Kenichi Handa <handa@m17n.org>
parents:
89575
diff
changeset
|
2208 EMIT_ONE_BYTE (code | 0x80); |
| 88365 | 2209 else |
| 2210 { | |
|
89642
e97441b6244b
(encode_coding_emacs_mule): Emit bytes with MSB.
Kenichi Handa <handa@m17n.org>
parents:
89575
diff
changeset
|
2211 code |= 0x8080; |
| 88365 | 2212 EMIT_ONE_BYTE (code >> 8); |
| 2213 EMIT_ONE_BYTE (code & 0xFF); | |
| 2214 } | |
| 17052 | 2215 } |
| 88365 | 2216 } |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
2217 record_conversion_result (coding, CODING_RESULT_SUCCESS); |
| 88365 | 2218 coding->produced_char += produced_chars; |
| 2219 coding->produced = dst - coding->destination; | |
| 2220 return 0; | |
|
34888
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
2221 } |
|
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2222 |
| 17052 | 2223 |
| 88365 | 2224 /*** 7. ISO2022 handlers ***/ |
| 17052 | 2225 |
| 2226 /* 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
|
2227 Since the intention of this note is to help understand the |
| 88771 | 2228 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
|
2229 SIMPLIFIED. For thorough understanding, please refer to the |
| 88771 | 2230 original document of ISO2022. This is equivalent to the standard |
| 2231 ECMA-35, obtainable from <URL:http://www.ecma.ch/> (*). | |
| 17052 | 2232 |
| 2233 ISO2022 provides many mechanisms to encode several character sets | |
| 88771 | 2234 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
|
2235 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
|
2236 text a little bit longer, but the text passes more easily through |
| 88771 | 2237 several types of gateway, some of which strip off the MSB (Most |
| 2238 Significant Bit). | |
| 2239 | |
| 2240 There are two kinds of character sets: control character sets and | |
| 2241 graphic character sets. The former contain control characters such | |
| 17052 | 2242 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
|
2243 functions are also provided by escape sequences). The latter |
| 88771 | 2244 contain graphic characters such as 'A' and '-'. Emacs recognizes |
| 17052 | 2245 two control character sets and many graphic character sets. |
| 2246 | |
| 2247 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
|
2248 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
|
2249 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
|
2250 - DIMENSION1_CHARS94 |
|
61c6b3be1d51
Comment for ISO 2022 encoding mechanism modified.
Kenichi Handa <handa@m17n.org>
parents:
24344
diff
changeset
|
2251 - DIMENSION1_CHARS96 |
|
61c6b3be1d51
Comment for ISO 2022 encoding mechanism modified.
Kenichi Handa <handa@m17n.org>
parents:
24344
diff
changeset
|
2252 - DIMENSION2_CHARS94 |
|
61c6b3be1d51
Comment for ISO 2022 encoding mechanism modified.
Kenichi Handa <handa@m17n.org>
parents:
24344
diff
changeset
|
2253 - DIMENSION2_CHARS96 |
|
61c6b3be1d51
Comment for ISO 2022 encoding mechanism modified.
Kenichi Handa <handa@m17n.org>
parents:
24344
diff
changeset
|
2254 |
|
61c6b3be1d51
Comment for ISO 2022 encoding mechanism modified.
Kenichi Handa <handa@m17n.org>
parents:
24344
diff
changeset
|
2255 In addition, each character set is assigned an identification tag, |
| 88771 | 2256 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
|
2257 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
|
2258 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
|
2259 (0x30..0x3F are for private use only). |
| 17052 | 2260 |
| 2261 Note (*): ECMA = European Computer Manufacturers Association | |
| 2262 | |
| 88771 | 2263 Here are examples of graphic character sets [NAME(<F>)]: |
| 17052 | 2264 o DIMENSION1_CHARS94 -- ASCII('B'), right-half-of-JISX0201('I'), ... |
| 2265 o DIMENSION1_CHARS96 -- right-half-of-ISO8859-1('A'), ... | |
| 2266 o DIMENSION2_CHARS94 -- GB2312('A'), JISX0208('B'), ... | |
| 2267 o DIMENSION2_CHARS96 -- none for the moment | |
| 2268 | |
|
24425
61c6b3be1d51
Comment for ISO 2022 encoding mechanism modified.
Kenichi Handa <handa@m17n.org>
parents:
24344
diff
changeset
|
2269 A code area (1 byte=8 bits) is divided into 4 areas, C0, GL, C1, and GR. |
| 17052 | 2270 C0 [0x00..0x1F] -- control character plane 0 |
| 2271 GL [0x20..0x7F] -- graphic character plane 0 | |
| 2272 C1 [0x80..0x9F] -- control character plane 1 | |
| 2273 GR [0xA0..0xFF] -- graphic character plane 1 | |
| 2274 | |
| 2275 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
|
2276 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
|
2277 - 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
|
2278 - 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
|
2279 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
|
2280 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
|
2281 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
|
2282 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
|
2283 defined to have corresponding escape sequences. |
| 17052 | 2284 |
| 2285 A graphic character set is at first designated to one of four | |
| 2286 graphic registers (G0 through G3), then these graphic registers are | |
| 2287 invoked to GL or GR. These designations and invocations can be | |
| 2288 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
|
2289 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
|
2290 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
|
2291 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
|
2292 |
|
61c6b3be1d51
Comment for ISO 2022 encoding mechanism modified.
Kenichi Handa <handa@m17n.org>
parents:
24344
diff
changeset
|
2293 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
|
2294 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
|
2295 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
|
2296 be used. |
| 17052 | 2297 |
| 2298 There are two ways of invocation: locking-shift and single-shift. | |
| 2299 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
|
2300 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
|
2301 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
|
2302 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
|
2303 escape sequences: |
| 17052 | 2304 |
| 2305 ---------------------------------------------------------------------- | |
|
24425
61c6b3be1d51
Comment for ISO 2022 encoding mechanism modified.
Kenichi Handa <handa@m17n.org>
parents:
24344
diff
changeset
|
2306 abbrev function cntrl escape seq description |
| 17052 | 2307 ---------------------------------------------------------------------- |
|
24425
61c6b3be1d51
Comment for ISO 2022 encoding mechanism modified.
Kenichi Handa <handa@m17n.org>
parents:
24344
diff
changeset
|
2308 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
|
2309 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
|
2310 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
|
2311 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
|
2312 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
|
2313 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
|
2314 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
|
2315 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
|
2316 SS3 (single-shift-3) 0x8F ESC 'O' invoke G3 for one char |
| 17052 | 2317 ---------------------------------------------------------------------- |
|
24425
61c6b3be1d51
Comment for ISO 2022 encoding mechanism modified.
Kenichi Handa <handa@m17n.org>
parents:
24344
diff
changeset
|
2318 (*) 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
|
2319 |
|
61c6b3be1d51
Comment for ISO 2022 encoding mechanism modified.
Kenichi Handa <handa@m17n.org>
parents:
24344
diff
changeset
|
2320 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
|
2321 ISO_CODE_XXX in `coding.h'. |
|
61c6b3be1d51
Comment for ISO 2022 encoding mechanism modified.
Kenichi Handa <handa@m17n.org>
parents:
24344
diff
changeset
|
2322 |
|
61c6b3be1d51
Comment for ISO 2022 encoding mechanism modified.
Kenichi Handa <handa@m17n.org>
parents:
24344
diff
changeset
|
2323 Designations are done by the following escape sequences: |
| 17052 | 2324 ---------------------------------------------------------------------- |
| 2325 escape sequence description | |
| 2326 ---------------------------------------------------------------------- | |
| 2327 ESC '(' <F> designate DIMENSION1_CHARS94<F> to G0 | |
| 2328 ESC ')' <F> designate DIMENSION1_CHARS94<F> to G1 | |
| 2329 ESC '*' <F> designate DIMENSION1_CHARS94<F> to G2 | |
| 2330 ESC '+' <F> designate DIMENSION1_CHARS94<F> to G3 | |
| 2331 ESC ',' <F> designate DIMENSION1_CHARS96<F> to G0 (*) | |
| 2332 ESC '-' <F> designate DIMENSION1_CHARS96<F> to G1 | |
| 2333 ESC '.' <F> designate DIMENSION1_CHARS96<F> to G2 | |
| 2334 ESC '/' <F> designate DIMENSION1_CHARS96<F> to G3 | |
| 2335 ESC '$' '(' <F> designate DIMENSION2_CHARS94<F> to G0 (**) | |
| 2336 ESC '$' ')' <F> designate DIMENSION2_CHARS94<F> to G1 | |
| 2337 ESC '$' '*' <F> designate DIMENSION2_CHARS94<F> to G2 | |
| 2338 ESC '$' '+' <F> designate DIMENSION2_CHARS94<F> to G3 | |
| 2339 ESC '$' ',' <F> designate DIMENSION2_CHARS96<F> to G0 (*) | |
| 2340 ESC '$' '-' <F> designate DIMENSION2_CHARS96<F> to G1 | |
| 2341 ESC '$' '.' <F> designate DIMENSION2_CHARS96<F> to G2 | |
| 2342 ESC '$' '/' <F> designate DIMENSION2_CHARS96<F> to G3 | |
| 2343 ---------------------------------------------------------------------- | |
| 2344 | |
| 2345 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
|
2346 of dimension 1, chars 94, and final character <F>, etc... |
| 17052 | 2347 |
| 2348 Note (*): Although these designations are not allowed in ISO2022, | |
| 2349 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
|
2350 CHARS96 character sets in a coding system which is characterized as |
| 17052 | 2351 7-bit environment, non-locking-shift, and non-single-shift. |
| 2352 | |
| 2353 Note (**): If <F> is '@', 'A', or 'B', the intermediate character | |
| 88365 | 2354 '(' must be omitted. We refer to this as "short-form" hereafter. |
| 2355 | |
| 88771 | 2356 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
|
2357 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
|
2358 coding systems such as Compound Text (used in X11's inter client |
| 88771 | 2359 communication, ISO-2022-JP (used in Japanese Internet), ISO-2022-KR |
| 2360 (used in Korean Internet), EUC (Extended UNIX Code, used in Asian | |
| 17052 | 2361 localized platforms), and all of these are variants of ISO2022. |
| 2362 | |
| 2363 In addition to the above, Emacs handles two more kinds of escape | |
| 2364 sequences: ISO6429's direction specification and Emacs' private | |
| 2365 sequence for specifying character composition. | |
| 2366 | |
|
24425
61c6b3be1d51
Comment for ISO 2022 encoding mechanism modified.
Kenichi Handa <handa@m17n.org>
parents:
24344
diff
changeset
|
2367 ISO6429's direction specification takes the following form: |
| 17052 | 2368 o CSI ']' -- end of the current direction |
| 2369 o CSI '0' ']' -- end of the current direction | |
| 2370 o CSI '1' ']' -- start of left-to-right text | |
| 2371 o CSI '2' ']' -- start of right-to-left text | |
| 2372 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
|
2373 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
|
2374 |
|
61c6b3be1d51
Comment for ISO 2022 encoding mechanism modified.
Kenichi Handa <handa@m17n.org>
parents:
24344
diff
changeset
|
2375 Character composition specification takes the following form: |
| 26847 | 2376 o ESC '0' -- start relative composition |
| 2377 o ESC '1' -- end composition | |
| 2378 o ESC '2' -- start rule-base composition (*) | |
| 2379 o ESC '3' -- start relative composition with alternate chars (**) | |
| 2380 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
|
2381 Since these are not standard escape sequences of any ISO standard, |
| 88771 | 2382 the use of them with these meanings is restricted to Emacs only. |
| 2383 | |
| 2384 (*) This form is used only in Emacs 20.7 and older versions, | |
| 2385 but newer versions can safely decode it. | |
| 2386 (**) This form is used only in Emacs 21.1 and newer versions, | |
| 2387 and older versions can't decode it. | |
| 2388 | |
| 2389 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
|
2390 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
|
2391 |
|
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2392 COMPOSITION_RELATIVE: |
| 26847 | 2393 ESC 0 CHAR [ CHAR ] ESC 1 |
| 88771 | 2394 COMPOSITION_WITH_RULE: |
| 26847 | 2395 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
|
2396 COMPOSITION_WITH_ALTCHARS: |
| 26847 | 2397 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
|
2398 COMPOSITION_WITH_RULE_ALTCHARS: |
| 26847 | 2399 ESC 4 ALTCHAR [ RULE ALTCHAR ] ESC 0 CHAR [ CHAR ] ESC 1 */ |
| 17052 | 2400 |
| 2401 enum iso_code_class_type iso_code_class[256]; | |
| 2402 | |
| 88365 | 2403 #define SAFE_CHARSET_P(coding, id) \ |
| 2404 ((id) <= (coding)->max_charset_id \ | |
| 2405 && (coding)->safe_charsets[id] >= 0) | |
| 2406 | |
| 2407 | |
| 2408 #define SHIFT_OUT_OK(category) \ | |
| 2409 (CODING_ISO_INITIAL (&coding_categories[category], 1) >= 0) | |
| 2410 | |
| 2411 static void | |
|
88631
780b91d4a7e5
(setup_iso_safe_charsets): Fix arg decl for K&R.
Dave Love <fx@gnu.org>
parents:
88607
diff
changeset
|
2412 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
|
2413 Lisp_Object attrs; |
| 88365 | 2414 { |
| 2415 Lisp_Object charset_list, safe_charsets; | |
| 2416 Lisp_Object request; | |
| 2417 Lisp_Object reg_usage; | |
| 2418 Lisp_Object tail; | |
| 2419 int reg94, reg96; | |
| 2420 int flags = XINT (AREF (attrs, coding_attr_iso_flags)); | |
| 2421 int max_charset_id; | |
| 2422 | |
| 2423 charset_list = CODING_ATTR_CHARSET_LIST (attrs); | |
| 2424 if ((flags & CODING_ISO_FLAG_FULL_SUPPORT) | |
| 2425 && ! EQ (charset_list, Viso_2022_charset_list)) | |
| 2426 { | |
| 2427 CODING_ATTR_CHARSET_LIST (attrs) | |
| 2428 = charset_list = Viso_2022_charset_list; | |
| 2429 ASET (attrs, coding_attr_safe_charsets, Qnil); | |
| 2430 } | |
| 2431 | |
| 2432 if (STRINGP (AREF (attrs, coding_attr_safe_charsets))) | |
| 2433 return; | |
| 2434 | |
| 2435 max_charset_id = 0; | |
| 2436 for (tail = charset_list; CONSP (tail); tail = XCDR (tail)) | |
| 2437 { | |
| 2438 int id = XINT (XCAR (tail)); | |
| 2439 if (max_charset_id < id) | |
| 2440 max_charset_id = id; | |
| 2441 } | |
| 2442 | |
| 2443 safe_charsets = Fmake_string (make_number (max_charset_id + 1), | |
| 2444 make_number (255)); | |
| 2445 request = AREF (attrs, coding_attr_iso_request); | |
| 2446 reg_usage = AREF (attrs, coding_attr_iso_usage); | |
| 2447 reg94 = XINT (XCAR (reg_usage)); | |
| 2448 reg96 = XINT (XCDR (reg_usage)); | |
| 2449 | |
| 2450 for (tail = charset_list; CONSP (tail); tail = XCDR (tail)) | |
| 2451 { | |
| 2452 Lisp_Object id; | |
| 2453 Lisp_Object reg; | |
| 2454 struct charset *charset; | |
| 2455 | |
| 2456 id = XCAR (tail); | |
| 2457 charset = CHARSET_FROM_ID (XINT (id)); | |
|
88681
2cdfbffa8a0d
(CODING_ISO_FLAG_USE_ROMAN): New macro
Kenichi Handa <handa@m17n.org>
parents:
88669
diff
changeset
|
2458 reg = Fcdr (Fassq (id, request)); |
| 88365 | 2459 if (! NILP (reg)) |
| 89483 | 2460 SSET (safe_charsets, XINT (id), XINT (reg)); |
| 88365 | 2461 else if (charset->iso_chars_96) |
| 2462 { | |
| 2463 if (reg96 < 4) | |
| 89483 | 2464 SSET (safe_charsets, XINT (id), reg96); |
| 88365 | 2465 } |
| 2466 else | |
| 2467 { | |
| 2468 if (reg94 < 4) | |
| 89483 | 2469 SSET (safe_charsets, XINT (id), reg94); |
| 88365 | 2470 } |
| 2471 } | |
| 2472 ASET (attrs, coding_attr_safe_charsets, safe_charsets); | |
| 2473 } | |
| 2474 | |
|
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
2475 |
| 17052 | 2476 /* 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
|
2477 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
|
2478 If it is, return 1, else return 0. */ |
| 17052 | 2479 |
|
34531
37f85e931855
(ONE_MORE_BYTE_CHECK_MULTIBYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34197
diff
changeset
|
2480 static int |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2481 detect_coding_iso_2022 (coding, detect_info) |
| 88365 | 2482 struct coding_system *coding; |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2483 struct coding_detection_info *detect_info; |
| 17052 | 2484 { |
| 89483 | 2485 const unsigned char *src = coding->source, *src_base = src; |
| 2486 const unsigned char *src_end = coding->source + coding->src_bytes; | |
| 88365 | 2487 int multibytep = coding->src_multibyte; |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2488 int single_shifting = 0; |
| 88365 | 2489 int id; |
| 2490 int c, c1; | |
| 2491 int consumed_chars = 0; | |
| 2492 int i; | |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2493 int rejected = 0; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2494 int found = 0; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2495 |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2496 detect_info->checked |= CATEGORY_MASK_ISO; |
| 88365 | 2497 |
| 2498 for (i = coding_category_iso_7; i <= coding_category_iso_8_else; i++) | |
| 2499 { | |
| 2500 struct coding_system *this = &(coding_categories[i]); | |
| 2501 Lisp_Object attrs, val; | |
| 2502 | |
| 2503 attrs = CODING_ID_ATTRS (this->id); | |
| 2504 if (CODING_ISO_FLAGS (this) & CODING_ISO_FLAG_FULL_SUPPORT | |
| 2505 && ! EQ (CODING_ATTR_SAFE_CHARSETS (attrs), Viso_2022_charset_list)) | |
| 2506 setup_iso_safe_charsets (attrs); | |
| 2507 val = CODING_ATTR_SAFE_CHARSETS (attrs); | |
| 89483 | 2508 this->max_charset_id = SCHARS (val) - 1; |
| 2509 this->safe_charsets = (char *) SDATA (val); | |
| 88365 | 2510 } |
| 2511 | |
| 2512 /* A coding system of this category is always ASCII compatible. */ | |
| 2513 src += coding->head_ascii; | |
| 2514 | |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2515 while (rejected != CATEGORY_MASK_ISO) |
| 88365 | 2516 { |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
2517 src_base = src; |
| 88365 | 2518 ONE_MORE_BYTE (c); |
| 17052 | 2519 switch (c) |
| 2520 { | |
| 2521 case ISO_CODE_ESC: | |
|
30204
35aec8514228
(inhibit_iso_escape_detection): New variable.
Kenichi Handa <handa@m17n.org>
parents:
29985
diff
changeset
|
2522 if (inhibit_iso_escape_detection) |
|
35aec8514228
(inhibit_iso_escape_detection): New variable.
Kenichi Handa <handa@m17n.org>
parents:
29985
diff
changeset
|
2523 break; |
|
23088
45c36d636f66
(detect_coding_iso2022): Don't check the byte length of
Kenichi Handa <handa@m17n.org>
parents:
23082
diff
changeset
|
2524 single_shifting = 0; |
| 88365 | 2525 ONE_MORE_BYTE (c); |
|
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
2526 if (c >= '(' && c <= '/') |
|
19134
8fa6e23f8d22
(detect_coding_iso2022): Do not exclude posibility of
Kenichi Handa <handa@m17n.org>
parents:
19118
diff
changeset
|
2527 { |
|
8fa6e23f8d22
(detect_coding_iso2022): Do not exclude posibility of
Kenichi Handa <handa@m17n.org>
parents:
19118
diff
changeset
|
2528 /* Designation sequence for a charset of dimension 1. */ |
| 88365 | 2529 ONE_MORE_BYTE (c1); |
|
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
2530 if (c1 < ' ' || c1 >= 0x80 |
| 88365 | 2531 || (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
|
2532 /* Invalid designation sequence. Just ignore. */ |
|
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
2533 break; |
|
19134
8fa6e23f8d22
(detect_coding_iso2022): Do not exclude posibility of
Kenichi Handa <handa@m17n.org>
parents:
19118
diff
changeset
|
2534 } |
|
8fa6e23f8d22
(detect_coding_iso2022): Do not exclude posibility of
Kenichi Handa <handa@m17n.org>
parents:
19118
diff
changeset
|
2535 else if (c == '$') |
| 17052 | 2536 { |
|
19134
8fa6e23f8d22
(detect_coding_iso2022): Do not exclude posibility of
Kenichi Handa <handa@m17n.org>
parents:
19118
diff
changeset
|
2537 /* Designation sequence for a charset of dimension 2. */ |
| 88365 | 2538 ONE_MORE_BYTE (c); |
|
19134
8fa6e23f8d22
(detect_coding_iso2022): Do not exclude posibility of
Kenichi Handa <handa@m17n.org>
parents:
19118
diff
changeset
|
2539 if (c >= '@' && c <= 'B') |
|
8fa6e23f8d22
(detect_coding_iso2022): Do not exclude posibility of
Kenichi Handa <handa@m17n.org>
parents:
19118
diff
changeset
|
2540 /* Designation for JISX0208.1978, GB2312, or JISX0208. */ |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2541 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
|
2542 else if (c >= '(' && c <= '/') |
|
17320
9d15bec5f47e
(detect_coding_iso2022, detect_coding_mask): Ignore
Kenichi Handa <handa@m17n.org>
parents:
17304
diff
changeset
|
2543 { |
| 88365 | 2544 ONE_MORE_BYTE (c1); |
|
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
2545 if (c1 < ' ' || c1 >= 0x80 |
| 88365 | 2546 || (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
|
2547 /* Invalid designation sequence. Just ignore. */ |
|
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
2548 break; |
|
17320
9d15bec5f47e
(detect_coding_iso2022, detect_coding_mask): Ignore
Kenichi Handa <handa@m17n.org>
parents:
17304
diff
changeset
|
2549 } |
|
19134
8fa6e23f8d22
(detect_coding_iso2022): Do not exclude posibility of
Kenichi Handa <handa@m17n.org>
parents:
19118
diff
changeset
|
2550 else |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2551 /* Invalid designation sequence. Just ignore it. */ |
|
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
2552 break; |
|
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
2553 } |
|
23116
6736da064f4a
(detect_coding_iso2022): Handle ESC N and ESC O
Kenichi Handa <handa@m17n.org>
parents:
23089
diff
changeset
|
2554 else if (c == 'N' || c == 'O') |
|
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
2555 { |
|
23116
6736da064f4a
(detect_coding_iso2022): Handle ESC N and ESC O
Kenichi Handa <handa@m17n.org>
parents:
23089
diff
changeset
|
2556 /* ESC <Fe> for SS2 or SS3. */ |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2557 single_shifting = 1; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2558 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
|
2559 break; |
|
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
2560 } |
| 26847 | 2561 else if (c >= '0' && c <= '4') |
| 2562 { | |
| 2563 /* ESC <Fp> for start/end composition. */ | |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2564 found |= CATEGORY_MASK_ISO; |
| 26847 | 2565 break; |
| 2566 } | |
|
19134
8fa6e23f8d22
(detect_coding_iso2022): Do not exclude posibility of
Kenichi Handa <handa@m17n.org>
parents:
19118
diff
changeset
|
2567 else |
| 88365 | 2568 { |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2569 /* Invalid escape sequence. Just ignore it. */ |
| 88365 | 2570 break; |
| 2571 } | |
|
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
2572 |
|
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
2573 /* 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
|
2574 rejected |= CATEGORY_MASK_ISO_8BIT; |
| 88365 | 2575 if (SAFE_CHARSET_P (&coding_categories[coding_category_iso_7], |
| 2576 id)) | |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2577 found |= CATEGORY_MASK_ISO_7; |
|
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
2578 else |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2579 rejected |= CATEGORY_MASK_ISO_7; |
| 88365 | 2580 if (SAFE_CHARSET_P (&coding_categories[coding_category_iso_7_tight], |
| 2581 id)) | |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2582 found |= CATEGORY_MASK_ISO_7_TIGHT; |
|
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
2583 else |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2584 rejected |= CATEGORY_MASK_ISO_7_TIGHT; |
| 88365 | 2585 if (SAFE_CHARSET_P (&coding_categories[coding_category_iso_7_else], |
| 2586 id)) | |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2587 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
|
2588 else |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2589 rejected |= CATEGORY_MASK_ISO_7_ELSE; |
| 88365 | 2590 if (SAFE_CHARSET_P (&coding_categories[coding_category_iso_8_else], |
| 2591 id)) | |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2592 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
|
2593 else |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2594 rejected |= CATEGORY_MASK_ISO_8_ELSE; |
| 17052 | 2595 break; |
| 2596 | |
| 2597 case ISO_CODE_SO: | |
|
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
2598 case ISO_CODE_SI: |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2599 /* Locking shift out/in. */ |
|
30204
35aec8514228
(inhibit_iso_escape_detection): New variable.
Kenichi Handa <handa@m17n.org>
parents:
29985
diff
changeset
|
2600 if (inhibit_iso_escape_detection) |
|
35aec8514228
(inhibit_iso_escape_detection): New variable.
Kenichi Handa <handa@m17n.org>
parents:
29985
diff
changeset
|
2601 break; |
|
23088
45c36d636f66
(detect_coding_iso2022): Don't check the byte length of
Kenichi Handa <handa@m17n.org>
parents:
23082
diff
changeset
|
2602 single_shifting = 0; |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2603 rejected |= CATEGORY_MASK_ISO_7BIT | CATEGORY_MASK_ISO_8BIT; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2604 found |= CATEGORY_MASK_ISO_ELSE; |
|
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
2605 break; |
|
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
2606 |
| 17052 | 2607 case ISO_CODE_CSI: |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2608 /* Control sequence introducer. */ |
|
23088
45c36d636f66
(detect_coding_iso2022): Don't check the byte length of
Kenichi Handa <handa@m17n.org>
parents:
23082
diff
changeset
|
2609 single_shifting = 0; |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2610 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
|
2611 found |= CATEGORY_MASK_ISO_8_ELSE; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2612 goto check_extra_latin; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2613 |
| 17052 | 2614 case ISO_CODE_SS2: |
| 2615 case ISO_CODE_SS3: | |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2616 /* Single shift. */ |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2617 if (inhibit_iso_escape_detection) |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2618 break; |
|
89780
a53cb5864a40
(detect_coding_iso_2022): Fix handling of SS2 and SS3.
Kenichi Handa <handa@m17n.org>
parents:
89779
diff
changeset
|
2619 single_shifting = 0; |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2620 rejected |= CATEGORY_MASK_ISO_7BIT; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2621 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
|
2622 & 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
|
2623 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
|
2624 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
|
2625 & 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
|
2626 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
|
2627 if (single_shifting) |
|
a53cb5864a40
(detect_coding_iso_2022): Fix handling of SS2 and SS3.
Kenichi Handa <handa@m17n.org>
parents:
89779
diff
changeset
|
2628 break; |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2629 goto check_extra_latin; |
| 17052 | 2630 |
| 2631 default: | |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
2632 if (c < 0) |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
2633 continue; |
| 17052 | 2634 if (c < 0x80) |
|
23088
45c36d636f66
(detect_coding_iso2022): Don't check the byte length of
Kenichi Handa <handa@m17n.org>
parents:
23082
diff
changeset
|
2635 { |
|
45c36d636f66
(detect_coding_iso2022): Don't check the byte length of
Kenichi Handa <handa@m17n.org>
parents:
23082
diff
changeset
|
2636 single_shifting = 0; |
|
45c36d636f66
(detect_coding_iso2022): Don't check the byte length of
Kenichi Handa <handa@m17n.org>
parents:
23082
diff
changeset
|
2637 break; |
|
45c36d636f66
(detect_coding_iso2022): Don't check the byte length of
Kenichi Handa <handa@m17n.org>
parents:
23082
diff
changeset
|
2638 } |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2639 if (c >= 0xA0) |
|
19280
e755044718ee
(ENCODE_ISO_CHARACTER_DIMENSION1): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
19193
diff
changeset
|
2640 { |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2641 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
|
2642 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
|
2643 /* 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
|
2644 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
|
2645 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
|
2646 only when we are not single shifting. */ |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2647 if (! single_shifting |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2648 && ! (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
|
2649 { |
|
29299
b33b38d81020
(detect_coding_iso2022): Fix code for checking
Kenichi Handa <handa@m17n.org>
parents:
29275
diff
changeset
|
2650 int i = 1; |
|
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2651 while (src < src_end) |
|
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2652 { |
| 88365 | 2653 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
|
2654 if (c < 0xA0) |
|
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2655 break; |
|
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2656 i++; |
|
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2657 } |
|
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2658 |
|
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2659 if (i & 1 && src < src_end) |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2660 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
|
2661 else |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2662 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
|
2663 } |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2664 break; |
| 17052 | 2665 } |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2666 check_extra_latin: |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2667 single_shifting = 0; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2668 if (! VECTORP (Vlatin_extra_code_table) |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2669 || NILP (XVECTOR (Vlatin_extra_code_table)->contents[c])) |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2670 { |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2671 rejected = CATEGORY_MASK_ISO; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2672 break; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2673 } |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2674 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
|
2675 & CODING_ISO_FLAG_LATIN_EXTRA) |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2676 found |= CATEGORY_MASK_ISO_8_1; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2677 else |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2678 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
|
2679 rejected |= CATEGORY_MASK_ISO_8_2; |
| 17052 | 2680 } |
| 2681 } | |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2682 detect_info->rejected |= CATEGORY_MASK_ISO; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2683 return 0; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2684 |
| 88365 | 2685 no_more_source: |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2686 detect_info->rejected |= rejected; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2687 detect_info->found |= (found & ~rejected); |
| 88365 | 2688 return 1; |
| 17052 | 2689 } |
| 2690 | |
| 2691 | |
| 2692 /* Set designation state into CODING. */ | |
| 88365 | 2693 #define DECODE_DESIGNATION(reg, dim, chars_96, final) \ |
| 2694 do { \ | |
| 2695 int id, prev; \ | |
| 2696 \ | |
| 2697 if (final < '0' || final >= 128 \ | |
| 2698 || ((id = ISO_CHARSET_TABLE (dim, chars_96, final)) < 0) \ | |
| 2699 || !SAFE_CHARSET_P (coding, id)) \ | |
| 2700 { \ | |
| 2701 CODING_ISO_DESIGNATION (coding, reg) = -2; \ | |
| 2702 goto invalid_code; \ | |
| 2703 } \ | |
| 2704 prev = CODING_ISO_DESIGNATION (coding, reg); \ | |
|
88681
2cdfbffa8a0d
(CODING_ISO_FLAG_USE_ROMAN): New macro
Kenichi Handa <handa@m17n.org>
parents:
88669
diff
changeset
|
2705 if (id == charset_jisx0201_roman) \ |
|
2cdfbffa8a0d
(CODING_ISO_FLAG_USE_ROMAN): New macro
Kenichi Handa <handa@m17n.org>
parents:
88669
diff
changeset
|
2706 { \ |
|
2cdfbffa8a0d
(CODING_ISO_FLAG_USE_ROMAN): New macro
Kenichi Handa <handa@m17n.org>
parents:
88669
diff
changeset
|
2707 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
|
2708 id = charset_ascii; \ |
|
2cdfbffa8a0d
(CODING_ISO_FLAG_USE_ROMAN): New macro
Kenichi Handa <handa@m17n.org>
parents:
88669
diff
changeset
|
2709 } \ |
|
2cdfbffa8a0d
(CODING_ISO_FLAG_USE_ROMAN): New macro
Kenichi Handa <handa@m17n.org>
parents:
88669
diff
changeset
|
2710 else if (id == charset_jisx0208_1978) \ |
|
2cdfbffa8a0d
(CODING_ISO_FLAG_USE_ROMAN): New macro
Kenichi Handa <handa@m17n.org>
parents:
88669
diff
changeset
|
2711 { \ |
|
2cdfbffa8a0d
(CODING_ISO_FLAG_USE_ROMAN): New macro
Kenichi Handa <handa@m17n.org>
parents:
88669
diff
changeset
|
2712 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
|
2713 id = charset_jisx0208; \ |
|
2cdfbffa8a0d
(CODING_ISO_FLAG_USE_ROMAN): New macro
Kenichi Handa <handa@m17n.org>
parents:
88669
diff
changeset
|
2714 } \ |
| 88365 | 2715 CODING_ISO_DESIGNATION (coding, reg) = id; \ |
| 2716 /* If there was an invalid designation to REG previously, and this \ | |
| 2717 designation is ASCII to REG, we should keep this designation \ | |
| 2718 sequence. */ \ | |
| 2719 if (prev == -2 && id == charset_ascii) \ | |
| 2720 goto invalid_code; \ | |
| 17052 | 2721 } while (0) |
| 2722 | |
| 88365 | 2723 |
| 2724 #define MAYBE_FINISH_COMPOSITION() \ | |
| 2725 do { \ | |
| 2726 int i; \ | |
| 2727 if (composition_state == COMPOSING_NO) \ | |
| 2728 break; \ | |
| 2729 /* It is assured that we have enough room for producing \ | |
| 2730 characters stored in the table `components'. */ \ | |
| 2731 if (charbuf + component_idx > charbuf_end) \ | |
| 2732 goto no_more_source; \ | |
| 2733 composition_state = COMPOSING_NO; \ | |
| 2734 if (method == COMPOSITION_RELATIVE \ | |
| 2735 || method == COMPOSITION_WITH_ALTCHARS) \ | |
| 2736 { \ | |
| 2737 for (i = 0; i < component_idx; i++) \ | |
| 2738 *charbuf++ = components[i]; \ | |
| 2739 char_offset += component_idx; \ | |
| 2740 } \ | |
| 2741 else \ | |
| 2742 { \ | |
| 2743 for (i = 0; i < component_idx; i += 2) \ | |
| 2744 *charbuf++ = components[i]; \ | |
| 2745 char_offset += (component_idx / 2) + 1; \ | |
| 2746 } \ | |
| 2747 } while (0) | |
| 2748 | |
|
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
2749 |
|
34888
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
2750 /* 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
|
2751 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
|
2752 ESC 2 : rulebase composition : ESC 2 CHAR RULE CHAR RULE ... CHAR ESC 1 |
| 88365 | 2753 ESC 3 : altchar composition : ESC 3 CHAR ... ESC 0 CHAR ... ESC 1 |
| 2754 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
|
2755 */ |
| 26847 | 2756 |
| 88365 | 2757 #define DECODE_COMPOSITION_START(c1) \ |
| 26847 | 2758 do { \ |
| 88365 | 2759 if (c1 == '0' \ |
|
88585
c7772f702227
(ONE_MORE_BYTE_NO_CHECK): Increment consumed_chars.
Kenichi Handa <handa@m17n.org>
parents:
88573
diff
changeset
|
2760 && composition_state == COMPOSING_COMPONENT_RULE) \ |
| 26847 | 2761 { \ |
| 88365 | 2762 component_len = component_idx; \ |
| 2763 composition_state = COMPOSING_CHAR; \ | |
| 26847 | 2764 } \ |
| 2765 else \ | |
| 2766 { \ | |
| 89483 | 2767 const unsigned char *p; \ |
| 88365 | 2768 \ |
| 2769 MAYBE_FINISH_COMPOSITION (); \ | |
| 2770 if (charbuf + MAX_COMPOSITION_COMPONENTS > charbuf_end) \ | |
| 2771 goto no_more_source; \ | |
| 2772 for (p = src; p < src_end - 1; p++) \ | |
| 2773 if (*p == ISO_CODE_ESC && p[1] == '1') \ | |
| 2774 break; \ | |
| 2775 if (p == src_end - 1) \ | |
| 2776 { \ | |
| 2777 if (coding->mode & CODING_MODE_LAST_BLOCK) \ | |
| 2778 goto invalid_code; \ | |
| 2779 goto no_more_source; \ | |
| 2780 } \ | |
| 2781 \ | |
| 2782 /* This is surely the start of a composition. */ \ | |
| 2783 method = (c1 == '0' ? COMPOSITION_RELATIVE \ | |
| 2784 : c1 == '2' ? COMPOSITION_WITH_RULE \ | |
| 2785 : c1 == '3' ? COMPOSITION_WITH_ALTCHARS \ | |
| 2786 : COMPOSITION_WITH_RULE_ALTCHARS); \ | |
| 2787 composition_state = (c1 <= '2' ? COMPOSING_CHAR \ | |
| 2788 : COMPOSING_COMPONENT_CHAR); \ | |
| 2789 component_idx = component_len = 0; \ | |
| 26847 | 2790 } \ |
| 2791 } while (0) | |
| 2792 | |
| 88365 | 2793 |
| 2794 /* Handle compositoin end sequence ESC 1. */ | |
| 2795 | |
| 2796 #define DECODE_COMPOSITION_END() \ | |
| 2797 do { \ | |
| 2798 int nchars = (component_len > 0 ? component_idx - component_len \ | |
| 2799 : method == COMPOSITION_RELATIVE ? component_idx \ | |
| 2800 : (component_idx + 1) / 2); \ | |
| 2801 int i; \ | |
| 2802 int *saved_charbuf = charbuf; \ | |
| 2803 \ | |
|
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
2804 ADD_COMPOSITION_DATA (charbuf, nchars, method); \ |
| 88365 | 2805 if (method != COMPOSITION_RELATIVE) \ |
| 2806 { \ | |
| 2807 if (component_len == 0) \ | |
| 2808 for (i = 0; i < component_idx; i++) \ | |
| 2809 *charbuf++ = components[i]; \ | |
| 2810 else \ | |
| 2811 for (i = 0; i < component_len; i++) \ | |
| 2812 *charbuf++ = components[i]; \ | |
| 2813 *saved_charbuf = saved_charbuf - charbuf; \ | |
| 2814 } \ | |
| 2815 if (method == COMPOSITION_WITH_RULE) \ | |
| 2816 for (i = 0; i < component_idx; i += 2, char_offset++) \ | |
| 2817 *charbuf++ = components[i]; \ | |
| 2818 else \ | |
| 2819 for (i = component_len; i < component_idx; i++, char_offset++) \ | |
| 2820 *charbuf++ = components[i]; \ | |
| 2821 coding->annotated = 1; \ | |
| 2822 composition_state = COMPOSING_NO; \ | |
| 2823 } while (0) | |
| 2824 | |
| 2825 | |
| 26847 | 2826 /* Decode a composition rule from the byte C1 (and maybe one more byte |
| 2827 from SRC) and store one encoded composition rule in | |
| 2828 coding->cmp_data. */ | |
| 2829 | |
| 2830 #define DECODE_COMPOSITION_RULE(c1) \ | |
| 2831 do { \ | |
| 2832 (c1) -= 32; \ | |
| 2833 if (c1 < 81) /* old format (before ver.21) */ \ | |
| 2834 { \ | |
| 2835 int gref = (c1) / 9; \ | |
| 2836 int nref = (c1) % 9; \ | |
| 2837 if (gref == 4) gref = 10; \ | |
| 2838 if (nref == 4) nref = 10; \ | |
| 88365 | 2839 c1 = COMPOSITION_ENCODE_RULE (gref, nref); \ |
| 26847 | 2840 } \ |
|
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2841 else if (c1 < 93) /* new format (after ver.21) */ \ |
| 26847 | 2842 { \ |
| 2843 ONE_MORE_BYTE (c2); \ | |
| 88365 | 2844 c1 = COMPOSITION_ENCODE_RULE (c1 - 81, c2 - 32); \ |
| 26847 | 2845 } \ |
| 88365 | 2846 else \ |
| 2847 c1 = 0; \ | |
| 26847 | 2848 } while (0) |
| 2849 | |
| 2850 | |
| 17052 | 2851 /* See the above "GENERAL NOTES on `decode_coding_XXX ()' functions". */ |
| 2852 | |
|
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2853 static void |
| 88365 | 2854 decode_coding_iso_2022 (coding) |
| 17052 | 2855 struct coding_system *coding; |
| 2856 { | |
| 89483 | 2857 const unsigned char *src = coding->source + coding->consumed; |
| 2858 const unsigned char *src_end = coding->source + coding->src_bytes; | |
| 2859 const unsigned char *src_base; | |
|
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
2860 int *charbuf = coding->charbuf + coding->charbuf_used; |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2861 int *charbuf_end |
|
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
2862 = coding->charbuf + coding->charbuf_size - 4 - MAX_ANNOTATION_LENGTH; |
| 88365 | 2863 int consumed_chars = 0, consumed_chars_base; |
| 2864 int multibytep = coding->src_multibyte; | |
| 17052 | 2865 /* Charsets invoked to graphic plane 0 and 1 respectively. */ |
| 88365 | 2866 int charset_id_0 = CODING_ISO_INVOKED_CHARSET (coding, 0); |
| 2867 int charset_id_1 = CODING_ISO_INVOKED_CHARSET (coding, 1); | |
| 2868 struct charset *charset; | |
| 2869 int c; | |
| 2870 /* For handling composition sequence. */ | |
| 2871 #define COMPOSING_NO 0 | |
| 2872 #define COMPOSING_CHAR 1 | |
| 2873 #define COMPOSING_RULE 2 | |
| 2874 #define COMPOSING_COMPONENT_CHAR 3 | |
| 2875 #define COMPOSING_COMPONENT_RULE 4 | |
| 2876 | |
| 2877 int composition_state = COMPOSING_NO; | |
| 2878 enum composition_method method; | |
| 2879 int components[MAX_COMPOSITION_COMPONENTS * 2 + 1]; | |
| 2880 int component_idx; | |
| 2881 int component_len; | |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
2882 Lisp_Object attrs, charset_list; |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2883 int char_offset = coding->produced_char; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2884 int last_offset = char_offset; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2885 int last_id = charset_ascii; |
| 88365 | 2886 |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
2887 CODING_GET_INFO (coding, attrs, charset_list); |
| 88365 | 2888 setup_iso_safe_charsets (attrs); |
|
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2889 |
|
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2890 while (1) |
|
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2891 { |
|
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2892 int c1, c2; |
|
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2893 |
|
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2894 src_base = src; |
| 88365 | 2895 consumed_chars_base = consumed_chars; |
| 2896 | |
| 2897 if (charbuf >= charbuf_end) | |
| 2898 break; | |
| 2899 | |
|
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2900 ONE_MORE_BYTE (c1); |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
2901 if (c1 < 0) |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
2902 goto invalid_code; |
| 17052 | 2903 |
|
89279
1fd77c471ee6
(decode_coding_utf_8): When eol_type is Qdos, handle
Kenichi Handa <handa@m17n.org>
parents:
89227
diff
changeset
|
2904 /* We produce at most one character. */ |
| 17052 | 2905 switch (iso_code_class [c1]) |
| 2906 { | |
| 2907 case ISO_0x20_or_0x7F: | |
| 88365 | 2908 if (composition_state != COMPOSING_NO) |
| 26847 | 2909 { |
| 88365 | 2910 if (composition_state == COMPOSING_RULE |
| 2911 || composition_state == COMPOSING_COMPONENT_RULE) | |
| 2912 { | |
| 2913 DECODE_COMPOSITION_RULE (c1); | |
| 2914 components[component_idx++] = c1; | |
| 2915 composition_state--; | |
| 2916 continue; | |
| 2917 } | |
| 26847 | 2918 } |
| 88365 | 2919 if (charset_id_0 < 0 |
| 2920 || ! 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
|
2921 /* This is SPACE or DEL. */ |
|
c7772f702227
(ONE_MORE_BYTE_NO_CHECK): Increment consumed_chars.
Kenichi Handa <handa@m17n.org>
parents:
88573
diff
changeset
|
2922 charset = CHARSET_FROM_ID (charset_ascii); |
|
c7772f702227
(ONE_MORE_BYTE_NO_CHECK): Increment consumed_chars.
Kenichi Handa <handa@m17n.org>
parents:
88573
diff
changeset
|
2923 else |
|
c7772f702227
(ONE_MORE_BYTE_NO_CHECK): Increment consumed_chars.
Kenichi Handa <handa@m17n.org>
parents:
88573
diff
changeset
|
2924 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
|
2925 break; |
| 17052 | 2926 |
| 2927 case ISO_graphic_plane_0: | |
|
88585
c7772f702227
(ONE_MORE_BYTE_NO_CHECK): Increment consumed_chars.
Kenichi Handa <handa@m17n.org>
parents:
88573
diff
changeset
|
2928 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
|
2929 { |
|
88585
c7772f702227
(ONE_MORE_BYTE_NO_CHECK): Increment consumed_chars.
Kenichi Handa <handa@m17n.org>
parents:
88573
diff
changeset
|
2930 if (composition_state == COMPOSING_RULE |
|
c7772f702227
(ONE_MORE_BYTE_NO_CHECK): Increment consumed_chars.
Kenichi Handa <handa@m17n.org>
parents:
88573
diff
changeset
|
2931 || composition_state == COMPOSING_COMPONENT_RULE) |
|
c7772f702227
(ONE_MORE_BYTE_NO_CHECK): Increment consumed_chars.
Kenichi Handa <handa@m17n.org>
parents:
88573
diff
changeset
|
2932 { |
|
c7772f702227
(ONE_MORE_BYTE_NO_CHECK): Increment consumed_chars.
Kenichi Handa <handa@m17n.org>
parents:
88573
diff
changeset
|
2933 DECODE_COMPOSITION_RULE (c1); |
|
c7772f702227
(ONE_MORE_BYTE_NO_CHECK): Increment consumed_chars.
Kenichi Handa <handa@m17n.org>
parents:
88573
diff
changeset
|
2934 components[component_idx++] = c1; |
|
c7772f702227
(ONE_MORE_BYTE_NO_CHECK): Increment consumed_chars.
Kenichi Handa <handa@m17n.org>
parents:
88573
diff
changeset
|
2935 composition_state--; |
|
c7772f702227
(ONE_MORE_BYTE_NO_CHECK): Increment consumed_chars.
Kenichi Handa <handa@m17n.org>
parents:
88573
diff
changeset
|
2936 continue; |
|
c7772f702227
(ONE_MORE_BYTE_NO_CHECK): Increment consumed_chars.
Kenichi Handa <handa@m17n.org>
parents:
88573
diff
changeset
|
2937 } |
|
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2938 } |
| 88365 | 2939 charset = CHARSET_FROM_ID (charset_id_0); |
| 17052 | 2940 break; |
| 2941 | |
| 2942 case ISO_0xA0_or_0xFF: | |
| 88365 | 2943 if (charset_id_1 < 0 |
| 2944 || ! CHARSET_ISO_CHARS_96 (CHARSET_FROM_ID (charset_id_1)) | |
| 2945 || CODING_ISO_FLAGS (coding) & CODING_ISO_FLAG_SEVEN_BITS) | |
| 2946 goto invalid_code; | |
| 17052 | 2947 /* This is a graphic character, we fall down ... */ |
| 2948 | |
| 2949 case ISO_graphic_plane_1: | |
| 88365 | 2950 if (charset_id_1 < 0) |
| 2951 goto invalid_code; | |
| 2952 charset = CHARSET_FROM_ID (charset_id_1); | |
| 17052 | 2953 break; |
| 2954 | |
|
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2955 case ISO_control_0: |
| 88365 | 2956 MAYBE_FINISH_COMPOSITION (); |
| 2957 charset = CHARSET_FROM_ID (charset_ascii); | |
| 17052 | 2958 break; |
| 2959 | |
|
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2960 case ISO_control_1: |
| 88365 | 2961 MAYBE_FINISH_COMPOSITION (); |
| 2962 goto invalid_code; | |
| 17052 | 2963 |
| 2964 case ISO_shift_out: | |
| 88365 | 2965 if (! (CODING_ISO_FLAGS (coding) & CODING_ISO_FLAG_LOCKING_SHIFT) |
| 2966 || CODING_ISO_DESIGNATION (coding, 1) < 0) | |
| 2967 goto invalid_code; | |
| 2968 CODING_ISO_INVOCATION (coding, 0) = 1; | |
| 2969 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
|
2970 continue; |
| 17052 | 2971 |
| 2972 case ISO_shift_in: | |
| 88365 | 2973 if (! (CODING_ISO_FLAGS (coding) & CODING_ISO_FLAG_LOCKING_SHIFT)) |
| 2974 goto invalid_code; | |
| 2975 CODING_ISO_INVOCATION (coding, 0) = 0; | |
| 2976 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
|
2977 continue; |
| 17052 | 2978 |
| 2979 case ISO_single_shift_2_7: | |
| 2980 case ISO_single_shift_2: | |
| 88365 | 2981 if (! (CODING_ISO_FLAGS (coding) & CODING_ISO_FLAG_SINGLE_SHIFT)) |
| 2982 goto invalid_code; | |
| 17052 | 2983 /* SS2 is handled as an escape sequence of ESC 'N' */ |
| 2984 c1 = 'N'; | |
| 2985 goto label_escape_sequence; | |
| 2986 | |
| 2987 case ISO_single_shift_3: | |
| 88365 | 2988 if (! (CODING_ISO_FLAGS (coding) & CODING_ISO_FLAG_SINGLE_SHIFT)) |
| 2989 goto invalid_code; | |
| 17052 | 2990 /* SS2 is handled as an escape sequence of ESC 'O' */ |
| 2991 c1 = 'O'; | |
| 2992 goto label_escape_sequence; | |
| 2993 | |
| 2994 case ISO_control_sequence_introducer: | |
| 2995 /* CSI is handled as an escape sequence of ESC '[' ... */ | |
| 2996 c1 = '['; | |
| 2997 goto label_escape_sequence; | |
| 2998 | |
| 2999 case ISO_escape: | |
| 3000 ONE_MORE_BYTE (c1); | |
| 3001 label_escape_sequence: | |
| 88365 | 3002 /* Escape sequences handled here are invocation, |
| 17052 | 3003 designation, direction specification, and character |
| 3004 composition specification. */ | |
| 3005 switch (c1) | |
| 3006 { | |
| 3007 case '&': /* revision of following character set */ | |
| 3008 ONE_MORE_BYTE (c1); | |
| 3009 if (!(c1 >= '@' && c1 <= '~')) | |
| 88365 | 3010 goto invalid_code; |
| 17052 | 3011 ONE_MORE_BYTE (c1); |
| 3012 if (c1 != ISO_CODE_ESC) | |
| 88365 | 3013 goto invalid_code; |
| 17052 | 3014 ONE_MORE_BYTE (c1); |
| 3015 goto label_escape_sequence; | |
| 3016 | |
| 3017 case '$': /* designation of 2-byte character set */ | |
| 88365 | 3018 if (! (CODING_ISO_FLAGS (coding) & CODING_ISO_FLAG_DESIGNATION)) |
| 3019 goto invalid_code; | |
| 17052 | 3020 ONE_MORE_BYTE (c1); |
| 3021 if (c1 >= '@' && c1 <= 'B') | |
| 3022 { /* 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
|
3023 or JISX0208.1980 */ |
| 88365 | 3024 DECODE_DESIGNATION (0, 2, 0, c1); |
| 17052 | 3025 } |
| 3026 else if (c1 >= 0x28 && c1 <= 0x2B) | |
| 3027 { /* designation of DIMENSION2_CHARS94 character set */ | |
| 3028 ONE_MORE_BYTE (c2); | |
| 88365 | 3029 DECODE_DESIGNATION (c1 - 0x28, 2, 0, c2); |
| 17052 | 3030 } |
| 3031 else if (c1 >= 0x2C && c1 <= 0x2F) | |
| 3032 { /* designation of DIMENSION2_CHARS96 character set */ | |
| 3033 ONE_MORE_BYTE (c2); | |
| 88365 | 3034 DECODE_DESIGNATION (c1 - 0x2C, 2, 1, c2); |
| 17052 | 3035 } |
| 3036 else | |
| 88365 | 3037 goto invalid_code; |
|
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3038 /* We must update these variables now. */ |
| 88365 | 3039 charset_id_0 = CODING_ISO_INVOKED_CHARSET (coding, 0); |
| 3040 charset_id_1 = CODING_ISO_INVOKED_CHARSET (coding, 1); | |
|
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3041 continue; |
| 17052 | 3042 |
| 3043 case 'n': /* invocation of locking-shift-2 */ | |
| 88365 | 3044 if (! (CODING_ISO_FLAGS (coding) & CODING_ISO_FLAG_LOCKING_SHIFT) |
| 3045 || CODING_ISO_DESIGNATION (coding, 2) < 0) | |
| 3046 goto invalid_code; | |
| 3047 CODING_ISO_INVOCATION (coding, 0) = 2; | |
| 3048 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
|
3049 continue; |
| 17052 | 3050 |
| 3051 case 'o': /* invocation of locking-shift-3 */ | |
| 88365 | 3052 if (! (CODING_ISO_FLAGS (coding) & CODING_ISO_FLAG_LOCKING_SHIFT) |
| 3053 || CODING_ISO_DESIGNATION (coding, 3) < 0) | |
| 3054 goto invalid_code; | |
| 3055 CODING_ISO_INVOCATION (coding, 0) = 3; | |
| 3056 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
|
3057 continue; |
| 17052 | 3058 |
| 3059 case 'N': /* invocation of single-shift-2 */ | |
| 88365 | 3060 if (! (CODING_ISO_FLAGS (coding) & CODING_ISO_FLAG_SINGLE_SHIFT) |
| 3061 || CODING_ISO_DESIGNATION (coding, 2) < 0) | |
| 3062 goto invalid_code; | |
| 3063 charset = CHARSET_FROM_ID (CODING_ISO_DESIGNATION (coding, 2)); | |
| 17052 | 3064 ONE_MORE_BYTE (c1); |
|
30578
705b94e152b1
(decode_coding_iso2022): More strict check for handling single
Kenichi Handa <handa@m17n.org>
parents:
30487
diff
changeset
|
3065 if (c1 < 0x20 || (c1 >= 0x80 && c1 < 0xA0)) |
| 88365 | 3066 goto invalid_code; |
| 17052 | 3067 break; |
| 3068 | |
| 3069 case 'O': /* invocation of single-shift-3 */ | |
| 88365 | 3070 if (! (CODING_ISO_FLAGS (coding) & CODING_ISO_FLAG_SINGLE_SHIFT) |
| 3071 || CODING_ISO_DESIGNATION (coding, 3) < 0) | |
| 3072 goto invalid_code; | |
| 3073 charset = CHARSET_FROM_ID (CODING_ISO_DESIGNATION (coding, 3)); | |
| 17052 | 3074 ONE_MORE_BYTE (c1); |
|
30578
705b94e152b1
(decode_coding_iso2022): More strict check for handling single
Kenichi Handa <handa@m17n.org>
parents:
30487
diff
changeset
|
3075 if (c1 < 0x20 || (c1 >= 0x80 && c1 < 0xA0)) |
| 88365 | 3076 goto invalid_code; |
| 17052 | 3077 break; |
| 3078 | |
| 26847 | 3079 case '0': case '2': case '3': case '4': /* start composition */ |
| 88365 | 3080 if (! (coding->common_flags & CODING_ANNOTATE_COMPOSITION_MASK)) |
| 3081 goto invalid_code; | |
| 26847 | 3082 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
|
3083 continue; |
| 17052 | 3084 |
| 26847 | 3085 case '1': /* end composition */ |
| 88365 | 3086 if (composition_state == COMPOSING_NO) |
| 3087 goto invalid_code; | |
| 3088 DECODE_COMPOSITION_END (); | |
|
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3089 continue; |
| 17052 | 3090 |
| 3091 case '[': /* specification of direction */ | |
| 88365 | 3092 if (! CODING_ISO_FLAGS (coding) & CODING_ISO_FLAG_DIRECTION) |
| 3093 goto invalid_code; | |
| 17052 | 3094 /* 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
|
3095 So, `coding->mode & CODING_MODE_DIRECTION' zero means |
| 88365 | 3096 left-to-right, and nozero means right-to-left. */ |
| 17052 | 3097 ONE_MORE_BYTE (c1); |
| 3098 switch (c1) | |
| 3099 { | |
| 3100 case ']': /* end of the current direction */ | |
|
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3101 coding->mode &= ~CODING_MODE_DIRECTION; |
| 17052 | 3102 |
| 3103 case '0': /* end of the current direction */ | |
| 3104 case '1': /* start of left-to-right direction */ | |
| 3105 ONE_MORE_BYTE (c1); | |
| 3106 if (c1 == ']') | |
|
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3107 coding->mode &= ~CODING_MODE_DIRECTION; |
| 17052 | 3108 else |
| 88365 | 3109 goto invalid_code; |
| 17052 | 3110 break; |
| 3111 | |
| 3112 case '2': /* start of right-to-left direction */ | |
| 3113 ONE_MORE_BYTE (c1); | |
| 3114 if (c1 == ']') | |
|
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3115 coding->mode |= CODING_MODE_DIRECTION; |
| 17052 | 3116 else |
| 88365 | 3117 goto invalid_code; |
| 17052 | 3118 break; |
| 3119 | |
| 3120 default: | |
| 88365 | 3121 goto invalid_code; |
| 17052 | 3122 } |
|
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3123 continue; |
| 17052 | 3124 |
|
89442
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
3125 case '%': |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
3126 ONE_MORE_BYTE (c1); |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
3127 if (c1 == '/') |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
3128 { |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
3129 /* CTEXT extended segment: |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
3130 ESC % / [0-4] M L --ENCODING-NAME-- \002 --BYTES-- |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
3131 We keep these bytes as is for the moment. |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
3132 They may be decoded by post-read-conversion. */ |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
3133 int dim, M, L; |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
3134 int size; |
| 89483 | 3135 |
|
89442
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
3136 ONE_MORE_BYTE (dim); |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
3137 ONE_MORE_BYTE (M); |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
3138 ONE_MORE_BYTE (L); |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
3139 size = ((M - 128) * 128) + (L - 128); |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
3140 if (charbuf + 8 + size > charbuf_end) |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
3141 goto break_loop; |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
3142 *charbuf++ = ISO_CODE_ESC; |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
3143 *charbuf++ = '%'; |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
3144 *charbuf++ = '/'; |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
3145 *charbuf++ = dim; |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
3146 *charbuf++ = BYTE8_TO_CHAR (M); |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
3147 *charbuf++ = BYTE8_TO_CHAR (L); |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
3148 while (size-- > 0) |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
3149 { |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
3150 ONE_MORE_BYTE (c1); |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
3151 *charbuf++ = ASCII_BYTE_P (c1) ? c1 : BYTE8_TO_CHAR (c1); |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
3152 } |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
3153 } |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
3154 else if (c1 == 'G') |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
3155 { |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
3156 /* XFree86 extension for embedding UTF-8 in CTEXT: |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
3157 ESC % G --UTF-8-BYTES-- ESC % @ |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
3158 We keep these bytes as is for the moment. |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
3159 They may be decoded by post-read-conversion. */ |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
3160 int *p = charbuf; |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
3161 |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
3162 if (p + 6 > charbuf_end) |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
3163 goto break_loop; |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
3164 *p++ = ISO_CODE_ESC; |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
3165 *p++ = '%'; |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
3166 *p++ = 'G'; |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
3167 while (p < charbuf_end) |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
3168 { |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
3169 ONE_MORE_BYTE (c1); |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
3170 if (c1 == ISO_CODE_ESC |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
3171 && src + 1 < src_end |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
3172 && src[0] == '%' |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
3173 && src[1] == '@') |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
3174 break; |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
3175 *p++ = ASCII_BYTE_P (c1) ? c1 : BYTE8_TO_CHAR (c1); |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
3176 } |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
3177 if (p + 3 > charbuf_end) |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
3178 goto break_loop; |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
3179 *p++ = ISO_CODE_ESC; |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
3180 *p++ = '%'; |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
3181 *p++ = '@'; |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
3182 charbuf = p; |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
3183 } |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
3184 else |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
3185 goto invalid_code; |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
3186 continue; |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
3187 break; |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
3188 |
| 17052 | 3189 default: |
| 88365 | 3190 if (! (CODING_ISO_FLAGS (coding) & CODING_ISO_FLAG_DESIGNATION)) |
| 3191 goto invalid_code; | |
| 17052 | 3192 if (c1 >= 0x28 && c1 <= 0x2B) |
| 3193 { /* designation of DIMENSION1_CHARS94 character set */ | |
| 3194 ONE_MORE_BYTE (c2); | |
| 88365 | 3195 DECODE_DESIGNATION (c1 - 0x28, 1, 0, c2); |
| 17052 | 3196 } |
| 3197 else if (c1 >= 0x2C && c1 <= 0x2F) | |
| 3198 { /* designation of DIMENSION1_CHARS96 character set */ | |
| 3199 ONE_MORE_BYTE (c2); | |
| 88365 | 3200 DECODE_DESIGNATION (c1 - 0x2C, 1, 1, c2); |
| 17052 | 3201 } |
| 3202 else | |
| 88365 | 3203 goto invalid_code; |
|
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3204 /* We must update these variables now. */ |
| 88365 | 3205 charset_id_0 = CODING_ISO_INVOKED_CHARSET (coding, 0); |
| 3206 charset_id_1 = CODING_ISO_INVOKED_CHARSET (coding, 1); | |
|
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3207 continue; |
| 17052 | 3208 } |
|
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3209 } |
|
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3210 |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3211 if (charset->id != charset_ascii |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3212 && last_id != charset->id) |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3213 { |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3214 if (last_id != charset_ascii) |
|
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
3215 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
|
3216 last_id = charset->id; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3217 last_offset = char_offset; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3218 } |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3219 |
|
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3220 /* Now we know CHARSET and 1st position code C1 of a character. |
| 88365 | 3221 Produce a decoded character while getting 2nd position code |
| 3222 C2 if necessary. */ | |
| 3223 c1 &= 0x7F; | |
| 3224 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
|
3225 { |
|
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3226 ONE_MORE_BYTE (c2); |
| 88365 | 3227 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
|
3228 /* C2 is not in a valid range. */ |
| 88365 | 3229 goto invalid_code; |
| 3230 c1 = (c1 << 8) | (c2 & 0x7F); | |
| 3231 if (CHARSET_DIMENSION (charset) > 2) | |
| 3232 { | |
| 3233 ONE_MORE_BYTE (c2); | |
| 3234 if (c2 < 0x20 || (c2 >= 0x80 && c2 < 0xA0)) | |
| 3235 /* C2 is not in a valid range. */ | |
| 3236 goto invalid_code; | |
| 3237 c1 = (c1 << 8) | (c2 & 0x7F); | |
| 3238 } | |
| 17052 | 3239 } |
| 88365 | 3240 |
| 3241 CODING_DECODE_CHAR (coding, src, src_base, src_end, charset, c1, c); | |
| 3242 if (c < 0) | |
| 3243 { | |
| 3244 MAYBE_FINISH_COMPOSITION (); | |
| 3245 for (; src_base < src; src_base++, char_offset++) | |
| 3246 { | |
| 3247 if (ASCII_BYTE_P (*src_base)) | |
| 3248 *charbuf++ = *src_base; | |
| 3249 else | |
| 3250 *charbuf++ = BYTE8_TO_CHAR (*src_base); | |
| 3251 } | |
| 3252 } | |
| 3253 else if (composition_state == COMPOSING_NO) | |
| 3254 { | |
| 3255 *charbuf++ = c; | |
| 3256 char_offset++; | |
| 3257 } | |
| 3258 else | |
|
88585
c7772f702227
(ONE_MORE_BYTE_NO_CHECK): Increment consumed_chars.
Kenichi Handa <handa@m17n.org>
parents:
88573
diff
changeset
|
3259 { |
|
c7772f702227
(ONE_MORE_BYTE_NO_CHECK): Increment consumed_chars.
Kenichi Handa <handa@m17n.org>
parents:
88573
diff
changeset
|
3260 components[component_idx++] = c; |
|
c7772f702227
(ONE_MORE_BYTE_NO_CHECK): Increment consumed_chars.
Kenichi Handa <handa@m17n.org>
parents:
88573
diff
changeset
|
3261 if (method == COMPOSITION_WITH_RULE |
|
c7772f702227
(ONE_MORE_BYTE_NO_CHECK): Increment consumed_chars.
Kenichi Handa <handa@m17n.org>
parents:
88573
diff
changeset
|
3262 || (method == COMPOSITION_WITH_RULE_ALTCHARS |
|
c7772f702227
(ONE_MORE_BYTE_NO_CHECK): Increment consumed_chars.
Kenichi Handa <handa@m17n.org>
parents:
88573
diff
changeset
|
3263 && composition_state == COMPOSING_COMPONENT_CHAR)) |
|
c7772f702227
(ONE_MORE_BYTE_NO_CHECK): Increment consumed_chars.
Kenichi Handa <handa@m17n.org>
parents:
88573
diff
changeset
|
3264 composition_state++; |
|
c7772f702227
(ONE_MORE_BYTE_NO_CHECK): Increment consumed_chars.
Kenichi Handa <handa@m17n.org>
parents:
88573
diff
changeset
|
3265 } |
| 17052 | 3266 continue; |
| 3267 | |
| 88365 | 3268 invalid_code: |
| 3269 MAYBE_FINISH_COMPOSITION (); | |
| 3270 src = src_base; | |
| 3271 consumed_chars = consumed_chars_base; | |
| 3272 ONE_MORE_BYTE (c); | |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
3273 *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
|
3274 char_offset++; |
|
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3275 coding->errors++; |
|
89442
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
3276 continue; |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
3277 |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
3278 break_loop: |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
3279 break; |
| 88365 | 3280 } |
| 3281 | |
| 3282 no_more_source: | |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3283 if (last_id != charset_ascii) |
|
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
3284 ADD_CHARSET_DATA (charbuf, char_offset - last_offset, last_id); |
| 88365 | 3285 coding->consumed_char += consumed_chars_base; |
| 3286 coding->consumed = src_base - coding->source; | |
| 3287 coding->charbuf_used = charbuf - coding->charbuf; | |
| 17052 | 3288 } |
| 3289 | |
|
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3290 |
| 18766 | 3291 /* ISO2022 encoding stuff. */ |
| 17052 | 3292 |
| 3293 /* | |
| 18766 | 3294 It is not enough to say just "ISO2022" on encoding, we have to |
| 88365 | 3295 specify more details. In Emacs, each coding system of ISO2022 |
| 17052 | 3296 variant has the following specifications: |
| 88365 | 3297 1. Initial designation to G0 thru G3. |
| 17052 | 3298 2. Allows short-form designation? |
| 3299 3. ASCII should be designated to G0 before control characters? | |
| 3300 4. ASCII should be designated to G0 at end of line? | |
| 3301 5. 7-bit environment or 8-bit environment? | |
| 3302 6. Use locking-shift? | |
| 3303 7. Use Single-shift? | |
| 3304 And the following two are only for Japanese: | |
| 3305 8. Use ASCII in place of JIS0201-1976-Roman? | |
| 3306 9. Use JISX0208-1983 in place of JISX0208-1978? | |
| 88365 | 3307 These specifications are encoded in CODING_ISO_FLAGS (coding) as flag bits |
| 3308 defined by macros CODING_ISO_FLAG_XXX. See `coding.h' for more | |
| 18766 | 3309 details. |
| 17052 | 3310 */ |
| 3311 | |
| 3312 /* 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
|
3313 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
|
3314 '@', '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
|
3315 designation sequence of short-form. */ |
| 17052 | 3316 |
| 3317 #define ENCODE_DESIGNATION(charset, reg, coding) \ | |
| 3318 do { \ | |
| 88365 | 3319 unsigned char final_char = CHARSET_ISO_FINAL (charset); \ |
| 17052 | 3320 char *intermediate_char_94 = "()*+"; \ |
| 3321 char *intermediate_char_96 = ",-./"; \ | |
| 88365 | 3322 int revision = -1; \ |
| 3323 int c; \ | |
| 3324 \ | |
| 3325 if (CODING_ISO_FLAGS (coding) & CODING_ISO_FLAG_REVISION) \ | |
| 88856 | 3326 revision = CHARSET_ISO_REVISION (charset); \ |
| 88365 | 3327 \ |
| 3328 if (revision >= 0) \ | |
|
20150
402b6e5f4b58
(encode_designation_at_bol): Fix bug of finding graphic
Kenichi Handa <handa@m17n.org>
parents:
20105
diff
changeset
|
3329 { \ |
| 88365 | 3330 EMIT_TWO_ASCII_BYTES (ISO_CODE_ESC, '&'); \ |
| 3331 EMIT_ONE_BYTE ('@' + revision); \ | |
| 17052 | 3332 } \ |
| 88365 | 3333 EMIT_ONE_ASCII_BYTE (ISO_CODE_ESC); \ |
| 17052 | 3334 if (CHARSET_DIMENSION (charset) == 1) \ |
| 3335 { \ | |
| 88365 | 3336 if (! CHARSET_ISO_CHARS_96 (charset)) \ |
| 3337 c = intermediate_char_94[reg]; \ | |
| 17052 | 3338 else \ |
| 88365 | 3339 c = intermediate_char_96[reg]; \ |
| 3340 EMIT_ONE_ASCII_BYTE (c); \ | |
| 17052 | 3341 } \ |
| 3342 else \ | |
| 3343 { \ | |
| 88365 | 3344 EMIT_ONE_ASCII_BYTE ('$'); \ |
| 3345 if (! CHARSET_ISO_CHARS_96 (charset)) \ | |
| 17052 | 3346 { \ |
| 88365 | 3347 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
|
3348 || reg != 0 \ |
|
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3349 || final_char < '@' || final_char > 'B') \ |
| 88365 | 3350 EMIT_ONE_ASCII_BYTE (intermediate_char_94[reg]); \ |
| 17052 | 3351 } \ |
| 3352 else \ | |
| 88365 | 3353 EMIT_ONE_ASCII_BYTE (intermediate_char_96[reg]); \ |
| 17052 | 3354 } \ |
| 88365 | 3355 EMIT_ONE_ASCII_BYTE (final_char); \ |
| 3356 \ | |
| 3357 CODING_ISO_DESIGNATION (coding, reg) = CHARSET_ID (charset); \ | |
| 17052 | 3358 } while (0) |
| 3359 | |
| 88365 | 3360 |
| 17052 | 3361 /* The following two macros produce codes (control character or escape |
| 3362 sequence) for ISO2022 single-shift functions (single-shift-2 and | |
| 3363 single-shift-3). */ | |
| 3364 | |
| 88365 | 3365 #define ENCODE_SINGLE_SHIFT_2 \ |
| 3366 do { \ | |
| 3367 if (CODING_ISO_FLAGS (coding) & CODING_ISO_FLAG_SEVEN_BITS) \ | |
| 3368 EMIT_TWO_ASCII_BYTES (ISO_CODE_ESC, 'N'); \ | |
| 3369 else \ | |
| 3370 EMIT_ONE_BYTE (ISO_CODE_SS2); \ | |
| 3371 CODING_ISO_SINGLE_SHIFTING (coding) = 1; \ | |
| 17052 | 3372 } while (0) |
| 3373 | |
| 88365 | 3374 |
| 3375 #define ENCODE_SINGLE_SHIFT_3 \ | |
| 3376 do { \ | |
| 3377 if (CODING_ISO_FLAGS (coding) & CODING_ISO_FLAG_SEVEN_BITS) \ | |
| 3378 EMIT_TWO_ASCII_BYTES (ISO_CODE_ESC, 'O'); \ | |
| 3379 else \ | |
| 3380 EMIT_ONE_BYTE (ISO_CODE_SS3); \ | |
| 3381 CODING_ISO_SINGLE_SHIFTING (coding) = 1; \ | |
| 17052 | 3382 } while (0) |
| 3383 | |
| 88365 | 3384 |
| 17052 | 3385 /* The following four macros produce codes (control character or |
| 3386 escape sequence) for ISO2022 locking-shift functions (shift-in, | |
| 3387 shift-out, locking-shift-2, and locking-shift-3). */ | |
| 3388 | |
| 88365 | 3389 #define ENCODE_SHIFT_IN \ |
| 3390 do { \ | |
| 3391 EMIT_ONE_ASCII_BYTE (ISO_CODE_SI); \ | |
| 3392 CODING_ISO_INVOCATION (coding, 0) = 0; \ | |
| 17052 | 3393 } while (0) |
| 3394 | |
| 88365 | 3395 |
| 3396 #define ENCODE_SHIFT_OUT \ | |
| 3397 do { \ | |
| 3398 EMIT_ONE_ASCII_BYTE (ISO_CODE_SO); \ | |
| 3399 CODING_ISO_INVOCATION (coding, 0) = 1; \ | |
| 17052 | 3400 } while (0) |
| 3401 | |
| 88365 | 3402 |
| 3403 #define ENCODE_LOCKING_SHIFT_2 \ | |
| 3404 do { \ | |
| 3405 EMIT_TWO_ASCII_BYTES (ISO_CODE_ESC, 'n'); \ | |
| 3406 CODING_ISO_INVOCATION (coding, 0) = 2; \ | |
| 17052 | 3407 } while (0) |
| 3408 | |
| 88365 | 3409 |
| 3410 #define ENCODE_LOCKING_SHIFT_3 \ | |
| 3411 do { \ | |
| 3412 EMIT_TWO_ASCII_BYTES (ISO_CODE_ESC, 'n'); \ | |
| 3413 CODING_ISO_INVOCATION (coding, 0) = 3; \ | |
| 17052 | 3414 } while (0) |
| 3415 | |
| 88365 | 3416 |
| 18766 | 3417 /* Produce codes for a DIMENSION1 character whose character set is |
| 3418 CHARSET and whose position-code is C1. Designation and invocation | |
| 17052 | 3419 sequences are also produced in advance if necessary. */ |
| 3420 | |
|
19285
af3d00fde172
(Fset_terminal_coding_system_internal): Set
Kenichi Handa <handa@m17n.org>
parents:
19280
diff
changeset
|
3421 #define ENCODE_ISO_CHARACTER_DIMENSION1(charset, c1) \ |
|
af3d00fde172
(Fset_terminal_coding_system_internal): Set
Kenichi Handa <handa@m17n.org>
parents:
19280
diff
changeset
|
3422 do { \ |
| 88365 | 3423 int id = CHARSET_ID (charset); \ |
|
88681
2cdfbffa8a0d
(CODING_ISO_FLAG_USE_ROMAN): New macro
Kenichi Handa <handa@m17n.org>
parents:
88669
diff
changeset
|
3424 \ |
|
2cdfbffa8a0d
(CODING_ISO_FLAG_USE_ROMAN): New macro
Kenichi Handa <handa@m17n.org>
parents:
88669
diff
changeset
|
3425 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
|
3426 && id == charset_ascii) \ |
|
2cdfbffa8a0d
(CODING_ISO_FLAG_USE_ROMAN): New macro
Kenichi Handa <handa@m17n.org>
parents:
88669
diff
changeset
|
3427 { \ |
|
2cdfbffa8a0d
(CODING_ISO_FLAG_USE_ROMAN): New macro
Kenichi Handa <handa@m17n.org>
parents:
88669
diff
changeset
|
3428 id = charset_jisx0201_roman; \ |
|
2cdfbffa8a0d
(CODING_ISO_FLAG_USE_ROMAN): New macro
Kenichi Handa <handa@m17n.org>
parents:
88669
diff
changeset
|
3429 charset = CHARSET_FROM_ID (id); \ |
|
2cdfbffa8a0d
(CODING_ISO_FLAG_USE_ROMAN): New macro
Kenichi Handa <handa@m17n.org>
parents:
88669
diff
changeset
|
3430 } \ |
|
2cdfbffa8a0d
(CODING_ISO_FLAG_USE_ROMAN): New macro
Kenichi Handa <handa@m17n.org>
parents:
88669
diff
changeset
|
3431 \ |
| 88365 | 3432 if (CODING_ISO_SINGLE_SHIFTING (coding)) \ |
|
19285
af3d00fde172
(Fset_terminal_coding_system_internal): Set
Kenichi Handa <handa@m17n.org>
parents:
19280
diff
changeset
|
3433 { \ |
| 88365 | 3434 if (CODING_ISO_FLAGS (coding) & CODING_ISO_FLAG_SEVEN_BITS) \ |
| 3435 EMIT_ONE_ASCII_BYTE (c1 & 0x7F); \ | |
|
19285
af3d00fde172
(Fset_terminal_coding_system_internal): Set
Kenichi Handa <handa@m17n.org>
parents:
19280
diff
changeset
|
3436 else \ |
| 88365 | 3437 EMIT_ONE_BYTE (c1 | 0x80); \ |
| 3438 CODING_ISO_SINGLE_SHIFTING (coding) = 0; \ | |
|
19285
af3d00fde172
(Fset_terminal_coding_system_internal): Set
Kenichi Handa <handa@m17n.org>
parents:
19280
diff
changeset
|
3439 break; \ |
|
af3d00fde172
(Fset_terminal_coding_system_internal): Set
Kenichi Handa <handa@m17n.org>
parents:
19280
diff
changeset
|
3440 } \ |
| 88365 | 3441 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
|
3442 { \ |
| 88365 | 3443 EMIT_ONE_ASCII_BYTE (c1 & 0x7F); \ |
|
19285
af3d00fde172
(Fset_terminal_coding_system_internal): Set
Kenichi Handa <handa@m17n.org>
parents:
19280
diff
changeset
|
3444 break; \ |
|
af3d00fde172
(Fset_terminal_coding_system_internal): Set
Kenichi Handa <handa@m17n.org>
parents:
19280
diff
changeset
|
3445 } \ |
| 88365 | 3446 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
|
3447 { \ |
| 88365 | 3448 EMIT_ONE_BYTE (c1 | 0x80); \ |
|
19285
af3d00fde172
(Fset_terminal_coding_system_internal): Set
Kenichi Handa <handa@m17n.org>
parents:
19280
diff
changeset
|
3449 break; \ |
|
af3d00fde172
(Fset_terminal_coding_system_internal): Set
Kenichi Handa <handa@m17n.org>
parents:
19280
diff
changeset
|
3450 } \ |
|
af3d00fde172
(Fset_terminal_coding_system_internal): Set
Kenichi Handa <handa@m17n.org>
parents:
19280
diff
changeset
|
3451 else \ |
|
af3d00fde172
(Fset_terminal_coding_system_internal): Set
Kenichi Handa <handa@m17n.org>
parents:
19280
diff
changeset
|
3452 /* 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
|
3453 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
|
3454 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
|
3455 character. */ \ |
| 88365 | 3456 dst = encode_invocation_designation (charset, coding, dst, \ |
| 3457 &produced_chars); \ | |
| 17052 | 3458 } while (1) |
| 3459 | |
| 88365 | 3460 |
| 3461 /* Produce codes for a DIMENSION2 character whose character set is | |
| 3462 CHARSET and whose position-codes are C1 and C2. Designation and | |
| 3463 invocation codes are also produced in advance if necessary. */ | |
| 3464 | |
| 3465 #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
|
3466 do { \ |
| 88365 | 3467 int id = CHARSET_ID (charset); \ |
|
88681
2cdfbffa8a0d
(CODING_ISO_FLAG_USE_ROMAN): New macro
Kenichi Handa <handa@m17n.org>
parents:
88669
diff
changeset
|
3468 \ |
|
2cdfbffa8a0d
(CODING_ISO_FLAG_USE_ROMAN): New macro
Kenichi Handa <handa@m17n.org>
parents:
88669
diff
changeset
|
3469 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
|
3470 && id == charset_jisx0208) \ |
|
2cdfbffa8a0d
(CODING_ISO_FLAG_USE_ROMAN): New macro
Kenichi Handa <handa@m17n.org>
parents:
88669
diff
changeset
|
3471 { \ |
|
2cdfbffa8a0d
(CODING_ISO_FLAG_USE_ROMAN): New macro
Kenichi Handa <handa@m17n.org>
parents:
88669
diff
changeset
|
3472 id = charset_jisx0208_1978; \ |
|
2cdfbffa8a0d
(CODING_ISO_FLAG_USE_ROMAN): New macro
Kenichi Handa <handa@m17n.org>
parents:
88669
diff
changeset
|
3473 charset = CHARSET_FROM_ID (id); \ |
|
2cdfbffa8a0d
(CODING_ISO_FLAG_USE_ROMAN): New macro
Kenichi Handa <handa@m17n.org>
parents:
88669
diff
changeset
|
3474 } \ |
|
2cdfbffa8a0d
(CODING_ISO_FLAG_USE_ROMAN): New macro
Kenichi Handa <handa@m17n.org>
parents:
88669
diff
changeset
|
3475 \ |
| 88365 | 3476 if (CODING_ISO_SINGLE_SHIFTING (coding)) \ |
| 3477 { \ | |
| 3478 if (CODING_ISO_FLAGS (coding) & CODING_ISO_FLAG_SEVEN_BITS) \ | |
| 3479 EMIT_TWO_ASCII_BYTES ((c1) & 0x7F, (c2) & 0x7F); \ | |
| 3480 else \ | |
| 3481 EMIT_TWO_BYTES ((c1) | 0x80, (c2) | 0x80); \ | |
| 3482 CODING_ISO_SINGLE_SHIFTING (coding) = 0; \ | |
| 3483 break; \ | |
| 3484 } \ | |
| 3485 else if (id == CODING_ISO_INVOKED_CHARSET (coding, 0)) \ | |
| 3486 { \ | |
| 3487 EMIT_TWO_ASCII_BYTES ((c1) & 0x7F, (c2) & 0x7F); \ | |
| 3488 break; \ | |
| 3489 } \ | |
| 3490 else if (id == CODING_ISO_INVOKED_CHARSET (coding, 1)) \ | |
| 3491 { \ | |
| 3492 EMIT_TWO_BYTES ((c1) | 0x80, (c2) | 0x80); \ | |
| 3493 break; \ | |
| 3494 } \ | |
| 3495 else \ | |
| 3496 /* Since CHARSET is not yet invoked to any graphic planes, we \ | |
| 3497 must invoke it, or, at first, designate it to some graphic \ | |
| 3498 register. Then repeat the loop to actually produce the \ | |
| 3499 character. */ \ | |
| 3500 dst = encode_invocation_designation (charset, coding, dst, \ | |
| 3501 &produced_chars); \ | |
| 3502 } while (1) | |
| 3503 | |
| 3504 | |
| 3505 #define ENCODE_ISO_CHARACTER(charset, c) \ | |
| 3506 do { \ | |
| 3507 int code = ENCODE_CHAR ((charset),(c)); \ | |
| 3508 \ | |
| 3509 if (CHARSET_DIMENSION (charset) == 1) \ | |
| 3510 ENCODE_ISO_CHARACTER_DIMENSION1 ((charset), code); \ | |
| 3511 else \ | |
| 3512 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
|
3513 } while (0) |
|
17725
92f042f73be2
(Valternate_charset_table): The valiable deleted.
Kenichi Handa <handa@m17n.org>
parents:
17717
diff
changeset
|
3514 |
|
30487
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
3515 |
| 17052 | 3516 /* Produce designation and invocation codes at a place pointed by DST |
| 88365 | 3517 to use CHARSET. The element `spec.iso_2022' of *CODING is updated. |
| 17052 | 3518 Return new DST. */ |
| 3519 | |
| 3520 unsigned char * | |
| 88365 | 3521 encode_invocation_designation (charset, coding, dst, p_nchars) |
| 3522 struct charset *charset; | |
| 17052 | 3523 struct coding_system *coding; |
| 3524 unsigned char *dst; | |
| 88365 | 3525 int *p_nchars; |
| 17052 | 3526 { |
| 88365 | 3527 int multibytep = coding->dst_multibyte; |
| 3528 int produced_chars = *p_nchars; | |
| 17052 | 3529 int reg; /* graphic register number */ |
| 88365 | 3530 int id = CHARSET_ID (charset); |
| 17052 | 3531 |
| 3532 /* At first, check designations. */ | |
| 3533 for (reg = 0; reg < 4; reg++) | |
| 88365 | 3534 if (id == CODING_ISO_DESIGNATION (coding, reg)) |
| 17052 | 3535 break; |
| 3536 | |
| 3537 if (reg >= 4) | |
| 3538 { | |
| 3539 /* CHARSET is not yet designated to any graphic registers. */ | |
| 3540 /* At first check the requested designation. */ | |
| 88365 | 3541 reg = CODING_ISO_REQUEST (coding, id); |
| 3542 if (reg < 0) | |
|
18002
a14261786239
(encode_invocation_designation): Use macro
Kenichi Handa <handa@m17n.org>
parents:
17835
diff
changeset
|
3543 /* Since CHARSET requests no special designation, designate it |
|
a14261786239
(encode_invocation_designation): Use macro
Kenichi Handa <handa@m17n.org>
parents:
17835
diff
changeset
|
3544 to graphic register 0. */ |
| 17052 | 3545 reg = 0; |
| 3546 | |
| 3547 ENCODE_DESIGNATION (charset, reg, coding); | |
| 3548 } | |
| 3549 | |
| 88365 | 3550 if (CODING_ISO_INVOCATION (coding, 0) != reg |
| 3551 && CODING_ISO_INVOCATION (coding, 1) != reg) | |
| 17052 | 3552 { |
| 3553 /* Since the graphic register REG is not invoked to any graphic | |
| 3554 planes, invoke it to graphic plane 0. */ | |
| 3555 switch (reg) | |
| 3556 { | |
| 3557 case 0: /* graphic register 0 */ | |
| 3558 ENCODE_SHIFT_IN; | |
| 3559 break; | |
| 3560 | |
| 3561 case 1: /* graphic register 1 */ | |
| 3562 ENCODE_SHIFT_OUT; | |
| 3563 break; | |
| 3564 | |
| 3565 case 2: /* graphic register 2 */ | |
| 88365 | 3566 if (CODING_ISO_FLAGS (coding) & CODING_ISO_FLAG_SINGLE_SHIFT) |
| 17052 | 3567 ENCODE_SINGLE_SHIFT_2; |
| 3568 else | |
| 3569 ENCODE_LOCKING_SHIFT_2; | |
| 3570 break; | |
| 3571 | |
| 3572 case 3: /* graphic register 3 */ | |
| 88365 | 3573 if (CODING_ISO_FLAGS (coding) & CODING_ISO_FLAG_SINGLE_SHIFT) |
| 17052 | 3574 ENCODE_SINGLE_SHIFT_3; |
| 3575 else | |
| 3576 ENCODE_LOCKING_SHIFT_3; | |
| 3577 break; | |
| 3578 } | |
| 3579 } | |
|
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3580 |
| 88365 | 3581 *p_nchars = produced_chars; |
| 17052 | 3582 return dst; |
| 3583 } | |
| 3584 | |
| 3585 /* The following three macros produce codes for indicating direction | |
| 3586 of text. */ | |
| 88365 | 3587 #define ENCODE_CONTROL_SEQUENCE_INTRODUCER \ |
| 3588 do { \ | |
| 3589 if (CODING_ISO_FLAGS (coding) == CODING_ISO_FLAG_SEVEN_BITS) \ | |
| 3590 EMIT_TWO_ASCII_BYTES (ISO_CODE_ESC, '['); \ | |
| 3591 else \ | |
| 3592 EMIT_ONE_BYTE (ISO_CODE_CSI); \ | |
| 17052 | 3593 } while (0) |
| 3594 | |
| 88365 | 3595 |
| 3596 #define ENCODE_DIRECTION_R2L() \ | |
| 3597 do { \ | |
| 3598 ENCODE_CONTROL_SEQUENCE_INTRODUCER (dst); \ | |
| 3599 EMIT_TWO_ASCII_BYTES ('2', ']'); \ | |
| 3600 } while (0) | |
| 3601 | |
| 3602 | |
| 3603 #define ENCODE_DIRECTION_L2R() \ | |
| 3604 do { \ | |
| 3605 ENCODE_CONTROL_SEQUENCE_INTRODUCER (dst); \ | |
| 3606 EMIT_TWO_ASCII_BYTES ('0', ']'); \ | |
| 3607 } while (0) | |
| 3608 | |
| 17052 | 3609 |
| 3610 /* Produce codes for designation and invocation to reset the graphic | |
| 3611 planes and registers to initial state. */ | |
| 88365 | 3612 #define ENCODE_RESET_PLANE_AND_REGISTER() \ |
| 3613 do { \ | |
| 3614 int reg; \ | |
| 3615 struct charset *charset; \ | |
| 3616 \ | |
| 3617 if (CODING_ISO_INVOCATION (coding, 0) != 0) \ | |
| 3618 ENCODE_SHIFT_IN; \ | |
| 3619 for (reg = 0; reg < 4; reg++) \ | |
| 3620 if (CODING_ISO_INITIAL (coding, reg) >= 0 \ | |
| 3621 && (CODING_ISO_DESIGNATION (coding, reg) \ | |
| 3622 != CODING_ISO_INITIAL (coding, reg))) \ | |
| 3623 { \ | |
| 3624 charset = CHARSET_FROM_ID (CODING_ISO_INITIAL (coding, reg)); \ | |
| 3625 ENCODE_DESIGNATION (charset, reg, coding); \ | |
| 3626 } \ | |
| 17052 | 3627 } while (0) |
| 3628 | |
| 88365 | 3629 |
|
17725
92f042f73be2
(Valternate_charset_table): The valiable deleted.
Kenichi Handa <handa@m17n.org>
parents:
17717
diff
changeset
|
3630 /* 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
|
3631 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
|
3632 |
|
92f042f73be2
(Valternate_charset_table): The valiable deleted.
Kenichi Handa <handa@m17n.org>
parents:
17717
diff
changeset
|
3633 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
|
3634 find all the necessary designations. */ |
|
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3635 |
|
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3636 static unsigned char * |
| 88365 | 3637 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
|
3638 struct coding_system *coding; |
| 88365 | 3639 int *charbuf, *charbuf_end; |
| 3640 unsigned char *dst; | |
|
17119
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
3641 { |
| 88365 | 3642 struct charset *charset; |
|
17725
92f042f73be2
(Valternate_charset_table): The valiable deleted.
Kenichi Handa <handa@m17n.org>
parents:
17717
diff
changeset
|
3643 /* 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
|
3644 int r[4]; |
| 88365 | 3645 int c, found = 0, reg; |
| 3646 int produced_chars = 0; | |
| 3647 int multibytep = coding->dst_multibyte; | |
| 3648 Lisp_Object attrs; | |
| 3649 Lisp_Object charset_list; | |
| 3650 | |
| 3651 attrs = CODING_ID_ATTRS (coding->id); | |
| 3652 charset_list = CODING_ATTR_CHARSET_LIST (attrs); | |
| 3653 if (EQ (charset_list, Qiso_2022)) | |
| 3654 charset_list = Viso_2022_charset_list; | |
|
17725
92f042f73be2
(Valternate_charset_table): The valiable deleted.
Kenichi Handa <handa@m17n.org>
parents:
17717
diff
changeset
|
3655 |
|
92f042f73be2
(Valternate_charset_table): The valiable deleted.
Kenichi Handa <handa@m17n.org>
parents:
17717
diff
changeset
|
3656 for (reg = 0; reg < 4; reg++) |
|
92f042f73be2
(Valternate_charset_table): The valiable deleted.
Kenichi Handa <handa@m17n.org>
parents:
17717
diff
changeset
|
3657 r[reg] = -1; |
|
92f042f73be2
(Valternate_charset_table): The valiable deleted.
Kenichi Handa <handa@m17n.org>
parents:
17717
diff
changeset
|
3658 |
|
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3659 while (found < 4) |
|
17119
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
3660 { |
| 88365 | 3661 int id; |
| 3662 | |
| 3663 c = *charbuf++; | |
|
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3664 if (c == '\n') |
|
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3665 break; |
| 88365 | 3666 charset = char_charset (c, charset_list, NULL); |
| 3667 id = CHARSET_ID (charset); | |
| 3668 reg = CODING_ISO_REQUEST (coding, id); | |
| 3669 if (reg >= 0 && r[reg] < 0) | |
|
17725
92f042f73be2
(Valternate_charset_table): The valiable deleted.
Kenichi Handa <handa@m17n.org>
parents:
17717
diff
changeset
|
3670 { |
|
92f042f73be2
(Valternate_charset_table): The valiable deleted.
Kenichi Handa <handa@m17n.org>
parents:
17717
diff
changeset
|
3671 found++; |
| 88365 | 3672 r[reg] = id; |
|
17119
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
3673 } |
|
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
3674 } |
|
17725
92f042f73be2
(Valternate_charset_table): The valiable deleted.
Kenichi Handa <handa@m17n.org>
parents:
17717
diff
changeset
|
3675 |
|
92f042f73be2
(Valternate_charset_table): The valiable deleted.
Kenichi Handa <handa@m17n.org>
parents:
17717
diff
changeset
|
3676 if (found) |
|
92f042f73be2
(Valternate_charset_table): The valiable deleted.
Kenichi Handa <handa@m17n.org>
parents:
17717
diff
changeset
|
3677 { |
|
92f042f73be2
(Valternate_charset_table): The valiable deleted.
Kenichi Handa <handa@m17n.org>
parents:
17717
diff
changeset
|
3678 for (reg = 0; reg < 4; reg++) |
|
92f042f73be2
(Valternate_charset_table): The valiable deleted.
Kenichi Handa <handa@m17n.org>
parents:
17717
diff
changeset
|
3679 if (r[reg] >= 0 |
| 88365 | 3680 && CODING_ISO_DESIGNATION (coding, reg) != r[reg]) |
| 3681 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
|
3682 } |
|
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3683 |
|
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3684 return dst; |
|
17119
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
3685 } |
|
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
3686 |
| 17052 | 3687 /* See the above "GENERAL NOTES on `encode_coding_XXX ()' functions". */ |
| 3688 | |
| 88365 | 3689 static int |
| 3690 encode_coding_iso_2022 (coding) | |
| 17052 | 3691 struct coding_system *coding; |
| 3692 { | |
| 88365 | 3693 int multibytep = coding->dst_multibyte; |
| 3694 int *charbuf = coding->charbuf; | |
| 3695 int *charbuf_end = charbuf + coding->charbuf_used; | |
| 3696 unsigned char *dst = coding->destination + coding->produced; | |
| 3697 unsigned char *dst_end = coding->destination + coding->dst_bytes; | |
| 3698 int safe_room = 16; | |
| 3699 int bol_designation | |
| 3700 = (CODING_ISO_FLAGS (coding) & CODING_ISO_FLAG_DESIGNATE_AT_BOL | |
| 3701 && CODING_ISO_BOL (coding)); | |
| 3702 int produced_chars = 0; | |
| 3703 Lisp_Object attrs, eol_type, charset_list; | |
| 3704 int ascii_compatible; | |
|
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3705 int c; |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3706 int preferred_charset_id = -1; |
| 88365 | 3707 |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
3708 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
|
3709 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
|
3710 if (VECTORP (eol_type)) |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
3711 eol_type = Qunix; |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
3712 |
|
88497
d2b9e0d4c2f6
(Fdecode_sjis_char): Fix typo (0x7F->0xFF). Fix the
Kenichi Handa <handa@m17n.org>
parents:
88485
diff
changeset
|
3713 setup_iso_safe_charsets (attrs); |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3714 /* Charset list may have been changed. */ |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3715 charset_list = CODING_ATTR_CHARSET_LIST (attrs); \ |
| 89483 | 3716 coding->safe_charsets = (char *) SDATA (CODING_ATTR_SAFE_CHARSETS(attrs)); |
| 88365 | 3717 |
| 3718 ascii_compatible = ! NILP (CODING_ATTR_ASCII_COMPAT (attrs)); | |
| 3719 | |
| 3720 while (charbuf < charbuf_end) | |
| 3721 { | |
| 3722 ASSURE_DESTINATION (safe_room); | |
| 3723 | |
| 3724 if (bol_designation) | |
|
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3725 { |
| 88365 | 3726 unsigned char *dst_prev = dst; |
| 3727 | |
|
17725
92f042f73be2
(Valternate_charset_table): The valiable deleted.
Kenichi Handa <handa@m17n.org>
parents:
17717
diff
changeset
|
3728 /* We have to produce designation sequences if any now. */ |
| 88365 | 3729 dst = encode_designation_at_bol (coding, charbuf, charbuf_end, dst); |
| 3730 bol_designation = 0; | |
| 3731 /* We are sure that designation sequences are all ASCII bytes. */ | |
| 3732 produced_chars += dst - dst_prev; | |
|
17119
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
3733 } |
|
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
3734 |
| 88365 | 3735 c = *charbuf++; |
|
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3736 |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3737 if (c < 0) |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3738 { |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3739 /* Handle an annotation. */ |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3740 switch (*charbuf) |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3741 { |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3742 case CODING_ANNOTATE_COMPOSITION_MASK: |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3743 /* Not yet implemented. */ |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3744 break; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3745 case CODING_ANNOTATE_CHARSET_MASK: |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3746 preferred_charset_id = charbuf[3]; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3747 if (preferred_charset_id >= 0 |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3748 && NILP (Fmemq (make_number (preferred_charset_id), |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3749 charset_list))) |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3750 preferred_charset_id = -1; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3751 break; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3752 default: |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3753 abort (); |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3754 } |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3755 charbuf += -c - 1; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3756 continue; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3757 } |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3758 |
|
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3759 /* 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
|
3760 if (c < 0x20 || c == 0x7F) |
| 17052 | 3761 { |
| 88365 | 3762 if (c == '\n' |
| 3763 || (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
|
3764 { |
| 88365 | 3765 if (CODING_ISO_FLAGS (coding) & CODING_ISO_FLAG_RESET_AT_EOL) |
| 3766 ENCODE_RESET_PLANE_AND_REGISTER (); | |
| 3767 if (CODING_ISO_FLAGS (coding) & CODING_ISO_FLAG_INIT_AT_BOL) | |
| 3768 { | |
| 3769 int i; | |
| 3770 | |
| 3771 for (i = 0; i < 4; i++) | |
| 3772 CODING_ISO_DESIGNATION (coding, i) | |
| 3773 = CODING_ISO_INITIAL (coding, i); | |
| 3774 } | |
| 3775 bol_designation | |
| 3776 = 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
|
3777 } |
| 88365 | 3778 else if (CODING_ISO_FLAGS (coding) & CODING_ISO_FLAG_RESET_AT_CNTL) |
| 3779 ENCODE_RESET_PLANE_AND_REGISTER (); | |
| 3780 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
|
3781 } |
| 88365 | 3782 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
|
3783 { |
| 88365 | 3784 if (ascii_compatible) |
| 3785 EMIT_ONE_ASCII_BYTE (c); | |
| 3786 else | |
|
88681
2cdfbffa8a0d
(CODING_ISO_FLAG_USE_ROMAN): New macro
Kenichi Handa <handa@m17n.org>
parents:
88669
diff
changeset
|
3787 { |
|
2cdfbffa8a0d
(CODING_ISO_FLAG_USE_ROMAN): New macro
Kenichi Handa <handa@m17n.org>
parents:
88669
diff
changeset
|
3788 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
|
3789 ENCODE_ISO_CHARACTER (charset, c); |
|
2cdfbffa8a0d
(CODING_ISO_FLAG_USE_ROMAN): New macro
Kenichi Handa <handa@m17n.org>
parents:
88669
diff
changeset
|
3790 } |
| 17052 | 3791 } |
|
88690
7f284ac55b07
(encode_coding_emacs_mule): Pay attention to raw-8-bit chars.
Kenichi Handa <handa@m17n.org>
parents:
88681
diff
changeset
|
3792 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
|
3793 { |
|
7f284ac55b07
(encode_coding_emacs_mule): Pay attention to raw-8-bit chars.
Kenichi Handa <handa@m17n.org>
parents:
88681
diff
changeset
|
3794 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
|
3795 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
|
3796 } |
|
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3797 else |
| 88365 | 3798 { |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3799 struct charset *charset; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3800 |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3801 if (preferred_charset_id >= 0) |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3802 { |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3803 charset = CHARSET_FROM_ID (preferred_charset_id); |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3804 if (! CHAR_CHARSET_P (c, charset)) |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3805 charset = char_charset (c, charset_list, NULL); |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3806 } |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3807 else |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3808 charset = char_charset (c, charset_list, NULL); |
| 88365 | 3809 if (!charset) |
| 3810 { | |
|
88573
133bf7ab1bad
(encode_coding_iso_2022): If coding requires safe
Kenichi Handa <handa@m17n.org>
parents:
88544
diff
changeset
|
3811 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
|
3812 { |
|
133bf7ab1bad
(encode_coding_iso_2022): If coding requires safe
Kenichi Handa <handa@m17n.org>
parents:
88544
diff
changeset
|
3813 c = CODING_INHIBIT_CHARACTER_SUBSTITUTION; |
|
133bf7ab1bad
(encode_coding_iso_2022): If coding requires safe
Kenichi Handa <handa@m17n.org>
parents:
88544
diff
changeset
|
3814 charset = CHARSET_FROM_ID (charset_ascii); |
|
133bf7ab1bad
(encode_coding_iso_2022): If coding requires safe
Kenichi Handa <handa@m17n.org>
parents:
88544
diff
changeset
|
3815 } |
|
133bf7ab1bad
(encode_coding_iso_2022): If coding requires safe
Kenichi Handa <handa@m17n.org>
parents:
88544
diff
changeset
|
3816 else |
|
133bf7ab1bad
(encode_coding_iso_2022): If coding requires safe
Kenichi Handa <handa@m17n.org>
parents:
88544
diff
changeset
|
3817 { |
|
133bf7ab1bad
(encode_coding_iso_2022): If coding requires safe
Kenichi Handa <handa@m17n.org>
parents:
88544
diff
changeset
|
3818 c = coding->default_char; |
|
133bf7ab1bad
(encode_coding_iso_2022): If coding requires safe
Kenichi Handa <handa@m17n.org>
parents:
88544
diff
changeset
|
3819 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
|
3820 } |
| 88365 | 3821 } |
| 3822 ENCODE_ISO_CHARACTER (charset, c); | |
| 3823 } | |
| 3824 } | |
| 3825 | |
| 3826 if (coding->mode & CODING_MODE_LAST_BLOCK | |
| 3827 && CODING_ISO_FLAGS (coding) & CODING_ISO_FLAG_RESET_AT_EOL) | |
| 3828 { | |
| 3829 ASSURE_DESTINATION (safe_room); | |
| 3830 ENCODE_RESET_PLANE_AND_REGISTER (); | |
| 3831 } | |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
3832 record_conversion_result (coding, CODING_RESULT_SUCCESS); |
| 88365 | 3833 CODING_ISO_BOL (coding) = bol_designation; |
| 3834 coding->produced_char += produced_chars; | |
| 3835 coding->produced = dst - coding->destination; | |
| 3836 return 0; | |
| 17052 | 3837 } |
| 3838 | |
| 3839 | |
| 88365 | 3840 /*** 8,9. SJIS and BIG5 handlers ***/ |
| 3841 | |
| 3842 /* Although SJIS and BIG5 are not ISO's coding system, they are used | |
| 17052 | 3843 quite widely. So, for the moment, Emacs supports them in the bare |
| 3844 C code. But, in the future, they may be supported only by CCL. */ | |
| 3845 | |
| 3846 /* SJIS is a coding system encoding three character sets: ASCII, right | |
| 3847 half of JISX0201-Kana, and JISX0208. An ASCII character is encoded | |
| 3848 as is. A character of charset katakana-jisx0201 is encoded by | |
| 3849 "position-code + 0x80". A character of charset japanese-jisx0208 | |
| 3850 is encoded in 2-byte but two position-codes are divided and shifted | |
| 88365 | 3851 so that it fit in the range below. |
| 17052 | 3852 |
| 3853 --- CODE RANGE of SJIS --- | |
| 3854 (character set) (range) | |
| 3855 ASCII 0x00 .. 0x7F | |
| 88365 | 3856 KATAKANA-JISX0201 0xA0 .. 0xDF |
|
24324
2eec590faf26
(Fdecode_sjis_char, Fencode_sjis_char): Hanlde
Kenichi Handa <handa@m17n.org>
parents:
24316
diff
changeset
|
3857 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
|
3858 (2nd byte) 0x40 .. 0x7E and 0x80 .. 0xFC |
| 17052 | 3859 ------------------------------- |
| 3860 | |
| 3861 */ | |
| 3862 | |
| 3863 /* BIG5 is a coding system encoding two character sets: ASCII and | |
| 3864 Big5. An ASCII character is encoded as is. Big5 is a two-byte | |
| 88365 | 3865 character set and is encoded in two-byte. |
| 17052 | 3866 |
| 3867 --- CODE RANGE of BIG5 --- | |
| 3868 (character set) (range) | |
| 3869 ASCII 0x00 .. 0x7F | |
| 3870 Big5 (1st byte) 0xA1 .. 0xFE | |
| 3871 (2nd byte) 0x40 .. 0x7E and 0xA1 .. 0xFE | |
| 3872 -------------------------- | |
| 3873 | |
| 88365 | 3874 */ |
| 17052 | 3875 |
| 3876 /* See the above "GENERAL NOTES on `detect_coding_XXX ()' functions". | |
| 3877 Check if a text is encoded in SJIS. If it is, return | |
| 88365 | 3878 CATEGORY_MASK_SJIS, else return 0. */ |
| 17052 | 3879 |
|
34531
37f85e931855
(ONE_MORE_BYTE_CHECK_MULTIBYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34197
diff
changeset
|
3880 static int |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3881 detect_coding_sjis (coding, detect_info) |
| 88365 | 3882 struct coding_system *coding; |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3883 struct coding_detection_info *detect_info; |
| 17052 | 3884 { |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
3885 const unsigned char *src = coding->source, *src_base; |
| 89483 | 3886 const unsigned char *src_end = coding->source + coding->src_bytes; |
| 88365 | 3887 int multibytep = coding->src_multibyte; |
| 3888 int consumed_chars = 0; | |
| 3889 int found = 0; | |
|
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3890 int c; |
| 88365 | 3891 |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3892 detect_info->checked |= CATEGORY_MASK_SJIS; |
| 88365 | 3893 /* A coding system of this category is always ASCII compatible. */ |
| 3894 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
|
3895 |
|
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3896 while (1) |
| 17052 | 3897 { |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
3898 src_base = src; |
| 88365 | 3899 ONE_MORE_BYTE (c); |
|
36647
0a75ccbe42b2
(detect_coding_sjis): Do more rigid check.
Kenichi Handa <handa@m17n.org>
parents:
36520
diff
changeset
|
3900 if (c < 0x80) |
|
0a75ccbe42b2
(detect_coding_sjis): Do more rigid check.
Kenichi Handa <handa@m17n.org>
parents:
36520
diff
changeset
|
3901 continue; |
| 88365 | 3902 if ((c >= 0x81 && c <= 0x9F) || (c >= 0xE0 && c <= 0xEF)) |
| 17052 | 3903 { |
| 88365 | 3904 ONE_MORE_BYTE (c); |
|
36647
0a75ccbe42b2
(detect_coding_sjis): Do more rigid check.
Kenichi Handa <handa@m17n.org>
parents:
36520
diff
changeset
|
3905 if (c < 0x40 || c == 0x7F || c > 0xFC) |
| 88365 | 3906 break; |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3907 found = CATEGORY_MASK_SJIS; |
| 17052 | 3908 } |
| 88365 | 3909 else if (c >= 0xA0 && c < 0xE0) |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3910 found = CATEGORY_MASK_SJIS; |
| 88365 | 3911 else |
| 3912 break; | |
| 3913 } | |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3914 detect_info->rejected |= CATEGORY_MASK_SJIS; |
| 88365 | 3915 return 0; |
| 3916 | |
| 3917 no_more_source: | |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
3918 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
|
3919 { |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3920 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
|
3921 return 0; |
|
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
3922 } |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3923 detect_info->found |= found; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3924 return 1; |
| 17052 | 3925 } |
| 3926 | |
| 3927 /* See the above "GENERAL NOTES on `detect_coding_XXX ()' functions". | |
| 3928 Check if a text is encoded in BIG5. If it is, return | |
| 88365 | 3929 CATEGORY_MASK_BIG5, else return 0. */ |
| 17052 | 3930 |
|
34531
37f85e931855
(ONE_MORE_BYTE_CHECK_MULTIBYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34197
diff
changeset
|
3931 static int |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3932 detect_coding_big5 (coding, detect_info) |
| 88365 | 3933 struct coding_system *coding; |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3934 struct coding_detection_info *detect_info; |
| 17052 | 3935 { |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
3936 const unsigned char *src = coding->source, *src_base; |
| 89483 | 3937 const unsigned char *src_end = coding->source + coding->src_bytes; |
| 88365 | 3938 int multibytep = coding->src_multibyte; |
| 3939 int consumed_chars = 0; | |
| 3940 int found = 0; | |
|
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3941 int c; |
| 88365 | 3942 |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3943 detect_info->checked |= CATEGORY_MASK_BIG5; |
| 88365 | 3944 /* A coding system of this category is always ASCII compatible. */ |
| 3945 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
|
3946 |
|
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3947 while (1) |
|
28022
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
3948 { |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
3949 src_base = src; |
| 88365 | 3950 ONE_MORE_BYTE (c); |
| 3951 if (c < 0x80) | |
|
28022
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
3952 continue; |
| 88365 | 3953 if (c >= 0xA1) |
|
28022
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
3954 { |
| 88365 | 3955 ONE_MORE_BYTE (c); |
| 3956 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
|
3957 return 0; |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3958 found = CATEGORY_MASK_BIG5; |
|
28022
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
3959 } |
| 88365 | 3960 else |
| 3961 break; | |
| 3962 } | |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3963 detect_info->rejected |= CATEGORY_MASK_BIG5; |
|
28022
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
3964 return 0; |
| 88365 | 3965 |
| 3966 no_more_source: | |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
3967 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
|
3968 { |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3969 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
|
3970 return 0; |
|
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
3971 } |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3972 detect_info->found |= found; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3973 return 1; |
|
28022
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
3974 } |
|
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
3975 |
| 17052 | 3976 /* See the above "GENERAL NOTES on `decode_coding_XXX ()' functions". |
| 3977 If SJIS_P is 1, decode SJIS text, else decode BIG5 test. */ | |
| 3978 | |
|
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3979 static void |
| 88365 | 3980 decode_coding_sjis (coding) |
| 17052 | 3981 struct coding_system *coding; |
| 3982 { | |
| 89483 | 3983 const unsigned char *src = coding->source + coding->consumed; |
| 3984 const unsigned char *src_end = coding->source + coding->src_bytes; | |
| 3985 const unsigned char *src_base; | |
|
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
3986 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
|
3987 int *charbuf_end |
|
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
3988 = coding->charbuf + coding->charbuf_size - MAX_ANNOTATION_LENGTH; |
| 88365 | 3989 int consumed_chars = 0, consumed_chars_base; |
| 3990 int multibytep = coding->src_multibyte; | |
| 3991 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
|
3992 struct charset *charset_kanji2; |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
3993 Lisp_Object attrs, charset_list, val; |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3994 int char_offset = coding->produced_char; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3995 int last_offset = char_offset; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3996 int last_id = charset_ascii; |
| 88365 | 3997 |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
3998 CODING_GET_INFO (coding, attrs, charset_list); |
| 88365 | 3999 |
| 4000 val = charset_list; | |
| 4001 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
|
4002 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
|
4003 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
|
4004 charset_kanji2 = NILP (val) ? NULL : CHARSET_FROM_ID (XINT (XCAR (val))); |
| 88365 | 4005 |
|
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4006 while (1) |
| 17052 | 4007 { |
| 88365 | 4008 int c, c1; |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4009 struct charset *charset; |
|
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4010 |
|
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4011 src_base = src; |
| 88365 | 4012 consumed_chars_base = consumed_chars; |
| 4013 | |
| 4014 if (charbuf >= charbuf_end) | |
| 4015 break; | |
| 4016 | |
| 4017 ONE_MORE_BYTE (c); | |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
4018 if (c < 0) |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
4019 goto invalid_code; |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4020 if (c < 0x80) |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4021 charset = charset_roman; |
|
89764
e3d26232ab78
(decode_coding_sjis): Handle 4th charset (typically JISX0212).
Kenichi Handa <handa@m17n.org>
parents:
89759
diff
changeset
|
4022 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
|
4023 goto invalid_code; |
|
89764
e3d26232ab78
(decode_coding_sjis): Handle 4th charset (typically JISX0212).
Kenichi Handa <handa@m17n.org>
parents:
89759
diff
changeset
|
4024 else if (c >= 0xA1 && c <= 0xDF) |
|
e3d26232ab78
(decode_coding_sjis): Handle 4th charset (typically JISX0212).
Kenichi Handa <handa@m17n.org>
parents:
89759
diff
changeset
|
4025 { |
|
e3d26232ab78
(decode_coding_sjis): Handle 4th charset (typically JISX0212).
Kenichi Handa <handa@m17n.org>
parents:
89759
diff
changeset
|
4026 /* SJIS -> JISX0201-Kana */ |
|
e3d26232ab78
(decode_coding_sjis): Handle 4th charset (typically JISX0212).
Kenichi Handa <handa@m17n.org>
parents:
89759
diff
changeset
|
4027 c &= 0x7F; |
|
e3d26232ab78
(decode_coding_sjis): Handle 4th charset (typically JISX0212).
Kenichi Handa <handa@m17n.org>
parents:
89759
diff
changeset
|
4028 charset = charset_kana; |
|
e3d26232ab78
(decode_coding_sjis): Handle 4th charset (typically JISX0212).
Kenichi Handa <handa@m17n.org>
parents:
89759
diff
changeset
|
4029 } |
|
e3d26232ab78
(decode_coding_sjis): Handle 4th charset (typically JISX0212).
Kenichi Handa <handa@m17n.org>
parents:
89759
diff
changeset
|
4030 else if (c <= 0xEF) |
|
e3d26232ab78
(decode_coding_sjis): Handle 4th charset (typically JISX0212).
Kenichi Handa <handa@m17n.org>
parents:
89759
diff
changeset
|
4031 { |
|
e3d26232ab78
(decode_coding_sjis): Handle 4th charset (typically JISX0212).
Kenichi Handa <handa@m17n.org>
parents:
89759
diff
changeset
|
4032 /* SJIS -> JISX0208 */ |
|
e3d26232ab78
(decode_coding_sjis): Handle 4th charset (typically JISX0212).
Kenichi Handa <handa@m17n.org>
parents:
89759
diff
changeset
|
4033 ONE_MORE_BYTE (c1); |
|
e3d26232ab78
(decode_coding_sjis): Handle 4th charset (typically JISX0212).
Kenichi Handa <handa@m17n.org>
parents:
89759
diff
changeset
|
4034 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
|
4035 goto invalid_code; |
|
89764
e3d26232ab78
(decode_coding_sjis): Handle 4th charset (typically JISX0212).
Kenichi Handa <handa@m17n.org>
parents:
89759
diff
changeset
|
4036 c = (c << 8) | c1; |
|
e3d26232ab78
(decode_coding_sjis): Handle 4th charset (typically JISX0212).
Kenichi Handa <handa@m17n.org>
parents:
89759
diff
changeset
|
4037 SJIS_TO_JIS (c); |
|
e3d26232ab78
(decode_coding_sjis): Handle 4th charset (typically JISX0212).
Kenichi Handa <handa@m17n.org>
parents:
89759
diff
changeset
|
4038 charset = charset_kanji; |
|
e3d26232ab78
(decode_coding_sjis): Handle 4th charset (typically JISX0212).
Kenichi Handa <handa@m17n.org>
parents:
89759
diff
changeset
|
4039 } |
|
e3d26232ab78
(decode_coding_sjis): Handle 4th charset (typically JISX0212).
Kenichi Handa <handa@m17n.org>
parents:
89759
diff
changeset
|
4040 else if (c <= 0xFC && charset_kanji2) |
|
e3d26232ab78
(decode_coding_sjis): Handle 4th charset (typically JISX0212).
Kenichi Handa <handa@m17n.org>
parents:
89759
diff
changeset
|
4041 { |
|
89779
74c503490829
(decode_coding_sjis): Fix comment.
Kenichi Handa <handa@m17n.org>
parents:
89764
diff
changeset
|
4042 /* SJIS -> JISX0213-2 */ |
|
89764
e3d26232ab78
(decode_coding_sjis): Handle 4th charset (typically JISX0212).
Kenichi Handa <handa@m17n.org>
parents:
89759
diff
changeset
|
4043 ONE_MORE_BYTE (c1); |
|
e3d26232ab78
(decode_coding_sjis): Handle 4th charset (typically JISX0212).
Kenichi Handa <handa@m17n.org>
parents:
89759
diff
changeset
|
4044 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
|
4045 goto invalid_code; |
|
89764
e3d26232ab78
(decode_coding_sjis): Handle 4th charset (typically JISX0212).
Kenichi Handa <handa@m17n.org>
parents:
89759
diff
changeset
|
4046 c = (c << 8) | c1; |
|
e3d26232ab78
(decode_coding_sjis): Handle 4th charset (typically JISX0212).
Kenichi Handa <handa@m17n.org>
parents:
89759
diff
changeset
|
4047 SJIS_TO_JIS2 (c); |
|
e3d26232ab78
(decode_coding_sjis): Handle 4th charset (typically JISX0212).
Kenichi Handa <handa@m17n.org>
parents:
89759
diff
changeset
|
4048 charset = charset_kanji2; |
|
e3d26232ab78
(decode_coding_sjis): Handle 4th charset (typically JISX0212).
Kenichi Handa <handa@m17n.org>
parents:
89759
diff
changeset
|
4049 } |
|
e3d26232ab78
(decode_coding_sjis): Handle 4th charset (typically JISX0212).
Kenichi Handa <handa@m17n.org>
parents:
89759
diff
changeset
|
4050 else |
|
e3d26232ab78
(decode_coding_sjis): Handle 4th charset (typically JISX0212).
Kenichi Handa <handa@m17n.org>
parents:
89759
diff
changeset
|
4051 goto invalid_code; |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4052 if (charset->id != charset_ascii |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4053 && last_id != charset->id) |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4054 { |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4055 if (last_id != charset_ascii) |
|
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
4056 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
|
4057 last_id = charset->id; |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4058 last_offset = char_offset; |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4059 } |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4060 CODING_DECODE_CHAR (coding, src, src_base, src_end, charset, c, c); |
| 88365 | 4061 *charbuf++ = c; |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
4062 char_offset++; |
| 88365 | 4063 continue; |
| 4064 | |
| 4065 invalid_code: | |
| 4066 src = src_base; | |
| 4067 consumed_chars = consumed_chars_base; | |
| 4068 ONE_MORE_BYTE (c); | |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
4069 *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
|
4070 char_offset++; |
| 88365 | 4071 coding->errors++; |
| 4072 } | |
| 4073 | |
| 4074 no_more_source: | |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
4075 if (last_id != charset_ascii) |
|
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
4076 ADD_CHARSET_DATA (charbuf, char_offset - last_offset, last_id); |
| 88365 | 4077 coding->consumed_char += consumed_chars_base; |
| 4078 coding->consumed = src_base - coding->source; | |
| 4079 coding->charbuf_used = charbuf - coding->charbuf; | |
| 4080 } | |
| 4081 | |
| 4082 static void | |
| 4083 decode_coding_big5 (coding) | |
| 4084 struct coding_system *coding; | |
| 4085 { | |
| 89483 | 4086 const unsigned char *src = coding->source + coding->consumed; |
| 4087 const unsigned char *src_end = coding->source + coding->src_bytes; | |
| 4088 const unsigned char *src_base; | |
|
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
4089 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
|
4090 int *charbuf_end |
|
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
4091 = coding->charbuf + coding->charbuf_size - MAX_ANNOTATION_LENGTH; |
| 88365 | 4092 int consumed_chars = 0, consumed_chars_base; |
| 4093 int multibytep = coding->src_multibyte; | |
| 4094 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
|
4095 Lisp_Object attrs, charset_list, val; |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
4096 int char_offset = coding->produced_char; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
4097 int last_offset = char_offset; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
4098 int last_id = charset_ascii; |
| 88365 | 4099 |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4100 CODING_GET_INFO (coding, attrs, charset_list); |
| 88365 | 4101 val = charset_list; |
| 4102 charset_roman = CHARSET_FROM_ID (XINT (XCAR (val))), val = XCDR (val); | |
| 4103 charset_big5 = CHARSET_FROM_ID (XINT (XCAR (val))); | |
| 4104 | |
| 4105 while (1) | |
| 4106 { | |
| 4107 int c, c1; | |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4108 struct charset *charset; |
| 88365 | 4109 |
| 4110 src_base = src; | |
| 4111 consumed_chars_base = consumed_chars; | |
| 4112 | |
| 4113 if (charbuf >= charbuf_end) | |
| 4114 break; | |
| 4115 | |
| 4116 ONE_MORE_BYTE (c); | |
| 4117 | |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
4118 if (c < 0) |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
4119 goto invalid_code; |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4120 if (c < 0x80) |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4121 charset = charset_roman; |
| 88365 | 4122 else |
| 4123 { | |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4124 /* BIG5 -> Big5 */ |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4125 if (c < 0xA1 || c > 0xFE) |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4126 goto invalid_code; |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4127 ONE_MORE_BYTE (c1); |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4128 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
|
4129 goto invalid_code; |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4130 c = c << 8 | c1; |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4131 charset = charset_big5; |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4132 } |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4133 if (charset->id != charset_ascii |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4134 && last_id != charset->id) |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4135 { |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4136 if (last_id != charset_ascii) |
|
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
4137 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
|
4138 last_id = charset->id; |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4139 last_offset = char_offset; |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4140 } |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4141 CODING_DECODE_CHAR (coding, src, src_base, src_end, charset, c, c); |
| 88365 | 4142 *charbuf++ = c; |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
4143 char_offset++; |
|
20931
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
4144 continue; |
|
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
4145 |
| 88365 | 4146 invalid_code: |
| 17052 | 4147 src = src_base; |
| 88365 | 4148 consumed_chars = consumed_chars_base; |
| 4149 ONE_MORE_BYTE (c); | |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
4150 *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
|
4151 char_offset++; |
| 88365 | 4152 coding->errors++; |
| 4153 } | |
| 4154 | |
| 4155 no_more_source: | |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
4156 if (last_id != charset_ascii) |
|
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
4157 ADD_CHARSET_DATA (charbuf, char_offset - last_offset, last_id); |
| 88365 | 4158 coding->consumed_char += consumed_chars_base; |
| 4159 coding->consumed = src_base - coding->source; | |
| 4160 coding->charbuf_used = charbuf - coding->charbuf; | |
| 17052 | 4161 } |
| 4162 | |
| 4163 /* 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
|
4164 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
|
4165 `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
|
4166 are sure that all these charsets are registered as official charset |
| 17052 | 4167 (i.e. do not have extended leading-codes). Characters of other |
| 4168 charsets are produced without any encoding. If SJIS_P is 1, encode | |
| 4169 SJIS text, else encode BIG5 text. */ | |
| 4170 | |
| 88365 | 4171 static int |
| 4172 encode_coding_sjis (coding) | |
| 17052 | 4173 struct coding_system *coding; |
| 4174 { | |
| 88365 | 4175 int multibytep = coding->dst_multibyte; |
| 4176 int *charbuf = coding->charbuf; | |
| 4177 int *charbuf_end = charbuf + coding->charbuf_used; | |
| 4178 unsigned char *dst = coding->destination + coding->produced; | |
| 4179 unsigned char *dst_end = coding->destination + coding->dst_bytes; | |
| 4180 int safe_room = 4; | |
| 4181 int produced_chars = 0; | |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4182 Lisp_Object attrs, charset_list, val; |
| 88365 | 4183 int ascii_compatible; |
| 4184 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
|
4185 struct charset *charset_kanji2; |
| 88365 | 4186 int c; |
| 4187 | |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4188 CODING_GET_INFO (coding, attrs, charset_list); |
| 88365 | 4189 val = charset_list; |
| 4190 charset_roman = CHARSET_FROM_ID (XINT (XCAR (val))), val = XCDR (val); | |
| 4191 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
|
4192 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
|
4193 charset_kanji2 = NILP (val) ? NULL : CHARSET_FROM_ID (XINT (XCAR (val))); |
| 88365 | 4194 |
| 4195 ascii_compatible = ! NILP (CODING_ATTR_ASCII_COMPAT (attrs)); | |
| 4196 | |
| 4197 while (charbuf < charbuf_end) | |
| 4198 { | |
| 4199 ASSURE_DESTINATION (safe_room); | |
| 4200 c = *charbuf++; | |
|
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4201 /* Now encode the character C. */ |
| 88365 | 4202 if (ASCII_CHAR_P (c) && ascii_compatible) |
| 4203 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
|
4204 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
|
4205 { |
|
7f284ac55b07
(encode_coding_emacs_mule): Pay attention to raw-8-bit chars.
Kenichi Handa <handa@m17n.org>
parents:
88681
diff
changeset
|
4206 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
|
4207 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
|
4208 } |
|
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4209 else |
|
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4210 { |
| 88365 | 4211 unsigned code; |
| 4212 struct charset *charset = char_charset (c, charset_list, &code); | |
| 4213 | |
| 4214 if (!charset) | |
| 4215 { | |
|
88573
133bf7ab1bad
(encode_coding_iso_2022): If coding requires safe
Kenichi Handa <handa@m17n.org>
parents:
88544
diff
changeset
|
4216 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
|
4217 { |
|
133bf7ab1bad
(encode_coding_iso_2022): If coding requires safe
Kenichi Handa <handa@m17n.org>
parents:
88544
diff
changeset
|
4218 code = CODING_INHIBIT_CHARACTER_SUBSTITUTION; |
|
133bf7ab1bad
(encode_coding_iso_2022): If coding requires safe
Kenichi Handa <handa@m17n.org>
parents:
88544
diff
changeset
|
4219 charset = CHARSET_FROM_ID (charset_ascii); |
|
133bf7ab1bad
(encode_coding_iso_2022): If coding requires safe
Kenichi Handa <handa@m17n.org>
parents:
88544
diff
changeset
|
4220 } |
|
133bf7ab1bad
(encode_coding_iso_2022): If coding requires safe
Kenichi Handa <handa@m17n.org>
parents:
88544
diff
changeset
|
4221 else |
|
133bf7ab1bad
(encode_coding_iso_2022): If coding requires safe
Kenichi Handa <handa@m17n.org>
parents:
88544
diff
changeset
|
4222 { |
|
133bf7ab1bad
(encode_coding_iso_2022): If coding requires safe
Kenichi Handa <handa@m17n.org>
parents:
88544
diff
changeset
|
4223 c = coding->default_char; |
|
133bf7ab1bad
(encode_coding_iso_2022): If coding requires safe
Kenichi Handa <handa@m17n.org>
parents:
88544
diff
changeset
|
4224 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
|
4225 } |
| 88365 | 4226 } |
| 4227 if (code == CHARSET_INVALID_CODE (charset)) | |
| 4228 abort (); | |
| 4229 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
|
4230 { |
| 88365 | 4231 int c1, c2; |
| 4232 JIS_TO_SJIS (code); | |
| 4233 c1 = code >> 8, c2 = code & 0xFF; | |
| 4234 EMIT_TWO_BYTES (c1, c2); | |
| 4235 } | |
| 4236 else if (charset == charset_kana) | |
| 4237 EMIT_ONE_BYTE (code | 0x80); | |
|
89764
e3d26232ab78
(decode_coding_sjis): Handle 4th charset (typically JISX0212).
Kenichi Handa <handa@m17n.org>
parents:
89759
diff
changeset
|
4238 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
|
4239 { |
|
e3d26232ab78
(decode_coding_sjis): Handle 4th charset (typically JISX0212).
Kenichi Handa <handa@m17n.org>
parents:
89759
diff
changeset
|
4240 int c1, c2; |
|
e3d26232ab78
(decode_coding_sjis): Handle 4th charset (typically JISX0212).
Kenichi Handa <handa@m17n.org>
parents:
89759
diff
changeset
|
4241 |
|
e3d26232ab78
(decode_coding_sjis): Handle 4th charset (typically JISX0212).
Kenichi Handa <handa@m17n.org>
parents:
89759
diff
changeset
|
4242 c1 = code >> 8; |
|
e3d26232ab78
(decode_coding_sjis): Handle 4th charset (typically JISX0212).
Kenichi Handa <handa@m17n.org>
parents:
89759
diff
changeset
|
4243 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
|
4244 || (c1 >= 0x2C && c1 <= 0x2F) || c1 >= 0x6E) |
|
e3d26232ab78
(decode_coding_sjis): Handle 4th charset (typically JISX0212).
Kenichi Handa <handa@m17n.org>
parents:
89759
diff
changeset
|
4245 { |
|
e3d26232ab78
(decode_coding_sjis): Handle 4th charset (typically JISX0212).
Kenichi Handa <handa@m17n.org>
parents:
89759
diff
changeset
|
4246 JIS_TO_SJIS2 (code); |
|
e3d26232ab78
(decode_coding_sjis): Handle 4th charset (typically JISX0212).
Kenichi Handa <handa@m17n.org>
parents:
89759
diff
changeset
|
4247 c1 = code >> 8, c2 = code & 0xFF; |
|
e3d26232ab78
(decode_coding_sjis): Handle 4th charset (typically JISX0212).
Kenichi Handa <handa@m17n.org>
parents:
89759
diff
changeset
|
4248 EMIT_TWO_BYTES (c1, c2); |
|
e3d26232ab78
(decode_coding_sjis): Handle 4th charset (typically JISX0212).
Kenichi Handa <handa@m17n.org>
parents:
89759
diff
changeset
|
4249 } |
|
e3d26232ab78
(decode_coding_sjis): Handle 4th charset (typically JISX0212).
Kenichi Handa <handa@m17n.org>
parents:
89759
diff
changeset
|
4250 else |
|
e3d26232ab78
(decode_coding_sjis): Handle 4th charset (typically JISX0212).
Kenichi Handa <handa@m17n.org>
parents:
89759
diff
changeset
|
4251 EMIT_ONE_ASCII_BYTE (code & 0x7F); |
|
e3d26232ab78
(decode_coding_sjis): Handle 4th charset (typically JISX0212).
Kenichi Handa <handa@m17n.org>
parents:
89759
diff
changeset
|
4252 } |
| 88365 | 4253 else |
| 4254 EMIT_ONE_ASCII_BYTE (code & 0x7F); | |
| 4255 } | |
| 4256 } | |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
4257 record_conversion_result (coding, CODING_RESULT_SUCCESS); |
| 88365 | 4258 coding->produced_char += produced_chars; |
| 4259 coding->produced = dst - coding->destination; | |
| 4260 return 0; | |
| 4261 } | |
| 4262 | |
| 4263 static int | |
| 4264 encode_coding_big5 (coding) | |
| 4265 struct coding_system *coding; | |
| 4266 { | |
| 4267 int multibytep = coding->dst_multibyte; | |
| 4268 int *charbuf = coding->charbuf; | |
| 4269 int *charbuf_end = charbuf + coding->charbuf_used; | |
| 4270 unsigned char *dst = coding->destination + coding->produced; | |
| 4271 unsigned char *dst_end = coding->destination + coding->dst_bytes; | |
| 4272 int safe_room = 4; | |
| 4273 int produced_chars = 0; | |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4274 Lisp_Object attrs, charset_list, val; |
| 88365 | 4275 int ascii_compatible; |
| 4276 struct charset *charset_roman, *charset_big5; | |
| 4277 int c; | |
| 4278 | |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4279 CODING_GET_INFO (coding, attrs, charset_list); |
| 88365 | 4280 val = charset_list; |
| 4281 charset_roman = CHARSET_FROM_ID (XINT (XCAR (val))), val = XCDR (val); | |
| 4282 charset_big5 = CHARSET_FROM_ID (XINT (XCAR (val))); | |
| 4283 ascii_compatible = ! NILP (CODING_ATTR_ASCII_COMPAT (attrs)); | |
| 4284 | |
| 4285 while (charbuf < charbuf_end) | |
| 4286 { | |
| 4287 ASSURE_DESTINATION (safe_room); | |
| 4288 c = *charbuf++; | |
| 4289 /* Now encode the character C. */ | |
| 4290 if (ASCII_CHAR_P (c) && ascii_compatible) | |
| 4291 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
|
4292 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
|
4293 { |
|
7f284ac55b07
(encode_coding_emacs_mule): Pay attention to raw-8-bit chars.
Kenichi Handa <handa@m17n.org>
parents:
88681
diff
changeset
|
4294 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
|
4295 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
|
4296 } |
| 88365 | 4297 else |
| 4298 { | |
| 4299 unsigned code; | |
| 4300 struct charset *charset = char_charset (c, charset_list, &code); | |
| 4301 | |
| 4302 if (! charset) | |
| 4303 { | |
|
88573
133bf7ab1bad
(encode_coding_iso_2022): If coding requires safe
Kenichi Handa <handa@m17n.org>
parents:
88544
diff
changeset
|
4304 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
|
4305 { |
|
133bf7ab1bad
(encode_coding_iso_2022): If coding requires safe
Kenichi Handa <handa@m17n.org>
parents:
88544
diff
changeset
|
4306 code = CODING_INHIBIT_CHARACTER_SUBSTITUTION; |
|
133bf7ab1bad
(encode_coding_iso_2022): If coding requires safe
Kenichi Handa <handa@m17n.org>
parents:
88544
diff
changeset
|
4307 charset = CHARSET_FROM_ID (charset_ascii); |
|
133bf7ab1bad
(encode_coding_iso_2022): If coding requires safe
Kenichi Handa <handa@m17n.org>
parents:
88544
diff
changeset
|
4308 } |
|
133bf7ab1bad
(encode_coding_iso_2022): If coding requires safe
Kenichi Handa <handa@m17n.org>
parents:
88544
diff
changeset
|
4309 else |
|
133bf7ab1bad
(encode_coding_iso_2022): If coding requires safe
Kenichi Handa <handa@m17n.org>
parents:
88544
diff
changeset
|
4310 { |
|
133bf7ab1bad
(encode_coding_iso_2022): If coding requires safe
Kenichi Handa <handa@m17n.org>
parents:
88544
diff
changeset
|
4311 c = coding->default_char; |
|
133bf7ab1bad
(encode_coding_iso_2022): If coding requires safe
Kenichi Handa <handa@m17n.org>
parents:
88544
diff
changeset
|
4312 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
|
4313 } |
| 88365 | 4314 } |
| 4315 if (code == CHARSET_INVALID_CODE (charset)) | |
| 4316 abort (); | |
| 4317 if (charset == charset_big5) | |
| 4318 { | |
| 4319 int c1, c2; | |
| 4320 | |
| 4321 c1 = code >> 8, c2 = code & 0xFF; | |
| 4322 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
|
4323 } |
| 17052 | 4324 else |
| 88365 | 4325 EMIT_ONE_ASCII_BYTE (code & 0x7F); |
| 17052 | 4326 } |
| 88365 | 4327 } |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
4328 record_conversion_result (coding, CODING_RESULT_SUCCESS); |
| 88365 | 4329 coding->produced_char += produced_chars; |
| 4330 coding->produced = dst - coding->destination; | |
| 4331 return 0; | |
| 17052 | 4332 } |
| 4333 | |
| 4334 | |
| 88365 | 4335 /*** 10. CCL handlers ***/ |
|
22874
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
4336 |
|
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
4337 /* See the above "GENERAL NOTES on `detect_coding_XXX ()' functions". |
|
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
4338 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
|
4339 encoder/decoder are written in CCL program. If it is, return |
| 88365 | 4340 CATEGORY_MASK_CCL, else return 0. */ |
|
22874
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
4341 |
|
34531
37f85e931855
(ONE_MORE_BYTE_CHECK_MULTIBYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34197
diff
changeset
|
4342 static int |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
4343 detect_coding_ccl (coding, detect_info) |
| 88365 | 4344 struct coding_system *coding; |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
4345 struct coding_detection_info *detect_info; |
| 88365 | 4346 { |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
4347 const unsigned char *src = coding->source, *src_base; |
| 89483 | 4348 const unsigned char *src_end = coding->source + coding->src_bytes; |
| 88365 | 4349 int multibytep = coding->src_multibyte; |
| 4350 int consumed_chars = 0; | |
| 4351 int found = 0; | |
|
89848
3edfa038a435
(detect_coding_emacs_mule): Fix counting of encoded
Kenichi Handa <handa@m17n.org>
parents:
89842
diff
changeset
|
4352 unsigned char *valids; |
| 88365 | 4353 int head_ascii = coding->head_ascii; |
| 4354 Lisp_Object attrs; | |
| 4355 | |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
4356 detect_info->checked |= CATEGORY_MASK_CCL; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
4357 |
| 88365 | 4358 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
|
4359 valids = CODING_CCL_VALIDS (coding); |
| 88365 | 4360 attrs = CODING_ID_ATTRS (coding->id); |
| 4361 if (! NILP (CODING_ATTR_ASCII_COMPAT (attrs))) | |
| 4362 src += head_ascii; | |
| 4363 | |
| 4364 while (1) | |
| 4365 { | |
| 4366 int c; | |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
4367 |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
4368 src_base = src; |
| 88365 | 4369 ONE_MORE_BYTE (c); |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
4370 if (c < 0 || ! valids[c]) |
| 88365 | 4371 break; |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
4372 if ((valids[c] > 1)) |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
4373 found = CATEGORY_MASK_CCL; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
4374 } |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
4375 detect_info->rejected |= CATEGORY_MASK_CCL; |
| 88365 | 4376 return 0; |
| 4377 | |
| 4378 no_more_source: | |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
4379 detect_info->found |= found; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
4380 return 1; |
| 88365 | 4381 } |
| 4382 | |
| 4383 static void | |
| 4384 decode_coding_ccl (coding) | |
| 4385 struct coding_system *coding; | |
|
22874
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
4386 { |
|
88876
af9012fdad56
(LEADING_CODE_PRIVATE_11, LEADING_CODE_PRIVATE_12,
Kenichi Handa <handa@m17n.org>
parents:
88862
diff
changeset
|
4387 const unsigned char *src = coding->source + coding->consumed; |
| 89483 | 4388 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
|
4389 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
|
4390 int *charbuf_end = coding->charbuf + coding->charbuf_size; |
| 88365 | 4391 int consumed_chars = 0; |
| 4392 int multibytep = coding->src_multibyte; | |
| 4393 struct ccl_program ccl; | |
| 4394 int source_charbuf[1024]; | |
| 4395 int source_byteidx[1024]; | |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4396 Lisp_Object attrs, charset_list; |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4397 |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4398 CODING_GET_INFO (coding, attrs, charset_list); |
| 88365 | 4399 setup_ccl_program (&ccl, CODING_CCL_DECODER (coding)); |
| 4400 | |
| 4401 while (src < src_end) | |
| 4402 { | |
|
88876
af9012fdad56
(LEADING_CODE_PRIVATE_11, LEADING_CODE_PRIVATE_12,
Kenichi Handa <handa@m17n.org>
parents:
88862
diff
changeset
|
4403 const unsigned char *p = src; |
| 88365 | 4404 int *source, *source_end; |
| 4405 int i = 0; | |
| 4406 | |
| 4407 if (multibytep) | |
| 4408 while (i < 1024 && p < src_end) | |
| 4409 { | |
| 4410 source_byteidx[i] = p - src; | |
| 4411 source_charbuf[i++] = STRING_CHAR_ADVANCE (p); | |
| 4412 } | |
| 4413 else | |
| 4414 while (i < 1024 && p < src_end) | |
| 4415 source_charbuf[i++] = *p++; | |
| 89483 | 4416 |
| 88365 | 4417 if (p == src_end && coding->mode & CODING_MODE_LAST_BLOCK) |
| 4418 ccl.last_block = 1; | |
| 4419 | |
| 4420 source = source_charbuf; | |
| 4421 source_end = source + i; | |
| 4422 while (source < source_end) | |
| 4423 { | |
| 4424 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
|
4425 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
|
4426 charset_list); |
| 88365 | 4427 source += ccl.consumed; |
| 4428 charbuf += ccl.produced; | |
| 4429 if (ccl.status != CCL_STAT_SUSPEND_BY_DST) | |
| 4430 break; | |
| 4431 } | |
| 4432 if (source < source_end) | |
| 4433 src += source_byteidx[source - source_charbuf]; | |
| 4434 else | |
| 4435 src = p; | |
| 4436 consumed_chars += source - source_charbuf; | |
| 4437 | |
| 4438 if (ccl.status != CCL_STAT_SUSPEND_BY_SRC | |
| 4439 && ccl.status != CODING_RESULT_INSUFFICIENT_SRC) | |
| 4440 break; | |
| 4441 } | |
| 4442 | |
| 4443 switch (ccl.status) | |
| 4444 { | |
| 4445 case CCL_STAT_SUSPEND_BY_SRC: | |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
4446 record_conversion_result (coding, CODING_RESULT_INSUFFICIENT_SRC); |
| 88365 | 4447 break; |
| 4448 case CCL_STAT_SUSPEND_BY_DST: | |
| 4449 break; | |
| 4450 case CCL_STAT_QUIT: | |
| 4451 case CCL_STAT_INVALID_CMD: | |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
4452 record_conversion_result (coding, CODING_RESULT_INTERRUPT); |
| 88365 | 4453 break; |
| 4454 default: | |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
4455 record_conversion_result (coding, CODING_RESULT_SUCCESS); |
| 88365 | 4456 break; |
| 4457 } | |
| 4458 coding->consumed_char += consumed_chars; | |
| 4459 coding->consumed = src - coding->source; | |
| 4460 coding->charbuf_used = charbuf - coding->charbuf; | |
|
22874
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
4461 } |
|
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
4462 |
| 88365 | 4463 static int |
| 4464 encode_coding_ccl (coding) | |
| 4465 struct coding_system *coding; | |
| 4466 { | |
| 4467 struct ccl_program ccl; | |
| 4468 int multibytep = coding->dst_multibyte; | |
| 4469 int *charbuf = coding->charbuf; | |
| 4470 int *charbuf_end = charbuf + coding->charbuf_used; | |
| 4471 unsigned char *dst = coding->destination + coding->produced; | |
| 4472 unsigned char *dst_end = coding->destination + coding->dst_bytes; | |
| 4473 unsigned char *adjusted_dst_end = dst_end - 1; | |
| 4474 int destination_charbuf[1024]; | |
| 4475 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
|
4476 Lisp_Object attrs, charset_list; |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4477 |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4478 CODING_GET_INFO (coding, attrs, charset_list); |
| 88365 | 4479 setup_ccl_program (&ccl, CODING_CCL_ENCODER (coding)); |
| 4480 | |
| 4481 ccl.last_block = coding->mode & CODING_MODE_LAST_BLOCK; | |
| 4482 ccl.dst_multibyte = coding->dst_multibyte; | |
| 4483 | |
| 4484 while (charbuf < charbuf_end && dst < adjusted_dst_end) | |
| 4485 { | |
| 4486 int dst_bytes = dst_end - dst; | |
| 4487 if (dst_bytes > 1024) | |
| 4488 dst_bytes = 1024; | |
| 4489 | |
| 4490 ccl_driver (&ccl, charbuf, destination_charbuf, | |
|
89373
4cc9e57fcabc
(decode_coding_ccl, encode_coding_ccl): Call ccl_driver
Kenichi Handa <handa@m17n.org>
parents:
89331
diff
changeset
|
4491 charbuf_end - charbuf, dst_bytes, charset_list); |
| 88365 | 4492 charbuf += ccl.consumed; |
| 4493 if (multibytep) | |
| 4494 for (i = 0; i < ccl.produced; i++) | |
| 4495 EMIT_ONE_BYTE (destination_charbuf[i] & 0xFF); | |
| 4496 else | |
| 4497 { | |
| 4498 for (i = 0; i < ccl.produced; i++) | |
| 4499 *dst++ = destination_charbuf[i] & 0xFF; | |
| 4500 produced_chars += ccl.produced; | |
| 4501 } | |
| 4502 } | |
| 4503 | |
| 4504 switch (ccl.status) | |
| 4505 { | |
| 4506 case CCL_STAT_SUSPEND_BY_SRC: | |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
4507 record_conversion_result (coding, CODING_RESULT_INSUFFICIENT_SRC); |
| 88365 | 4508 break; |
| 4509 case CCL_STAT_SUSPEND_BY_DST: | |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
4510 record_conversion_result (coding, CODING_RESULT_INSUFFICIENT_DST); |
| 88365 | 4511 break; |
| 4512 case CCL_STAT_QUIT: | |
| 4513 case CCL_STAT_INVALID_CMD: | |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
4514 record_conversion_result (coding, CODING_RESULT_INTERRUPT); |
| 88365 | 4515 break; |
| 4516 default: | |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
4517 record_conversion_result (coding, CODING_RESULT_SUCCESS); |
| 88365 | 4518 break; |
| 4519 } | |
| 4520 | |
| 4521 coding->produced_char += produced_chars; | |
| 4522 coding->produced = dst - coding->destination; | |
| 4523 return 0; | |
| 4524 } | |
| 4525 | |
| 4526 | |
|
22874
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
4527 |
| 88365 | 4528 /*** 10, 11. no-conversion handlers ***/ |
| 17052 | 4529 |
|
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4530 /* 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
|
4531 |
|
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4532 static void |
| 88365 | 4533 decode_coding_raw_text (coding) |
| 17052 | 4534 struct coding_system *coding; |
| 4535 { | |
| 88365 | 4536 coding->chars_at_source = 1; |
|
88456
a7b309f72920
(coding_alloc_by_making_gap): Check the case that the
Kenichi Handa <handa@m17n.org>
parents:
88443
diff
changeset
|
4537 coding->consumed_char = 0; |
|
a7b309f72920
(coding_alloc_by_making_gap): Check the case that the
Kenichi Handa <handa@m17n.org>
parents:
88443
diff
changeset
|
4538 coding->consumed = 0; |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
4539 record_conversion_result (coding, CODING_RESULT_SUCCESS); |
| 88365 | 4540 } |
| 4541 | |
| 4542 static int | |
| 4543 encode_coding_raw_text (coding) | |
| 4544 struct coding_system *coding; | |
| 4545 { | |
| 4546 int multibytep = coding->dst_multibyte; | |
| 4547 int *charbuf = coding->charbuf; | |
| 4548 int *charbuf_end = coding->charbuf + coding->charbuf_used; | |
| 4549 unsigned char *dst = coding->destination + coding->produced; | |
| 4550 unsigned char *dst_end = coding->destination + coding->dst_bytes; | |
| 4551 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
|
4552 int c; |
|
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4553 |
| 88365 | 4554 if (multibytep) |
| 4555 { | |
| 4556 int safe_room = MAX_MULTIBYTE_LENGTH * 2; | |
| 4557 | |
| 4558 if (coding->src_multibyte) | |
| 4559 while (charbuf < charbuf_end) | |
| 4560 { | |
| 4561 ASSURE_DESTINATION (safe_room); | |
| 4562 c = *charbuf++; | |
| 4563 if (ASCII_CHAR_P (c)) | |
| 4564 EMIT_ONE_ASCII_BYTE (c); | |
| 4565 else if (CHAR_BYTE8_P (c)) | |
| 4566 { | |
| 4567 c = CHAR_TO_BYTE8 (c); | |
| 4568 EMIT_ONE_BYTE (c); | |
| 4569 } | |
| 4570 else | |
| 4571 { | |
| 4572 unsigned char str[MAX_MULTIBYTE_LENGTH], *p0 = str, *p1 = str; | |
| 4573 | |
| 4574 CHAR_STRING_ADVANCE (c, p1); | |
| 4575 while (p0 < p1) | |
|
88950
ad258ee59fbb
* coding.c (make_conversion_work_buffer): Adjusted for the change
Kenichi Handa <handa@m17n.org>
parents:
88936
diff
changeset
|
4576 { |
|
ad258ee59fbb
* coding.c (make_conversion_work_buffer): Adjusted for the change
Kenichi Handa <handa@m17n.org>
parents:
88936
diff
changeset
|
4577 EMIT_ONE_BYTE (*p0); |
|
ad258ee59fbb
* coding.c (make_conversion_work_buffer): Adjusted for the change
Kenichi Handa <handa@m17n.org>
parents:
88936
diff
changeset
|
4578 p0++; |
|
ad258ee59fbb
* coding.c (make_conversion_work_buffer): Adjusted for the change
Kenichi Handa <handa@m17n.org>
parents:
88936
diff
changeset
|
4579 } |
| 88365 | 4580 } |
| 4581 } | |
| 4582 else | |
| 4583 while (charbuf < charbuf_end) | |
| 4584 { | |
| 4585 ASSURE_DESTINATION (safe_room); | |
| 4586 c = *charbuf++; | |
|
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4587 EMIT_ONE_BYTE (c); |
| 88365 | 4588 } |
|
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4589 } |
|
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4590 else |
|
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4591 { |
| 88365 | 4592 if (coding->src_multibyte) |
|
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4593 { |
| 88365 | 4594 int safe_room = MAX_MULTIBYTE_LENGTH; |
| 4595 | |
| 4596 while (charbuf < charbuf_end) | |
| 4597 { | |
| 4598 ASSURE_DESTINATION (safe_room); | |
| 4599 c = *charbuf++; | |
| 4600 if (ASCII_CHAR_P (c)) | |
| 4601 *dst++ = c; | |
| 4602 else if (CHAR_BYTE8_P (c)) | |
| 4603 *dst++ = CHAR_TO_BYTE8 (c); | |
| 4604 else | |
| 4605 CHAR_STRING_ADVANCE (c, dst); | |
| 4606 produced_chars++; | |
| 4607 } | |
|
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4608 } |
|
20931
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
4609 else |
|
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4610 { |
| 88365 | 4611 ASSURE_DESTINATION (charbuf_end - charbuf); |
| 4612 while (charbuf < charbuf_end && dst < dst_end) | |
| 4613 *dst++ = *charbuf++; | |
| 4614 produced_chars = dst - (coding->destination + coding->dst_bytes); | |
| 89483 | 4615 } |
| 88365 | 4616 } |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
4617 record_conversion_result (coding, CODING_RESULT_SUCCESS); |
| 88365 | 4618 coding->produced_char += produced_chars; |
| 4619 coding->produced = dst - coding->destination; | |
| 4620 return 0; | |
| 4621 } | |
| 4622 | |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
4623 /* 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
|
4624 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
|
4625 is, return 1, else return 0. */ |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
4626 |
| 88365 | 4627 static int |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
4628 detect_coding_charset (coding, detect_info) |
| 88365 | 4629 struct coding_system *coding; |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
4630 struct coding_detection_info *detect_info; |
| 88365 | 4631 { |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
4632 const unsigned char *src = coding->source, *src_base; |
| 89483 | 4633 const unsigned char *src_end = coding->source + coding->src_bytes; |
| 88365 | 4634 int multibytep = coding->src_multibyte; |
| 4635 int consumed_chars = 0; | |
| 4636 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
|
4637 int found = 0; |
| 88365 | 4638 |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
4639 detect_info->checked |= CATEGORY_MASK_CHARSET; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
4640 |
| 88365 | 4641 coding = &coding_categories[coding_category_charset]; |
| 4642 attrs = CODING_ID_ATTRS (coding->id); | |
| 4643 valids = AREF (attrs, coding_attr_charset_valids); | |
| 4644 | |
| 4645 if (! NILP (CODING_ATTR_ASCII_COMPAT (attrs))) | |
| 4646 src += coding->head_ascii; | |
| 4647 | |
| 4648 while (1) | |
| 4649 { | |
| 4650 int c; | |
| 4651 | |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
4652 src_base = src; |
| 88365 | 4653 ONE_MORE_BYTE (c); |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
4654 if (c < 0) |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
4655 continue; |
| 88365 | 4656 if (NILP (AREF (valids, c))) |
| 4657 break; | |
|
89225
32058afc72e2
(detect_coding_charset): If only ASCII bytes are found, return 0.
Kenichi Handa <handa@m17n.org>
parents:
89221
diff
changeset
|
4658 if (c >= 0x80) |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
4659 found = CATEGORY_MASK_CHARSET; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
4660 } |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
4661 detect_info->rejected |= CATEGORY_MASK_CHARSET; |
| 88365 | 4662 return 0; |
| 4663 | |
| 4664 no_more_source: | |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
4665 detect_info->found |= found; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
4666 return 1; |
| 88365 | 4667 } |
| 4668 | |
| 4669 static void | |
| 4670 decode_coding_charset (coding) | |
| 4671 struct coding_system *coding; | |
| 4672 { | |
| 89483 | 4673 const unsigned char *src = coding->source + coding->consumed; |
| 4674 const unsigned char *src_end = coding->source + coding->src_bytes; | |
| 4675 const unsigned char *src_base; | |
|
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
4676 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
|
4677 int *charbuf_end |
|
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
4678 = coding->charbuf + coding->charbuf_size - MAX_ANNOTATION_LENGTH; |
| 88365 | 4679 int consumed_chars = 0, consumed_chars_base; |
| 4680 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
|
4681 Lisp_Object attrs, charset_list, valids; |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
4682 int char_offset = coding->produced_char; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
4683 int last_offset = char_offset; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
4684 int last_id = charset_ascii; |
| 88365 | 4685 |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4686 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
|
4687 valids = AREF (attrs, coding_attr_charset_valids); |
| 88365 | 4688 |
| 4689 while (1) | |
| 4690 { | |
|
88465
ae455bb40718
(decode_coding_charset, encode_coding_charset): Handle
Kenichi Handa <handa@m17n.org>
parents:
88456
diff
changeset
|
4691 int c; |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4692 Lisp_Object val; |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4693 struct charset *charset; |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4694 int dim; |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4695 int len = 1; |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4696 unsigned code; |
| 88365 | 4697 |
| 4698 src_base = src; | |
| 4699 consumed_chars_base = consumed_chars; | |
| 4700 | |
| 4701 if (charbuf >= charbuf_end) | |
| 4702 break; | |
| 4703 | |
|
88465
ae455bb40718
(decode_coding_charset, encode_coding_charset): Handle
Kenichi Handa <handa@m17n.org>
parents:
88456
diff
changeset
|
4704 ONE_MORE_BYTE (c); |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
4705 if (c < 0) |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
4706 goto invalid_code; |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4707 code = c; |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4708 |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4709 val = AREF (valids, c); |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4710 if (NILP (val)) |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4711 goto invalid_code; |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4712 if (INTEGERP (val)) |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4713 { |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4714 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
|
4715 dim = CHARSET_DIMENSION (charset); |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4716 while (len < dim) |
| 88365 | 4717 { |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4718 ONE_MORE_BYTE (c); |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4719 code = (code << 8) | c; |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4720 len++; |
| 88365 | 4721 } |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4722 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
|
4723 charset, code, c); |
|
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4724 } |
| 88365 | 4725 else |
|
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4726 { |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4727 /* 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
|
4728 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
|
4729 comes first). */ |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4730 while (CONSP (val)) |
|
88465
ae455bb40718
(decode_coding_charset, encode_coding_charset): Handle
Kenichi Handa <handa@m17n.org>
parents:
88456
diff
changeset
|
4731 { |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4732 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
|
4733 dim = CHARSET_DIMENSION (charset); |
|
88607
18436bf3d6dd
(Fdefine_coding_system_internal): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
88598
diff
changeset
|
4734 while (len < dim) |
|
88465
ae455bb40718
(decode_coding_charset, encode_coding_charset): Handle
Kenichi Handa <handa@m17n.org>
parents:
88456
diff
changeset
|
4735 { |
|
88598
b88195f69856
(decode_coding_charset): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
88597
diff
changeset
|
4736 ONE_MORE_BYTE (c); |
|
b88195f69856
(decode_coding_charset): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
88597
diff
changeset
|
4737 code = (code << 8) | c; |
|
88607
18436bf3d6dd
(Fdefine_coding_system_internal): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
88598
diff
changeset
|
4738 len++; |
|
88465
ae455bb40718
(decode_coding_charset, encode_coding_charset): Handle
Kenichi Handa <handa@m17n.org>
parents:
88456
diff
changeset
|
4739 } |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4740 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
|
4741 src_end, charset, code, c); |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4742 if (c >= 0) |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4743 break; |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4744 val = XCDR (val); |
|
88465
ae455bb40718
(decode_coding_charset, encode_coding_charset): Handle
Kenichi Handa <handa@m17n.org>
parents:
88456
diff
changeset
|
4745 } |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4746 } |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4747 if (c < 0) |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4748 goto invalid_code; |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4749 if (charset->id != charset_ascii |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4750 && last_id != charset->id) |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4751 { |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4752 if (last_id != charset_ascii) |
|
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
4753 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
|
4754 last_id = charset->id; |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4755 last_offset = char_offset; |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4756 } |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4757 |
| 88365 | 4758 *charbuf++ = c; |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
4759 char_offset++; |
| 88365 | 4760 continue; |
| 4761 | |
| 4762 invalid_code: | |
| 4763 src = src_base; | |
| 4764 consumed_chars = consumed_chars_base; | |
| 4765 ONE_MORE_BYTE (c); | |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
4766 *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
|
4767 char_offset++; |
| 88365 | 4768 coding->errors++; |
| 4769 } | |
| 4770 | |
| 4771 no_more_source: | |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
4772 if (last_id != charset_ascii) |
|
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
4773 ADD_CHARSET_DATA (charbuf, char_offset - last_offset, last_id); |
| 88365 | 4774 coding->consumed_char += consumed_chars_base; |
| 4775 coding->consumed = src_base - coding->source; | |
| 4776 coding->charbuf_used = charbuf - coding->charbuf; | |
| 4777 } | |
| 4778 | |
| 4779 static int | |
| 4780 encode_coding_charset (coding) | |
| 4781 struct coding_system *coding; | |
| 4782 { | |
| 4783 int multibytep = coding->dst_multibyte; | |
| 4784 int *charbuf = coding->charbuf; | |
| 4785 int *charbuf_end = charbuf + coding->charbuf_used; | |
| 4786 unsigned char *dst = coding->destination + coding->produced; | |
| 4787 unsigned char *dst_end = coding->destination + coding->dst_bytes; | |
| 4788 int safe_room = MAX_MULTIBYTE_LENGTH; | |
| 4789 int produced_chars = 0; | |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4790 Lisp_Object attrs, charset_list; |
| 88365 | 4791 int ascii_compatible; |
| 4792 int c; | |
| 4793 | |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4794 CODING_GET_INFO (coding, attrs, charset_list); |
| 88365 | 4795 ascii_compatible = ! NILP (CODING_ATTR_ASCII_COMPAT (attrs)); |
| 4796 | |
| 4797 while (charbuf < charbuf_end) | |
| 4798 { | |
|
88465
ae455bb40718
(decode_coding_charset, encode_coding_charset): Handle
Kenichi Handa <handa@m17n.org>
parents:
88456
diff
changeset
|
4799 struct charset *charset; |
| 88365 | 4800 unsigned code; |
| 89483 | 4801 |
| 88365 | 4802 ASSURE_DESTINATION (safe_room); |
| 4803 c = *charbuf++; | |
| 4804 if (ascii_compatible && ASCII_CHAR_P (c)) | |
| 4805 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
|
4806 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
|
4807 { |
|
7f284ac55b07
(encode_coding_emacs_mule): Pay attention to raw-8-bit chars.
Kenichi Handa <handa@m17n.org>
parents:
88681
diff
changeset
|
4808 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
|
4809 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
|
4810 } |
| 88365 | 4811 else |
|
88465
ae455bb40718
(decode_coding_charset, encode_coding_charset): Handle
Kenichi Handa <handa@m17n.org>
parents:
88456
diff
changeset
|
4812 { |
|
ae455bb40718
(decode_coding_charset, encode_coding_charset): Handle
Kenichi Handa <handa@m17n.org>
parents:
88456
diff
changeset
|
4813 charset = char_charset (c, charset_list, &code); |
|
ae455bb40718
(decode_coding_charset, encode_coding_charset): Handle
Kenichi Handa <handa@m17n.org>
parents:
88456
diff
changeset
|
4814 if (charset) |
|
ae455bb40718
(decode_coding_charset, encode_coding_charset): Handle
Kenichi Handa <handa@m17n.org>
parents:
88456
diff
changeset
|
4815 { |
|
ae455bb40718
(decode_coding_charset, encode_coding_charset): Handle
Kenichi Handa <handa@m17n.org>
parents:
88456
diff
changeset
|
4816 if (CHARSET_DIMENSION (charset) == 1) |
|
ae455bb40718
(decode_coding_charset, encode_coding_charset): Handle
Kenichi Handa <handa@m17n.org>
parents:
88456
diff
changeset
|
4817 EMIT_ONE_BYTE (code); |
|
ae455bb40718
(decode_coding_charset, encode_coding_charset): Handle
Kenichi Handa <handa@m17n.org>
parents:
88456
diff
changeset
|
4818 else if (CHARSET_DIMENSION (charset) == 2) |
|
ae455bb40718
(decode_coding_charset, encode_coding_charset): Handle
Kenichi Handa <handa@m17n.org>
parents:
88456
diff
changeset
|
4819 EMIT_TWO_BYTES (code >> 8, code & 0xFF); |
|
ae455bb40718
(decode_coding_charset, encode_coding_charset): Handle
Kenichi Handa <handa@m17n.org>
parents:
88456
diff
changeset
|
4820 else if (CHARSET_DIMENSION (charset) == 3) |
|
ae455bb40718
(decode_coding_charset, encode_coding_charset): Handle
Kenichi Handa <handa@m17n.org>
parents:
88456
diff
changeset
|
4821 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
|
4822 else |
|
ae455bb40718
(decode_coding_charset, encode_coding_charset): Handle
Kenichi Handa <handa@m17n.org>
parents:
88456
diff
changeset
|
4823 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
|
4824 (code >> 8) & 0xFF, code & 0xFF); |
|
ae455bb40718
(decode_coding_charset, encode_coding_charset): Handle
Kenichi Handa <handa@m17n.org>
parents:
88456
diff
changeset
|
4825 } |
|
ae455bb40718
(decode_coding_charset, encode_coding_charset): Handle
Kenichi Handa <handa@m17n.org>
parents:
88456
diff
changeset
|
4826 else |
|
88573
133bf7ab1bad
(encode_coding_iso_2022): If coding requires safe
Kenichi Handa <handa@m17n.org>
parents:
88544
diff
changeset
|
4827 { |
|
133bf7ab1bad
(encode_coding_iso_2022): If coding requires safe
Kenichi Handa <handa@m17n.org>
parents:
88544
diff
changeset
|
4828 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
|
4829 c = CODING_INHIBIT_CHARACTER_SUBSTITUTION; |
|
133bf7ab1bad
(encode_coding_iso_2022): If coding requires safe
Kenichi Handa <handa@m17n.org>
parents:
88544
diff
changeset
|
4830 else |
|
133bf7ab1bad
(encode_coding_iso_2022): If coding requires safe
Kenichi Handa <handa@m17n.org>
parents:
88544
diff
changeset
|
4831 c = coding->default_char; |
|
133bf7ab1bad
(encode_coding_iso_2022): If coding requires safe
Kenichi Handa <handa@m17n.org>
parents:
88544
diff
changeset
|
4832 EMIT_ONE_BYTE (c); |
|
133bf7ab1bad
(encode_coding_iso_2022): If coding requires safe
Kenichi Handa <handa@m17n.org>
parents:
88544
diff
changeset
|
4833 } |
|
88465
ae455bb40718
(decode_coding_charset, encode_coding_charset): Handle
Kenichi Handa <handa@m17n.org>
parents:
88456
diff
changeset
|
4834 } |
| 88365 | 4835 } |
| 4836 | |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
4837 record_conversion_result (coding, CODING_RESULT_SUCCESS); |
| 88365 | 4838 coding->produced_char += produced_chars; |
| 4839 coding->produced = dst - coding->destination; | |
| 4840 return 0; | |
| 17052 | 4841 } |
| 4842 | |
| 4843 | |
|
22874
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
4844 /*** 7. C library functions ***/ |
| 17052 | 4845 |
| 88365 | 4846 /* Setup coding context CODING from information about CODING_SYSTEM. |
| 4847 If CODING_SYSTEM is nil, `no-conversion' is assumed. If | |
| 4848 CODING_SYSTEM is invalid, signal an error. */ | |
| 4849 | |
| 4850 void | |
|
17119
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
4851 setup_coding_system (coding_system, coding) |
|
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
4852 Lisp_Object coding_system; |
| 17052 | 4853 struct coding_system *coding; |
| 4854 { | |
| 88365 | 4855 Lisp_Object attrs; |
| 4856 Lisp_Object eol_type; | |
| 4857 Lisp_Object coding_type; | |
|
20105
c017642863c2
(Qcoding_system_spec): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
19824
diff
changeset
|
4858 Lisp_Object val; |
| 17052 | 4859 |
|
24460
be35d27a4bfb
(setup_coding_system): Check for CODING_SYSTEM = nil.
Kenichi Handa <handa@m17n.org>
parents:
24425
diff
changeset
|
4860 if (NILP (coding_system)) |
| 88365 | 4861 coding_system = Qno_conversion; |
| 4862 | |
| 4863 CHECK_CODING_SYSTEM_GET_ID (coding_system, coding->id); | |
| 4864 | |
| 4865 attrs = CODING_ID_ATTRS (coding->id); | |
| 4866 eol_type = CODING_ID_EOL_TYPE (coding->id); | |
| 4867 | |
| 4868 coding->mode = 0; | |
| 4869 coding->head_ascii = -1; | |
| 4870 coding->common_flags | |
| 4871 = (VECTORP (eol_type) ? CODING_REQUIRE_DETECTION_MASK : 0); | |
|
89448
de8b460070cc
(setup_coding_system): If coding has
Kenichi Handa <handa@m17n.org>
parents:
89446
diff
changeset
|
4872 if (! NILP (CODING_ATTR_POST_READ (attrs))) |
|
de8b460070cc
(setup_coding_system): If coding has
Kenichi Handa <handa@m17n.org>
parents:
89446
diff
changeset
|
4873 coding->common_flags |= CODING_REQUIRE_DECODING_MASK; |
|
de8b460070cc
(setup_coding_system): If coding has
Kenichi Handa <handa@m17n.org>
parents:
89446
diff
changeset
|
4874 if (! NILP (CODING_ATTR_PRE_WRITE (attrs))) |
|
de8b460070cc
(setup_coding_system): If coding has
Kenichi Handa <handa@m17n.org>
parents:
89446
diff
changeset
|
4875 coding->common_flags |= CODING_REQUIRE_ENCODING_MASK; |
| 89483 | 4876 if (! NILP (CODING_ATTR_FOR_UNIBYTE (attrs))) |
| 4877 coding->common_flags |= CODING_FOR_UNIBYTE_MASK; | |
| 88365 | 4878 |
| 4879 val = CODING_ATTR_SAFE_CHARSETS (attrs); | |
| 89483 | 4880 coding->max_charset_id = SCHARS (val) - 1; |
| 4881 coding->safe_charsets = (char *) SDATA (val); | |
| 88365 | 4882 coding->default_char = XINT (CODING_ATTR_DEFAULT_CHAR (attrs)); |
| 4883 | |
| 4884 coding_type = CODING_ATTR_TYPE (attrs); | |
| 4885 if (EQ (coding_type, Qundecided)) | |
| 4886 { | |
| 4887 coding->detector = NULL; | |
| 4888 coding->decoder = decode_coding_raw_text; | |
| 4889 coding->encoder = encode_coding_raw_text; | |
| 4890 coding->common_flags |= CODING_REQUIRE_DETECTION_MASK; | |
| 4891 } | |
| 4892 else if (EQ (coding_type, Qiso_2022)) | |
| 4893 { | |
| 4894 int i; | |
| 4895 int flags = XINT (AREF (attrs, coding_attr_iso_flags)); | |
| 4896 | |
| 4897 /* Invoke graphic register 0 to plane 0. */ | |
| 4898 CODING_ISO_INVOCATION (coding, 0) = 0; | |
| 4899 /* Invoke graphic register 1 to plane 1 if we can use 8-bit. */ | |
| 4900 CODING_ISO_INVOCATION (coding, 1) | |
| 4901 = (flags & CODING_ISO_FLAG_SEVEN_BITS ? -1 : 1); | |
| 4902 /* Setup the initial status of designation. */ | |
| 4903 for (i = 0; i < 4; i++) | |
| 4904 CODING_ISO_DESIGNATION (coding, i) = CODING_ISO_INITIAL (coding, i); | |
| 4905 /* Not single shifting initially. */ | |
| 4906 CODING_ISO_SINGLE_SHIFTING (coding) = 0; | |
| 4907 /* Beginning of buffer should also be regarded as bol. */ | |
| 4908 CODING_ISO_BOL (coding) = 1; | |
| 4909 coding->detector = detect_coding_iso_2022; | |
| 4910 coding->decoder = decode_coding_iso_2022; | |
| 4911 coding->encoder = encode_coding_iso_2022; | |
| 4912 if (flags & CODING_ISO_FLAG_SAFE) | |
| 4913 coding->mode |= CODING_MODE_SAFE_ENCODING; | |
|
20227
71008f909642
(setup_coding_system): Initialize common_flags member
Kenichi Handa <handa@m17n.org>
parents:
20150
diff
changeset
|
4914 coding->common_flags |
| 88365 | 4915 |= (CODING_REQUIRE_DECODING_MASK | CODING_REQUIRE_ENCODING_MASK |
| 4916 | CODING_REQUIRE_FLUSHING_MASK); | |
| 4917 if (flags & CODING_ISO_FLAG_COMPOSITION) | |
| 4918 coding->common_flags |= CODING_ANNOTATE_COMPOSITION_MASK; | |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
4919 if (flags & CODING_ISO_FLAG_DESIGNATION) |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
4920 coding->common_flags |= CODING_ANNOTATE_CHARSET_MASK; |
| 88365 | 4921 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
|
4922 { |
| 88365 | 4923 setup_iso_safe_charsets (attrs); |
| 4924 val = CODING_ATTR_SAFE_CHARSETS (attrs); | |
| 89483 | 4925 coding->max_charset_id = SCHARS (val) - 1; |
| 4926 coding->safe_charsets = (char *) SDATA (val); | |
|
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4927 } |
| 88365 | 4928 CODING_ISO_FLAGS (coding) = flags; |
| 4929 } | |
| 4930 else if (EQ (coding_type, Qcharset)) | |
| 4931 { | |
| 4932 coding->detector = detect_coding_charset; | |
| 4933 coding->decoder = decode_coding_charset; | |
| 4934 coding->encoder = encode_coding_charset; | |
| 4935 coding->common_flags | |
| 4936 |= (CODING_REQUIRE_DECODING_MASK | CODING_REQUIRE_ENCODING_MASK); | |
| 4937 } | |
| 4938 else if (EQ (coding_type, Qutf_8)) | |
| 4939 { | |
| 4940 coding->detector = detect_coding_utf_8; | |
| 4941 coding->decoder = decode_coding_utf_8; | |
| 4942 coding->encoder = encode_coding_utf_8; | |
|
34888
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
4943 coding->common_flags |
| 88365 | 4944 |= (CODING_REQUIRE_DECODING_MASK | CODING_REQUIRE_ENCODING_MASK); |
| 4945 } | |
| 4946 else if (EQ (coding_type, Qutf_16)) | |
| 4947 { | |
| 4948 val = AREF (attrs, coding_attr_utf_16_bom); | |
| 4949 CODING_UTF_16_BOM (coding) = (CONSP (val) ? utf_16_detect_bom | |
| 4950 : EQ (val, Qt) ? utf_16_with_bom | |
| 4951 : utf_16_without_bom); | |
| 4952 val = AREF (attrs, coding_attr_utf_16_endian); | |
|
89420
c3e67ce6ee0f
(Qsignature, Qendian): Delete these variables.
Kenichi Handa <handa@m17n.org>
parents:
89418
diff
changeset
|
4953 CODING_UTF_16_ENDIAN (coding) = (EQ (val, Qbig) ? utf_16_big_endian |
| 88365 | 4954 : utf_16_little_endian); |
|
88438
3a34b722dd71
(encode_coding_utf_8): Initialize produced_chars to 0.
Kenichi Handa <handa@m17n.org>
parents:
88430
diff
changeset
|
4955 CODING_UTF_16_SURROGATE (coding) = 0; |
| 88365 | 4956 coding->detector = detect_coding_utf_16; |
| 4957 coding->decoder = decode_coding_utf_16; | |
| 4958 coding->encoder = encode_coding_utf_16; | |
|
20227
71008f909642
(setup_coding_system): Initialize common_flags member
Kenichi Handa <handa@m17n.org>
parents:
20150
diff
changeset
|
4959 coding->common_flags |
| 88365 | 4960 |= (CODING_REQUIRE_DECODING_MASK | CODING_REQUIRE_ENCODING_MASK); |
|
89420
c3e67ce6ee0f
(Qsignature, Qendian): Delete these variables.
Kenichi Handa <handa@m17n.org>
parents:
89418
diff
changeset
|
4961 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
|
4962 coding->common_flags |= CODING_REQUIRE_DETECTION_MASK; |
| 88365 | 4963 } |
| 4964 else if (EQ (coding_type, Qccl)) | |
| 4965 { | |
| 4966 coding->detector = detect_coding_ccl; | |
| 4967 coding->decoder = decode_coding_ccl; | |
| 4968 coding->encoder = encode_coding_ccl; | |
|
20227
71008f909642
(setup_coding_system): Initialize common_flags member
Kenichi Handa <handa@m17n.org>
parents:
20150
diff
changeset
|
4969 coding->common_flags |
| 88365 | 4970 |= (CODING_REQUIRE_DECODING_MASK | CODING_REQUIRE_ENCODING_MASK |
| 4971 | CODING_REQUIRE_FLUSHING_MASK); | |
| 4972 } | |
| 4973 else if (EQ (coding_type, Qemacs_mule)) | |
| 4974 { | |
| 4975 coding->detector = detect_coding_emacs_mule; | |
| 4976 coding->decoder = decode_coding_emacs_mule; | |
| 4977 coding->encoder = encode_coding_emacs_mule; | |
| 4978 coding->common_flags | |
| 4979 |= (CODING_REQUIRE_DECODING_MASK | CODING_REQUIRE_ENCODING_MASK); | |
| 4980 if (! NILP (AREF (attrs, coding_attr_emacs_mule_full)) | |
| 4981 && ! EQ (CODING_ATTR_CHARSET_LIST (attrs), Vemacs_mule_charset_list)) | |
| 4982 { | |
| 4983 Lisp_Object tail, safe_charsets; | |
| 4984 int max_charset_id = 0; | |
| 4985 | |
| 4986 for (tail = Vemacs_mule_charset_list; CONSP (tail); | |
| 4987 tail = XCDR (tail)) | |
| 4988 if (max_charset_id < XFASTINT (XCAR (tail))) | |
| 4989 max_charset_id = XFASTINT (XCAR (tail)); | |
| 4990 safe_charsets = Fmake_string (make_number (max_charset_id + 1), | |
| 4991 make_number (255)); | |
| 4992 for (tail = Vemacs_mule_charset_list; CONSP (tail); | |
| 4993 tail = XCDR (tail)) | |
| 89483 | 4994 SSET (safe_charsets, XFASTINT (XCAR (tail)), 0); |
| 88365 | 4995 coding->max_charset_id = max_charset_id; |
| 89483 | 4996 coding->safe_charsets = (char *) SDATA (safe_charsets); |
| 88365 | 4997 } |
| 4998 } | |
| 4999 else if (EQ (coding_type, Qshift_jis)) | |
| 5000 { | |
| 5001 coding->detector = detect_coding_sjis; | |
| 5002 coding->decoder = decode_coding_sjis; | |
| 5003 coding->encoder = encode_coding_sjis; | |
| 5004 coding->common_flags | |
| 5005 |= (CODING_REQUIRE_DECODING_MASK | CODING_REQUIRE_ENCODING_MASK); | |
| 5006 } | |
| 5007 else if (EQ (coding_type, Qbig5)) | |
| 5008 { | |
| 5009 coding->detector = detect_coding_big5; | |
| 5010 coding->decoder = decode_coding_big5; | |
| 5011 coding->encoder = encode_coding_big5; | |
|
20227
71008f909642
(setup_coding_system): Initialize common_flags member
Kenichi Handa <handa@m17n.org>
parents:
20150
diff
changeset
|
5012 coding->common_flags |
| 88365 | 5013 |= (CODING_REQUIRE_DECODING_MASK | CODING_REQUIRE_ENCODING_MASK); |
| 5014 } | |
| 5015 else /* EQ (coding_type, Qraw_text) */ | |
| 5016 { | |
| 5017 coding->detector = NULL; | |
| 5018 coding->decoder = decode_coding_raw_text; | |
| 5019 coding->encoder = encode_coding_raw_text; | |
| 5020 } | |
| 5021 | |
| 5022 return; | |
| 17052 | 5023 } |
| 5024 | |
| 88365 | 5025 /* Return raw-text or one of its subsidiaries that has the same |
| 5026 eol_type as CODING-SYSTEM. */ | |
| 5027 | |
| 5028 Lisp_Object | |
| 5029 raw_text_coding_system (coding_system) | |
| 5030 Lisp_Object coding_system; | |
| 26847 | 5031 { |
|
88430
6418a272b97e
* coding.c: Delete unused variables.
Kenichi Handa <handa@m17n.org>
parents:
88365
diff
changeset
|
5032 Lisp_Object spec, attrs; |
| 88365 | 5033 Lisp_Object eol_type, raw_text_eol_type; |
| 5034 | |
|
89462
4e359ebf3984
(decode_coding_iso_2022): Fix handling of invalid
Kenichi Handa <handa@m17n.org>
parents:
89448
diff
changeset
|
5035 if (NILP (coding_system)) |
|
4e359ebf3984
(decode_coding_iso_2022): Fix handling of invalid
Kenichi Handa <handa@m17n.org>
parents:
89448
diff
changeset
|
5036 return Qraw_text; |
| 88365 | 5037 spec = CODING_SYSTEM_SPEC (coding_system); |
| 5038 attrs = AREF (spec, 0); | |
| 89483 | 5039 |
| 88365 | 5040 if (EQ (CODING_ATTR_TYPE (attrs), Qraw_text)) |
| 5041 return coding_system; | |
| 5042 | |
| 5043 eol_type = AREF (spec, 2); | |
| 5044 if (VECTORP (eol_type)) | |
| 5045 return Qraw_text; | |
| 5046 spec = CODING_SYSTEM_SPEC (Qraw_text); | |
| 5047 raw_text_eol_type = AREF (spec, 2); | |
| 5048 return (EQ (eol_type, Qunix) ? AREF (raw_text_eol_type, 0) | |
| 5049 : EQ (eol_type, Qdos) ? AREF (raw_text_eol_type, 1) | |
| 5050 : AREF (raw_text_eol_type, 2)); | |
| 26847 | 5051 } |
| 5052 | |
| 88365 | 5053 |
| 5054 /* If CODING_SYSTEM doesn't specify end-of-line format but PARENT | |
| 5055 does, return one of the subsidiary that has the same eol-spec as | |
| 5056 PARENT. Otherwise, return CODING_SYSTEM. */ | |
| 5057 | |
| 5058 Lisp_Object | |
| 5059 coding_inherit_eol_type (coding_system, parent) | |
| 88473 | 5060 Lisp_Object coding_system, parent; |
|
22616
c493ce6a31e4
(setup_raw_text_coding_system): New function.
Kenichi Handa <handa@m17n.org>
parents:
22529
diff
changeset
|
5061 { |
|
89545
4f394eed6ff2
(inhibit_pre_post_conversion): Removed (unused).
Dave Love <fx@gnu.org>
parents:
89519
diff
changeset
|
5062 Lisp_Object spec, eol_type; |
| 88365 | 5063 |
|
89462
4e359ebf3984
(decode_coding_iso_2022): Fix handling of invalid
Kenichi Handa <handa@m17n.org>
parents:
89448
diff
changeset
|
5064 if (NILP (coding_system)) |
|
4e359ebf3984
(decode_coding_iso_2022): Fix handling of invalid
Kenichi Handa <handa@m17n.org>
parents:
89448
diff
changeset
|
5065 coding_system = Qraw_text; |
| 88365 | 5066 spec = CODING_SYSTEM_SPEC (coding_system); |
| 5067 eol_type = AREF (spec, 2); | |
|
89462
4e359ebf3984
(decode_coding_iso_2022): Fix handling of invalid
Kenichi Handa <handa@m17n.org>
parents:
89448
diff
changeset
|
5068 if (VECTORP (eol_type) |
|
4e359ebf3984
(decode_coding_iso_2022): Fix handling of invalid
Kenichi Handa <handa@m17n.org>
parents:
89448
diff
changeset
|
5069 && ! NILP (parent)) |
| 88365 | 5070 { |
| 5071 Lisp_Object parent_spec; | |
| 5072 Lisp_Object parent_eol_type; | |
| 5073 | |
| 5074 parent_spec | |
| 5075 = CODING_SYSTEM_SPEC (buffer_defaults.buffer_file_coding_system); | |
| 5076 parent_eol_type = AREF (parent_spec, 2); | |
| 5077 if (EQ (parent_eol_type, Qunix)) | |
| 5078 coding_system = AREF (eol_type, 0); | |
| 5079 else if (EQ (parent_eol_type, Qdos)) | |
| 5080 coding_system = AREF (eol_type, 1); | |
| 5081 else if (EQ (parent_eol_type, Qmac)) | |
| 5082 coding_system = AREF (eol_type, 2); | |
| 5083 } | |
| 5084 return coding_system; | |
|
22616
c493ce6a31e4
(setup_raw_text_coding_system): New function.
Kenichi Handa <handa@m17n.org>
parents:
22529
diff
changeset
|
5085 } |
|
c493ce6a31e4
(setup_raw_text_coding_system): New function.
Kenichi Handa <handa@m17n.org>
parents:
22529
diff
changeset
|
5086 |
| 17052 | 5087 /* Emacs has a mechanism to automatically detect a coding system if it |
| 5088 is one of Emacs' internal format, ISO2022, SJIS, and BIG5. But, | |
| 5089 it's impossible to distinguish some coding systems accurately | |
| 5090 because they use the same range of codes. So, at first, coding | |
| 5091 systems are categorized into 7, those are: | |
| 5092 | |
|
17835
f36ffb6f1208
Name change through the code:
Kenichi Handa <handa@m17n.org>
parents:
17725
diff
changeset
|
5093 o coding-category-emacs-mule |
| 17052 | 5094 |
| 5095 The category for a coding system which has the same code range | |
| 5096 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
|
5097 symbol) `emacs-mule' by default. |
| 17052 | 5098 |
| 5099 o coding-category-sjis | |
| 5100 | |
| 5101 The category for a coding system which has the same code range | |
| 5102 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
|
5103 symbol) `japanese-shift-jis' by default. |
| 17052 | 5104 |
| 5105 o coding-category-iso-7 | |
| 5106 | |
| 5107 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
|
5108 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
|
5109 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
|
5110 charsets. Assigned the coding-system (Lisp symbol) |
|
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5111 `iso-2022-7bit' by default. |
|
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5112 |
|
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5113 o coding-category-iso-7-tight |
|
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5114 |
|
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5115 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
|
5116 encode/decode only the specified charsets. |
| 17052 | 5117 |
| 5118 o coding-category-iso-8-1 | |
| 5119 | |
| 5120 The category for a coding system which has the same code range | |
| 5121 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
|
5122 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
|
5123 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
|
5124 symbol) `iso-latin-1' by default. |
| 17052 | 5125 |
| 5126 o coding-category-iso-8-2 | |
| 5127 | |
| 5128 The category for a coding system which has the same code range | |
| 5129 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
|
5130 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
|
5131 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
|
5132 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
|
5133 |
|
954e6be0a757
(detect_coding_iso2022): Distinguish coding-category-iso-7-else and
Kenichi Handa <handa@m17n.org>
parents:
18766
diff
changeset
|
5134 o coding-category-iso-7-else |
| 17052 | 5135 |
| 5136 The category for a coding system which has the same code range | |
| 88365 | 5137 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
|
5138 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
|
5139 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
|
5140 |
|
954e6be0a757
(detect_coding_iso2022): Distinguish coding-category-iso-7-else and
Kenichi Handa <handa@m17n.org>
parents:
18766
diff
changeset
|
5141 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
|
5142 |
|
954e6be0a757
(detect_coding_iso2022): Distinguish coding-category-iso-7-else and
Kenichi Handa <handa@m17n.org>
parents:
18766
diff
changeset
|
5143 The category for a coding system which has the same code range |
| 88365 | 5144 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
|
5145 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
|
5146 symbol) `iso-2022-8bit-ss2' by default. |
| 17052 | 5147 |
| 5148 o coding-category-big5 | |
| 5149 | |
| 5150 The category for a coding system which has the same code range | |
| 5151 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
|
5152 `cn-big5' by default. |
| 17052 | 5153 |
|
28022
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
5154 o coding-category-utf-8 |
|
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
5155 |
|
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
5156 The category for a coding system which has the same code range |
| 89851 | 5157 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
|
5158 symbol) `utf-8' by default. |
|
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
5159 |
|
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
5160 o coding-category-utf-16-be |
|
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
5161 |
|
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
5162 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
|
5163 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
|
5164 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
|
5165 `utf-16-be' by default. |
|
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
5166 |
|
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
5167 o coding-category-utf-16-le |
|
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
5168 |
|
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
5169 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
|
5170 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
|
5171 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
|
5172 symbol) `utf-16-le' by default. |
|
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
5173 |
|
22874
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
5174 o coding-category-ccl |
|
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
5175 |
|
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
5176 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
|
5177 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
|
5178 coding system is assigned. |
|
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
5179 |
| 17052 | 5180 o coding-category-binary |
| 5181 | |
| 5182 The category for a coding system not categorized in any of the | |
| 5183 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
|
5184 `no-conversion' by default. |
| 17052 | 5185 |
| 5186 Each of them is a Lisp symbol and the value is an actual | |
| 88365 | 5187 `coding-system's (this is also a Lisp symbol) assigned by a user. |
| 17052 | 5188 What Emacs does actually is to detect a category of coding system. |
| 5189 Then, it uses a `coding-system' assigned to it. If Emacs can't | |
| 88365 | 5190 decide only one possible category, it selects a category of the |
| 17052 | 5191 highest priority. Priorities of categories are also specified by a |
| 5192 user in a Lisp variable `coding-category-list'. | |
| 5193 | |
| 5194 */ | |
| 5195 | |
| 88365 | 5196 #define EOL_SEEN_NONE 0 |
| 5197 #define EOL_SEEN_LF 1 | |
| 5198 #define EOL_SEEN_CR 2 | |
| 5199 #define EOL_SEEN_CRLF 4 | |
| 5200 | |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
5201 /* Detect how end-of-line of a text of length SRC_BYTES pointed by |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
5202 SOURCE is encoded. If CATEGORY is one of |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
5203 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
|
5204 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
|
5205 |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
5206 Return one of EOL_SEEN_XXX. */ |
| 17052 | 5207 |
|
19173
04ed7c3f5cee
(detect_eol_type): If EOL representation does not
Richard M. Stallman <rms@gnu.org>
parents:
19134
diff
changeset
|
5208 #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
|
5209 |
|
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5210 static int |
|
89193
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
5211 detect_eol (source, src_bytes, category) |
|
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5212 unsigned char *source; |
| 88365 | 5213 EMACS_INT src_bytes; |
|
89193
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
5214 enum coding_category category; |
| 17052 | 5215 { |
|
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5216 unsigned char *src = source, *src_end = src + src_bytes; |
| 17052 | 5217 unsigned char c; |
| 88365 | 5218 int total = 0; |
| 5219 int eol_seen = EOL_SEEN_NONE; | |
| 5220 | |
|
89193
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
5221 if ((1 << category) & CATEGORY_MASK_UTF_16) |
| 88365 | 5222 { |
| 5223 int msb, lsb; | |
| 5224 | |
|
89193
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
5225 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
|
5226 | coding_category_utf_16_le_nosig); |
| 88365 | 5227 lsb = 1 - msb; |
| 5228 | |
| 5229 while (src + 1 < src_end) | |
| 17052 | 5230 { |
| 88365 | 5231 c = src[lsb]; |
| 5232 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
|
5233 { |
| 88365 | 5234 int this_eol; |
| 5235 | |
| 5236 if (c == '\n') | |
| 5237 this_eol = EOL_SEEN_LF; | |
| 5238 else if (src + 3 >= src_end | |
| 5239 || src[msb + 2] != 0 | |
| 5240 || src[lsb + 2] != '\n') | |
| 5241 this_eol = EOL_SEEN_CR; | |
| 5242 else | |
| 89483 | 5243 this_eol = EOL_SEEN_CRLF; |
| 88365 | 5244 |
| 5245 if (eol_seen == EOL_SEEN_NONE) | |
| 5246 /* This is the first end-of-line. */ | |
| 5247 eol_seen = this_eol; | |
| 5248 else if (eol_seen != this_eol) | |
| 5249 { | |
| 5250 /* The found type is different from what found before. */ | |
| 5251 eol_seen = EOL_SEEN_LF; | |
| 5252 break; | |
| 5253 } | |
| 5254 if (++total == MAX_EOL_CHECK_COUNT) | |
| 5255 break; | |
| 5256 } | |
| 5257 src += 2; | |
| 5258 } | |
|
30833
2db6e42a6ba3
(MINIMUM_CONVERSION_BUFFER_SIZE): Macro deleted.
Kenichi Handa <handa@m17n.org>
parents:
30756
diff
changeset
|
5259 } |
| 88365 | 5260 else |
| 5261 { | |
| 5262 while (src < src_end) | |
| 5263 { | |
| 5264 c = *src++; | |
| 5265 if (c == '\n' || c == '\r') | |
| 5266 { | |
| 5267 int this_eol; | |
| 5268 | |
| 5269 if (c == '\n') | |
| 5270 this_eol = EOL_SEEN_LF; | |
| 5271 else if (src >= src_end || *src != '\n') | |
| 5272 this_eol = EOL_SEEN_CR; | |
| 5273 else | |
| 5274 this_eol = EOL_SEEN_CRLF, src++; | |
| 5275 | |
| 5276 if (eol_seen == EOL_SEEN_NONE) | |
| 5277 /* This is the first end-of-line. */ | |
| 5278 eol_seen = this_eol; | |
| 5279 else if (eol_seen != this_eol) | |
| 5280 { | |
| 5281 /* The found type is different from what found before. */ | |
| 5282 eol_seen = EOL_SEEN_LF; | |
| 5283 break; | |
| 5284 } | |
| 5285 if (++total == MAX_EOL_CHECK_COUNT) | |
| 5286 break; | |
|
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5287 } |
| 17052 | 5288 } |
| 5289 } | |
| 88365 | 5290 return eol_seen; |
| 17052 | 5291 } |
| 5292 | |
| 88365 | 5293 |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5294 static Lisp_Object |
| 88365 | 5295 adjust_coding_eol_type (coding, eol_seen) |
| 5296 struct coding_system *coding; | |
| 5297 int eol_seen; | |
| 5298 { | |
|
88430
6418a272b97e
* coding.c: Delete unused variables.
Kenichi Handa <handa@m17n.org>
parents:
88365
diff
changeset
|
5299 Lisp_Object eol_type; |
| 89483 | 5300 |
| 88365 | 5301 eol_type = CODING_ID_EOL_TYPE (coding->id); |
| 5302 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
|
5303 { |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5304 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
|
5305 eol_type = Qunix; |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5306 } |
|
88862
108e2535280d
(adjust_coding_eol_type): Fix eol_type/eol_seen mixup.
Dave Love <fx@gnu.org>
parents:
88856
diff
changeset
|
5307 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
|
5308 { |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5309 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
|
5310 eol_type = Qdos; |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5311 } |
|
88862
108e2535280d
(adjust_coding_eol_type): Fix eol_type/eol_seen mixup.
Dave Love <fx@gnu.org>
parents:
88856
diff
changeset
|
5312 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
|
5313 { |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5314 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
|
5315 eol_type = Qmac; |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5316 } |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5317 return eol_type; |
| 88365 | 5318 } |
| 5319 | |
| 5320 /* Detect how a text specified in CODING is encoded. If a coding | |
| 5321 system is detected, update fields of CODING by the detected coding | |
| 5322 system. */ | |
| 5323 | |
| 5324 void | |
| 5325 detect_coding (coding) | |
| 5326 struct coding_system *coding; | |
|
28022
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
5327 { |
| 89483 | 5328 const unsigned char *src, *src_end; |
| 88365 | 5329 Lisp_Object attrs, coding_type; |
| 5330 | |
| 5331 coding->consumed = coding->consumed_char = 0; | |
| 5332 coding->produced = coding->produced_char = 0; | |
| 5333 coding_set_source (coding); | |
| 5334 | |
| 5335 src_end = coding->source + coding->src_bytes; | |
| 5336 | |
| 5337 /* If we have not yet decided the text encoding type, detect it | |
| 5338 now. */ | |
| 5339 if (EQ (CODING_ATTR_TYPE (CODING_ID_ATTRS (coding->id)), Qundecided)) | |
| 5340 { | |
| 5341 int c, i; | |
| 5342 | |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5343 for (i = 0, src = coding->source; src < src_end; i++, src++) |
|
28022
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
5344 { |
| 88365 | 5345 c = *src; |
|
89780
a53cb5864a40
(detect_coding_iso_2022): Fix handling of SS2 and SS3.
Kenichi Handa <handa@m17n.org>
parents:
89779
diff
changeset
|
5346 if (c & 0x80 || (c < 0x20 && (c == ISO_CODE_ESC |
| 88365 | 5347 || c == ISO_CODE_SI |
| 5348 || c == ISO_CODE_SO))) | |
| 5349 break; | |
| 5350 } | |
| 5351 coding->head_ascii = src - (coding->source + coding->consumed); | |
| 5352 | |
| 5353 if (coding->head_ascii < coding->src_bytes) | |
| 5354 { | |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
5355 struct coding_detection_info detect_info; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
5356 enum coding_category category; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
5357 struct coding_system *this; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
5358 |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
5359 detect_info.checked = detect_info.found = detect_info.rejected = 0; |
| 88365 | 5360 for (i = 0; i < coding_category_raw_text; i++) |
|
28022
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
5361 { |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
5362 category = coding_priorities[i]; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
5363 this = coding_categories + category; |
| 88365 | 5364 if (this->id < 0) |
|
28022
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
5365 { |
| 88365 | 5366 /* No coding system of this category is defined. */ |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
5367 detect_info.rejected |= (1 << category); |
|
28022
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
5368 } |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
5369 else if (category >= coding_category_raw_text) |
|
89193
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
5370 continue; |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
5371 else if (detect_info.checked & (1 << category)) |
|
28022
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
5372 { |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
5373 if (detect_info.found & (1 << category)) |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
5374 break; |
|
28022
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
5375 } |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
5376 else if ((*(this->detector)) (coding, &detect_info) |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
5377 && detect_info.found & (1 << category)) |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5378 { |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5379 if (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
|
5380 { |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5381 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
|
5382 category = coding_category_utf_16_le; |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5383 else |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5384 category = coding_category_utf_16_be; |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5385 } |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5386 break; |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5387 } |
|
28022
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
5388 } |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
5389 if (i < coding_category_raw_text) |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
5390 setup_coding_system (CODING_ID_NAME (this->id), coding); |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
5391 else if (detect_info.rejected == CATEGORY_MASK_ANY) |
| 88365 | 5392 setup_coding_system (Qraw_text, coding); |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
5393 else if (detect_info.rejected) |
| 88365 | 5394 for (i = 0; i < coding_category_raw_text; i++) |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
5395 if (! (detect_info.rejected & (1 << coding_priorities[i]))) |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
5396 { |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
5397 this = coding_categories + coding_priorities[i]; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
5398 setup_coding_system (CODING_ID_NAME (this->id), coding); |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
5399 break; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
5400 } |
| 88365 | 5401 } |
| 5402 } | |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5403 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
|
5404 == coding_category_utf_16_auto) |
|
89420
c3e67ce6ee0f
(Qsignature, Qendian): Delete these variables.
Kenichi Handa <handa@m17n.org>
parents:
89418
diff
changeset
|
5405 { |
|
c3e67ce6ee0f
(Qsignature, Qendian): Delete these variables.
Kenichi Handa <handa@m17n.org>
parents:
89418
diff
changeset
|
5406 Lisp_Object coding_systems; |
|
c3e67ce6ee0f
(Qsignature, Qendian): Delete these variables.
Kenichi Handa <handa@m17n.org>
parents:
89418
diff
changeset
|
5407 struct coding_detection_info detect_info; |
|
c3e67ce6ee0f
(Qsignature, Qendian): Delete these variables.
Kenichi Handa <handa@m17n.org>
parents:
89418
diff
changeset
|
5408 |
|
c3e67ce6ee0f
(Qsignature, Qendian): Delete these variables.
Kenichi Handa <handa@m17n.org>
parents:
89418
diff
changeset
|
5409 coding_systems |
|
c3e67ce6ee0f
(Qsignature, Qendian): Delete these variables.
Kenichi Handa <handa@m17n.org>
parents:
89418
diff
changeset
|
5410 = 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
|
5411 detect_info.found = detect_info.rejected = 0; |
|
c3e67ce6ee0f
(Qsignature, Qendian): Delete these variables.
Kenichi Handa <handa@m17n.org>
parents:
89418
diff
changeset
|
5412 if (CONSP (coding_systems) |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5413 && detect_coding_utf_16 (coding, &detect_info)) |
|
89420
c3e67ce6ee0f
(Qsignature, Qendian): Delete these variables.
Kenichi Handa <handa@m17n.org>
parents:
89418
diff
changeset
|
5414 { |
|
c3e67ce6ee0f
(Qsignature, Qendian): Delete these variables.
Kenichi Handa <handa@m17n.org>
parents:
89418
diff
changeset
|
5415 if (detect_info.found & CATEGORY_MASK_UTF_16_LE) |
|
c3e67ce6ee0f
(Qsignature, Qendian): Delete these variables.
Kenichi Handa <handa@m17n.org>
parents:
89418
diff
changeset
|
5416 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
|
5417 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
|
5418 setup_coding_system (XCDR (coding_systems), coding); |
|
c3e67ce6ee0f
(Qsignature, Qendian): Delete these variables.
Kenichi Handa <handa@m17n.org>
parents:
89418
diff
changeset
|
5419 } |
|
c3e67ce6ee0f
(Qsignature, Qendian): Delete these variables.
Kenichi Handa <handa@m17n.org>
parents:
89418
diff
changeset
|
5420 } |
| 88365 | 5421 } |
| 5422 | |
| 5423 | |
| 5424 static void | |
| 5425 decode_eol (coding) | |
| 5426 struct coding_system *coding; | |
| 5427 { | |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5428 Lisp_Object eol_type; |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5429 unsigned char *p, *pbeg, *pend; |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5430 |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5431 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
|
5432 if (EQ (eol_type, Qunix)) |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5433 return; |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5434 |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5435 if (NILP (coding->dst_object)) |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5436 pbeg = coding->destination; |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5437 else |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5438 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
|
5439 pend = pbeg + coding->produced; |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5440 |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5441 if (VECTORP (eol_type)) |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5442 { |
| 88365 | 5443 int eol_seen = EOL_SEEN_NONE; |
| 5444 | |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5445 for (p = pbeg; p < pend; p++) |
| 88365 | 5446 { |
| 5447 if (*p == '\n') | |
| 5448 eol_seen |= EOL_SEEN_LF; | |
| 5449 else if (*p == '\r') | |
|
28022
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
5450 { |
| 88365 | 5451 if (p + 1 < pend && *(p + 1) == '\n') |
| 5452 { | |
| 5453 eol_seen |= EOL_SEEN_CRLF; | |
| 5454 p++; | |
| 5455 } | |
| 5456 else | |
| 5457 eol_seen |= EOL_SEEN_CR; | |
|
28022
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
5458 } |
|
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
5459 } |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5460 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
|
5461 && eol_seen != EOL_SEEN_LF |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5462 && eol_seen != EOL_SEEN_CRLF |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5463 && eol_seen != EOL_SEEN_CR) |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5464 eol_seen = EOL_SEEN_LF; |
| 88365 | 5465 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
|
5466 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
|
5467 } |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5468 |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5469 if (EQ (eol_type, Qmac)) |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5470 { |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5471 for (p = pbeg; p < pend; p++) |
| 88365 | 5472 if (*p == '\r') |
| 5473 *p = '\n'; | |
| 5474 } | |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5475 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
|
5476 { |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5477 int n = 0; |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5478 |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5479 if (NILP (coding->dst_object)) |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5480 { |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5481 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
|
5482 if (*p == '\r') |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5483 { |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5484 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
|
5485 n++; |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5486 } |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5487 } |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5488 else |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5489 { |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5490 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
|
5491 if (*p == '\r') |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5492 { |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5493 int pos_byte = coding->dst_pos_byte + (p - pbeg); |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5494 int pos = BYTE_TO_CHAR (pos_byte); |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5495 |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5496 del_range_2 (pos, pos_byte, pos + 1, pos_byte + 1, 0); |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5497 n++; |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5498 } |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5499 } |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5500 coding->produced -= n; |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5501 coding->produced_char -= n; |
| 17052 | 5502 } |
| 5503 } | |
| 5504 | |
|
89732
8acde12aba89
(get_translation_table): New function.
Kenichi Handa <handa@m17n.org>
parents:
89730
diff
changeset
|
5505 |
|
89759
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
5506 /* Return a translation table (or list of them) from coding system |
|
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
5507 attribute vector ATTRS for encoding (ENCODEP is nonzero) or |
|
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
5508 decoding (ENCODEP is zero). */ |
|
89732
8acde12aba89
(get_translation_table): New function.
Kenichi Handa <handa@m17n.org>
parents:
89730
diff
changeset
|
5509 |
|
89858
23cb9ed79225
(get_translation_table): Declare it as Lisp_Object.
Kenichi Handa <handa@m17n.org>
parents:
89856
diff
changeset
|
5510 static Lisp_Object |
|
89859
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
5511 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
|
5512 Lisp_Object attrs; |
|
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
5513 int encodep, *max_lookup; |
|
89732
8acde12aba89
(get_translation_table): New function.
Kenichi Handa <handa@m17n.org>
parents:
89730
diff
changeset
|
5514 { |
|
8acde12aba89
(get_translation_table): New function.
Kenichi Handa <handa@m17n.org>
parents:
89730
diff
changeset
|
5515 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
|
5516 Lisp_Object val; |
|
89732
8acde12aba89
(get_translation_table): New function.
Kenichi Handa <handa@m17n.org>
parents:
89730
diff
changeset
|
5517 |
|
8acde12aba89
(get_translation_table): New function.
Kenichi Handa <handa@m17n.org>
parents:
89730
diff
changeset
|
5518 if (encodep) |
|
8acde12aba89
(get_translation_table): New function.
Kenichi Handa <handa@m17n.org>
parents:
89730
diff
changeset
|
5519 translation_table = CODING_ATTR_ENCODE_TBL (attrs), |
|
8acde12aba89
(get_translation_table): New function.
Kenichi Handa <handa@m17n.org>
parents:
89730
diff
changeset
|
5520 standard = Vstandard_translation_table_for_encode; |
|
8acde12aba89
(get_translation_table): New function.
Kenichi Handa <handa@m17n.org>
parents:
89730
diff
changeset
|
5521 else |
|
8acde12aba89
(get_translation_table): New function.
Kenichi Handa <handa@m17n.org>
parents:
89730
diff
changeset
|
5522 translation_table = CODING_ATTR_DECODE_TBL (attrs), |
|
8acde12aba89
(get_translation_table): New function.
Kenichi Handa <handa@m17n.org>
parents:
89730
diff
changeset
|
5523 standard = Vstandard_translation_table_for_decode; |
|
89759
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
5524 if (NILP (translation_table)) |
|
89859
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
5525 translation_table = standard; |
|
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
5526 else |
|
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
5527 { |
|
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
5528 if (SYMBOLP (translation_table)) |
|
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
5529 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
|
5530 else if (CONSP (translation_table)) |
|
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
5531 { |
|
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
5532 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
|
5533 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
|
5534 if (SYMBOLP (XCAR (val))) |
|
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
5535 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
|
5536 } |
|
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
5537 if (CHAR_TABLE_P (standard)) |
|
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
5538 { |
|
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
5539 if (CONSP (translation_table)) |
|
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
5540 translation_table = nconc2 (translation_table, |
|
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
5541 Fcons (standard, Qnil)); |
|
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
5542 else |
|
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
5543 translation_table = Fcons (translation_table, |
|
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
5544 Fcons (standard, Qnil)); |
|
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
5545 } |
|
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
5546 } |
|
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
5547 *max_lookup = 1; |
|
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
5548 if (CHAR_TABLE_P (translation_table) |
|
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
5549 && CHAR_TABLE_EXTRA_SLOTS (XCHAR_TABLE (translation_table)) > 1) |
|
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
5550 { |
|
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
5551 val = XCHAR_TABLE (translation_table)->extras[1]; |
|
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
5552 if (NATNUMP (val) && *max_lookup < XFASTINT (val)) |
|
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
5553 *max_lookup = XFASTINT (val); |
|
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
5554 } |
|
89759
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
5555 else if (CONSP (translation_table)) |
|
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
5556 { |
|
89859
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
5557 Lisp_Object tail, val; |
|
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
5558 |
|
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
5559 for (tail = translation_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
|
5560 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
|
5561 && CHAR_TABLE_EXTRA_SLOTS (XCHAR_TABLE (XCAR (tail))) > 1) |
|
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
5562 { |
|
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
5563 val = XCHAR_TABLE (XCAR (tail))->extras[1]; |
|
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
5564 if (NATNUMP (val) && *max_lookup < XFASTINT (val)) |
|
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
5565 *max_lookup = XFASTINT (val); |
|
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
5566 } |
|
89759
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
5567 } |
|
89732
8acde12aba89
(get_translation_table): New function.
Kenichi Handa <handa@m17n.org>
parents:
89730
diff
changeset
|
5568 return translation_table; |
|
8acde12aba89
(get_translation_table): New function.
Kenichi Handa <handa@m17n.org>
parents:
89730
diff
changeset
|
5569 } |
|
8acde12aba89
(get_translation_table): New function.
Kenichi Handa <handa@m17n.org>
parents:
89730
diff
changeset
|
5570 |
|
89859
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
5571 #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
|
5572 do { \ |
|
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
5573 trans = Qnil; \ |
|
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
5574 if (CHAR_TABLE_P (table)) \ |
|
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
5575 { \ |
|
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
5576 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
|
5577 if (CHARACTERP (trans)) \ |
|
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
5578 c = XFASTINT (trans), trans = Qnil; \ |
|
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
5579 } \ |
|
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
5580 else if (CONSP (table)) \ |
|
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
5581 { \ |
|
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
5582 Lisp_Object tail; \ |
|
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
5583 \ |
|
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
5584 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
|
5585 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
|
5586 { \ |
|
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
5587 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
|
5588 if (CHARACTERP (trans)) \ |
|
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
5589 c = XFASTINT (trans), trans = Qnil; \ |
|
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
5590 else if (! NILP (trans)) \ |
|
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
5591 break; \ |
|
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
5592 } \ |
|
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
5593 } \ |
|
89858
23cb9ed79225
(get_translation_table): Declare it as Lisp_Object.
Kenichi Handa <handa@m17n.org>
parents:
89856
diff
changeset
|
5594 } while (0) |
|
23cb9ed79225
(get_translation_table): Declare it as Lisp_Object.
Kenichi Handa <handa@m17n.org>
parents:
89856
diff
changeset
|
5595 |
|
89732
8acde12aba89
(get_translation_table): New function.
Kenichi Handa <handa@m17n.org>
parents:
89730
diff
changeset
|
5596 |
|
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
5597 static Lisp_Object |
|
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
5598 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
|
5599 Lisp_Object val; |
|
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
5600 int *buf, *buf_end; |
|
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
5601 int last_block; |
|
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
5602 int *from_nchars, *to_nchars; |
|
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
5603 { |
|
89856
18b52da60a76
(get_translation): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89852
diff
changeset
|
5604 /* 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
|
5605 [TO-CHAR ...]. */ |
|
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
5606 if (CONSP (val)) |
|
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
5607 { |
|
89856
18b52da60a76
(get_translation): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89852
diff
changeset
|
5608 Lisp_Object from, tail; |
|
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
5609 int i, len; |
|
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
5610 |
|
89856
18b52da60a76
(get_translation): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89852
diff
changeset
|
5611 for (tail = val; CONSP (tail); tail = XCDR (tail)) |
|
18b52da60a76
(get_translation): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89852
diff
changeset
|
5612 { |
|
18b52da60a76
(get_translation): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89852
diff
changeset
|
5613 val = XCAR (tail); |
|
18b52da60a76
(get_translation): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89852
diff
changeset
|
5614 from = XCAR (val); |
|
18b52da60a76
(get_translation): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89852
diff
changeset
|
5615 len = ASIZE (from); |
|
18b52da60a76
(get_translation): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89852
diff
changeset
|
5616 for (i = 0; i < len; i++) |
|
18b52da60a76
(get_translation): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89852
diff
changeset
|
5617 { |
|
18b52da60a76
(get_translation): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89852
diff
changeset
|
5618 if (buf + i == buf_end) |
|
18b52da60a76
(get_translation): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89852
diff
changeset
|
5619 { |
|
18b52da60a76
(get_translation): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89852
diff
changeset
|
5620 if (! last_block) |
|
18b52da60a76
(get_translation): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89852
diff
changeset
|
5621 return Qt; |
|
18b52da60a76
(get_translation): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89852
diff
changeset
|
5622 break; |
|
18b52da60a76
(get_translation): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89852
diff
changeset
|
5623 } |
|
18b52da60a76
(get_translation): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89852
diff
changeset
|
5624 if (XINT (AREF (from, i)) != buf[i]) |
|
18b52da60a76
(get_translation): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89852
diff
changeset
|
5625 break; |
|
18b52da60a76
(get_translation): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89852
diff
changeset
|
5626 } |
|
18b52da60a76
(get_translation): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89852
diff
changeset
|
5627 if (i == len) |
|
18b52da60a76
(get_translation): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89852
diff
changeset
|
5628 { |
|
18b52da60a76
(get_translation): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89852
diff
changeset
|
5629 val = XCDR (val); |
|
18b52da60a76
(get_translation): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89852
diff
changeset
|
5630 *from_nchars = len; |
|
18b52da60a76
(get_translation): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89852
diff
changeset
|
5631 break; |
|
18b52da60a76
(get_translation): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89852
diff
changeset
|
5632 } |
|
18b52da60a76
(get_translation): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89852
diff
changeset
|
5633 } |
|
18b52da60a76
(get_translation): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89852
diff
changeset
|
5634 if (! CONSP (tail)) |
|
18b52da60a76
(get_translation): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89852
diff
changeset
|
5635 return Qnil; |
|
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
5636 } |
|
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
5637 if (VECTORP (val)) |
|
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
5638 *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
|
5639 else |
|
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
5640 *buf = XINT (val); |
|
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
5641 return val; |
|
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
5642 } |
|
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
5643 |
|
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
5644 |
| 88365 | 5645 static int |
|
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
5646 produce_chars (coding, translation_table, last_block) |
| 88365 | 5647 struct coding_system *coding; |
|
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
5648 Lisp_Object translation_table; |
|
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
5649 int last_block; |
| 17052 | 5650 { |
| 88365 | 5651 unsigned char *dst = coding->destination + coding->produced; |
| 5652 unsigned char *dst_end = coding->destination + coding->dst_bytes; | |
| 5653 int produced; | |
| 5654 int produced_chars = 0; | |
|
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
5655 int carryover = 0; |
| 88365 | 5656 |
| 5657 if (! coding->chars_at_source) | |
| 5658 { | |
| 5659 /* Characters are in coding->charbuf. */ | |
|
89575
59d10ebd2a0b
(produce_chars): Revert last change.
Andreas Schwab <schwab@suse.de>
parents:
89571
diff
changeset
|
5660 int *buf = coding->charbuf; |
|
59d10ebd2a0b
(produce_chars): Revert last change.
Andreas Schwab <schwab@suse.de>
parents:
89571
diff
changeset
|
5661 int *buf_end = buf + coding->charbuf_used; |
| 88365 | 5662 |
| 5663 if (BUFFERP (coding->src_object) | |
| 5664 && EQ (coding->src_object, coding->dst_object)) | |
| 89483 | 5665 dst_end = ((unsigned char *) coding->source) + coding->consumed; |
| 88365 | 5666 |
| 5667 while (buf < buf_end) | |
| 5668 { | |
|
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
5669 int c = *buf, i; |
|
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
5670 |
| 88365 | 5671 if (c >= 0) |
| 5672 { | |
|
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
5673 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
|
5674 Lisp_Object trans = Qnil; |
|
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
5675 |
|
89859
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
5676 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
|
5677 if (! NILP (trans)) |
|
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
5678 { |
|
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
5679 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
|
5680 &from_nchars, &to_nchars); |
|
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
5681 if (EQ (trans, Qt)) |
|
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
5682 break; |
|
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
5683 c = *buf; |
|
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
5684 } |
|
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
5685 |
|
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
5686 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
|
5687 { |
|
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
5688 dst = alloc_destination (coding, |
|
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
5689 buf_end - buf |
|
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
5690 + MAX_MULTIBYTE_LENGTH * to_nchars, |
|
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
5691 dst); |
|
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
5692 dst_end = coding->destination + coding->dst_bytes; |
|
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
5693 } |
|
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
5694 |
|
89856
18b52da60a76
(get_translation): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89852
diff
changeset
|
5695 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
|
5696 { |
|
89856
18b52da60a76
(get_translation): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89852
diff
changeset
|
5697 if (i > 0) |
|
18b52da60a76
(get_translation): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89852
diff
changeset
|
5698 c = XINT (AREF (trans, i)); |
|
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
5699 if (coding->dst_multibyte |
|
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
5700 || ! CHAR_BYTE8_P (c)) |
|
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
5701 CHAR_STRING_ADVANCE (c, dst); |
|
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
5702 else |
|
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
5703 *dst++ = CHAR_TO_BYTE8 (c); |
|
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
5704 } |
|
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
5705 produced_chars += to_nchars; |
|
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
5706 *buf++ = to_nchars; |
|
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
5707 while (--from_nchars > 0) |
|
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
5708 *buf++ = 0; |
| 88365 | 5709 } |
| 5710 else | |
|
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
5711 /* 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
|
5712 buf += -c; |
|
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
5713 } |
|
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
5714 carryover = buf_end - buf; |
|
30833
2db6e42a6ba3
(MINIMUM_CONVERSION_BUFFER_SIZE): Macro deleted.
Kenichi Handa <handa@m17n.org>
parents:
30756
diff
changeset
|
5715 } |
|
2db6e42a6ba3
(MINIMUM_CONVERSION_BUFFER_SIZE): Macro deleted.
Kenichi Handa <handa@m17n.org>
parents:
30756
diff
changeset
|
5716 else |
|
2db6e42a6ba3
(MINIMUM_CONVERSION_BUFFER_SIZE): Macro deleted.
Kenichi Handa <handa@m17n.org>
parents:
30756
diff
changeset
|
5717 { |
| 89483 | 5718 const unsigned char *src = coding->source; |
| 5719 const unsigned char *src_end = src + coding->src_bytes; | |
| 88365 | 5720 Lisp_Object eol_type; |
| 5721 | |
| 5722 eol_type = CODING_ID_EOL_TYPE (coding->id); | |
| 5723 | |
| 5724 if (coding->src_multibyte != coding->dst_multibyte) | |
|
34892
3868f2e7355a
(setup_coding_system): Initialize
Kenichi Handa <handa@m17n.org>
parents:
34888
diff
changeset
|
5725 { |
| 88365 | 5726 if (coding->src_multibyte) |
|
34892
3868f2e7355a
(setup_coding_system): Initialize
Kenichi Handa <handa@m17n.org>
parents:
34888
diff
changeset
|
5727 { |
|
88443
6b86cf30a0b9
(produce_chars): Set the variable `multibytep' correctly.
Kenichi Handa <handa@m17n.org>
parents:
88438
diff
changeset
|
5728 int multibytep = 1; |
| 88365 | 5729 int consumed_chars; |
| 5730 | |
| 5731 while (1) | |
|
34892
3868f2e7355a
(setup_coding_system): Initialize
Kenichi Handa <handa@m17n.org>
parents:
34888
diff
changeset
|
5732 { |
| 89483 | 5733 const unsigned char *src_base = src; |
| 88365 | 5734 int c; |
| 5735 | |
| 5736 ONE_MORE_BYTE (c); | |
| 5737 if (c == '\r') | |
| 5738 { | |
| 5739 if (EQ (eol_type, Qdos)) | |
| 5740 { | |
|
89279
1fd77c471ee6
(decode_coding_utf_8): When eol_type is Qdos, handle
Kenichi Handa <handa@m17n.org>
parents:
89227
diff
changeset
|
5741 if (src == src_end) |
|
1fd77c471ee6
(decode_coding_utf_8): When eol_type is Qdos, handle
Kenichi Handa <handa@m17n.org>
parents:
89227
diff
changeset
|
5742 { |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
5743 record_conversion_result |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
5744 (coding, CODING_RESULT_INSUFFICIENT_SRC); |
|
89279
1fd77c471ee6
(decode_coding_utf_8): When eol_type is Qdos, handle
Kenichi Handa <handa@m17n.org>
parents:
89227
diff
changeset
|
5745 goto no_more_source; |
|
1fd77c471ee6
(decode_coding_utf_8): When eol_type is Qdos, handle
Kenichi Handa <handa@m17n.org>
parents:
89227
diff
changeset
|
5746 } |
|
1fd77c471ee6
(decode_coding_utf_8): When eol_type is Qdos, handle
Kenichi Handa <handa@m17n.org>
parents:
89227
diff
changeset
|
5747 if (*src == '\n') |
| 88365 | 5748 c = *src++; |
| 5749 } | |
| 5750 else if (EQ (eol_type, Qmac)) | |
| 5751 c = '\n'; | |
| 5752 } | |
| 5753 if (dst == dst_end) | |
| 5754 { | |
|
88456
a7b309f72920
(coding_alloc_by_making_gap): Check the case that the
Kenichi Handa <handa@m17n.org>
parents:
88443
diff
changeset
|
5755 coding->consumed = src - coding->source; |
|
a7b309f72920
(coding_alloc_by_making_gap): Check the case that the
Kenichi Handa <handa@m17n.org>
parents:
88443
diff
changeset
|
5756 |
|
a7b309f72920
(coding_alloc_by_making_gap): Check the case that the
Kenichi Handa <handa@m17n.org>
parents:
88443
diff
changeset
|
5757 if (EQ (coding->src_object, coding->dst_object)) |
| 89483 | 5758 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
|
5759 if (dst == dst_end) |
|
a7b309f72920
(coding_alloc_by_making_gap): Check the case that the
Kenichi Handa <handa@m17n.org>
parents:
88443
diff
changeset
|
5760 { |
|
a7b309f72920
(coding_alloc_by_making_gap): Check the case that the
Kenichi Handa <handa@m17n.org>
parents:
88443
diff
changeset
|
5761 dst = alloc_destination (coding, src_end - src + 1, |
|
a7b309f72920
(coding_alloc_by_making_gap): Check the case that the
Kenichi Handa <handa@m17n.org>
parents:
88443
diff
changeset
|
5762 dst); |
|
a7b309f72920
(coding_alloc_by_making_gap): Check the case that the
Kenichi Handa <handa@m17n.org>
parents:
88443
diff
changeset
|
5763 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
|
5764 coding_set_source (coding); |
|
a7b309f72920
(coding_alloc_by_making_gap): Check the case that the
Kenichi Handa <handa@m17n.org>
parents:
88443
diff
changeset
|
5765 src = coding->source + coding->consumed; |
|
a7b309f72920
(coding_alloc_by_making_gap): Check the case that the
Kenichi Handa <handa@m17n.org>
parents:
88443
diff
changeset
|
5766 src_end = coding->source + coding->src_bytes; |
|
a7b309f72920
(coding_alloc_by_making_gap): Check the case that the
Kenichi Handa <handa@m17n.org>
parents:
88443
diff
changeset
|
5767 } |
| 88365 | 5768 } |
| 5769 *dst++ = c; | |
| 5770 produced_chars++; | |
| 5771 } | |
| 5772 no_more_source: | |
| 5773 ; | |
| 5774 } | |
| 5775 else | |
| 5776 while (src < src_end) | |
| 5777 { | |
|
88443
6b86cf30a0b9
(produce_chars): Set the variable `multibytep' correctly.
Kenichi Handa <handa@m17n.org>
parents:
88438
diff
changeset
|
5778 int multibytep = 1; |
| 88365 | 5779 int c = *src++; |
| 5780 | |
| 5781 if (c == '\r') | |
| 5782 { | |
| 5783 if (EQ (eol_type, Qdos)) | |
| 5784 { | |
| 5785 if (src < src_end | |
| 5786 && *src == '\n') | |
| 5787 c = *src++; | |
| 5788 } | |
| 5789 else if (EQ (eol_type, Qmac)) | |
| 5790 c = '\n'; | |
| 5791 } | |
| 5792 if (dst >= dst_end - 1) | |
| 5793 { | |
|
88456
a7b309f72920
(coding_alloc_by_making_gap): Check the case that the
Kenichi Handa <handa@m17n.org>
parents:
88443
diff
changeset
|
5794 coding->consumed = src - coding->source; |
|
a7b309f72920
(coding_alloc_by_making_gap): Check the case that the
Kenichi Handa <handa@m17n.org>
parents:
88443
diff
changeset
|
5795 |
|
a7b309f72920
(coding_alloc_by_making_gap): Check the case that the
Kenichi Handa <handa@m17n.org>
parents:
88443
diff
changeset
|
5796 if (EQ (coding->src_object, coding->dst_object)) |
| 89483 | 5797 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
|
5798 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
|
5799 { |
|
a7b309f72920
(coding_alloc_by_making_gap): Check the case that the
Kenichi Handa <handa@m17n.org>
parents:
88443
diff
changeset
|
5800 dst = alloc_destination (coding, src_end - src + 2, |
|
a7b309f72920
(coding_alloc_by_making_gap): Check the case that the
Kenichi Handa <handa@m17n.org>
parents:
88443
diff
changeset
|
5801 dst); |
|
a7b309f72920
(coding_alloc_by_making_gap): Check the case that the
Kenichi Handa <handa@m17n.org>
parents:
88443
diff
changeset
|
5802 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
|
5803 coding_set_source (coding); |
|
a7b309f72920
(coding_alloc_by_making_gap): Check the case that the
Kenichi Handa <handa@m17n.org>
parents:
88443
diff
changeset
|
5804 src = coding->source + coding->consumed; |
|
a7b309f72920
(coding_alloc_by_making_gap): Check the case that the
Kenichi Handa <handa@m17n.org>
parents:
88443
diff
changeset
|
5805 src_end = coding->source + coding->src_bytes; |
|
a7b309f72920
(coding_alloc_by_making_gap): Check the case that the
Kenichi Handa <handa@m17n.org>
parents:
88443
diff
changeset
|
5806 } |
| 88365 | 5807 } |
| 5808 EMIT_ONE_BYTE (c); | |
| 5809 } | |
| 5810 } | |
| 5811 else | |
| 5812 { | |
| 5813 if (!EQ (coding->src_object, coding->dst_object)) | |
| 5814 { | |
| 5815 int require = coding->src_bytes - coding->dst_bytes; | |
| 5816 | |
| 5817 if (require > 0) | |
| 5818 { | |
| 5819 EMACS_INT offset = src - coding->source; | |
| 5820 | |
| 5821 dst = alloc_destination (coding, require, dst); | |
| 5822 coding_set_source (coding); | |
| 5823 src = coding->source + offset; | |
| 5824 src_end = coding->source + coding->src_bytes; | |
|
34892
3868f2e7355a
(setup_coding_system): Initialize
Kenichi Handa <handa@m17n.org>
parents:
34888
diff
changeset
|
5825 } |
|
3868f2e7355a
(setup_coding_system): Initialize
Kenichi Handa <handa@m17n.org>
parents:
34888
diff
changeset
|
5826 } |
| 88365 | 5827 produced_chars = coding->src_chars; |
| 5828 while (src < src_end) | |
|
34892
3868f2e7355a
(setup_coding_system): Initialize
Kenichi Handa <handa@m17n.org>
parents:
34888
diff
changeset
|
5829 { |
| 88365 | 5830 int c = *src++; |
| 5831 | |
| 5832 if (c == '\r') | |
| 5833 { | |
| 5834 if (EQ (eol_type, Qdos)) | |
| 5835 { | |
| 5836 if (src < src_end | |
| 5837 && *src == '\n') | |
| 5838 c = *src++; | |
| 5839 produced_chars--; | |
| 5840 } | |
| 5841 else if (EQ (eol_type, Qmac)) | |
| 5842 c = '\n'; | |
| 5843 } | |
| 5844 *dst++ = c; | |
|
34892
3868f2e7355a
(setup_coding_system): Initialize
Kenichi Handa <handa@m17n.org>
parents:
34888
diff
changeset
|
5845 } |
|
3868f2e7355a
(setup_coding_system): Initialize
Kenichi Handa <handa@m17n.org>
parents:
34888
diff
changeset
|
5846 } |
|
88456
a7b309f72920
(coding_alloc_by_making_gap): Check the case that the
Kenichi Handa <handa@m17n.org>
parents:
88443
diff
changeset
|
5847 coding->consumed = coding->src_bytes; |
|
a7b309f72920
(coding_alloc_by_making_gap): Check the case that the
Kenichi Handa <handa@m17n.org>
parents:
88443
diff
changeset
|
5848 coding->consumed_char = coding->src_chars; |
| 88365 | 5849 } |
| 5850 | |
| 5851 produced = dst - (coding->destination + coding->produced); | |
| 5852 if (BUFFERP (coding->dst_object)) | |
| 5853 insert_from_gap (produced_chars, produced); | |
| 5854 coding->produced += produced; | |
| 5855 coding->produced_char += produced_chars; | |
|
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
5856 return carryover; |
| 88365 | 5857 } |
| 5858 | |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
5859 /* 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
|
5860 CHARBUF. CHARBUF is an array: |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
5861 [ -LENGTH ANNOTATION_MASK FROM TO METHOD COMP_LEN [ COMPONENTS... ] ] |
| 88365 | 5862 */ |
| 5863 | |
| 5864 static INLINE void | |
|
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
5865 produce_composition (coding, charbuf, pos) |
| 88365 | 5866 struct coding_system *coding; |
| 5867 int *charbuf; | |
|
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
5868 EMACS_INT pos; |
| 88365 | 5869 { |
| 5870 int len; | |
|
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
5871 EMACS_INT to; |
| 88365 | 5872 enum composition_method method; |
| 5873 Lisp_Object components; | |
| 5874 | |
| 5875 len = -charbuf[0]; | |
|
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
5876 to = pos + charbuf[2]; |
|
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
5877 method = (enum composition_method) (charbuf[3]); |
| 88365 | 5878 |
| 5879 if (method == COMPOSITION_RELATIVE) | |
| 5880 components = Qnil; | |
| 5881 else | |
| 5882 { | |
| 5883 Lisp_Object args[MAX_COMPOSITION_COMPONENTS * 2 - 1]; | |
| 5884 int i; | |
| 5885 | |
|
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
5886 len -= 4; |
|
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
5887 charbuf += 4; |
| 88365 | 5888 for (i = 0; i < len; i++) |
| 5889 args[i] = make_number (charbuf[i]); | |
| 5890 components = (method == COMPOSITION_WITH_ALTCHARS | |
| 5891 ? Fstring (len, args) : Fvector (len, args)); | |
| 5892 } | |
|
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
5893 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
|
5894 } |
|
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5895 |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
5896 |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
5897 /* 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
|
5898 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
|
5899 [ -LENGTH ANNOTATION_MASK NCHARS CHARSET-ID ] |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
5900 */ |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
5901 |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
5902 static INLINE void |
|
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
5903 produce_charset (coding, charbuf, pos) |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
5904 struct coding_system *coding; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
5905 int *charbuf; |
|
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
5906 EMACS_INT pos; |
|
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
5907 { |
|
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
5908 EMACS_INT from = pos - charbuf[2]; |
|
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
5909 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
|
5910 |
|
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
5911 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
|
5912 Qcharset, CHARSET_NAME (charset), |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
5913 coding->dst_object); |
| 88365 | 5914 } |
| 5915 | |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
5916 |
| 88365 | 5917 #define CHARBUF_SIZE 0x4000 |
| 5918 | |
| 5919 #define ALLOC_CONVERSION_WORK_AREA(coding) \ | |
| 5920 do { \ | |
| 5921 int size = CHARBUF_SIZE;; \ | |
| 5922 \ | |
| 5923 coding->charbuf = NULL; \ | |
| 5924 while (size > 1024) \ | |
| 5925 { \ | |
| 5926 coding->charbuf = (int *) alloca (sizeof (int) * size); \ | |
| 5927 if (coding->charbuf) \ | |
| 5928 break; \ | |
| 5929 size >>= 1; \ | |
| 5930 } \ | |
| 5931 if (! coding->charbuf) \ | |
| 5932 { \ | |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
5933 record_conversion_result (coding, CODING_RESULT_INSUFFICIENT_MEM); \ |
| 88365 | 5934 return coding->result; \ |
| 5935 } \ | |
| 5936 coding->charbuf_size = size; \ | |
| 5937 } while (0) | |
| 5938 | |
|
29725
2bc397e9b09a
(setup_coding_system) <4>: Reset member `cr_carryover'.
Kenichi Handa <handa@m17n.org>
parents:
29663
diff
changeset
|
5939 |
|
2bc397e9b09a
(setup_coding_system) <4>: Reset member `cr_carryover'.
Kenichi Handa <handa@m17n.org>
parents:
29663
diff
changeset
|
5940 static void |
|
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
5941 produce_annotation (coding, pos) |
|
29725
2bc397e9b09a
(setup_coding_system) <4>: Reset member `cr_carryover'.
Kenichi Handa <handa@m17n.org>
parents:
29663
diff
changeset
|
5942 struct coding_system *coding; |
|
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
5943 EMACS_INT pos; |
|
29725
2bc397e9b09a
(setup_coding_system) <4>: Reset member `cr_carryover'.
Kenichi Handa <handa@m17n.org>
parents:
29663
diff
changeset
|
5944 { |
| 88365 | 5945 int *charbuf = coding->charbuf; |
| 5946 int *charbuf_end = charbuf + coding->charbuf_used; | |
| 5947 | |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
5948 if (NILP (coding->dst_object)) |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
5949 return; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
5950 |
| 88365 | 5951 while (charbuf < charbuf_end) |
| 5952 { | |
| 5953 if (*charbuf >= 0) | |
|
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
5954 pos += *charbuf++; |
| 88365 | 5955 else |
|
29877
7b43e1fb478a
(decode_eol_post_ccl): Special handling for undecided
Eli Zaretskii <eliz@gnu.org>
parents:
29725
diff
changeset
|
5956 { |
| 88365 | 5957 int len = -*charbuf; |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
5958 switch (charbuf[1]) |
|
29725
2bc397e9b09a
(setup_coding_system) <4>: Reset member `cr_carryover'.
Kenichi Handa <handa@m17n.org>
parents:
29663
diff
changeset
|
5959 { |
| 88365 | 5960 case CODING_ANNOTATE_COMPOSITION_MASK: |
|
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
5961 produce_composition (coding, charbuf, pos); |
| 88365 | 5962 break; |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
5963 case CODING_ANNOTATE_CHARSET_MASK: |
|
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
5964 produce_charset (coding, charbuf, pos); |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
5965 break; |
| 88365 | 5966 default: |
| 5967 abort (); | |
|
29725
2bc397e9b09a
(setup_coding_system) <4>: Reset member `cr_carryover'.
Kenichi Handa <handa@m17n.org>
parents:
29663
diff
changeset
|
5968 } |
| 88365 | 5969 charbuf += len; |
|
29725
2bc397e9b09a
(setup_coding_system) <4>: Reset member `cr_carryover'.
Kenichi Handa <handa@m17n.org>
parents:
29663
diff
changeset
|
5970 } |
|
2bc397e9b09a
(setup_coding_system) <4>: Reset member `cr_carryover'.
Kenichi Handa <handa@m17n.org>
parents:
29663
diff
changeset
|
5971 } |
|
2bc397e9b09a
(setup_coding_system) <4>: Reset member `cr_carryover'.
Kenichi Handa <handa@m17n.org>
parents:
29663
diff
changeset
|
5972 } |
|
2bc397e9b09a
(setup_coding_system) <4>: Reset member `cr_carryover'.
Kenichi Handa <handa@m17n.org>
parents:
29663
diff
changeset
|
5973 |
| 88365 | 5974 /* Decode the data at CODING->src_object into CODING->dst_object. |
| 5975 CODING->src_object is a buffer, a string, or nil. | |
| 5976 CODING->dst_object is a buffer. | |
| 5977 | |
| 5978 If CODING->src_object is a buffer, it must be the current buffer. | |
| 5979 In this case, if CODING->src_pos is positive, it is a position of | |
| 5980 the source text in the buffer, otherwise, the source text is in the | |
| 5981 gap area of the buffer, and CODING->src_pos specifies the offset of | |
| 5982 the text from GPT (which must be the same as PT). If this is the | |
| 5983 same buffer as CODING->dst_object, CODING->src_pos must be | |
| 5984 negative. | |
| 5985 | |
| 5986 If CODING->src_object is a string, CODING->src_pos in an index to | |
| 5987 that string. | |
| 5988 | |
| 5989 If CODING->src_object is nil, CODING->source must already point to | |
| 5990 the non-relocatable memory area. In this case, CODING->src_pos is | |
| 5991 an offset from CODING->source. | |
| 5992 | |
| 5993 The decoded data is inserted at the current point of the buffer | |
| 5994 CODING->dst_object. | |
| 5995 */ | |
| 5996 | |
| 5997 static int | |
| 5998 decode_coding (coding) | |
|
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5999 struct coding_system *coding; |
|
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
6000 { |
| 88365 | 6001 Lisp_Object attrs; |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6002 Lisp_Object undo_list; |
|
89732
8acde12aba89
(get_translation_table): New function.
Kenichi Handa <handa@m17n.org>
parents:
89730
diff
changeset
|
6003 Lisp_Object translation_table; |
|
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
6004 int carryover; |
|
89859
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
6005 int max_lookup; |
|
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
6006 int i; |
| 88365 | 6007 |
| 6008 if (BUFFERP (coding->src_object) | |
| 6009 && coding->src_pos > 0 | |
| 6010 && coding->src_pos < GPT | |
| 6011 && coding->src_pos + coding->src_chars > GPT) | |
| 6012 move_gap_both (coding->src_pos, coding->src_pos_byte); | |
| 6013 | |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6014 undo_list = Qt; |
| 88365 | 6015 if (BUFFERP (coding->dst_object)) |
| 6016 { | |
| 6017 if (current_buffer != XBUFFER (coding->dst_object)) | |
| 6018 set_buffer_internal (XBUFFER (coding->dst_object)); | |
| 6019 if (GPT != PT) | |
| 6020 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
|
6021 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
|
6022 current_buffer->undo_list = Qt; |
| 88365 | 6023 } |
| 6024 | |
| 6025 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
|
6026 coding->produced = coding->produced_char = 0; |
| 88365 | 6027 coding->chars_at_source = 0; |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
6028 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
|
6029 coding->errors = 0; |
| 88365 | 6030 |
| 6031 ALLOC_CONVERSION_WORK_AREA (coding); | |
| 6032 | |
| 6033 attrs = CODING_ID_ATTRS (coding->id); | |
|
89859
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
6034 translation_table = get_translation_table (attrs, 0, &max_lookup); |
| 88365 | 6035 |
|
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
6036 carryover = 0; |
| 88365 | 6037 do |
| 6038 { | |
|
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
6039 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
|
6040 |
| 88365 | 6041 coding_set_source (coding); |
| 6042 coding->annotated = 0; | |
|
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
6043 coding->charbuf_used = carryover; |
| 88365 | 6044 (*(coding->decoder)) (coding); |
| 6045 coding_set_destination (coding); | |
|
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
6046 carryover = produce_chars (coding, translation_table, 0); |
| 88365 | 6047 if (coding->annotated) |
|
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
6048 produce_annotation (coding, pos); |
|
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
6049 for (i = 0; i < carryover; i++) |
|
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
6050 coding->charbuf[i] |
|
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
6051 = coding->charbuf[coding->charbuf_used - carryover + i]; |
| 88365 | 6052 } |
| 6053 while (coding->consumed < coding->src_bytes | |
| 6054 && ! coding->result); | |
| 6055 | |
|
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
6056 if (carryover > 0) |
|
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
6057 { |
|
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
6058 coding_set_destination (coding); |
|
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
6059 coding->charbuf_used = carryover; |
|
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
6060 produce_chars (coding, translation_table, 1); |
|
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
6061 } |
|
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
6062 |
| 88365 | 6063 coding->carryover_bytes = 0; |
| 6064 if (coding->consumed < coding->src_bytes) | |
| 6065 { | |
| 6066 int nbytes = coding->src_bytes - coding->consumed; | |
| 89483 | 6067 const unsigned char *src; |
| 88365 | 6068 |
| 6069 coding_set_source (coding); | |
| 6070 coding_set_destination (coding); | |
| 6071 src = coding->source + coding->consumed; | |
| 6072 | |
| 6073 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
|
6074 { |
| 88365 | 6075 /* Flush out unprocessed data as binary chars. We are sure |
| 6076 that the number of data is less than the size of | |
| 6077 coding->charbuf. */ | |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
6078 coding->charbuf_used = 0; |
| 88365 | 6079 while (nbytes-- > 0) |
| 6080 { | |
| 6081 int c = *src++; | |
|
89279
1fd77c471ee6
(decode_coding_utf_8): When eol_type is Qdos, handle
Kenichi Handa <handa@m17n.org>
parents:
89227
diff
changeset
|
6082 |
|
1fd77c471ee6
(decode_coding_utf_8): When eol_type is Qdos, handle
Kenichi Handa <handa@m17n.org>
parents:
89227
diff
changeset
|
6083 coding->charbuf[coding->charbuf_used++] = (c & 0x80 ? - c : c); |
| 88365 | 6084 } |
| 6085 produce_chars (coding); | |
|
29725
2bc397e9b09a
(setup_coding_system) <4>: Reset member `cr_carryover'.
Kenichi Handa <handa@m17n.org>
parents:
29663
diff
changeset
|
6086 } |
| 88365 | 6087 else |
|
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
6088 { |
| 88365 | 6089 /* Record unprocessed bytes in coding->carryover. We are |
| 6090 sure that the number of data is less than the size of | |
| 6091 coding->carryover. */ | |
| 6092 unsigned char *p = coding->carryover; | |
| 6093 | |
| 6094 coding->carryover_bytes = nbytes; | |
| 6095 while (nbytes-- > 0) | |
| 6096 *p++ = *src++; | |
|
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
6097 } |
| 88365 | 6098 coding->consumed = coding->src_bytes; |
| 6099 } | |
| 6100 | |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6101 if (BUFFERP (coding->dst_object)) |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6102 { |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6103 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
|
6104 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
|
6105 } |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6106 if (! EQ (CODING_ID_EOL_TYPE (coding->id), Qunix)) |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6107 decode_eol (coding); |
|
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
6108 return coding->result; |
|
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
6109 } |
|
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
6110 |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6111 |
|
89394
6ffca50f25b9
(Fcheck_coding_systems_region): Fix type errors.
Dave Love <fx@gnu.org>
parents:
89373
diff
changeset
|
6112 /* 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
|
6113 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
|
6114 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
|
6115 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
|
6116 next element of BUF. |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6117 |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6118 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
|
6119 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
|
6120 return BUF. */ |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6121 |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6122 static INLINE int * |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6123 handle_composition_annotation (pos, limit, coding, buf, stop) |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6124 EMACS_INT pos, limit; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6125 struct coding_system *coding; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6126 int *buf; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6127 EMACS_INT *stop; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6128 { |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6129 EMACS_INT start, end; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6130 Lisp_Object prop; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6131 |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6132 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
|
6133 || end > limit) |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6134 *stop = limit; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6135 else if (start > pos) |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6136 *stop = start; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6137 else |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6138 { |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6139 if (start == pos) |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6140 { |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6141 /* We found a composition. Store the corresponding |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6142 annotation data in BUF. */ |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6143 int *head = buf; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6144 enum composition_method method = COMPOSITION_METHOD (prop); |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6145 int nchars = COMPOSITION_LENGTH (prop); |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6146 |
|
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
6147 ADD_COMPOSITION_DATA (buf, nchars, method); |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6148 if (method != COMPOSITION_RELATIVE) |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6149 { |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6150 Lisp_Object components; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6151 int len, i, i_byte; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6152 |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6153 components = COMPOSITION_COMPONENTS (prop); |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6154 if (VECTORP (components)) |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6155 { |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6156 len = XVECTOR (components)->size; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6157 for (i = 0; i < len; i++) |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6158 *buf++ = XINT (AREF (components, i)); |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6159 } |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6160 else if (STRINGP (components)) |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6161 { |
| 89483 | 6162 len = SCHARS (components); |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6163 i = i_byte = 0; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6164 while (i < len) |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6165 { |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6166 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
|
6167 buf++; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6168 } |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6169 } |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6170 else if (INTEGERP (components)) |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6171 { |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6172 len = 1; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6173 *buf++ = XINT (components); |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6174 } |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6175 else if (CONSP (components)) |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6176 { |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6177 for (len = 0; CONSP (components); |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6178 len++, components = XCDR (components)) |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6179 *buf++ = XINT (XCAR (components)); |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6180 } |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6181 else |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6182 abort (); |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6183 *head -= len; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6184 } |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6185 } |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6186 |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6187 if (find_composition (end, limit, &start, &end, &prop, |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6188 coding->src_object) |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6189 && end <= limit) |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6190 *stop = start; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6191 else |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6192 *stop = limit; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6193 } |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6194 return buf; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6195 } |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6196 |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6197 |
|
89394
6ffca50f25b9
(Fcheck_coding_systems_region): Fix type errors.
Dave Love <fx@gnu.org>
parents:
89373
diff
changeset
|
6198 /* 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
|
6199 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
|
6200 *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
|
6201 (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
|
6202 BUF. |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6203 |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6204 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
|
6205 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
|
6206 |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6207 static INLINE int * |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6208 handle_charset_annotation (pos, limit, coding, buf, stop) |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6209 EMACS_INT pos, limit; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6210 struct coding_system *coding; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6211 int *buf; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6212 EMACS_INT *stop; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6213 { |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6214 Lisp_Object val, next; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6215 int id; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6216 |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6217 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
|
6218 if (! NILP (val) && CHARSETP (val)) |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6219 id = XINT (CHARSET_SYMBOL_ID (val)); |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6220 else |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6221 id = -1; |
|
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
6222 ADD_CHARSET_DATA (buf, 0, id); |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6223 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
|
6224 coding->src_object, |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6225 make_number (limit)); |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6226 *stop = XINT (next); |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6227 return buf; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6228 } |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6229 |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6230 |
| 88365 | 6231 static void |
|
89859
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
6232 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
|
6233 struct coding_system *coding; |
|
89856
18b52da60a76
(get_translation): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89852
diff
changeset
|
6234 Lisp_Object translation_table; |
|
89859
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
6235 int max_lookup; |
|
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
6236 { |
| 88365 | 6237 int *buf = coding->charbuf; |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6238 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
|
6239 const unsigned char *src = coding->source + coding->consumed; |
|
89442
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
6240 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
|
6241 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
|
6242 EMACS_INT end_pos = coding->src_pos + coding->src_chars; |
| 88365 | 6243 int multibytep = coding->src_multibyte; |
| 6244 Lisp_Object eol_type; | |
| 6245 int c; | |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6246 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
|
6247 int *lookup_buf = NULL; |
|
89856
18b52da60a76
(get_translation): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89852
diff
changeset
|
6248 |
|
18b52da60a76
(get_translation): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89852
diff
changeset
|
6249 if (! NILP (translation_table)) |
|
89859
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
6250 lookup_buf = alloca (sizeof (int) * max_lookup); |
| 88365 | 6251 |
| 6252 eol_type = CODING_ID_EOL_TYPE (coding->id); | |
| 6253 if (VECTORP (eol_type)) | |
| 6254 eol_type = Qunix; | |
| 6255 | |
| 6256 /* Note: composition handling is not yet implemented. */ | |
| 6257 coding->common_flags &= ~CODING_ANNOTATE_COMPOSITION_MASK; | |
| 6258 | |
|
89562
12fbcfebb9ad
(consume_chars): If coding->src_object is nil, don't check annotation.
Kenichi Handa <handa@m17n.org>
parents:
89545
diff
changeset
|
6259 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
|
6260 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
|
6261 else |
|
89562
12fbcfebb9ad
(consume_chars): If coding->src_object is nil, don't check annotation.
Kenichi Handa <handa@m17n.org>
parents:
89545
diff
changeset
|
6262 { |
|
12fbcfebb9ad
(consume_chars): If coding->src_object is nil, don't check annotation.
Kenichi Handa <handa@m17n.org>
parents:
89545
diff
changeset
|
6263 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
|
6264 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
|
6265 else |
|
12fbcfebb9ad
(consume_chars): If coding->src_object is nil, don't check annotation.
Kenichi Handa <handa@m17n.org>
parents:
89545
diff
changeset
|
6266 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
|
6267 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
|
6268 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
|
6269 else |
|
12fbcfebb9ad
(consume_chars): If coding->src_object is nil, don't check annotation.
Kenichi Handa <handa@m17n.org>
parents:
89545
diff
changeset
|
6270 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
|
6271 } |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6272 |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6273 /* Compensate for CRLF and conversion. */ |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6274 buf_end -= 1 + MAX_ANNOTATION_LENGTH; |
| 88365 | 6275 while (buf < buf_end) |
| 6276 { | |
|
89856
18b52da60a76
(get_translation): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89852
diff
changeset
|
6277 Lisp_Object trans; |
|
18b52da60a76
(get_translation): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89852
diff
changeset
|
6278 |
| 88365 | 6279 if (pos == stop) |
|
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
6280 { |
| 88365 | 6281 if (pos == end_pos) |
| 6282 break; | |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6283 if (pos == stop_composition) |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6284 buf = handle_composition_annotation (pos, end_pos, coding, |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6285 buf, &stop_composition); |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6286 if (pos == stop_charset) |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6287 buf = handle_charset_annotation (pos, end_pos, coding, |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6288 buf, &stop_charset); |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6289 stop = (stop_composition < stop_charset |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6290 ? stop_composition : stop_charset); |
| 88365 | 6291 } |
| 6292 | |
| 6293 if (! multibytep) | |
|
89442
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
6294 { |
|
89462
4e359ebf3984
(decode_coding_iso_2022): Fix handling of invalid
Kenichi Handa <handa@m17n.org>
parents:
89448
diff
changeset
|
6295 EMACS_INT bytes; |
|
4e359ebf3984
(decode_coding_iso_2022): Fix handling of invalid
Kenichi Handa <handa@m17n.org>
parents:
89448
diff
changeset
|
6296 |
|
4e359ebf3984
(decode_coding_iso_2022): Fix handling of invalid
Kenichi Handa <handa@m17n.org>
parents:
89448
diff
changeset
|
6297 if (! CODING_FOR_UNIBYTE (coding) |
|
4e359ebf3984
(decode_coding_iso_2022): Fix handling of invalid
Kenichi Handa <handa@m17n.org>
parents:
89448
diff
changeset
|
6298 && (bytes = MULTIBYTE_LENGTH (src, src_end)) > 0) |
|
89442
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
6299 c = STRING_CHAR_ADVANCE (src), pos += bytes; |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
6300 else |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
6301 c = *src++, pos++; |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
6302 } |
| 88365 | 6303 else |
|
89442
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
6304 c = STRING_CHAR_ADVANCE (src), pos++; |
| 88365 | 6305 if ((c == '\r') && (coding->mode & CODING_MODE_SELECTIVE_DISPLAY)) |
| 6306 c = '\n'; | |
| 6307 if (! EQ (eol_type, Qunix)) | |
| 6308 { | |
| 6309 if (c == '\n') | |
| 6310 { | |
| 6311 if (EQ (eol_type, Qdos)) | |
| 6312 *buf++ = '\r'; | |
| 6313 else | |
| 6314 c = '\r'; | |
| 6315 } | |
|
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
6316 } |
|
89856
18b52da60a76
(get_translation): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89852
diff
changeset
|
6317 |
|
89858
23cb9ed79225
(get_translation_table): Declare it as Lisp_Object.
Kenichi Handa <handa@m17n.org>
parents:
89856
diff
changeset
|
6318 trans = Qnil; |
|
89859
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
6319 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
|
6320 if (NILP (trans)) |
|
89856
18b52da60a76
(get_translation): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89852
diff
changeset
|
6321 *buf++ = c; |
|
18b52da60a76
(get_translation): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89852
diff
changeset
|
6322 else |
|
18b52da60a76
(get_translation): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89852
diff
changeset
|
6323 { |
|
18b52da60a76
(get_translation): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89852
diff
changeset
|
6324 int from_nchars = 1, to_nchars = 1; |
|
18b52da60a76
(get_translation): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89852
diff
changeset
|
6325 int *lookup_buf_end; |
|
18b52da60a76
(get_translation): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89852
diff
changeset
|
6326 const unsigned char *p = src; |
|
18b52da60a76
(get_translation): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89852
diff
changeset
|
6327 int i; |
|
18b52da60a76
(get_translation): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89852
diff
changeset
|
6328 |
|
18b52da60a76
(get_translation): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89852
diff
changeset
|
6329 lookup_buf[0] = c; |
|
18b52da60a76
(get_translation): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89852
diff
changeset
|
6330 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
|
6331 lookup_buf[i] = STRING_CHAR_ADVANCE (p); |
|
18b52da60a76
(get_translation): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89852
diff
changeset
|
6332 lookup_buf_end = lookup_buf + i; |
|
18b52da60a76
(get_translation): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89852
diff
changeset
|
6333 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
|
6334 &from_nchars, &to_nchars); |
|
18b52da60a76
(get_translation): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89852
diff
changeset
|
6335 if (EQ (trans, Qt) |
|
18b52da60a76
(get_translation): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89852
diff
changeset
|
6336 || buf + to_nchars > buf_end) |
|
18b52da60a76
(get_translation): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89852
diff
changeset
|
6337 break; |
|
18b52da60a76
(get_translation): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89852
diff
changeset
|
6338 *buf++ = *lookup_buf; |
|
18b52da60a76
(get_translation): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89852
diff
changeset
|
6339 for (i = 1; i < to_nchars; i++) |
|
18b52da60a76
(get_translation): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89852
diff
changeset
|
6340 *buf++ = XINT (AREF (trans, i)); |
|
18b52da60a76
(get_translation): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89852
diff
changeset
|
6341 for (i = 1; i < from_nchars; i++, pos++) |
|
18b52da60a76
(get_translation): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89852
diff
changeset
|
6342 src += MULTIBYTE_LENGTH_NO_CHECK (src); |
|
18b52da60a76
(get_translation): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89852
diff
changeset
|
6343 } |
| 88365 | 6344 } |
| 6345 | |
| 6346 coding->consumed = src - coding->source; | |
| 6347 coding->consumed_char = pos - coding->src_pos; | |
| 6348 coding->charbuf_used = buf - coding->charbuf; | |
| 6349 coding->chars_at_source = 0; | |
|
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
6350 } |
|
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
6351 |
| 88365 | 6352 |
| 6353 /* Encode the text at CODING->src_object into CODING->dst_object. | |
| 6354 CODING->src_object is a buffer or a string. | |
| 6355 CODING->dst_object is a buffer or nil. | |
| 6356 | |
| 6357 If CODING->src_object is a buffer, it must be the current buffer. | |
| 6358 In this case, if CODING->src_pos is positive, it is a position of | |
| 6359 the source text in the buffer, otherwise. the source text is in the | |
| 6360 gap area of the buffer, and coding->src_pos specifies the offset of | |
| 6361 the text from GPT (which must be the same as PT). If this is the | |
| 6362 same buffer as CODING->dst_object, CODING->src_pos must be | |
| 6363 negative and CODING should not have `pre-write-conversion'. | |
| 6364 | |
| 6365 If CODING->src_object is a string, CODING should not have | |
| 6366 `pre-write-conversion'. | |
| 6367 | |
| 6368 If CODING->dst_object is a buffer, the encoded data is inserted at | |
| 6369 the current point of that buffer. | |
| 6370 | |
| 6371 If CODING->dst_object is nil, the encoded data is placed at the | |
| 6372 memory area specified by CODING->destination. */ | |
| 6373 | |
| 6374 static int | |
| 6375 encode_coding (coding) | |
|
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
6376 struct coding_system *coding; |
|
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
6377 { |
| 88365 | 6378 Lisp_Object attrs; |
|
89732
8acde12aba89
(get_translation_table): New function.
Kenichi Handa <handa@m17n.org>
parents:
89730
diff
changeset
|
6379 Lisp_Object translation_table; |
|
89859
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
6380 int max_lookup; |
| 88365 | 6381 |
| 6382 attrs = CODING_ID_ATTRS (coding->id); | |
|
89859
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
6383 translation_table = get_translation_table (attrs, 1, &max_lookup); |
| 88365 | 6384 |
| 6385 if (BUFFERP (coding->dst_object)) | |
| 6386 { | |
| 6387 set_buffer_internal (XBUFFER (coding->dst_object)); | |
| 6388 coding->dst_multibyte | |
| 6389 = ! NILP (current_buffer->enable_multibyte_characters); | |
| 6390 } | |
| 6391 | |
| 6392 coding->consumed = coding->consumed_char = 0; | |
| 6393 coding->produced = coding->produced_char = 0; | |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
6394 record_conversion_result (coding, CODING_RESULT_SUCCESS); |
| 88365 | 6395 coding->errors = 0; |
| 6396 | |
| 6397 ALLOC_CONVERSION_WORK_AREA (coding); | |
| 6398 | |
| 6399 do { | |
| 6400 coding_set_source (coding); | |
|
89859
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
6401 consume_chars (coding, translation_table, max_lookup); |
| 88365 | 6402 coding_set_destination (coding); |
| 6403 (*(coding->encoder)) (coding); | |
| 6404 } while (coding->consumed_char < coding->src_chars); | |
| 6405 | |
| 6406 if (BUFFERP (coding->dst_object)) | |
| 6407 insert_from_gap (coding->produced_char, coding->produced); | |
| 6408 | |
| 6409 return (coding->result); | |
| 6410 } | |
| 6411 | |
|
89442
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
6412 |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6413 /* 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
|
6414 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
|
6415 |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6416 /* 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
|
6417 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
|
6418 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
|
6419 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
|
6420 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
|
6421 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
|
6422 |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6423 /* 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
|
6424 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
|
6425 |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6426 |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6427 /* 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
|
6428 multibyteness of returning buffer. */ |
| 88365 | 6429 |
| 6430 Lisp_Object | |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6431 make_conversion_work_buffer (multibyte) |
| 88365 | 6432 { |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6433 Lisp_Object name, workbuf; |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6434 struct buffer *current; |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6435 |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6436 if (reused_workbuf_in_use++) |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
6437 { |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
6438 name = Fgenerate_new_buffer_name (Vcode_conversion_workbuf_name, Qnil); |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
6439 workbuf = Fget_buffer_create (name); |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
6440 } |
|
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
6441 else |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
6442 { |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
6443 name = Vcode_conversion_workbuf_name; |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
6444 workbuf = Fget_buffer_create (name); |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
6445 if (NILP (Vcode_conversion_reused_workbuf)) |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
6446 Vcode_conversion_reused_workbuf = workbuf; |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
6447 } |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6448 current = current_buffer; |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6449 set_buffer_internal (XBUFFER (workbuf)); |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6450 Ferase_buffer (); |
| 88365 | 6451 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
|
6452 current_buffer->enable_multibyte_characters = multibyte ? Qt : Qnil; |
| 88365 | 6453 set_buffer_internal (current); |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6454 return workbuf; |
|
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
6455 } |
|
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
6456 |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6457 |
|
89442
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
6458 static Lisp_Object |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6459 code_conversion_restore (arg) |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6460 Lisp_Object arg; |
|
26067
f54ca66e2571
(code_convert_string): Add record_unwind_protect to
Kenichi Handa <handa@m17n.org>
parents:
25860
diff
changeset
|
6461 { |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6462 Lisp_Object current, workbuf; |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6463 |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6464 current = XCAR (arg); |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6465 workbuf = XCDR (arg); |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6466 if (! NILP (workbuf)) |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6467 { |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6468 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
|
6469 reused_workbuf_in_use = 0; |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6470 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
|
6471 Fkill_buffer (workbuf); |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6472 } |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6473 set_buffer_internal (XBUFFER (current)); |
|
89442
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
6474 return Qnil; |
|
26067
f54ca66e2571
(code_convert_string): Add record_unwind_protect to
Kenichi Handa <handa@m17n.org>
parents:
25860
diff
changeset
|
6475 } |
|
f54ca66e2571
(code_convert_string): Add record_unwind_protect to
Kenichi Handa <handa@m17n.org>
parents:
25860
diff
changeset
|
6476 |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6477 Lisp_Object |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6478 code_conversion_save (with_work_buf, multibyte) |
|
89442
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
6479 int with_work_buf, multibyte; |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
6480 { |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6481 Lisp_Object workbuf = Qnil; |
|
89442
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
6482 |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
6483 if (with_work_buf) |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6484 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
|
6485 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
|
6486 Fcons (Fcurrent_buffer (), workbuf)); |
|
89442
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
6487 return workbuf; |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
6488 } |
| 88365 | 6489 |
| 6490 int | |
| 6491 decode_coding_gap (coding, chars, bytes) | |
| 26847 | 6492 struct coding_system *coding; |
| 88365 | 6493 EMACS_INT chars, bytes; |
| 6494 { | |
| 6495 int count = specpdl_ptr - specpdl; | |
|
89448
de8b460070cc
(setup_coding_system): If coding has
Kenichi Handa <handa@m17n.org>
parents:
89446
diff
changeset
|
6496 Lisp_Object attrs; |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6497 |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6498 code_conversion_save (0, 0); |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6499 |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6500 coding->src_object = Fcurrent_buffer (); |
| 88365 | 6501 coding->src_chars = chars; |
| 6502 coding->src_bytes = bytes; | |
| 6503 coding->src_pos = -chars; | |
| 6504 coding->src_pos_byte = -bytes; | |
| 6505 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
|
6506 coding->dst_object = coding->src_object; |
| 88365 | 6507 coding->dst_pos = PT; |
| 6508 coding->dst_pos_byte = PT_BYTE; | |
|
88443
6b86cf30a0b9
(produce_chars): Set the variable `multibytep' correctly.
Kenichi Handa <handa@m17n.org>
parents:
88438
diff
changeset
|
6509 coding->dst_multibyte = ! NILP (current_buffer->enable_multibyte_characters); |
|
89279
1fd77c471ee6
(decode_coding_utf_8): When eol_type is Qdos, handle
Kenichi Handa <handa@m17n.org>
parents:
89227
diff
changeset
|
6510 coding->mode |= CODING_MODE_LAST_BLOCK; |
| 88365 | 6511 |
| 6512 if (CODING_REQUIRE_DETECTION (coding)) | |
| 6513 detect_coding (coding); | |
| 89483 | 6514 |
| 88365 | 6515 decode_coding (coding); |
| 6516 | |
|
89448
de8b460070cc
(setup_coding_system): If coding has
Kenichi Handa <handa@m17n.org>
parents:
89446
diff
changeset
|
6517 attrs = CODING_ID_ATTRS (coding->id); |
|
de8b460070cc
(setup_coding_system): If coding has
Kenichi Handa <handa@m17n.org>
parents:
89446
diff
changeset
|
6518 if (! NILP (CODING_ATTR_POST_READ (attrs))) |
|
de8b460070cc
(setup_coding_system): If coding has
Kenichi Handa <handa@m17n.org>
parents:
89446
diff
changeset
|
6519 { |
|
de8b460070cc
(setup_coding_system): If coding has
Kenichi Handa <handa@m17n.org>
parents:
89446
diff
changeset
|
6520 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
|
6521 Lisp_Object val; |
|
de8b460070cc
(setup_coding_system): If coding has
Kenichi Handa <handa@m17n.org>
parents:
89446
diff
changeset
|
6522 |
|
de8b460070cc
(setup_coding_system): If coding has
Kenichi Handa <handa@m17n.org>
parents:
89446
diff
changeset
|
6523 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
|
6524 val = call1 (CODING_ATTR_POST_READ (attrs), |
|
de8b460070cc
(setup_coding_system): If coding has
Kenichi Handa <handa@m17n.org>
parents:
89446
diff
changeset
|
6525 make_number (coding->produced_char)); |
|
de8b460070cc
(setup_coding_system): If coding has
Kenichi Handa <handa@m17n.org>
parents:
89446
diff
changeset
|
6526 CHECK_NATNUM (val); |
|
de8b460070cc
(setup_coding_system): If coding has
Kenichi Handa <handa@m17n.org>
parents:
89446
diff
changeset
|
6527 coding->produced_char += Z - prev_Z; |
|
de8b460070cc
(setup_coding_system): If coding has
Kenichi Handa <handa@m17n.org>
parents:
89446
diff
changeset
|
6528 coding->produced += Z_BYTE - prev_Z_BYTE; |
|
de8b460070cc
(setup_coding_system): If coding has
Kenichi Handa <handa@m17n.org>
parents:
89446
diff
changeset
|
6529 } |
|
de8b460070cc
(setup_coding_system): If coding has
Kenichi Handa <handa@m17n.org>
parents:
89446
diff
changeset
|
6530 |
| 88365 | 6531 unbind_to (count, Qnil); |
| 6532 return coding->result; | |
| 6533 } | |
| 6534 | |
| 6535 int | |
| 6536 encode_coding_gap (coding, chars, bytes) | |
| 6537 struct coding_system *coding; | |
| 6538 EMACS_INT chars, bytes; | |
| 26847 | 6539 { |
| 88365 | 6540 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
|
6541 |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6542 code_conversion_save (0, 0); |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6543 |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6544 coding->src_object = Fcurrent_buffer (); |
| 88365 | 6545 coding->src_chars = chars; |
| 6546 coding->src_bytes = bytes; | |
| 6547 coding->src_pos = -chars; | |
| 6548 coding->src_pos_byte = -bytes; | |
| 6549 coding->src_multibyte = chars < bytes; | |
| 6550 coding->dst_object = coding->src_object; | |
| 6551 coding->dst_pos = PT; | |
| 6552 coding->dst_pos_byte = PT_BYTE; | |
| 6553 | |
| 6554 encode_coding (coding); | |
| 6555 | |
| 6556 unbind_to (count, Qnil); | |
| 6557 return coding->result; | |
| 26847 | 6558 } |
| 6559 | |
| 88365 | 6560 |
| 6561 /* Decode the text in the range FROM/FROM_BYTE and TO/TO_BYTE in | |
| 6562 SRC_OBJECT into DST_OBJECT by coding context CODING. | |
| 6563 | |
| 6564 SRC_OBJECT is a buffer, a string, or Qnil. | |
| 6565 | |
| 6566 If it is a buffer, the text is at point of the buffer. FROM and TO | |
| 6567 are positions in the buffer. | |
| 6568 | |
| 6569 If it is a string, the text is at the beginning of the string. | |
| 6570 FROM and TO are indices to the string. | |
| 6571 | |
| 6572 If it is nil, the text is at coding->source. FROM and TO are | |
| 6573 indices to coding->source. | |
| 6574 | |
| 6575 DST_OBJECT is a buffer, Qt, or Qnil. | |
| 6576 | |
| 6577 If it is a buffer, the decoded text is inserted at point of the | |
| 6578 buffer. If the buffer is the same as SRC_OBJECT, the source text | |
| 6579 is deleted. | |
| 6580 | |
| 6581 If it is Qt, a string is made from the decoded text, and | |
| 6582 set in CODING->dst_object. | |
| 6583 | |
| 6584 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
|
6585 The caller must allocate CODING->dst_bytes bytes at |
| 88365 | 6586 CODING->destination by xmalloc. If the decoded text is longer than |
| 6587 CODING->dst_bytes, CODING->destination is relocated by xrealloc. | |
| 6588 */ | |
| 26847 | 6589 |
|
29275
b4ea9178e480
(DECODE_COMPOSITION_START): If coding->cmp_data is not
Kenichi Handa <handa@m17n.org>
parents:
29247
diff
changeset
|
6590 void |
| 88365 | 6591 decode_coding_object (coding, src_object, from, from_byte, to, to_byte, |
| 6592 dst_object) | |
| 26847 | 6593 struct coding_system *coding; |
| 88365 | 6594 Lisp_Object src_object; |
| 6595 EMACS_INT from, from_byte, to, to_byte; | |
| 6596 Lisp_Object dst_object; | |
| 26847 | 6597 { |
| 88365 | 6598 int count = specpdl_ptr - specpdl; |
| 6599 unsigned char *destination; | |
| 6600 EMACS_INT dst_bytes; | |
| 6601 EMACS_INT chars = to - from; | |
| 6602 EMACS_INT bytes = to_byte - from_byte; | |
| 6603 Lisp_Object attrs; | |
|
89442
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
6604 Lisp_Object buffer; |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
6605 int saved_pt = -1, saved_pt_byte; |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
6606 |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
6607 buffer = Fcurrent_buffer (); |
| 88365 | 6608 |
| 6609 if (NILP (dst_object)) | |
| 6610 { | |
| 6611 destination = coding->destination; | |
| 6612 dst_bytes = coding->dst_bytes; | |
| 6613 } | |
| 6614 | |
| 6615 coding->src_object = src_object; | |
| 6616 coding->src_chars = chars; | |
| 6617 coding->src_bytes = bytes; | |
| 6618 coding->src_multibyte = chars < bytes; | |
| 6619 | |
| 6620 if (STRINGP (src_object)) | |
| 6621 { | |
| 6622 coding->src_pos = from; | |
| 6623 coding->src_pos_byte = from_byte; | |
| 6624 } | |
| 6625 else if (BUFFERP (src_object)) | |
| 6626 { | |
| 6627 set_buffer_internal (XBUFFER (src_object)); | |
| 6628 if (from != GPT) | |
| 6629 move_gap_both (from, from_byte); | |
| 6630 if (EQ (src_object, dst_object)) | |
| 26847 | 6631 { |
|
89442
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
6632 saved_pt = PT, saved_pt_byte = PT_BYTE; |
| 88365 | 6633 TEMP_SET_PT_BOTH (from, from_byte); |
| 6634 del_range_both (from, from_byte, to, to_byte, 1); | |
| 6635 coding->src_pos = -chars; | |
| 6636 coding->src_pos_byte = -bytes; | |
|
20931
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
6637 } |
|
42661
e85e4d9494b1
(code_convert_region): Don't copy old text if undo disabled.
Richard M. Stallman <rms@gnu.org>
parents:
42105
diff
changeset
|
6638 else |
|
e85e4d9494b1
(code_convert_region): Don't copy old text if undo disabled.
Richard M. Stallman <rms@gnu.org>
parents:
42105
diff
changeset
|
6639 { |
| 88365 | 6640 coding->src_pos = from; |
| 6641 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
|
6642 } |
| 88365 | 6643 } |
| 6644 | |
| 6645 if (CODING_REQUIRE_DETECTION (coding)) | |
| 6646 detect_coding (coding); | |
| 6647 attrs = CODING_ID_ATTRS (coding->id); | |
| 6648 | |
|
89418
a9c2b3712863
(coding_set_source): Fix for the case that the current
Kenichi Handa <handa@m17n.org>
parents:
89404
diff
changeset
|
6649 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
|
6650 || (! 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
|
6651 && NILP (dst_object))) |
| 88365 | 6652 { |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6653 coding->dst_object = code_conversion_save (1, 1); |
| 88365 | 6654 coding->dst_pos = BEG; |
| 6655 coding->dst_pos_byte = BEG_BYTE; | |
| 6656 coding->dst_multibyte = 1; | |
| 6657 } | |
| 6658 else if (BUFFERP (dst_object)) | |
| 6659 { | |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6660 code_conversion_save (0, 0); |
| 88365 | 6661 coding->dst_object = dst_object; |
| 6662 coding->dst_pos = BUF_PT (XBUFFER (dst_object)); | |
| 6663 coding->dst_pos_byte = BUF_PT_BYTE (XBUFFER (dst_object)); | |
| 6664 coding->dst_multibyte | |
| 6665 = ! NILP (XBUFFER (dst_object)->enable_multibyte_characters); | |
| 6666 } | |
| 6667 else | |
| 6668 { | |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6669 code_conversion_save (0, 0); |
| 88365 | 6670 coding->dst_object = Qnil; |
| 6671 coding->dst_multibyte = 1; | |
| 6672 } | |
| 6673 | |
| 6674 decode_coding (coding); | |
| 6675 | |
| 6676 if (BUFFERP (coding->dst_object)) | |
| 6677 set_buffer_internal (XBUFFER (coding->dst_object)); | |
| 6678 | |
| 6679 if (! NILP (CODING_ATTR_POST_READ (attrs))) | |
| 6680 { | |
| 6681 struct gcpro gcpro1, gcpro2; | |
| 6682 EMACS_INT prev_Z = Z, prev_Z_BYTE = Z_BYTE; | |
| 6683 Lisp_Object val; | |
| 6684 | |
|
88506
a7f0d13affa5
(decode_coding_object): Move point to coding->dst_pos before
Kenichi Handa <handa@m17n.org>
parents:
88497
diff
changeset
|
6685 TEMP_SET_PT_BOTH (coding->dst_pos, coding->dst_pos_byte); |
| 88365 | 6686 GCPRO2 (coding->src_object, coding->dst_object); |
| 6687 val = call1 (CODING_ATTR_POST_READ (attrs), | |
| 6688 make_number (coding->produced_char)); | |
| 6689 UNGCPRO; | |
| 6690 CHECK_NATNUM (val); | |
| 6691 coding->produced_char += Z - prev_Z; | |
| 6692 coding->produced += Z_BYTE - prev_Z_BYTE; | |
| 6693 } | |
| 6694 | |
| 6695 if (EQ (dst_object, Qt)) | |
| 6696 { | |
| 6697 coding->dst_object = Fbuffer_string (); | |
| 6698 } | |
| 6699 else if (NILP (dst_object) && BUFFERP (coding->dst_object)) | |
| 6700 { | |
| 6701 set_buffer_internal (XBUFFER (coding->dst_object)); | |
| 6702 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
|
6703 { |
| 88365 | 6704 destination |
| 6705 = (unsigned char *) xrealloc (destination, coding->produced); | |
| 6706 if (! destination) | |
|
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
6707 { |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
6708 record_conversion_result (coding, |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
6709 CODING_RESULT_INSUFFICIENT_DST); |
| 88365 | 6710 unbind_to (count, Qnil); |
| 6711 return; | |
|
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
6712 } |
| 88365 | 6713 if (BEGV < GPT && GPT < BEGV + coding->produced_char) |
| 6714 move_gap_both (BEGV, BEGV_BYTE); | |
| 6715 bcopy (BEGV_ADDR, destination, coding->produced); | |
| 6716 coding->destination = destination; | |
|
23279
ca159e828a68
(ccl_coding_driver): If ccl_driver is interrupted by a
Kenichi Handa <handa@m17n.org>
parents:
23258
diff
changeset
|
6717 } |
| 88365 | 6718 } |
| 6719 | |
|
89442
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
6720 if (saved_pt >= 0) |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
6721 { |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
6722 /* This is the case of: |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
6723 (BUFFERP (src_object) && EQ (src_object, dst_object)) |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
6724 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
|
6725 contents, we must recover it now. */ |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
6726 set_buffer_internal (XBUFFER (src_object)); |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
6727 if (saved_pt < from) |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
6728 TEMP_SET_PT_BOTH (saved_pt, saved_pt_byte); |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
6729 else if (saved_pt < from + chars) |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
6730 TEMP_SET_PT_BOTH (from, from_byte); |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
6731 else if (! NILP (current_buffer->enable_multibyte_characters)) |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
6732 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
|
6733 saved_pt_byte + (coding->produced - bytes)); |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
6734 else |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
6735 TEMP_SET_PT_BOTH (saved_pt + (coding->produced - bytes), |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
6736 saved_pt_byte + (coding->produced - bytes)); |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
6737 } |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
6738 |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
6739 unbind_to (count, coding->dst_object); |
| 88365 | 6740 } |
| 6741 | |
| 6742 | |
| 6743 void | |
| 6744 encode_coding_object (coding, src_object, from, from_byte, to, to_byte, | |
| 6745 dst_object) | |
| 6746 struct coding_system *coding; | |
| 6747 Lisp_Object src_object; | |
| 6748 EMACS_INT from, from_byte, to, to_byte; | |
| 6749 Lisp_Object dst_object; | |
| 6750 { | |
| 6751 int count = specpdl_ptr - specpdl; | |
| 6752 EMACS_INT chars = to - from; | |
| 6753 EMACS_INT bytes = to_byte - from_byte; | |
| 6754 Lisp_Object attrs; | |
|
89442
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
6755 Lisp_Object buffer; |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
6756 int saved_pt = -1, saved_pt_byte; |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
6757 |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
6758 buffer = Fcurrent_buffer (); |
| 88365 | 6759 |
| 6760 coding->src_object = src_object; | |
| 6761 coding->src_chars = chars; | |
| 6762 coding->src_bytes = bytes; | |
| 6763 coding->src_multibyte = chars < bytes; | |
| 6764 | |
| 6765 attrs = CODING_ID_ATTRS (coding->id); | |
| 6766 | |
| 6767 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
|
6768 { |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6769 coding->src_object = code_conversion_save (1, coding->src_multibyte); |
| 88365 | 6770 set_buffer_internal (XBUFFER (coding->src_object)); |
| 6771 if (STRINGP (src_object)) | |
| 6772 insert_from_string (src_object, from, from_byte, chars, bytes, 0); | |
| 6773 else if (BUFFERP (src_object)) | |
| 6774 insert_from_buffer (XBUFFER (src_object), from, chars, 0); | |
| 6775 else | |
| 6776 insert_1_both (coding->source + from, chars, bytes, 0, 0, 0); | |
| 6777 | |
| 6778 if (EQ (src_object, dst_object)) | |
| 6779 { | |
| 6780 set_buffer_internal (XBUFFER (src_object)); | |
|
89442
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
6781 saved_pt = PT, saved_pt_byte = PT_BYTE; |
| 88365 | 6782 del_range_both (from, from_byte, to, to_byte, 1); |
| 6783 set_buffer_internal (XBUFFER (coding->src_object)); | |
| 6784 } | |
| 6785 | |
|
88510
d266b8fb8761
(encode_coding_object): Give correct arguments ot
Kenichi Handa <handa@m17n.org>
parents:
88506
diff
changeset
|
6786 call2 (CODING_ATTR_PRE_WRITE (attrs), |
|
d266b8fb8761
(encode_coding_object): Give correct arguments ot
Kenichi Handa <handa@m17n.org>
parents:
88506
diff
changeset
|
6787 make_number (BEG), make_number (Z)); |
|
d266b8fb8761
(encode_coding_object): Give correct arguments ot
Kenichi Handa <handa@m17n.org>
parents:
88506
diff
changeset
|
6788 coding->src_object = Fcurrent_buffer (); |
| 88365 | 6789 if (BEG != GPT) |
| 6790 move_gap_both (BEG, BEG_BYTE); | |
| 6791 coding->src_chars = Z - BEG; | |
| 6792 coding->src_bytes = Z_BYTE - BEG_BYTE; | |
| 6793 coding->src_pos = BEG; | |
| 6794 coding->src_pos_byte = BEG_BYTE; | |
| 6795 coding->src_multibyte = Z < Z_BYTE; | |
| 6796 } | |
| 6797 else if (STRINGP (src_object)) | |
| 6798 { | |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6799 code_conversion_save (0, 0); |
| 88365 | 6800 coding->src_pos = from; |
| 6801 coding->src_pos_byte = from_byte; | |
| 6802 } | |
| 6803 else if (BUFFERP (src_object)) | |
| 6804 { | |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6805 code_conversion_save (0, 0); |
| 88365 | 6806 set_buffer_internal (XBUFFER (src_object)); |
| 6807 if (EQ (src_object, dst_object)) | |
| 6808 { | |
|
89442
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
6809 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
|
6810 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
|
6811 coding->src_pos = 0; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6812 coding->src_pos_byte = 0; |
| 88365 | 6813 } |
|
23514
7bad909cd6f1
(setup_coding_system): Fix setting up
Kenichi Handa <handa@m17n.org>
parents:
23475
diff
changeset
|
6814 else |
| 88365 | 6815 { |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6816 if (from < GPT && to >= GPT) |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6817 move_gap_both (from, from_byte); |
| 88365 | 6818 coding->src_pos = from; |
| 6819 coding->src_pos_byte = from_byte; | |
| 6820 } | |
| 6821 } | |
|
89442
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
6822 else |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6823 code_conversion_save (0, 0); |
| 88365 | 6824 |
| 6825 if (BUFFERP (dst_object)) | |
| 6826 { | |
| 6827 coding->dst_object = dst_object; | |
|
89042
2b9f8973f240
(coding_set_destination): Fix coding->destination for
Kenichi Handa <handa@m17n.org>
parents:
88977
diff
changeset
|
6828 if (EQ (src_object, dst_object)) |
|
2b9f8973f240
(coding_set_destination): Fix coding->destination for
Kenichi Handa <handa@m17n.org>
parents:
88977
diff
changeset
|
6829 { |
|
2b9f8973f240
(coding_set_destination): Fix coding->destination for
Kenichi Handa <handa@m17n.org>
parents:
88977
diff
changeset
|
6830 coding->dst_pos = from; |
|
2b9f8973f240
(coding_set_destination): Fix coding->destination for
Kenichi Handa <handa@m17n.org>
parents:
88977
diff
changeset
|
6831 coding->dst_pos_byte = from_byte; |
|
2b9f8973f240
(coding_set_destination): Fix coding->destination for
Kenichi Handa <handa@m17n.org>
parents:
88977
diff
changeset
|
6832 } |
|
2b9f8973f240
(coding_set_destination): Fix coding->destination for
Kenichi Handa <handa@m17n.org>
parents:
88977
diff
changeset
|
6833 else |
|
2b9f8973f240
(coding_set_destination): Fix coding->destination for
Kenichi Handa <handa@m17n.org>
parents:
88977
diff
changeset
|
6834 { |
|
2b9f8973f240
(coding_set_destination): Fix coding->destination for
Kenichi Handa <handa@m17n.org>
parents:
88977
diff
changeset
|
6835 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
|
6836 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
|
6837 } |
| 88365 | 6838 coding->dst_multibyte |
| 6839 = ! NILP (XBUFFER (dst_object)->enable_multibyte_characters); | |
| 6840 } | |
| 6841 else if (EQ (dst_object, Qt)) | |
| 6842 { | |
| 6843 coding->dst_object = Qnil; | |
| 6844 coding->dst_bytes = coding->src_chars; | |
|
88510
d266b8fb8761
(encode_coding_object): Give correct arguments ot
Kenichi Handa <handa@m17n.org>
parents:
88506
diff
changeset
|
6845 if (coding->dst_bytes == 0) |
|
d266b8fb8761
(encode_coding_object): Give correct arguments ot
Kenichi Handa <handa@m17n.org>
parents:
88506
diff
changeset
|
6846 coding->dst_bytes = 1; |
|
d266b8fb8761
(encode_coding_object): Give correct arguments ot
Kenichi Handa <handa@m17n.org>
parents:
88506
diff
changeset
|
6847 coding->destination = (unsigned char *) xmalloc (coding->dst_bytes); |
| 88365 | 6848 coding->dst_multibyte = 0; |
| 6849 } | |
| 6850 else | |
| 6851 { | |
| 6852 coding->dst_object = Qnil; | |
| 6853 coding->dst_multibyte = 0; | |
| 6854 } | |
| 6855 | |
| 6856 encode_coding (coding); | |
| 6857 | |
| 6858 if (EQ (dst_object, Qt)) | |
| 6859 { | |
| 6860 if (BUFFERP (coding->dst_object)) | |
| 6861 coding->dst_object = Fbuffer_string (); | |
| 6862 else | |
| 6863 { | |
| 6864 coding->dst_object | |
| 6865 = make_unibyte_string ((char *) coding->destination, | |
| 6866 coding->produced); | |
| 6867 xfree (coding->destination); | |
| 6868 } | |
| 6869 } | |
| 6870 | |
|
89442
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
6871 if (saved_pt >= 0) |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
6872 { |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
6873 /* This is the case of: |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
6874 (BUFFERP (src_object) && EQ (src_object, dst_object)) |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
6875 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
|
6876 contents, we must recover it now. */ |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
6877 set_buffer_internal (XBUFFER (src_object)); |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
6878 if (saved_pt < from) |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
6879 TEMP_SET_PT_BOTH (saved_pt, saved_pt_byte); |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
6880 else if (saved_pt < from + chars) |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
6881 TEMP_SET_PT_BOTH (from, from_byte); |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
6882 else if (! NILP (current_buffer->enable_multibyte_characters)) |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
6883 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
|
6884 saved_pt_byte + (coding->produced - bytes)); |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
6885 else |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
6886 TEMP_SET_PT_BOTH (saved_pt + (coding->produced - bytes), |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
6887 saved_pt_byte + (coding->produced - bytes)); |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
6888 } |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
6889 |
| 88365 | 6890 unbind_to (count, Qnil); |
|
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
6891 } |
|
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
6892 |
|
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
6893 |
|
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
6894 Lisp_Object |
| 88365 | 6895 preferred_coding_system () |
|
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
6896 { |
| 88365 | 6897 int id = coding_categories[coding_priorities[0]].id; |
| 6898 | |
| 6899 return CODING_ID_NAME (id); | |
|
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
6900 } |
|
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
6901 |
| 17052 | 6902 |
| 6903 #ifdef emacs | |
|
22874
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
6904 /*** 8. Emacs Lisp library functions ***/ |
| 17052 | 6905 |
| 6906 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
|
6907 doc: /* Return t if OBJECT is nil or a coding-system. |
| 88365 | 6908 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
|
6909 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
|
6910 (obj) |
| 17052 | 6911 Lisp_Object obj; |
| 6912 { | |
| 88365 | 6913 return ((NILP (obj) || CODING_SYSTEM_P (obj)) ? Qt : Qnil); |
| 17052 | 6914 } |
| 6915 | |
|
17717
4891aaecc5cc
(Fread_coding_system, Fread_non_nil_coding_system):
Richard M. Stallman <rms@gnu.org>
parents:
17485
diff
changeset
|
6916 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
|
6917 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
|
6918 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
|
6919 (prompt) |
| 17052 | 6920 Lisp_Object prompt; |
| 6921 { | |
|
17119
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
6922 Lisp_Object val; |
|
17717
4891aaecc5cc
(Fread_coding_system, Fread_non_nil_coding_system):
Richard M. Stallman <rms@gnu.org>
parents:
17485
diff
changeset
|
6923 do |
|
4891aaecc5cc
(Fread_coding_system, Fread_non_nil_coding_system):
Richard M. Stallman <rms@gnu.org>
parents:
17485
diff
changeset
|
6924 { |
|
20105
c017642863c2
(Qcoding_system_spec): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
19824
diff
changeset
|
6925 val = Fcompleting_read (prompt, Vcoding_system_alist, Qnil, |
|
c017642863c2
(Qcoding_system_spec): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
19824
diff
changeset
|
6926 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
|
6927 } |
|
46370
40db0673e6f0
Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents:
46293
diff
changeset
|
6928 while (SCHARS (val) == 0); |
|
17119
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
6929 return (Fintern (val, Qnil)); |
| 17052 | 6930 } |
| 6931 | |
|
19758
49a1662b68dd
(Fread_coding_system): New optional arg DEFAULT_CODING_SYSTEM.
Richard M. Stallman <rms@gnu.org>
parents:
19750
diff
changeset
|
6932 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
|
6933 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
|
6934 If the user enters null input, return second argument DEFAULT-CODING-SYSTEM. */) |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
6935 (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
|
6936 Lisp_Object prompt, default_coding_system; |
| 17052 | 6937 { |
|
19747
bed06df9cbc5
(setup_coding_system, Ffind_operation_coding_system)
Richard M. Stallman <rms@gnu.org>
parents:
19743
diff
changeset
|
6938 Lisp_Object val; |
|
19758
49a1662b68dd
(Fread_coding_system): New optional arg DEFAULT_CODING_SYSTEM.
Richard M. Stallman <rms@gnu.org>
parents:
19750
diff
changeset
|
6939 if (SYMBOLP (default_coding_system)) |
|
89519
040a08a2a879
(Fread_coding_system): Fix arg of XSETSTRING.
Dave Love <fx@gnu.org>
parents:
89483
diff
changeset
|
6940 XSETSTRING (default_coding_system, XPNTR (SYMBOL_NAME (default_coding_system))); |
|
20105
c017642863c2
(Qcoding_system_spec): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
19824
diff
changeset
|
6941 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
|
6942 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
|
6943 default_coding_system, Qnil); |
|
46370
40db0673e6f0
Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents:
46293
diff
changeset
|
6944 return (SCHARS (val) == 0 ? Qnil : Fintern (val, Qnil)); |
| 17052 | 6945 } |
| 6946 | |
| 6947 DEFUN ("check-coding-system", Fcheck_coding_system, Scheck_coding_system, | |
| 6948 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
|
6949 doc: /* Check validity of CODING-SYSTEM. |
| 89218 | 6950 If valid, return CODING-SYSTEM, else signal a `coding-system-error' error. */) |
| 88365 | 6951 (coding_system) |
| 17052 | 6952 Lisp_Object coding_system; |
| 6953 { | |
|
40656
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Jan?k <Pavel@Janik.cz>
parents:
40461
diff
changeset
|
6954 CHECK_SYMBOL (coding_system); |
| 17052 | 6955 if (!NILP (Fcoding_system_p (coding_system))) |
| 6956 return coding_system; | |
| 6957 while (1) | |
|
18180
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
6958 Fsignal (Qcoding_system_error, Fcons (coding_system, Qnil)); |
| 17052 | 6959 } |
| 88365 | 6960 |
|
20680
dd46027e8412
(code_convert_region): Always count chars inserted
Richard M. Stallman <rms@gnu.org>
parents:
20668
diff
changeset
|
6961 |
|
89193
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
6962 /* 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
|
6963 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
|
6964 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
|
6965 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
|
6966 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
|
6967 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
|
6968 Otherwise, the bytes are raw bytes. |
|
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
6969 |
|
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
6970 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
|
6971 |
|
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
6972 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
|
6973 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
|
6974 (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
|
6975 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
|
6976 detect only text-format. */ |
|
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
6977 |
|
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
6978 Lisp_Object |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6979 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
|
6980 coding_system) |
|
46548
cb1914307488
(encode_eol, detect_coding, detect_eol):
Ken Raeburn <raeburn@raeburn.org>
parents:
46462
diff
changeset
|
6981 const unsigned char *src; |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6982 int src_chars, src_bytes, highest; |
|
34531
37f85e931855
(ONE_MORE_BYTE_CHECK_MULTIBYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34197
diff
changeset
|
6983 int multibytep; |
| 88365 | 6984 Lisp_Object coding_system; |
| 17052 | 6985 { |
| 89483 | 6986 const unsigned char *src_end = src + src_bytes; |
| 88365 | 6987 Lisp_Object attrs, eol_type; |
| 6988 Lisp_Object val; | |
| 6989 struct coding_system coding; | |
|
89193
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
6990 int id; |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6991 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
|
6992 enum coding_category base_category; |
| 88365 | 6993 |
| 6994 if (NILP (coding_system)) | |
| 6995 coding_system = Qundecided; | |
| 6996 setup_coding_system (coding_system, &coding); | |
| 6997 attrs = CODING_ID_ATTRS (coding.id); | |
| 6998 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
|
6999 coding_system = CODING_ATTR_BASE_NAME (attrs); |
| 88365 | 7000 |
| 7001 coding.source = src; | |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
7002 coding.src_chars = src_chars; |
| 88365 | 7003 coding.src_bytes = src_bytes; |
| 7004 coding.src_multibyte = multibytep; | |
| 7005 coding.consumed = 0; | |
|
89193
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
7006 coding.mode |= CODING_MODE_LAST_BLOCK; |
|
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
7007 |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7008 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
|
7009 |
|
89193
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
7010 /* 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
|
7011 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
|
7012 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
|
7013 { |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7014 enum coding_category category; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7015 struct coding_system *this; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7016 int c, i; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7017 |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
7018 /* Skip all ASCII bytes except for a few ISO2022 controls. */ |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
7019 for (i = 0; src < src_end; i++, src++) |
| 17052 | 7020 { |
| 88365 | 7021 c = *src; |
|
89780
a53cb5864a40
(detect_coding_iso_2022): Fix handling of SS2 and SS3.
Kenichi Handa <handa@m17n.org>
parents:
89779
diff
changeset
|
7022 if (c & 0x80 || (c < 0x20 && (c == ISO_CODE_ESC |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
7023 || c == ISO_CODE_SI |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
7024 || c == ISO_CODE_SO))) |
|
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
7025 break; |
| 17052 | 7026 } |
| 88365 | 7027 coding.head_ascii = src - coding.source; |
| 7028 | |
| 7029 if (src < src_end) | |
| 7030 for (i = 0; i < coding_category_raw_text; i++) | |
| 7031 { | |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7032 category = coding_priorities[i]; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7033 this = coding_categories + category; |
| 88365 | 7034 |
| 7035 if (this->id < 0) | |
| 7036 { | |
| 7037 /* No coding system of this category is defined. */ | |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7038 detect_info.rejected |= (1 << category); |
| 88365 | 7039 } |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7040 else if (category >= coding_category_raw_text) |
|
89193
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
7041 continue; |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7042 else if (detect_info.checked & (1 << category)) |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7043 { |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7044 if (highest |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7045 && (detect_info.found & (1 << category))) |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7046 break; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7047 } |
| 88365 | 7048 else |
| 7049 { | |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7050 if ((*(this->detector)) (&coding, &detect_info) |
|
89193
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
7051 && highest |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7052 && (detect_info.found & (1 << category))) |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
7053 { |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
7054 if (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
|
7055 { |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
7056 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
|
7057 category = coding_category_utf_16_le; |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
7058 else |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
7059 category = coding_category_utf_16_be; |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
7060 } |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
7061 break; |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
7062 } |
| 88365 | 7063 } |
| 7064 } | |
|
89193
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
7065 |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7066 if (detect_info.rejected == CATEGORY_MASK_ANY) |
|
89193
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
7067 { |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7068 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
|
7069 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
|
7070 val = Fcons (make_number (id), Qnil); |
|
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
7071 } |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7072 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
|
7073 { |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7074 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
|
7075 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
|
7076 val = Fcons (make_number (id), Qnil); |
|
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
7077 } |
|
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
7078 else if (highest) |
|
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
7079 { |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7080 if (detect_info.found) |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7081 { |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7082 detect_info.found = 1 << category; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7083 val = Fcons (make_number (this->id), Qnil); |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7084 } |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7085 else |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7086 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
|
7087 if (! (detect_info.rejected & (1 << coding_priorities[i]))) |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7088 { |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7089 detect_info.found = 1 << coding_priorities[i]; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7090 id = coding_categories[coding_priorities[i]].id; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7091 val = Fcons (make_number (id), Qnil); |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7092 break; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7093 } |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7094 } |
|
89193
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
7095 else |
|
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
7096 { |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7097 int mask = detect_info.rejected | detect_info.found; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7098 int found = 0; |
|
89193
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
7099 val = Qnil; |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7100 |
|
89193
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
7101 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
|
7102 { |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7103 category = coding_priorities[i]; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7104 if (! (mask & (1 << category))) |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7105 { |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7106 found |= 1 << category; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7107 id = coding_categories[category].id; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7108 val = Fcons (make_number (id), val); |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7109 } |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7110 } |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7111 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
|
7112 { |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7113 category = coding_priorities[i]; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7114 if (detect_info.found & (1 << category)) |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7115 { |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7116 id = coding_categories[category].id; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7117 val = Fcons (make_number (id), val); |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7118 } |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7119 } |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7120 detect_info.found |= found; |
|
89193
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
7121 } |
|
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
7122 } |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
7123 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
|
7124 { |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
7125 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
|
7126 { |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
7127 enum coding_category category; |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
7128 struct coding_system *this; |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
7129 |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
7130 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
|
7131 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
|
7132 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
|
7133 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
|
7134 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
|
7135 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
|
7136 else |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
7137 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
|
7138 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
|
7139 } |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
7140 } |
| 88365 | 7141 else |
| 7142 { | |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7143 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
|
7144 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
|
7145 } |
|
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
7146 |
|
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
7147 /* Then, detect eol-format if necessary. */ |
| 88365 | 7148 { |
|
89193
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
7149 int normal_eol = -1, utf_16_be_eol = -1, utf_16_le_eol; |
| 88365 | 7150 Lisp_Object tail; |
| 7151 | |
|
89193
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
7152 if (VECTORP (eol_type)) |
|
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
7153 { |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7154 if (detect_info.found & ~CATEGORY_MASK_UTF_16) |
|
89193
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
7155 normal_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
|
7156 coding_category_raw_text); |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7157 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
|
7158 | 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
|
7159 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
|
7160 coding_category_utf_16_be); |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7161 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
|
7162 | 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
|
7163 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
|
7164 coding_category_utf_16_le); |
|
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
7165 } |
|
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
7166 else |
|
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
7167 { |
|
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
7168 if (EQ (eol_type, Qunix)) |
|
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
7169 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
|
7170 else if (EQ (eol_type, Qdos)) |
|
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
7171 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
|
7172 else |
|
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
7173 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
|
7174 } |
|
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
7175 |
| 88365 | 7176 for (tail = val; CONSP (tail); tail = XCDR (tail)) |
| 7177 { | |
|
89193
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
7178 enum coding_category category; |
| 88365 | 7179 int this_eol; |
|
89193
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
7180 |
|
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
7181 id = XINT (XCAR (tail)); |
|
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
7182 attrs = CODING_ID_ATTRS (id); |
|
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
7183 category = XINT (CODING_ATTR_CATEGORY (attrs)); |
|
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
7184 eol_type = CODING_ID_EOL_TYPE (id); |
| 88365 | 7185 if (VECTORP (eol_type)) |
| 7186 { | |
|
89193
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
7187 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
|
7188 || 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
|
7189 this_eol = utf_16_be_eol; |
|
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
7190 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
|
7191 || 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
|
7192 this_eol = utf_16_le_eol; |
| 88365 | 7193 else |
|
89193
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
7194 this_eol = normal_eol; |
|
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
7195 |
| 88365 | 7196 if (this_eol == EOL_SEEN_LF) |
| 7197 XSETCAR (tail, AREF (eol_type, 0)); | |
| 7198 else if (this_eol == EOL_SEEN_CRLF) | |
| 7199 XSETCAR (tail, AREF (eol_type, 1)); | |
| 7200 else if (this_eol == EOL_SEEN_CR) | |
| 7201 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
|
7202 else |
|
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
7203 XSETCAR (tail, CODING_ID_NAME (id)); |
| 88365 | 7204 } |
|
89193
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
7205 else |
|
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
7206 XSETCAR (tail, CODING_ID_NAME (id)); |
| 88365 | 7207 } |
| 7208 } | |
| 7209 | |
|
25662
0a7261c1d487
Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25370
diff
changeset
|
7210 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
|
7211 } |
|
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
7212 |
| 88365 | 7213 |
|
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
7214 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
|
7215 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
|
7216 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
|
7217 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
|
7218 |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
7219 If only ASCII characters are found, it returns a list of single element |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
7220 `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
|
7221 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
|
7222 |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
7223 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
|
7224 highest priority. */) |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
7225 (start, end, highest) |
|
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
7226 Lisp_Object start, end, highest; |
| 17052 | 7227 { |
|
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
7228 int from, to; |
|
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
7229 int from_byte, to_byte; |
|
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
7230 |
|
40656
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Jan?k <Pavel@Janik.cz>
parents:
40461
diff
changeset
|
7231 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
|
7232 CHECK_NUMBER_COERCE_MARKER (end); |
|
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
7233 |
|
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
7234 validate_region (&start, &end); |
|
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
7235 from = XINT (start), to = XINT (end); |
|
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
7236 from_byte = CHAR_TO_BYTE (from); |
|
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
7237 to_byte = CHAR_TO_BYTE (to); |
|
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
7238 |
|
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
7239 if (from < GPT && to >= GPT) |
|
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
7240 move_gap_both (to, to_byte); |
| 88365 | 7241 |
|
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
7242 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
|
7243 to - from, to_byte - from_byte, |
|
34531
37f85e931855
(ONE_MORE_BYTE_CHECK_MULTIBYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34197
diff
changeset
|
7244 !NILP (highest), |
|
37f85e931855
(ONE_MORE_BYTE_CHECK_MULTIBYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34197
diff
changeset
|
7245 !NILP (current_buffer |
| 88365 | 7246 ->enable_multibyte_characters), |
| 7247 Qnil); | |
|
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
7248 } |
|
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
7249 |
|
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
7250 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
|
7251 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
|
7252 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
|
7253 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
|
7254 |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
7255 If only ASCII characters are found, it returns a list of single element |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
7256 `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
|
7257 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
|
7258 |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
7259 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
|
7260 highest priority. */) |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
7261 (string, highest) |
|
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
7262 Lisp_Object string, highest; |
|
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
7263 { |
|
40656
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Jan?k <Pavel@Janik.cz>
parents:
40461
diff
changeset
|
7264 CHECK_STRING (string); |
|
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
7265 |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
7266 return detect_coding_system (SDATA (string), |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
7267 SCHARS (string), SBYTES (string), |
| 89483 | 7268 !NILP (highest), STRING_MULTIBYTE (string), |
| 88365 | 7269 Qnil); |
|
30487
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
7270 } |
|
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
7271 |
|
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
7272 |
| 88365 | 7273 static INLINE int |
| 7274 char_encodable_p (c, attrs) | |
| 7275 int c; | |
| 7276 Lisp_Object attrs; | |
|
30487
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
7277 { |
| 88365 | 7278 Lisp_Object tail; |
| 7279 struct charset *charset; | |
|
89732
8acde12aba89
(get_translation_table): New function.
Kenichi Handa <handa@m17n.org>
parents:
89730
diff
changeset
|
7280 Lisp_Object translation_table; |
|
8acde12aba89
(get_translation_table): New function.
Kenichi Handa <handa@m17n.org>
parents:
89730
diff
changeset
|
7281 |
|
8acde12aba89
(get_translation_table): New function.
Kenichi Handa <handa@m17n.org>
parents:
89730
diff
changeset
|
7282 translation_table = CODING_ATTR_TRANS_TBL (attrs); |
|
89759
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
7283 if (! NILP (translation_table)) |
|
89732
8acde12aba89
(get_translation_table): New function.
Kenichi Handa <handa@m17n.org>
parents:
89730
diff
changeset
|
7284 c = translate_char (translation_table, c); |
| 88365 | 7285 for (tail = CODING_ATTR_CHARSET_LIST (attrs); |
| 7286 CONSP (tail); tail = XCDR (tail)) | |
| 7287 { | |
| 7288 charset = CHARSET_FROM_ID (XINT (XCAR (tail))); | |
| 7289 if (CHAR_CHARSET_P (c, charset)) | |
| 7290 break; | |
| 7291 } | |
| 7292 return (! NILP (tail)); | |
|
30487
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
7293 } |
|
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
7294 |
|
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
7295 |
|
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
7296 /* Return a list of coding systems that safely encode the text between |
| 88365 | 7297 START and END. If EXCLUDE is non-nil, it is a list of coding |
| 7298 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
|
7299 coding systems. In any case, if the text contains only ASCII or is |
| 88365 | 7300 unibyte, return t. */ |
|
30487
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
7301 |
|
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
7302 DEFUN ("find-coding-systems-region-internal", |
|
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
7303 Ffind_coding_systems_region_internal, |
| 88365 | 7304 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
|
7305 doc: /* Internal use only. */) |
| 88365 | 7306 (start, end, exclude) |
| 7307 Lisp_Object start, end, exclude; | |
|
30487
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
7308 { |
| 88365 | 7309 Lisp_Object coding_attrs_list, safe_codings; |
| 7310 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
|
7311 const unsigned char *p, *pbeg, *pend; |
| 88365 | 7312 int c; |
| 7313 Lisp_Object tail, elt; | |
|
30487
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
7314 |
|
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
7315 if (STRINGP (start)) |
|
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
7316 { |
| 88365 | 7317 if (!STRING_MULTIBYTE (start) |
| 89483 | 7318 || SCHARS (start) == SBYTES (start)) |
|
30487
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
7319 return Qt; |
| 88365 | 7320 start_byte = 0; |
| 89483 | 7321 end_byte = SBYTES (start); |
|
30487
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
7322 } |
|
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
7323 else |
|
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
7324 { |
|
40656
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Jan?k <Pavel@Janik.cz>
parents:
40461
diff
changeset
|
7325 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
|
7326 CHECK_NUMBER_COERCE_MARKER (end); |
|
30487
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
7327 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
|
7328 args_out_of_range (start, end); |
|
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
7329 if (NILP (current_buffer->enable_multibyte_characters)) |
|
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
7330 return Qt; |
| 88365 | 7331 start_byte = CHAR_TO_BYTE (XINT (start)); |
| 7332 end_byte = CHAR_TO_BYTE (XINT (end)); | |
| 7333 if (XINT (end) - XINT (start) == end_byte - start_byte) | |
| 7334 return Qt; | |
| 7335 | |
|
89394
6ffca50f25b9
(Fcheck_coding_systems_region): Fix type errors.
Dave Love <fx@gnu.org>
parents:
89373
diff
changeset
|
7336 if (XINT (start) < GPT && XINT (end) > GPT) |
| 88365 | 7337 { |
|
89394
6ffca50f25b9
(Fcheck_coding_systems_region): Fix type errors.
Dave Love <fx@gnu.org>
parents:
89373
diff
changeset
|
7338 if ((GPT - XINT (start)) < (XINT (end) - GPT)) |
|
6ffca50f25b9
(Fcheck_coding_systems_region): Fix type errors.
Dave Love <fx@gnu.org>
parents:
89373
diff
changeset
|
7339 move_gap_both (XINT (start), start_byte); |
| 88365 | 7340 else |
|
89394
6ffca50f25b9
(Fcheck_coding_systems_region): Fix type errors.
Dave Love <fx@gnu.org>
parents:
89373
diff
changeset
|
7341 move_gap_both (XINT (end), end_byte); |
| 88365 | 7342 } |
| 7343 } | |
| 7344 | |
| 7345 coding_attrs_list = Qnil; | |
| 7346 for (tail = Vcoding_system_list; CONSP (tail); tail = XCDR (tail)) | |
| 7347 if (NILP (exclude) | |
| 7348 || NILP (Fmemq (XCAR (tail), exclude))) | |
| 7349 { | |
| 7350 Lisp_Object attrs; | |
| 7351 | |
| 7352 attrs = AREF (CODING_SYSTEM_SPEC (XCAR (tail)), 0); | |
| 7353 if (EQ (XCAR (tail), CODING_ATTR_BASE_NAME (attrs)) | |
| 7354 && ! EQ (CODING_ATTR_TYPE (attrs), Qundecided)) | |
|
89732
8acde12aba89
(get_translation_table): New function.
Kenichi Handa <handa@m17n.org>
parents:
89730
diff
changeset
|
7355 { |
|
8acde12aba89
(get_translation_table): New function.
Kenichi Handa <handa@m17n.org>
parents:
89730
diff
changeset
|
7356 ASET (attrs, coding_attr_trans_tbl, |
|
8acde12aba89
(get_translation_table): New function.
Kenichi Handa <handa@m17n.org>
parents:
89730
diff
changeset
|
7357 get_translation_table (attrs, 1)); |
|
8acde12aba89
(get_translation_table): New function.
Kenichi Handa <handa@m17n.org>
parents:
89730
diff
changeset
|
7358 coding_attrs_list = Fcons (attrs, coding_attrs_list); |
|
8acde12aba89
(get_translation_table): New function.
Kenichi Handa <handa@m17n.org>
parents:
89730
diff
changeset
|
7359 } |
| 88365 | 7360 } |
| 7361 | |
| 7362 if (STRINGP (start)) | |
| 89483 | 7363 p = pbeg = SDATA (start); |
| 88365 | 7364 else |
| 7365 p = pbeg = BYTE_POS_ADDR (start_byte); | |
| 7366 pend = p + (end_byte - start_byte); | |
| 7367 | |
| 7368 while (p < pend && ASCII_BYTE_P (*p)) p++; | |
| 7369 while (p < pend && ASCII_BYTE_P (*(pend - 1))) pend--; | |
| 7370 | |
| 7371 while (p < pend) | |
| 7372 { | |
| 7373 if (ASCII_BYTE_P (*p)) | |
| 7374 p++; | |
|
30487
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
7375 else |
|
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
7376 { |
| 88365 | 7377 c = STRING_CHAR_ADVANCE (p); |
| 7378 | |
| 7379 charset_map_loaded = 0; | |
| 7380 for (tail = coding_attrs_list; CONSP (tail);) | |
| 7381 { | |
| 7382 elt = XCAR (tail); | |
| 7383 if (NILP (elt)) | |
| 7384 tail = XCDR (tail); | |
| 7385 else if (char_encodable_p (c, elt)) | |
| 7386 tail = XCDR (tail); | |
| 7387 else if (CONSP (XCDR (tail))) | |
| 7388 { | |
| 7389 XSETCAR (tail, XCAR (XCDR (tail))); | |
| 7390 XSETCDR (tail, XCDR (XCDR (tail))); | |
| 7391 } | |
| 7392 else | |
| 7393 { | |
| 7394 XSETCAR (tail, Qnil); | |
| 7395 tail = XCDR (tail); | |
| 7396 } | |
| 7397 } | |
| 7398 if (charset_map_loaded) | |
| 7399 { | |
| 7400 EMACS_INT p_offset = p - pbeg, pend_offset = pend - pbeg; | |
| 7401 | |
| 7402 if (STRINGP (start)) | |
| 89483 | 7403 pbeg = SDATA (start); |
| 88365 | 7404 else |
| 7405 pbeg = BYTE_POS_ADDR (start_byte); | |
| 7406 p = pbeg + p_offset; | |
| 7407 pend = pbeg + pend_offset; | |
| 7408 } | |
|
30487
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
7409 } |
|
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
7410 } |
|
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
7411 |
| 88365 | 7412 safe_codings = Qnil; |
| 7413 for (tail = coding_attrs_list; CONSP (tail); tail = XCDR (tail)) | |
| 7414 if (! NILP (XCAR (tail))) | |
| 7415 safe_codings = Fcons (CODING_ATTR_BASE_NAME (XCAR (tail)), safe_codings); | |
| 7416 | |
| 7417 return safe_codings; | |
| 7418 } | |
| 7419 | |
| 7420 | |
|
46859
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
7421 DEFUN ("unencodable-char-position", Funencodable_char_position, |
|
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
7422 Sunencodable_char_position, 3, 5, 0, |
|
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
7423 doc: /* |
|
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
7424 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
|
7425 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
|
7426 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
|
7427 |
|
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
7428 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
|
7429 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
|
7430 list of positions. |
|
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
7431 |
|
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
7432 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
|
7433 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
|
7434 to the string. */) |
|
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
7435 (start, end, coding_system, count, string) |
|
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
7436 Lisp_Object start, end, coding_system, count, string; |
|
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
7437 { |
|
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
7438 int n; |
|
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
7439 struct coding_system coding; |
|
89732
8acde12aba89
(get_translation_table): New function.
Kenichi Handa <handa@m17n.org>
parents:
89730
diff
changeset
|
7440 Lisp_Object attrs, charset_list, translation_table; |
|
46859
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
7441 Lisp_Object positions; |
|
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
7442 int from, to; |
| 89483 | 7443 const unsigned char *p, *stop, *pend; |
| 7444 int ascii_compatible; | |
| 7445 | |
| 7446 setup_coding_system (Fcheck_coding_system (coding_system), &coding); | |
| 7447 attrs = CODING_ID_ATTRS (coding.id); | |
| 7448 if (EQ (CODING_ATTR_TYPE (attrs), Qraw_text)) | |
| 7449 return Qnil; | |
| 7450 ascii_compatible = ! NILP (CODING_ATTR_ASCII_COMPAT (attrs)); | |
| 7451 charset_list = CODING_ATTR_CHARSET_LIST (attrs); | |
|
89732
8acde12aba89
(get_translation_table): New function.
Kenichi Handa <handa@m17n.org>
parents:
89730
diff
changeset
|
7452 translation_table = get_translation_table (attrs, 1); |
|
46859
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
7453 |
|
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
7454 if (NILP (string)) |
|
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
7455 { |
|
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
7456 validate_region (&start, &end); |
|
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
7457 from = XINT (start); |
|
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
7458 to = XINT (end); |
| 89483 | 7459 if (NILP (current_buffer->enable_multibyte_characters) |
| 7460 || (ascii_compatible | |
| 7461 && (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
|
7462 return Qnil; |
|
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
7463 p = CHAR_POS_ADDR (from); |
| 89483 | 7464 pend = CHAR_POS_ADDR (to); |
| 7465 if (from < GPT && to >= GPT) | |
| 7466 stop = GPT_ADDR; | |
|
48829
f6c59ca557c7
(Funencodable_char_position): Set pend correctly.
Kenichi Handa <handa@m17n.org>
parents:
48230
diff
changeset
|
7467 else |
| 89483 | 7468 stop = pend; |
|
46859
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
7469 } |
|
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
7470 else |
|
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
7471 { |
|
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
7472 CHECK_STRING (string); |
|
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
7473 CHECK_NATNUM (start); |
|
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
7474 CHECK_NATNUM (end); |
|
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
7475 from = XINT (start); |
|
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
7476 to = XINT (end); |
|
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
7477 if (from > to |
|
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
7478 || to > SCHARS (string)) |
|
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
7479 args_out_of_range_3 (string, start, end); |
|
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
7480 if (! STRING_MULTIBYTE (string)) |
|
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
7481 return Qnil; |
|
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
7482 p = SDATA (string) + string_char_to_byte (string, from); |
| 89483 | 7483 stop = pend = SDATA (string) + string_char_to_byte (string, to); |
| 7484 if (ascii_compatible && (to - from) == (pend - p)) | |
| 7485 return Qnil; | |
| 7486 } | |
|
46859
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
7487 |
|
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
7488 if (NILP (count)) |
|
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
7489 n = 1; |
|
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
7490 else |
|
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
7491 { |
|
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
7492 CHECK_NATNUM (count); |
|
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
7493 n = XINT (count); |
|
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
7494 } |
|
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
7495 |
| 89483 | 7496 positions = Qnil; |
| 7497 while (1) | |
| 7498 { | |
| 7499 int c; | |
| 7500 | |
| 7501 if (ascii_compatible) | |
| 7502 while (p < stop && ASCII_BYTE_P (*p)) | |
| 7503 p++, from++; | |
| 7504 if (p >= stop) | |
| 7505 { | |
| 7506 if (p >= pend) | |
| 7507 break; | |
| 7508 stop = pend; | |
| 7509 p = GAP_END_ADDR; | |
| 7510 } | |
| 7511 | |
| 7512 c = STRING_CHAR_ADVANCE (p); | |
| 7513 if (! (ASCII_CHAR_P (c) && ascii_compatible) | |
|
89732
8acde12aba89
(get_translation_table): New function.
Kenichi Handa <handa@m17n.org>
parents:
89730
diff
changeset
|
7514 && ! char_charset (translate_char (translation_table, c), |
|
8acde12aba89
(get_translation_table): New function.
Kenichi Handa <handa@m17n.org>
parents:
89730
diff
changeset
|
7515 charset_list, NULL)) |
| 89483 | 7516 { |
| 7517 positions = Fcons (make_number (from), positions); | |
| 7518 n--; | |
| 7519 if (n == 0) | |
| 7520 break; | |
| 7521 } | |
| 7522 | |
| 7523 from++; | |
| 7524 } | |
| 7525 | |
| 7526 return (NILP (count) ? Fcar (positions) : Fnreverse (positions)); | |
| 7527 } | |
| 7528 | |
| 7529 | |
| 88365 | 7530 DEFUN ("check-coding-systems-region", Fcheck_coding_systems_region, |
| 7531 Scheck_coding_systems_region, 3, 3, 0, | |
| 7532 doc: /* Check if the region is encodable by coding systems. | |
| 7533 | |
| 7534 START and END are buffer positions specifying the region. | |
| 7535 CODING-SYSTEM-LIST is a list of coding systems to check. | |
| 7536 | |
| 7537 The value is an alist ((CODING-SYSTEM POS0 POS1 ...) ...), where | |
| 7538 CODING-SYSTEM is a member of CODING-SYSTEM-LIst and can't encode the | |
| 7539 whole region, POS0, POS1, ... are buffer positions where non-encodable | |
| 7540 characters are found. | |
| 7541 | |
| 7542 If all coding systems in CODING-SYSTEM-LIST can encode the region, the | |
| 7543 value is nil. | |
| 7544 | |
| 7545 START may be a string. In that case, check if the string is | |
| 7546 encodable, and the value contains indices to the string instead of | |
| 7547 buffer positions. END is ignored. */) | |
| 7548 (start, end, coding_system_list) | |
| 7549 Lisp_Object start, end, coding_system_list; | |
| 7550 { | |
| 7551 Lisp_Object list; | |
| 7552 EMACS_INT start_byte, end_byte; | |
| 7553 int pos; | |
|
88876
af9012fdad56
(LEADING_CODE_PRIVATE_11, LEADING_CODE_PRIVATE_12,
Kenichi Handa <handa@m17n.org>
parents:
88862
diff
changeset
|
7554 const unsigned char *p, *pbeg, *pend; |
| 88365 | 7555 int c; |
|
89732
8acde12aba89
(get_translation_table): New function.
Kenichi Handa <handa@m17n.org>
parents:
89730
diff
changeset
|
7556 Lisp_Object tail, elt, attrs; |
| 88365 | 7557 |
| 7558 if (STRINGP (start)) | |
| 7559 { | |
| 7560 if (!STRING_MULTIBYTE (start) | |
| 89483 | 7561 && SCHARS (start) != SBYTES (start)) |
| 88365 | 7562 return Qnil; |
| 7563 start_byte = 0; | |
| 89483 | 7564 end_byte = SBYTES (start); |
| 88365 | 7565 pos = 0; |
|
30487
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
7566 } |
|
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
7567 else |
| 88365 | 7568 { |
| 7569 CHECK_NUMBER_COERCE_MARKER (start); | |
| 7570 CHECK_NUMBER_COERCE_MARKER (end); | |
| 7571 if (XINT (start) < BEG || XINT (end) > Z || XINT (start) > XINT (end)) | |
| 7572 args_out_of_range (start, end); | |
| 7573 if (NILP (current_buffer->enable_multibyte_characters)) | |
| 7574 return Qnil; | |
| 7575 start_byte = CHAR_TO_BYTE (XINT (start)); | |
| 7576 end_byte = CHAR_TO_BYTE (XINT (end)); | |
| 7577 if (XINT (end) - XINT (start) == end_byte - start_byte) | |
| 7578 return Qt; | |
| 7579 | |
|
89394
6ffca50f25b9
(Fcheck_coding_systems_region): Fix type errors.
Dave Love <fx@gnu.org>
parents:
89373
diff
changeset
|
7580 if (XINT (start) < GPT && XINT (end) > GPT) |
| 88365 | 7581 { |
|
89394
6ffca50f25b9
(Fcheck_coding_systems_region): Fix type errors.
Dave Love <fx@gnu.org>
parents:
89373
diff
changeset
|
7582 if ((GPT - XINT (start)) < (XINT (end) - GPT)) |
|
6ffca50f25b9
(Fcheck_coding_systems_region): Fix type errors.
Dave Love <fx@gnu.org>
parents:
89373
diff
changeset
|
7583 move_gap_both (XINT (start), start_byte); |
| 88365 | 7584 else |
|
89394
6ffca50f25b9
(Fcheck_coding_systems_region): Fix type errors.
Dave Love <fx@gnu.org>
parents:
89373
diff
changeset
|
7585 move_gap_both (XINT (end), end_byte); |
| 88365 | 7586 } |
|
89394
6ffca50f25b9
(Fcheck_coding_systems_region): Fix type errors.
Dave Love <fx@gnu.org>
parents:
89373
diff
changeset
|
7587 pos = XINT (start); |
| 88365 | 7588 } |
| 7589 | |
| 7590 list = Qnil; | |
| 7591 for (tail = coding_system_list; CONSP (tail); tail = XCDR (tail)) | |
| 7592 { | |
| 7593 elt = XCAR (tail); | |
|
89732
8acde12aba89
(get_translation_table): New function.
Kenichi Handa <handa@m17n.org>
parents:
89730
diff
changeset
|
7594 attrs = AREF (CODING_SYSTEM_SPEC (elt), 0); |
|
8acde12aba89
(get_translation_table): New function.
Kenichi Handa <handa@m17n.org>
parents:
89730
diff
changeset
|
7595 ASET (attrs, coding_attr_trans_tbl, get_translation_table (attrs, 1)); |
|
8acde12aba89
(get_translation_table): New function.
Kenichi Handa <handa@m17n.org>
parents:
89730
diff
changeset
|
7596 list = Fcons (Fcons (elt, Fcons (attrs, Qnil)), list); |
| 88365 | 7597 } |
| 7598 | |
| 7599 if (STRINGP (start)) | |
| 89483 | 7600 p = pbeg = SDATA (start); |
| 88365 | 7601 else |
| 7602 p = pbeg = BYTE_POS_ADDR (start_byte); | |
| 7603 pend = p + (end_byte - start_byte); | |
| 7604 | |
| 7605 while (p < pend && ASCII_BYTE_P (*p)) p++, pos++; | |
| 7606 while (p < pend && ASCII_BYTE_P (*(pend - 1))) pend--; | |
| 7607 | |
| 7608 while (p < pend) | |
| 7609 { | |
| 7610 if (ASCII_BYTE_P (*p)) | |
| 7611 p++; | |
| 7612 else | |
| 7613 { | |
| 7614 c = STRING_CHAR_ADVANCE (p); | |
| 7615 | |
| 7616 charset_map_loaded = 0; | |
| 7617 for (tail = list; CONSP (tail); tail = XCDR (tail)) | |
| 7618 { | |
| 7619 elt = XCDR (XCAR (tail)); | |
| 7620 if (! char_encodable_p (c, XCAR (elt))) | |
| 7621 XSETCDR (elt, Fcons (make_number (pos), XCDR (elt))); | |
| 7622 } | |
| 7623 if (charset_map_loaded) | |
| 7624 { | |
| 7625 EMACS_INT p_offset = p - pbeg, pend_offset = pend - pbeg; | |
| 7626 | |
| 7627 if (STRINGP (start)) | |
| 89483 | 7628 pbeg = SDATA (start); |
| 88365 | 7629 else |
| 7630 pbeg = BYTE_POS_ADDR (start_byte); | |
| 7631 p = pbeg + p_offset; | |
| 7632 pend = pbeg + pend_offset; | |
| 7633 } | |
| 7634 } | |
| 7635 pos++; | |
| 7636 } | |
| 7637 | |
| 7638 tail = list; | |
| 7639 list = Qnil; | |
| 7640 for (; CONSP (tail); tail = XCDR (tail)) | |
| 7641 { | |
| 7642 elt = XCAR (tail); | |
| 7643 if (CONSP (XCDR (XCDR (elt)))) | |
| 7644 list = Fcons (Fcons (XCAR (elt), Fnreverse (XCDR (XCDR (elt)))), | |
| 7645 list); | |
| 7646 } | |
| 7647 | |
| 7648 return list; | |
|
30487
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
7649 } |
|
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
7650 |
|
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
7651 |
|
20803
0fa2183c587d
(ENCODE_ISO_CHARACTER): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
20794
diff
changeset
|
7652 Lisp_Object |
| 88365 | 7653 code_convert_region (start, end, coding_system, dst_object, encodep, norecord) |
| 7654 Lisp_Object start, end, coding_system, dst_object; | |
| 7655 int encodep, norecord; | |
|
20680
dd46027e8412
(code_convert_region): Always count chars inserted
Richard M. Stallman <rms@gnu.org>
parents:
20668
diff
changeset
|
7656 { |
|
dd46027e8412
(code_convert_region): Always count chars inserted
Richard M. Stallman <rms@gnu.org>
parents:
20668
diff
changeset
|
7657 struct coding_system coding; |
| 88365 | 7658 EMACS_INT from, from_byte, to, to_byte; |
| 7659 Lisp_Object src_object; | |
|
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
7660 |
|
40656
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Jan?k <Pavel@Janik.cz>
parents:
40461
diff
changeset
|
7661 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
|
7662 CHECK_NUMBER_COERCE_MARKER (end); |
| 88365 | 7663 if (NILP (coding_system)) |
| 7664 coding_system = Qno_conversion; | |
| 7665 else | |
| 7666 CHECK_CODING_SYSTEM (coding_system); | |
| 7667 src_object = Fcurrent_buffer (); | |
| 7668 if (NILP (dst_object)) | |
| 7669 dst_object = src_object; | |
| 7670 else if (! EQ (dst_object, Qt)) | |
| 7671 CHECK_BUFFER (dst_object); | |
|
20680
dd46027e8412
(code_convert_region): Always count chars inserted
Richard M. Stallman <rms@gnu.org>
parents:
20668
diff
changeset
|
7672 |
|
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
7673 validate_region (&start, &end); |
|
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
7674 from = XFASTINT (start); |
| 88365 | 7675 from_byte = CHAR_TO_BYTE (from); |
|
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
7676 to = XFASTINT (end); |
| 88365 | 7677 to_byte = CHAR_TO_BYTE (to); |
| 7678 | |
| 7679 setup_coding_system (coding_system, &coding); | |
|
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
7680 coding.mode |= CODING_MODE_LAST_BLOCK; |
| 88365 | 7681 |
| 7682 if (encodep) | |
| 7683 encode_coding_object (&coding, src_object, from, from_byte, to, to_byte, | |
| 7684 dst_object); | |
| 7685 else | |
| 7686 decode_coding_object (&coding, src_object, from, from_byte, to, to_byte, | |
| 7687 dst_object); | |
| 7688 if (! norecord) | |
| 7689 Vlast_coding_system_used = CODING_ID_NAME (coding.id); | |
| 7690 | |
| 7691 return (BUFFERP (dst_object) | |
| 7692 ? make_number (coding.produced_char) | |
| 7693 : coding.dst_object); | |
|
20803
0fa2183c587d
(ENCODE_ISO_CHARACTER): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
20794
diff
changeset
|
7694 } |
|
0fa2183c587d
(ENCODE_ISO_CHARACTER): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
20794
diff
changeset
|
7695 |
| 88365 | 7696 |
|
20803
0fa2183c587d
(ENCODE_ISO_CHARACTER): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
20794
diff
changeset
|
7697 DEFUN ("decode-coding-region", Fdecode_coding_region, Sdecode_coding_region, |
| 88365 | 7698 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
|
7699 doc: /* Decode the current region from the specified coding system. |
| 88365 | 7700 When called from a program, takes four arguments: |
| 7701 START, END, CODING-SYSTEM, and DESTINATION. | |
| 7702 START and END are buffer positions. | |
| 7703 | |
| 7704 Optional 4th arguments DESTINATION specifies where the decoded text goes. | |
| 7705 If nil, the region between START and END is replace by the decoded text. | |
| 7706 If buffer, the decoded text is inserted in the buffer. | |
| 7707 If t, the decoded text is returned. | |
| 7708 | |
|
40713
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
7709 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
|
7710 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
|
7711 not fully specified.) |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
7712 It returns the length of the decoded text. */) |
| 88365 | 7713 (start, end, coding_system, destination) |
| 7714 Lisp_Object start, end, coding_system, destination; | |
|
20803
0fa2183c587d
(ENCODE_ISO_CHARACTER): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
20794
diff
changeset
|
7715 { |
| 88365 | 7716 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
|
7717 } |
|
dd46027e8412
(code_convert_region): Always count chars inserted
Richard M. Stallman <rms@gnu.org>
parents:
20668
diff
changeset
|
7718 |
|
dd46027e8412
(code_convert_region): Always count chars inserted
Richard M. Stallman <rms@gnu.org>
parents:
20668
diff
changeset
|
7719 DEFUN ("encode-coding-region", Fencode_coding_region, Sencode_coding_region, |
| 88365 | 7720 3, 4, "r\nzCoding system: ", |
| 7721 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
|
7722 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
|
7723 START, END, and CODING-SYSTEM. START and END are buffer positions. |
| 88365 | 7724 |
| 7725 Optional 4th arguments DESTINATION specifies where the encoded text goes. | |
| 7726 If nil, the region between START and END is replace by the encoded text. | |
| 7727 If buffer, the encoded text is inserted in the buffer. | |
| 7728 If t, the encoded text is returned. | |
| 7729 | |
|
40713
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
7730 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
|
7731 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
|
7732 not fully specified.) |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
7733 It returns the length of the encoded text. */) |
| 88365 | 7734 (start, end, coding_system, destination) |
| 7735 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
|
7736 { |
| 88365 | 7737 return code_convert_region (start, end, coding_system, destination, 1, 0); |
| 17052 | 7738 } |
| 7739 | |
|
20803
0fa2183c587d
(ENCODE_ISO_CHARACTER): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
20794
diff
changeset
|
7740 Lisp_Object |
| 88365 | 7741 code_convert_string (string, coding_system, dst_object, |
| 7742 encodep, nocopy, norecord) | |
| 7743 Lisp_Object string, coding_system, dst_object; | |
| 7744 int encodep, nocopy, norecord; | |
| 17052 | 7745 { |
| 7746 struct coding_system coding; | |
| 88365 | 7747 EMACS_INT chars, bytes; |
| 17052 | 7748 |
|
40656
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Jan?k <Pavel@Janik.cz>
parents:
40461
diff
changeset
|
7749 CHECK_STRING (string); |
| 88365 | 7750 if (NILP (coding_system)) |
| 7751 { | |
| 7752 if (! norecord) | |
| 7753 Vlast_coding_system_used = Qno_conversion; | |
| 7754 if (NILP (dst_object)) | |
| 7755 return (nocopy ? Fcopy_sequence (string) : string); | |
| 7756 } | |
| 17052 | 7757 |
|
17119
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
7758 if (NILP (coding_system)) |
| 88365 | 7759 coding_system = Qno_conversion; |
| 7760 else | |
| 7761 CHECK_CODING_SYSTEM (coding_system); | |
| 7762 if (NILP (dst_object)) | |
| 7763 dst_object = Qt; | |
| 7764 else if (! EQ (dst_object, Qt)) | |
| 7765 CHECK_BUFFER (dst_object); | |
| 7766 | |
| 7767 setup_coding_system (coding_system, &coding); | |
|
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
7768 coding.mode |= CODING_MODE_LAST_BLOCK; |
| 89483 | 7769 chars = SCHARS (string); |
| 7770 bytes = SBYTES (string); | |
| 88365 | 7771 if (encodep) |
| 7772 encode_coding_object (&coding, string, 0, 0, chars, bytes, dst_object); | |
| 7773 else | |
| 7774 decode_coding_object (&coding, string, 0, 0, chars, bytes, dst_object); | |
| 7775 if (! norecord) | |
| 7776 Vlast_coding_system_used = CODING_ID_NAME (coding.id); | |
| 7777 | |
| 7778 return (BUFFERP (dst_object) | |
| 7779 ? make_number (coding.produced_char) | |
| 7780 : coding.dst_object); | |
|
20803
0fa2183c587d
(ENCODE_ISO_CHARACTER): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
20794
diff
changeset
|
7781 } |
|
0fa2183c587d
(ENCODE_ISO_CHARACTER): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
20794
diff
changeset
|
7782 |
|
0fa2183c587d
(ENCODE_ISO_CHARACTER): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
20794
diff
changeset
|
7783 |
|
22341
572ba933a4bf
(code_convert_string_norecord): New function.
Karl Heuer <kwzh@gnu.org>
parents:
22329
diff
changeset
|
7784 /* Encode or decode STRING according to CODING_SYSTEM. |
| 26847 | 7785 Do not set Vlast_coding_system_used. |
| 7786 | |
| 7787 This function is called only from macros DECODE_FILE and | |
| 7788 ENCODE_FILE, thus we ignore character composition. */ | |
|
22341
572ba933a4bf
(code_convert_string_norecord): New function.
Karl Heuer <kwzh@gnu.org>
parents:
22329
diff
changeset
|
7789 |
|
572ba933a4bf
(code_convert_string_norecord): New function.
Karl Heuer <kwzh@gnu.org>
parents:
22329
diff
changeset
|
7790 Lisp_Object |
|
572ba933a4bf
(code_convert_string_norecord): New function.
Karl Heuer <kwzh@gnu.org>
parents:
22329
diff
changeset
|
7791 code_convert_string_norecord (string, coding_system, encodep) |
|
572ba933a4bf
(code_convert_string_norecord): New function.
Karl Heuer <kwzh@gnu.org>
parents:
22329
diff
changeset
|
7792 Lisp_Object string, coding_system; |
|
572ba933a4bf
(code_convert_string_norecord): New function.
Karl Heuer <kwzh@gnu.org>
parents:
22329
diff
changeset
|
7793 int encodep; |
|
572ba933a4bf
(code_convert_string_norecord): New function.
Karl Heuer <kwzh@gnu.org>
parents:
22329
diff
changeset
|
7794 { |
|
88430
6418a272b97e
* coding.c: Delete unused variables.
Kenichi Handa <handa@m17n.org>
parents:
88365
diff
changeset
|
7795 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
|
7796 } |
| 88365 | 7797 |
| 7798 | |
| 7799 DEFUN ("decode-coding-string", Fdecode_coding_string, Sdecode_coding_string, | |
| 7800 2, 4, 0, | |
| 7801 doc: /* Decode STRING which is encoded in CODING-SYSTEM, and return the result. | |
| 7802 | |
| 7803 Optional third arg NOCOPY non-nil means it is OK to return STRING itself | |
| 7804 if the decoding operation is trivial. | |
| 7805 | |
| 7806 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
|
7807 inserted in BUFFER instead of returned as a string. In this case, |
| 88365 | 7808 the return value is BUFFER. |
| 7809 | |
| 7810 This function sets `last-coding-system-used' to the precise coding system | |
| 7811 used (which may be different from CODING-SYSTEM if CODING-SYSTEM is | |
| 7812 not fully specified. */) | |
| 7813 (string, coding_system, nocopy, buffer) | |
| 7814 Lisp_Object string, coding_system, nocopy, buffer; | |
| 7815 { | |
| 7816 return code_convert_string (string, coding_system, buffer, | |
| 7817 0, ! NILP (nocopy), 0); | |
| 7818 } | |
| 7819 | |
| 7820 DEFUN ("encode-coding-string", Fencode_coding_string, Sencode_coding_string, | |
| 7821 2, 4, 0, | |
| 7822 doc: /* Encode STRING to CODING-SYSTEM, and return the result. | |
| 7823 | |
| 7824 Optional third arg NOCOPY non-nil means it is OK to return STRING | |
| 7825 itself if the encoding operation is trivial. | |
| 7826 | |
| 7827 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
|
7828 inserted in BUFFER instead of returned as a string. In this case, |
| 88365 | 7829 the return value is BUFFER. |
| 7830 | |
| 7831 This function sets `last-coding-system-used' to the precise coding system | |
| 7832 used (which may be different from CODING-SYSTEM if CODING-SYSTEM is | |
| 7833 not fully specified.) */) | |
| 7834 (string, coding_system, nocopy, buffer) | |
| 7835 Lisp_Object string, coding_system, nocopy, buffer; | |
| 7836 { | |
| 7837 return code_convert_string (string, coding_system, buffer, | |
| 88856 | 7838 1, ! NILP (nocopy), 1); |
| 88365 | 7839 } |
| 7840 | |
|
20680
dd46027e8412
(code_convert_region): Always count chars inserted
Richard M. Stallman <rms@gnu.org>
parents:
20668
diff
changeset
|
7841 |
| 17052 | 7842 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
|
7843 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
|
7844 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
|
7845 (code) |
| 17052 | 7846 Lisp_Object code; |
| 7847 { | |
| 88365 | 7848 Lisp_Object spec, attrs, val; |
| 7849 struct charset *charset_roman, *charset_kanji, *charset_kana, *charset; | |
| 7850 int c; | |
| 7851 | |
| 7852 CHECK_NATNUM (code); | |
| 7853 c = XFASTINT (code); | |
| 7854 CHECK_CODING_SYSTEM_GET_SPEC (Vsjis_coding_system, spec); | |
| 7855 attrs = AREF (spec, 0); | |
| 7856 | |
| 7857 if (ASCII_BYTE_P (c) | |
| 7858 && ! NILP (CODING_ATTR_ASCII_COMPAT (attrs))) | |
| 7859 return code; | |
| 7860 | |
| 7861 val = CODING_ATTR_CHARSET_LIST (attrs); | |
| 7862 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
|
7863 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
|
7864 charset_kanji = CHARSET_FROM_ID (XINT (XCAR (val))); |
| 88365 | 7865 |
| 7866 if (c <= 0x7F) | |
| 7867 charset = charset_roman; | |
| 7868 else if (c >= 0xA0 && c < 0xDF) | |
| 7869 { | |
| 7870 charset = charset_kana; | |
| 7871 c -= 0x80; | |
|
24065
7e291dea6141
(Fdecode_sjis_char): Decode Japanese Katakana character
Kenichi Handa <handa@m17n.org>
parents:
24056
diff
changeset
|
7872 } |
|
7e291dea6141
(Fdecode_sjis_char): Decode Japanese Katakana character
Kenichi Handa <handa@m17n.org>
parents:
24056
diff
changeset
|
7873 else |
|
7e291dea6141
(Fdecode_sjis_char): Decode Japanese Katakana character
Kenichi Handa <handa@m17n.org>
parents:
24056
diff
changeset
|
7874 { |
|
88497
d2b9e0d4c2f6
(Fdecode_sjis_char): Fix typo (0x7F->0xFF). Fix the
Kenichi Handa <handa@m17n.org>
parents:
88485
diff
changeset
|
7875 int s1 = c >> 8, s2 = c & 0xFF; |
| 88365 | 7876 |
| 7877 if (s1 < 0x81 || (s1 > 0x9F && s1 < 0xE0) || s1 > 0xEF | |
| 7878 || s2 < 0x40 || s2 == 0x7F || s2 > 0xFC) | |
| 7879 error ("Invalid code: %d", code); | |
| 7880 SJIS_TO_JIS (c); | |
| 7881 charset = charset_kanji; | |
| 7882 } | |
| 7883 c = DECODE_CHAR (charset, c); | |
| 7884 if (c < 0) | |
| 7885 error ("Invalid code: %d", code); | |
| 7886 return make_number (c); | |
| 17052 | 7887 } |
| 7888 | |
| 88365 | 7889 |
| 17052 | 7890 DEFUN ("encode-sjis-char", Fencode_sjis_char, Sencode_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
|
7891 doc: /* Encode a Japanese character CHAR to shift_jis encoding. |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
7892 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
|
7893 (ch) |
| 88365 | 7894 Lisp_Object ch; |
| 17052 | 7895 { |
| 88365 | 7896 Lisp_Object spec, attrs, charset_list; |
| 7897 int c; | |
| 7898 struct charset *charset; | |
| 7899 unsigned code; | |
| 7900 | |
| 7901 CHECK_CHARACTER (ch); | |
| 7902 c = XFASTINT (ch); | |
| 7903 CHECK_CODING_SYSTEM_GET_SPEC (Vsjis_coding_system, spec); | |
| 7904 attrs = AREF (spec, 0); | |
| 7905 | |
| 7906 if (ASCII_CHAR_P (c) | |
| 7907 && ! NILP (CODING_ATTR_ASCII_COMPAT (attrs))) | |
| 7908 return ch; | |
| 7909 | |
| 7910 charset_list = CODING_ATTR_CHARSET_LIST (attrs); | |
| 7911 charset = char_charset (c, charset_list, &code); | |
| 7912 if (code == CHARSET_INVALID_CODE (charset)) | |
| 7913 error ("Can't encode by shift_jis encoding: %d", c); | |
| 7914 JIS_TO_SJIS (code); | |
| 7915 | |
| 7916 return make_number (code); | |
| 17052 | 7917 } |
| 7918 | |
| 7919 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
|
7920 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
|
7921 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
|
7922 (code) |
| 17052 | 7923 Lisp_Object code; |
| 7924 { | |
| 88365 | 7925 Lisp_Object spec, attrs, val; |
| 7926 struct charset *charset_roman, *charset_big5, *charset; | |
| 7927 int c; | |
| 7928 | |
| 7929 CHECK_NATNUM (code); | |
| 7930 c = XFASTINT (code); | |
| 7931 CHECK_CODING_SYSTEM_GET_SPEC (Vbig5_coding_system, spec); | |
| 7932 attrs = AREF (spec, 0); | |
| 7933 | |
| 7934 if (ASCII_BYTE_P (c) | |
| 7935 && ! NILP (CODING_ATTR_ASCII_COMPAT (attrs))) | |
| 7936 return code; | |
| 7937 | |
| 7938 val = CODING_ATTR_CHARSET_LIST (attrs); | |
| 7939 charset_roman = CHARSET_FROM_ID (XINT (XCAR (val))), val = XCDR (val); | |
| 7940 charset_big5 = CHARSET_FROM_ID (XINT (XCAR (val))); | |
| 7941 | |
| 7942 if (c <= 0x7F) | |
| 7943 charset = charset_roman; | |
|
24324
2eec590faf26
(Fdecode_sjis_char, Fencode_sjis_char): Hanlde
Kenichi Handa <handa@m17n.org>
parents:
24316
diff
changeset
|
7944 else |
|
2eec590faf26
(Fdecode_sjis_char, Fencode_sjis_char): Hanlde
Kenichi Handa <handa@m17n.org>
parents:
24316
diff
changeset
|
7945 { |
| 88365 | 7946 int b1 = c >> 8, b2 = c & 0x7F; |
| 7947 if (b1 < 0xA1 || b1 > 0xFE | |
| 7948 || b2 < 0x40 || (b2 > 0x7E && b2 < 0xA1) || b2 > 0xFE) | |
| 7949 error ("Invalid code: %d", code); | |
| 7950 charset = charset_big5; | |
| 7951 } | |
| 7952 c = DECODE_CHAR (charset, (unsigned )c); | |
| 7953 if (c < 0) | |
| 7954 error ("Invalid code: %d", code); | |
| 7955 return make_number (c); | |
| 17052 | 7956 } |
| 7957 | |
| 7958 DEFUN ("encode-big5-char", Fencode_big5_char, Sencode_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
|
7959 doc: /* Encode the Big5 character CHAR to BIG5 coding system. |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
7960 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
|
7961 (ch) |
| 17052 | 7962 Lisp_Object ch; |
| 7963 { | |
| 88365 | 7964 Lisp_Object spec, attrs, charset_list; |
| 7965 struct charset *charset; | |
| 7966 int c; | |
| 7967 unsigned code; | |
| 7968 | |
| 7969 CHECK_CHARACTER (ch); | |
| 7970 c = XFASTINT (ch); | |
| 7971 CHECK_CODING_SYSTEM_GET_SPEC (Vbig5_coding_system, spec); | |
| 7972 attrs = AREF (spec, 0); | |
| 7973 if (ASCII_CHAR_P (c) | |
| 7974 && ! NILP (CODING_ATTR_ASCII_COMPAT (attrs))) | |
| 7975 return ch; | |
| 7976 | |
| 7977 charset_list = CODING_ATTR_CHARSET_LIST (attrs); | |
| 7978 charset = char_charset (c, charset_list, &code); | |
| 7979 if (code == CHARSET_INVALID_CODE (charset)) | |
| 7980 error ("Can't encode by Big5 encoding: %d", c); | |
| 7981 | |
| 7982 return make_number (code); | |
| 17052 | 7983 } |
| 88365 | 7984 |
|
20680
dd46027e8412
(code_convert_region): Always count chars inserted
Richard M. Stallman <rms@gnu.org>
parents:
20668
diff
changeset
|
7985 |
|
18002
a14261786239
(encode_invocation_designation): Use macro
Kenichi Handa <handa@m17n.org>
parents:
17835
diff
changeset
|
7986 DEFUN ("set-terminal-coding-system-internal", |
|
a14261786239
(encode_invocation_designation): Use macro
Kenichi Handa <handa@m17n.org>
parents:
17835
diff
changeset
|
7987 Fset_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
|
7988 Sset_terminal_coding_system_internal, 1, 1, 0, |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
7989 doc: /* Internal use only. */) |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
7990 (coding_system) |
| 88473 | 7991 Lisp_Object coding_system; |
| 17052 | 7992 { |
|
40656
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Jan?k <Pavel@Janik.cz>
parents:
40461
diff
changeset
|
7993 CHECK_SYMBOL (coding_system); |
| 88365 | 7994 setup_coding_system (Fcheck_coding_system (coding_system), |
| 7995 &terminal_coding); | |
| 89483 | 7996 |
|
20150
402b6e5f4b58
(encode_designation_at_bol): Fix bug of finding graphic
Kenichi Handa <handa@m17n.org>
parents:
20105
diff
changeset
|
7997 /* We had better not send unsafe characters to terminal. */ |
| 88365 | 7998 terminal_coding.mode |= CODING_MODE_SAFE_ENCODING; |
| 7999 /* Characer composition should be disabled. */ | |
| 8000 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
|
8001 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
|
8002 terminal_coding.dst_multibyte = 0; |
| 17052 | 8003 return Qnil; |
| 8004 } | |
| 8005 | |
|
19280
e755044718ee
(ENCODE_ISO_CHARACTER_DIMENSION1): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
19193
diff
changeset
|
8006 DEFUN ("set-safe-terminal-coding-system-internal", |
|
e755044718ee
(ENCODE_ISO_CHARACTER_DIMENSION1): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
19193
diff
changeset
|
8007 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
|
8008 Sset_safe_terminal_coding_system_internal, 1, 1, 0, |
| 41006 | 8009 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
|
8010 (coding_system) |
| 88473 | 8011 Lisp_Object coding_system; |
|
19280
e755044718ee
(ENCODE_ISO_CHARACTER_DIMENSION1): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
19193
diff
changeset
|
8012 { |
|
40656
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Jan?k <Pavel@Janik.cz>
parents:
40461
diff
changeset
|
8013 CHECK_SYMBOL (coding_system); |
|
19280
e755044718ee
(ENCODE_ISO_CHARACTER_DIMENSION1): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
19193
diff
changeset
|
8014 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
|
8015 &safe_terminal_coding); |
| 88365 | 8016 /* Characer composition should be disabled. */ |
| 8017 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
|
8018 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
|
8019 safe_terminal_coding.dst_multibyte = 0; |
|
19280
e755044718ee
(ENCODE_ISO_CHARACTER_DIMENSION1): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
19193
diff
changeset
|
8020 return Qnil; |
|
e755044718ee
(ENCODE_ISO_CHARACTER_DIMENSION1): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
19193
diff
changeset
|
8021 } |
|
e755044718ee
(ENCODE_ISO_CHARACTER_DIMENSION1): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
19193
diff
changeset
|
8022 |
| 17052 | 8023 DEFUN ("terminal-coding-system", |
| 8024 Fterminal_coding_system, Sterminal_coding_system, 0, 0, 0, | |
|
40713
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
8025 doc: /* Return coding system specified for terminal output. */) |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
8026 () |
| 17052 | 8027 { |
| 88365 | 8028 return CODING_ID_NAME (terminal_coding.id); |
| 17052 | 8029 } |
| 8030 | |
|
18002
a14261786239
(encode_invocation_designation): Use macro
Kenichi Handa <handa@m17n.org>
parents:
17835
diff
changeset
|
8031 DEFUN ("set-keyboard-coding-system-internal", |
|
a14261786239
(encode_invocation_designation): Use macro
Kenichi Handa <handa@m17n.org>
parents:
17835
diff
changeset
|
8032 Fset_keyboard_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
|
8033 Sset_keyboard_coding_system_internal, 1, 1, 0, |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
8034 doc: /* Internal use only. */) |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
8035 (coding_system) |
| 17052 | 8036 Lisp_Object coding_system; |
| 8037 { | |
|
40656
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Jan?k <Pavel@Janik.cz>
parents:
40461
diff
changeset
|
8038 CHECK_SYMBOL (coding_system); |
| 88365 | 8039 setup_coding_system (Fcheck_coding_system (coding_system), |
| 8040 &keyboard_coding); | |
| 8041 /* Characer composition should be disabled. */ | |
| 8042 keyboard_coding.common_flags &= ~CODING_ANNOTATE_COMPOSITION_MASK; | |
| 17052 | 8043 return Qnil; |
| 8044 } | |
| 8045 | |
| 8046 DEFUN ("keyboard-coding-system", | |
| 8047 Fkeyboard_coding_system, Skeyboard_coding_system, 0, 0, 0, | |
|
40713
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
8048 doc: /* Return coding system specified for decoding keyboard input. */) |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
8049 () |
| 17052 | 8050 { |
| 88365 | 8051 return CODING_ID_NAME (keyboard_coding.id); |
| 17052 | 8052 } |
| 8053 | |
| 8054 | |
|
18536
69c0e220b626
(Vstandard_character_unification_table_for_decode):
Kenichi Handa <handa@m17n.org>
parents:
18523
diff
changeset
|
8055 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
|
8056 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
|
8057 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
|
8058 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
|
8059 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
|
8060 \(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
|
8061 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
|
8062 |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
8063 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
|
8064 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
|
8065 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
|
8066 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
|
8067 |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
8068 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
|
8069 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
|
8070 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
|
8071 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
|
8072 |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
8073 TARGET has a meaning which depends on OPERATION: |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
8074 For file I/O, TARGET is a file name. |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
8075 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
|
8076 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
|
8077 |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
8078 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
|
8079 `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
|
8080 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
|
8081 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
|
8082 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
|
8083 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
|
8084 which is a list of all the arguments given to this function. |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
8085 |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
8086 usage: (find-operation-coding-system OPERATION ARGUMENTS ...) */) |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
8087 (nargs, args) |
| 17052 | 8088 int nargs; |
| 8089 Lisp_Object *args; | |
| 8090 { | |
| 8091 Lisp_Object operation, target_idx, target, val; | |
| 8092 register Lisp_Object chain; | |
| 8093 | |
| 8094 if (nargs < 2) | |
| 8095 error ("Too few arguments"); | |
| 8096 operation = args[0]; | |
| 8097 if (!SYMBOLP (operation) | |
| 8098 || !INTEGERP (target_idx = Fget (operation, Qtarget_idx))) | |
| 88365 | 8099 error ("Invalid first arguement"); |
| 17052 | 8100 if (nargs < 1 + XINT (target_idx)) |
| 8101 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
|
8102 SDATA (SYMBOL_NAME (operation))); |
| 17052 | 8103 target = args[XINT (target_idx) + 1]; |
| 8104 if (!(STRINGP (target) | |
| 8105 || (EQ (operation, Qopen_network_stream) && INTEGERP (target)))) | |
| 88365 | 8106 error ("Invalid %dth argument", XINT (target_idx) + 1); |
| 17052 | 8107 |
|
18613
614b916ff5bf
Fix bugs with inappropriate mixing of Lisp_Object with int.
Richard M. Stallman <rms@gnu.org>
parents:
18536
diff
changeset
|
8108 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
|
8109 || EQ (operation, Qwrite_region)) |
|
18180
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
8110 ? 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
|
8111 : (EQ (operation, Qopen_network_stream) |
|
18180
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
8112 ? Vnetwork_coding_system_alist |
|
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
8113 : Vprocess_coding_system_alist)); |
| 17052 | 8114 if (NILP (chain)) |
| 8115 return Qnil; | |
| 8116 | |
|
25662
0a7261c1d487
Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25370
diff
changeset
|
8117 for (; CONSP (chain); chain = XCDR (chain)) |
| 17052 | 8118 { |
|
19747
bed06df9cbc5
(setup_coding_system, Ffind_operation_coding_system)
Richard M. Stallman <rms@gnu.org>
parents:
19743
diff
changeset
|
8119 Lisp_Object elt; |
| 88365 | 8120 |
|
25662
0a7261c1d487
Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25370
diff
changeset
|
8121 elt = XCAR (chain); |
| 17052 | 8122 if (CONSP (elt) |
| 8123 && ((STRINGP (target) | |
|
25662
0a7261c1d487
Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25370
diff
changeset
|
8124 && STRINGP (XCAR (elt)) |
|
0a7261c1d487
Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25370
diff
changeset
|
8125 && 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
|
8126 || (INTEGERP (target) && EQ (target, XCAR (elt))))) |
|
18180
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
8127 { |
|
25662
0a7261c1d487
Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25370
diff
changeset
|
8128 val = XCDR (elt); |
|
19763
ab2fd2c85986
(Ffind_operation_coding_system): If a function in
Kenichi Handa <handa@m17n.org>
parents:
19758
diff
changeset
|
8129 /* 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
|
8130 function symbol, we return VAL as a coding system. */ |
|
18180
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
8131 if (CONSP (val)) |
|
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
8132 return val; |
|
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
8133 if (! SYMBOLP (val)) |
|
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
8134 return Qnil; |
|
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
8135 if (! NILP (Fcoding_system_p (val))) |
|
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
8136 return Fcons (val, val); |
|
19763
ab2fd2c85986
(Ffind_operation_coding_system): If a function in
Kenichi Handa <handa@m17n.org>
parents:
19758
diff
changeset
|
8137 if (! NILP (Ffboundp (val))) |
|
ab2fd2c85986
(Ffind_operation_coding_system): If a function in
Kenichi Handa <handa@m17n.org>
parents:
19758
diff
changeset
|
8138 { |
|
ab2fd2c85986
(Ffind_operation_coding_system): If a function in
Kenichi Handa <handa@m17n.org>
parents:
19758
diff
changeset
|
8139 val = call1 (val, Flist (nargs, args)); |
|
ab2fd2c85986
(Ffind_operation_coding_system): If a function in
Kenichi Handa <handa@m17n.org>
parents:
19758
diff
changeset
|
8140 if (CONSP (val)) |
|
ab2fd2c85986
(Ffind_operation_coding_system): If a function in
Kenichi Handa <handa@m17n.org>
parents:
19758
diff
changeset
|
8141 return val; |
|
ab2fd2c85986
(Ffind_operation_coding_system): If a function in
Kenichi Handa <handa@m17n.org>
parents:
19758
diff
changeset
|
8142 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
|
8143 return Fcons (val, val); |
|
ab2fd2c85986
(Ffind_operation_coding_system): If a function in
Kenichi Handa <handa@m17n.org>
parents:
19758
diff
changeset
|
8144 } |
|
18180
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
8145 return Qnil; |
|
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
8146 } |
| 17052 | 8147 } |
| 8148 return Qnil; | |
| 8149 } | |
| 8150 | |
| 88365 | 8151 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
|
8152 Sset_coding_system_priority, 0, MANY, 0, |
| 88645 | 8153 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
|
8154 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
|
8155 all but the first one are ignored. |
|
040a08a2a879
(Fread_coding_system): Fix arg of XSETSTRING.
Dave Love <fx@gnu.org>
parents:
89483
diff
changeset
|
8156 |
|
040a08a2a879
(Fread_coding_system): Fix arg of XSETSTRING.
Dave Love <fx@gnu.org>
parents:
89483
diff
changeset
|
8157 usage: (set-coding-system-priority ...) */) |
| 88365 | 8158 (nargs, args) |
| 8159 int nargs; | |
| 8160 Lisp_Object *args; | |
| 8161 { | |
| 8162 int i, j; | |
| 8163 int changed[coding_category_max]; | |
| 8164 enum coding_category priorities[coding_category_max]; | |
| 8165 | |
| 8166 bzero (changed, sizeof changed); | |
| 8167 | |
| 8168 for (i = j = 0; i < nargs; i++) | |
| 8169 { | |
| 8170 enum coding_category category; | |
| 8171 Lisp_Object spec, attrs; | |
| 8172 | |
| 8173 CHECK_CODING_SYSTEM_GET_SPEC (args[i], spec); | |
| 8174 attrs = AREF (spec, 0); | |
| 8175 category = XINT (CODING_ATTR_CATEGORY (attrs)); | |
| 8176 if (changed[category]) | |
| 8177 /* Ignore this coding system because a coding system of the | |
| 8178 same category already had a higher priority. */ | |
| 8179 continue; | |
| 8180 changed[category] = 1; | |
| 8181 priorities[j++] = category; | |
| 8182 if (coding_categories[category].id >= 0 | |
| 8183 && ! EQ (args[i], CODING_ID_NAME (coding_categories[category].id))) | |
| 8184 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
|
8185 Fset (AREF (Vcoding_category_table, category), args[i]); |
| 88365 | 8186 } |
| 8187 | |
| 8188 /* Now we have decided top J priorities. Reflect the order of the | |
| 8189 original priorities to the remaining priorities. */ | |
| 8190 | |
| 8191 for (i = j, j = 0; i < coding_category_max; i++, j++) | |
| 8192 { | |
| 8193 while (j < coding_category_max | |
| 8194 && changed[coding_priorities[j]]) | |
| 8195 j++; | |
| 8196 if (j == coding_category_max) | |
| 8197 abort (); | |
| 8198 priorities[i] = coding_priorities[j]; | |
| 8199 } | |
| 8200 | |
| 8201 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
|
8202 |
|
e911ca706166
(Fset_coding_system_priority): Doc fix. Update values
Kenichi Handa <handa@m17n.org>
parents:
89462
diff
changeset
|
8203 /* Update `coding-category-list'. */ |
|
e911ca706166
(Fset_coding_system_priority): Doc fix. Update values
Kenichi Handa <handa@m17n.org>
parents:
89462
diff
changeset
|
8204 Vcoding_category_list = Qnil; |
|
e911ca706166
(Fset_coding_system_priority): Doc fix. Update values
Kenichi Handa <handa@m17n.org>
parents:
89462
diff
changeset
|
8205 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
|
8206 Vcoding_category_list |
|
e911ca706166
(Fset_coding_system_priority): Doc fix. Update values
Kenichi Handa <handa@m17n.org>
parents:
89462
diff
changeset
|
8207 = 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
|
8208 Vcoding_category_list); |
|
e911ca706166
(Fset_coding_system_priority): Doc fix. Update values
Kenichi Handa <handa@m17n.org>
parents:
89462
diff
changeset
|
8209 |
| 88365 | 8210 return Qnil; |
| 8211 } | |
| 8212 | |
| 8213 DEFUN ("coding-system-priority-list", Fcoding_system_priority_list, | |
| 8214 Scoding_system_priority_list, 0, 1, 0, | |
| 88645 | 8215 doc: /* Return a list of coding systems ordered by their priorities. |
| 8216 HIGHESTP non-nil means just return the highest priority one. */) | |
| 88365 | 8217 (highestp) |
| 8218 Lisp_Object highestp; | |
|
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
8219 { |
|
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
8220 int i; |
| 88365 | 8221 Lisp_Object val; |
| 8222 | |
| 8223 for (i = 0, val = Qnil; i < coding_category_max; i++) | |
| 8224 { | |
| 8225 enum coding_category category = coding_priorities[i]; | |
| 8226 int id = coding_categories[category].id; | |
| 8227 Lisp_Object attrs; | |
| 8228 | |
| 8229 if (id < 0) | |
| 8230 continue; | |
| 8231 attrs = CODING_ID_ATTRS (id); | |
| 8232 if (! NILP (highestp)) | |
| 8233 return CODING_ATTR_BASE_NAME (attrs); | |
| 8234 val = Fcons (CODING_ATTR_BASE_NAME (attrs), val); | |
| 8235 } | |
| 8236 return Fnreverse (val); | |
| 8237 } | |
| 8238 | |
|
88631
780b91d4a7e5
(setup_iso_safe_charsets): Fix arg decl for K&R.
Dave Love <fx@gnu.org>
parents:
88607
diff
changeset
|
8239 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
|
8240 |
| 88365 | 8241 static Lisp_Object |
| 8242 make_subsidiaries (base) | |
| 8243 Lisp_Object base; | |
| 8244 { | |
| 8245 Lisp_Object subsidiaries; | |
| 89483 | 8246 int base_name_len = SBYTES (SYMBOL_NAME (base)); |
| 88365 | 8247 char *buf = (char *) alloca (base_name_len + 6); |
| 8248 int i; | |
| 89483 | 8249 |
| 8250 bcopy (SDATA (SYMBOL_NAME (base)), buf, base_name_len); | |
| 88365 | 8251 subsidiaries = Fmake_vector (make_number (3), Qnil); |
| 8252 for (i = 0; i < 3; i++) | |
| 8253 { | |
| 8254 bcopy (suffixes[i], buf + base_name_len, strlen (suffixes[i]) + 1); | |
| 8255 ASET (subsidiaries, i, intern (buf)); | |
| 8256 } | |
| 8257 return subsidiaries; | |
| 8258 } | |
| 8259 | |
| 8260 | |
| 8261 DEFUN ("define-coding-system-internal", Fdefine_coding_system_internal, | |
| 8262 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
|
8263 doc: /* For internal use only. |
|
f464d728344c
(Vchar_coding_system_table, Qchar_coding_system):
Dave Love <fx@gnu.org>
parents:
88510
diff
changeset
|
8264 usage: (define-coding-system-internal ...) */) |
| 88365 | 8265 (nargs, args) |
| 8266 int nargs; | |
| 8267 Lisp_Object *args; | |
| 8268 { | |
| 8269 Lisp_Object name; | |
| 8270 Lisp_Object spec_vec; /* [ ATTRS ALIASE EOL_TYPE ] */ | |
| 8271 Lisp_Object attrs; /* Vector of attributes. */ | |
| 8272 Lisp_Object eol_type; | |
| 8273 Lisp_Object aliases; | |
| 8274 Lisp_Object coding_type, charset_list, safe_charsets; | |
| 8275 enum coding_category category; | |
| 8276 Lisp_Object tail, val; | |
| 8277 int max_charset_id = 0; | |
| 8278 int i; | |
| 8279 | |
| 8280 if (nargs < coding_arg_max) | |
| 8281 goto short_args; | |
| 8282 | |
| 8283 attrs = Fmake_vector (make_number (coding_attr_last_index), Qnil); | |
| 8284 | |
| 8285 name = args[coding_arg_name]; | |
| 8286 CHECK_SYMBOL (name); | |
| 8287 CODING_ATTR_BASE_NAME (attrs) = name; | |
| 8288 | |
| 8289 val = args[coding_arg_mnemonic]; | |
| 8290 if (! STRINGP (val)) | |
| 8291 CHECK_CHARACTER (val); | |
| 8292 CODING_ATTR_MNEMONIC (attrs) = val; | |
| 8293 | |
| 8294 coding_type = args[coding_arg_coding_type]; | |
| 8295 CHECK_SYMBOL (coding_type); | |
| 8296 CODING_ATTR_TYPE (attrs) = coding_type; | |
| 8297 | |
| 8298 charset_list = args[coding_arg_charset_list]; | |
| 8299 if (SYMBOLP (charset_list)) | |
| 8300 { | |
| 8301 if (EQ (charset_list, Qiso_2022)) | |
| 8302 { | |
| 8303 if (! EQ (coding_type, Qiso_2022)) | |
| 8304 error ("Invalid charset-list"); | |
| 8305 charset_list = Viso_2022_charset_list; | |
| 8306 } | |
| 8307 else if (EQ (charset_list, Qemacs_mule)) | |
| 8308 { | |
| 8309 if (! EQ (coding_type, Qemacs_mule)) | |
| 8310 error ("Invalid charset-list"); | |
| 8311 charset_list = Vemacs_mule_charset_list; | |
| 8312 } | |
| 8313 for (tail = charset_list; CONSP (tail); tail = XCDR (tail)) | |
| 8314 if (max_charset_id < XFASTINT (XCAR (tail))) | |
| 8315 max_charset_id = XFASTINT (XCAR (tail)); | |
| 8316 } | |
| 8317 else | |
| 8318 { | |
| 8319 charset_list = Fcopy_sequence (charset_list); | |
| 8320 for (tail = charset_list; !NILP (tail); tail = Fcdr (tail)) | |
| 8321 { | |
| 8322 struct charset *charset; | |
| 8323 | |
| 8324 val = Fcar (tail); | |
| 8325 CHECK_CHARSET_GET_CHARSET (val, charset); | |
| 8326 if (EQ (coding_type, Qiso_2022) | |
| 8327 ? CHARSET_ISO_FINAL (charset) < 0 | |
| 8328 : EQ (coding_type, Qemacs_mule) | |
| 8329 ? CHARSET_EMACS_MULE_ID (charset) < 0 | |
| 8330 : 0) | |
| 8331 error ("Can't handle charset `%s'", | |
| 89483 | 8332 SDATA (SYMBOL_NAME (CHARSET_NAME (charset)))); |
| 8333 | |
| 8334 XSETCAR (tail, make_number (charset->id)); | |
| 88365 | 8335 if (max_charset_id < charset->id) |
| 8336 max_charset_id = charset->id; | |
| 8337 } | |
| 8338 } | |
| 8339 CODING_ATTR_CHARSET_LIST (attrs) = charset_list; | |
| 8340 | |
| 8341 safe_charsets = Fmake_string (make_number (max_charset_id + 1), | |
| 8342 make_number (255)); | |
| 8343 for (tail = charset_list; CONSP (tail); tail = XCDR (tail)) | |
| 89483 | 8344 SSET (safe_charsets, XFASTINT (XCAR (tail)), 0); |
| 88365 | 8345 CODING_ATTR_SAFE_CHARSETS (attrs) = safe_charsets; |
| 8346 | |
|
89225
32058afc72e2
(detect_coding_charset): If only ASCII bytes are found, return 0.
Kenichi Handa <handa@m17n.org>
parents:
89221
diff
changeset
|
8347 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
|
8348 |
| 88365 | 8349 val = args[coding_arg_decode_translation_table]; |
|
89759
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
8350 if (! CHAR_TABLE_P (val) && ! CONSP (val)) |
|
89732
8acde12aba89
(get_translation_table): New function.
Kenichi Handa <handa@m17n.org>
parents:
89730
diff
changeset
|
8351 CHECK_SYMBOL (val); |
| 88365 | 8352 CODING_ATTR_DECODE_TBL (attrs) = val; |
| 8353 | |
| 8354 val = args[coding_arg_encode_translation_table]; | |
|
89759
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
8355 if (! CHAR_TABLE_P (val) && ! CONSP (val)) |
|
89732
8acde12aba89
(get_translation_table): New function.
Kenichi Handa <handa@m17n.org>
parents:
89730
diff
changeset
|
8356 CHECK_SYMBOL (val); |
| 88365 | 8357 CODING_ATTR_ENCODE_TBL (attrs) = val; |
| 8358 | |
| 8359 val = args[coding_arg_post_read_conversion]; | |
| 8360 CHECK_SYMBOL (val); | |
| 8361 CODING_ATTR_POST_READ (attrs) = val; | |
| 8362 | |
| 8363 val = args[coding_arg_pre_write_conversion]; | |
| 8364 CHECK_SYMBOL (val); | |
| 8365 CODING_ATTR_PRE_WRITE (attrs) = val; | |
| 8366 | |
| 8367 val = args[coding_arg_default_char]; | |
| 8368 if (NILP (val)) | |
| 8369 CODING_ATTR_DEFAULT_CHAR (attrs) = make_number (' '); | |
| 8370 else | |
| 8371 { | |
| 89483 | 8372 CHECK_CHARACTER (val); |
| 88365 | 8373 CODING_ATTR_DEFAULT_CHAR (attrs) = val; |
| 8374 } | |
| 8375 | |
| 89483 | 8376 val = args[coding_arg_for_unibyte]; |
| 8377 CODING_ATTR_FOR_UNIBYTE (attrs) = NILP (val) ? Qnil : Qt; | |
| 8378 | |
| 88365 | 8379 val = args[coding_arg_plist]; |
| 8380 CHECK_LIST (val); | |
| 8381 CODING_ATTR_PLIST (attrs) = val; | |
| 8382 | |
| 8383 if (EQ (coding_type, Qcharset)) | |
| 8384 { | |
|
88597
74b74f59bc09
(decode_coding_charset): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
88587
diff
changeset
|
8385 /* 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
|
8386 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
|
8387 |
|
74b74f59bc09
(decode_coding_charset): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
88587
diff
changeset
|
8388 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
|
8389 coding system. |
|
74b74f59bc09
(decode_coding_charset): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
88587
diff
changeset
|
8390 |
|
74b74f59bc09
(decode_coding_charset): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
88587
diff
changeset
|
8391 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
|
8392 charset whose ID is NUM. |
|
74b74f59bc09
(decode_coding_charset): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
88587
diff
changeset
|
8393 |
|
74b74f59bc09
(decode_coding_charset): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
88587
diff
changeset
|
8394 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
|
8395 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
|
8396 charsets. A charset of smaller dimension comes firtst. */ |
| 88365 | 8397 val = Fmake_vector (make_number (256), Qnil); |
| 8398 | |
|
89653
cbaa9fd1aa5c
(Fdefine_coding_system_internal): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89648
diff
changeset
|
8399 for (tail = charset_list; CONSP (tail); tail = XCDR (tail)) |
| 88365 | 8400 { |
|
88597
74b74f59bc09
(decode_coding_charset): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
88587
diff
changeset
|
8401 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
|
8402 int dim = CHARSET_DIMENSION (charset); |
|
74b74f59bc09
(decode_coding_charset): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
88587
diff
changeset
|
8403 int idx = (dim - 1) * 4; |
| 89483 | 8404 |
|
89653
cbaa9fd1aa5c
(Fdefine_coding_system_internal): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89648
diff
changeset
|
8405 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
|
8406 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
|
8407 |
|
88477
5f974cbba7b3
(coding_set_source): Delete the local variable beg_byte.
Kenichi Handa <handa@m17n.org>
parents:
88473
diff
changeset
|
8408 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
|
8409 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
|
8410 { |
|
88597
74b74f59bc09
(decode_coding_charset): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
88587
diff
changeset
|
8411 Lisp_Object tmp, tmp2; |
|
74b74f59bc09
(decode_coding_charset): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
88587
diff
changeset
|
8412 int dim2; |
|
74b74f59bc09
(decode_coding_charset): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
88587
diff
changeset
|
8413 |
|
74b74f59bc09
(decode_coding_charset): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
88587
diff
changeset
|
8414 tmp = AREF (val, i); |
|
74b74f59bc09
(decode_coding_charset): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
88587
diff
changeset
|
8415 if (NILP (tmp)) |
|
74b74f59bc09
(decode_coding_charset): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
88587
diff
changeset
|
8416 tmp = XCAR (tail); |
|
74b74f59bc09
(decode_coding_charset): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
88587
diff
changeset
|
8417 else if (NUMBERP (tmp)) |
|
74b74f59bc09
(decode_coding_charset): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
88587
diff
changeset
|
8418 { |
|
74b74f59bc09
(decode_coding_charset): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
88587
diff
changeset
|
8419 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
|
8420 if (dim < dim2) |
|
88607
18436bf3d6dd
(Fdefine_coding_system_internal): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
88598
diff
changeset
|
8421 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
|
8422 else |
|
88607
18436bf3d6dd
(Fdefine_coding_system_internal): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
88598
diff
changeset
|
8423 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
|
8424 } |
|
88477
5f974cbba7b3
(coding_set_source): Delete the local variable beg_byte.
Kenichi Handa <handa@m17n.org>
parents:
88473
diff
changeset
|
8425 else |
|
88597
74b74f59bc09
(decode_coding_charset): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
88587
diff
changeset
|
8426 { |
|
74b74f59bc09
(decode_coding_charset): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
88587
diff
changeset
|
8427 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
|
8428 { |
|
74b74f59bc09
(decode_coding_charset): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
88587
diff
changeset
|
8429 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
|
8430 if (dim < dim2) |
|
74b74f59bc09
(decode_coding_charset): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
88587
diff
changeset
|
8431 break; |
|
74b74f59bc09
(decode_coding_charset): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
88587
diff
changeset
|
8432 } |
|
74b74f59bc09
(decode_coding_charset): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
88587
diff
changeset
|
8433 if (NILP (tmp2)) |
|
74b74f59bc09
(decode_coding_charset): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
88587
diff
changeset
|
8434 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
|
8435 else |
|
74b74f59bc09
(decode_coding_charset): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
88587
diff
changeset
|
8436 { |
|
74b74f59bc09
(decode_coding_charset): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
88587
diff
changeset
|
8437 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
|
8438 XSETCAR (tmp2, XCAR (tail)); |
|
74b74f59bc09
(decode_coding_charset): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
88587
diff
changeset
|
8439 } |
|
74b74f59bc09
(decode_coding_charset): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
88587
diff
changeset
|
8440 } |
|
74b74f59bc09
(decode_coding_charset): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
88587
diff
changeset
|
8441 ASET (val, i, tmp); |
|
88477
5f974cbba7b3
(coding_set_source): Delete the local variable beg_byte.
Kenichi Handa <handa@m17n.org>
parents:
88473
diff
changeset
|
8442 } |
| 88365 | 8443 } |
| 8444 ASET (attrs, coding_attr_charset_valids, val); | |
| 8445 category = coding_category_charset; | |
| 8446 } | |
| 8447 else if (EQ (coding_type, Qccl)) | |
| 8448 { | |
| 8449 Lisp_Object valids; | |
| 89483 | 8450 |
| 88365 | 8451 if (nargs < coding_arg_ccl_max) |
| 8452 goto short_args; | |
| 8453 | |
| 8454 val = args[coding_arg_ccl_decoder]; | |
| 8455 CHECK_CCL_PROGRAM (val); | |
| 8456 if (VECTORP (val)) | |
| 8457 val = Fcopy_sequence (val); | |
| 8458 ASET (attrs, coding_attr_ccl_decoder, val); | |
| 8459 | |
| 8460 val = args[coding_arg_ccl_encoder]; | |
| 8461 CHECK_CCL_PROGRAM (val); | |
| 8462 if (VECTORP (val)) | |
| 8463 val = Fcopy_sequence (val); | |
| 8464 ASET (attrs, coding_attr_ccl_encoder, val); | |
| 8465 | |
| 8466 val = args[coding_arg_ccl_valids]; | |
| 8467 valids = Fmake_string (make_number (256), make_number (0)); | |
| 8468 for (tail = val; !NILP (tail); tail = Fcdr (tail)) | |
| 8469 { | |
|
89373
4cc9e57fcabc
(decode_coding_ccl, encode_coding_ccl): Call ccl_driver
Kenichi Handa <handa@m17n.org>
parents:
89331
diff
changeset
|
8470 int from, to; |
|
4cc9e57fcabc
(decode_coding_ccl, encode_coding_ccl): Call ccl_driver
Kenichi Handa <handa@m17n.org>
parents:
89331
diff
changeset
|
8471 |
| 88365 | 8472 val = Fcar (tail); |
| 8473 if (INTEGERP (val)) | |
|
89373
4cc9e57fcabc
(decode_coding_ccl, encode_coding_ccl): Call ccl_driver
Kenichi Handa <handa@m17n.org>
parents:
89331
diff
changeset
|
8474 { |
|
4cc9e57fcabc
(decode_coding_ccl, encode_coding_ccl): Call ccl_driver
Kenichi Handa <handa@m17n.org>
parents:
89331
diff
changeset
|
8475 from = to = XINT (val); |
|
4cc9e57fcabc
(decode_coding_ccl, encode_coding_ccl): Call ccl_driver
Kenichi Handa <handa@m17n.org>
parents:
89331
diff
changeset
|
8476 if (from < 0 || from > 255) |
|
4cc9e57fcabc
(decode_coding_ccl, encode_coding_ccl): Call ccl_driver
Kenichi Handa <handa@m17n.org>
parents:
89331
diff
changeset
|
8477 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
|
8478 } |
| 88365 | 8479 else |
| 8480 { | |
| 8481 CHECK_CONS (val); | |
| 89483 | 8482 CHECK_NATNUM_CAR (val); |
| 8483 CHECK_NATNUM_CDR (val); | |
| 88365 | 8484 from = XINT (XCAR (val)); |
| 89483 | 8485 if (from > 255) |
|
89373
4cc9e57fcabc
(decode_coding_ccl, encode_coding_ccl): Call ccl_driver
Kenichi Handa <handa@m17n.org>
parents:
89331
diff
changeset
|
8486 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
|
8487 make_number (0), make_number (255)); |
| 88365 | 8488 to = XINT (XCDR (val)); |
|
89373
4cc9e57fcabc
(decode_coding_ccl, encode_coding_ccl): Call ccl_driver
Kenichi Handa <handa@m17n.org>
parents:
89331
diff
changeset
|
8489 if (to < from || to > 255) |
|
4cc9e57fcabc
(decode_coding_ccl, encode_coding_ccl): Call ccl_driver
Kenichi Handa <handa@m17n.org>
parents:
89331
diff
changeset
|
8490 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
|
8491 XCAR (val), make_number (255)); |
| 88365 | 8492 } |
|
89373
4cc9e57fcabc
(decode_coding_ccl, encode_coding_ccl): Call ccl_driver
Kenichi Handa <handa@m17n.org>
parents:
89331
diff
changeset
|
8493 for (i = from; i <= to; i++) |
| 89483 | 8494 SSET (valids, i, 1); |
| 88365 | 8495 } |
| 8496 ASET (attrs, coding_attr_ccl_valids, valids); | |
| 89483 | 8497 |
| 88365 | 8498 category = coding_category_ccl; |
| 8499 } | |
| 8500 else if (EQ (coding_type, Qutf_16)) | |
| 8501 { | |
| 8502 Lisp_Object bom, endian; | |
| 8503 | |
|
89225
32058afc72e2
(detect_coding_charset): If only ASCII bytes are found, return 0.
Kenichi Handa <handa@m17n.org>
parents:
89221
diff
changeset
|
8504 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
|
8505 |
| 88365 | 8506 if (nargs < coding_arg_utf16_max) |
| 8507 goto short_args; | |
| 8508 | |
| 8509 bom = args[coding_arg_utf16_bom]; | |
| 8510 if (! NILP (bom) && ! EQ (bom, Qt)) | |
|
22874
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
8511 { |
| 88365 | 8512 CHECK_CONS (bom); |
| 89483 | 8513 val = XCAR (bom); |
| 8514 CHECK_CODING_SYSTEM (val); | |
| 8515 val = XCDR (bom); | |
| 8516 CHECK_CODING_SYSTEM (val); | |
| 88365 | 8517 } |
| 8518 ASET (attrs, coding_attr_utf_16_bom, bom); | |
| 8519 | |
| 8520 endian = args[coding_arg_utf16_endian]; | |
|
89420
c3e67ce6ee0f
(Qsignature, Qendian): Delete these variables.
Kenichi Handa <handa@m17n.org>
parents:
89418
diff
changeset
|
8521 CHECK_SYMBOL (endian); |
|
c3e67ce6ee0f
(Qsignature, Qendian): Delete these variables.
Kenichi Handa <handa@m17n.org>
parents:
89418
diff
changeset
|
8522 if (NILP (endian)) |
|
c3e67ce6ee0f
(Qsignature, Qendian): Delete these variables.
Kenichi Handa <handa@m17n.org>
parents:
89418
diff
changeset
|
8523 endian = Qbig; |
|
c3e67ce6ee0f
(Qsignature, Qendian): Delete these variables.
Kenichi Handa <handa@m17n.org>
parents:
89418
diff
changeset
|
8524 else if (! EQ (endian, Qbig) && ! EQ (endian, Qlittle)) |
| 89483 | 8525 error ("Invalid endian: %s", SDATA (SYMBOL_NAME (endian))); |
| 88365 | 8526 ASET (attrs, coding_attr_utf_16_endian, endian); |
| 8527 | |
| 8528 category = (CONSP (bom) | |
| 8529 ? coding_category_utf_16_auto | |
| 8530 : NILP (bom) | |
|
89420
c3e67ce6ee0f
(Qsignature, Qendian): Delete these variables.
Kenichi Handa <handa@m17n.org>
parents:
89418
diff
changeset
|
8531 ? (EQ (endian, Qbig) |
| 88365 | 8532 ? coding_category_utf_16_be_nosig |
| 8533 : coding_category_utf_16_le_nosig) | |
|
89420
c3e67ce6ee0f
(Qsignature, Qendian): Delete these variables.
Kenichi Handa <handa@m17n.org>
parents:
89418
diff
changeset
|
8534 : (EQ (endian, Qbig) |
| 88365 | 8535 ? coding_category_utf_16_be |
| 8536 : coding_category_utf_16_le)); | |
| 8537 } | |
| 8538 else if (EQ (coding_type, Qiso_2022)) | |
| 8539 { | |
| 8540 Lisp_Object initial, reg_usage, request, flags; | |
|
89442
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
8541 int i; |
| 88365 | 8542 |
| 8543 if (nargs < coding_arg_iso2022_max) | |
| 8544 goto short_args; | |
| 8545 | |
| 8546 initial = Fcopy_sequence (args[coding_arg_iso2022_initial]); | |
| 8547 CHECK_VECTOR (initial); | |
| 8548 for (i = 0; i < 4; i++) | |
| 8549 { | |
| 8550 val = Faref (initial, make_number (i)); | |
| 8551 if (! NILP (val)) | |
| 8552 { | |
|
89225
32058afc72e2
(detect_coding_charset): If only ASCII bytes are found, return 0.
Kenichi Handa <handa@m17n.org>
parents:
89221
diff
changeset
|
8553 struct charset *charset; |
|
32058afc72e2
(detect_coding_charset): If only ASCII bytes are found, return 0.
Kenichi Handa <handa@m17n.org>
parents:
89221
diff
changeset
|
8554 |
|
32058afc72e2
(detect_coding_charset): If only ASCII bytes are found, return 0.
Kenichi Handa <handa@m17n.org>
parents:
89221
diff
changeset
|
8555 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
|
8556 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
|
8557 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
|
8558 CODING_ATTR_ASCII_COMPAT (attrs) = Qt; |
| 88365 | 8559 } |
| 8560 else | |
| 8561 ASET (initial, i, make_number (-1)); | |
| 8562 } | |
| 8563 | |
| 8564 reg_usage = args[coding_arg_iso2022_reg_usage]; | |
| 8565 CHECK_CONS (reg_usage); | |
| 89483 | 8566 CHECK_NUMBER_CAR (reg_usage); |
| 8567 CHECK_NUMBER_CDR (reg_usage); | |
| 88365 | 8568 |
| 8569 request = Fcopy_sequence (args[coding_arg_iso2022_request]); | |
| 8570 for (tail = request; ! NILP (tail); tail = Fcdr (tail)) | |
| 8571 { | |
| 8572 int id; | |
| 89483 | 8573 Lisp_Object tmp; |
| 88365 | 8574 |
| 8575 val = Fcar (tail); | |
| 8576 CHECK_CONS (val); | |
| 89483 | 8577 tmp = XCAR (val); |
| 8578 CHECK_CHARSET_GET_ID (tmp, id); | |
| 8579 CHECK_NATNUM_CDR (val); | |
| 88365 | 8580 if (XINT (XCDR (val)) >= 4) |
| 8581 error ("Invalid graphic register number: %d", XINT (XCDR (val))); | |
| 89483 | 8582 XSETCAR (val, make_number (id)); |
| 88365 | 8583 } |
| 8584 | |
| 8585 flags = args[coding_arg_iso2022_flags]; | |
| 8586 CHECK_NATNUM (flags); | |
| 8587 i = XINT (flags); | |
| 8588 if (EQ (args[coding_arg_charset_list], Qiso_2022)) | |
| 8589 flags = make_number (i | CODING_ISO_FLAG_FULL_SUPPORT); | |
| 8590 | |
| 8591 ASET (attrs, coding_attr_iso_initial, initial); | |
| 8592 ASET (attrs, coding_attr_iso_usage, reg_usage); | |
| 8593 ASET (attrs, coding_attr_iso_request, request); | |
| 8594 ASET (attrs, coding_attr_iso_flags, flags); | |
| 8595 setup_iso_safe_charsets (attrs); | |
| 8596 | |
| 8597 if (i & CODING_ISO_FLAG_SEVEN_BITS) | |
| 8598 category = ((i & (CODING_ISO_FLAG_LOCKING_SHIFT | |
| 8599 | CODING_ISO_FLAG_SINGLE_SHIFT)) | |
| 8600 ? coding_category_iso_7_else | |
| 8601 : EQ (args[coding_arg_charset_list], Qiso_2022) | |
| 8602 ? coding_category_iso_7 | |
| 8603 : coding_category_iso_7_tight); | |
| 8604 else | |
| 8605 { | |
| 8606 int id = XINT (AREF (initial, 1)); | |
| 8607 | |
|
88977
3b05c02eebf2
(Fdefine_coding_system_internal): Fix category setting
Kenichi Handa <handa@m17n.org>
parents:
88950
diff
changeset
|
8608 category = (((i & CODING_ISO_FLAG_LOCKING_SHIFT) |
| 88365 | 8609 || EQ (args[coding_arg_charset_list], Qiso_2022) |
| 8610 || id < 0) | |
| 8611 ? coding_category_iso_8_else | |
| 8612 : (CHARSET_DIMENSION (CHARSET_FROM_ID (id)) == 1) | |
| 8613 ? coding_category_iso_8_1 | |
| 8614 : coding_category_iso_8_2); | |
|
22874
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
8615 } |
|
89227
101ee928c088
(Fdefine_coding_system_internal): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89225
diff
changeset
|
8616 if (category != coding_category_iso_8_1 |
|
101ee928c088
(Fdefine_coding_system_internal): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89225
diff
changeset
|
8617 && category != coding_category_iso_8_2) |
|
101ee928c088
(Fdefine_coding_system_internal): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89225
diff
changeset
|
8618 CODING_ATTR_ASCII_COMPAT (attrs) = Qnil; |
| 88365 | 8619 } |
| 8620 else if (EQ (coding_type, Qemacs_mule)) | |
| 8621 { | |
| 8622 if (EQ (args[coding_arg_charset_list], Qemacs_mule)) | |
| 8623 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
|
8624 CODING_ATTR_ASCII_COMPAT (attrs) = Qt; |
| 88365 | 8625 category = coding_category_emacs_mule; |
| 8626 } | |
| 8627 else if (EQ (coding_type, Qshift_jis)) | |
| 8628 { | |
| 8629 | |
| 8630 struct charset *charset; | |
| 8631 | |
|
89732
8acde12aba89
(get_translation_table): New function.
Kenichi Handa <handa@m17n.org>
parents:
89730
diff
changeset
|
8632 if (XINT (Flength (charset_list)) != 3 |
|
89739
293c9235be3f
(Fdefine_coding_system_internal): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89732
diff
changeset
|
8633 && XINT (Flength (charset_list)) != 4) |
|
89732
8acde12aba89
(get_translation_table): New function.
Kenichi Handa <handa@m17n.org>
parents:
89730
diff
changeset
|
8634 error ("There should be three or four charsets"); |
| 88365 | 8635 |
| 8636 charset = CHARSET_FROM_ID (XINT (XCAR (charset_list))); | |
| 8637 if (CHARSET_DIMENSION (charset) != 1) | |
| 8638 error ("Dimension of charset %s is not one", | |
| 89483 | 8639 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
|
8640 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
|
8641 CODING_ATTR_ASCII_COMPAT (attrs) = Qt; |
| 88365 | 8642 |
| 8643 charset_list = XCDR (charset_list); | |
| 8644 charset = CHARSET_FROM_ID (XINT (XCAR (charset_list))); | |
| 8645 if (CHARSET_DIMENSION (charset) != 1) | |
| 8646 error ("Dimension of charset %s is not one", | |
| 89483 | 8647 SDATA (SYMBOL_NAME (CHARSET_NAME (charset)))); |
| 88365 | 8648 |
| 8649 charset_list = XCDR (charset_list); | |
| 8650 charset = CHARSET_FROM_ID (XINT (XCAR (charset_list))); | |
| 8651 if (CHARSET_DIMENSION (charset) != 2) | |
| 8652 error ("Dimension of charset %s is not two", | |
| 89483 | 8653 SDATA (SYMBOL_NAME (CHARSET_NAME (charset)))); |
| 88365 | 8654 |
|
89732
8acde12aba89
(get_translation_table): New function.
Kenichi Handa <handa@m17n.org>
parents:
89730
diff
changeset
|
8655 charset_list = XCDR (charset_list); |
|
89740
78c1fd14ed42
(Fdefine_coding_system_internal): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89739
diff
changeset
|
8656 if (! NILP (charset_list)) |
|
78c1fd14ed42
(Fdefine_coding_system_internal): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89739
diff
changeset
|
8657 { |
|
78c1fd14ed42
(Fdefine_coding_system_internal): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89739
diff
changeset
|
8658 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
|
8659 if (CHARSET_DIMENSION (charset) != 2) |
|
78c1fd14ed42
(Fdefine_coding_system_internal): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89739
diff
changeset
|
8660 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
|
8661 SDATA (SYMBOL_NAME (CHARSET_NAME (charset)))); |
|
78c1fd14ed42
(Fdefine_coding_system_internal): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89739
diff
changeset
|
8662 } |
|
89732
8acde12aba89
(get_translation_table): New function.
Kenichi Handa <handa@m17n.org>
parents:
89730
diff
changeset
|
8663 |
| 88365 | 8664 category = coding_category_sjis; |
| 8665 Vsjis_coding_system = name; | |
| 8666 } | |
| 8667 else if (EQ (coding_type, Qbig5)) | |
| 8668 { | |
| 8669 struct charset *charset; | |
| 8670 | |
| 8671 if (XINT (Flength (charset_list)) != 2) | |
| 8672 error ("There should be just two charsets"); | |
| 8673 | |
| 8674 charset = CHARSET_FROM_ID (XINT (XCAR (charset_list))); | |
| 8675 if (CHARSET_DIMENSION (charset) != 1) | |
| 8676 error ("Dimension of charset %s is not one", | |
| 89483 | 8677 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
|
8678 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
|
8679 CODING_ATTR_ASCII_COMPAT (attrs) = Qt; |
| 88365 | 8680 |
| 8681 charset_list = XCDR (charset_list); | |
| 8682 charset = CHARSET_FROM_ID (XINT (XCAR (charset_list))); | |
| 8683 if (CHARSET_DIMENSION (charset) != 2) | |
| 8684 error ("Dimension of charset %s is not two", | |
| 89483 | 8685 SDATA (SYMBOL_NAME (CHARSET_NAME (charset)))); |
| 88365 | 8686 |
| 8687 category = coding_category_big5; | |
| 8688 Vbig5_coding_system = name; | |
| 8689 } | |
| 8690 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
|
8691 { |
|
32058afc72e2
(detect_coding_charset): If only ASCII bytes are found, return 0.
Kenichi Handa <handa@m17n.org>
parents:
89221
diff
changeset
|
8692 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
|
8693 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
|
8694 } |
| 88365 | 8695 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
|
8696 { |
|
32058afc72e2
(detect_coding_charset): If only ASCII bytes are found, return 0.
Kenichi Handa <handa@m17n.org>
parents:
89221
diff
changeset
|
8697 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
|
8698 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
|
8699 } |
| 88365 | 8700 else if (EQ (coding_type, Qundecided)) |
| 8701 category = coding_category_undecided; | |
| 8702 else | |
| 8703 error ("Invalid coding system type: %s", | |
| 89483 | 8704 SDATA (SYMBOL_NAME (coding_type))); |
| 88365 | 8705 |
| 8706 CODING_ATTR_CATEGORY (attrs) = make_number (category); | |
|
89468
7dbbe692f70c
* coding.c (QCcategory): New variable.
Kenichi Handa <handa@m17n.org>
parents:
89467
diff
changeset
|
8707 CODING_ATTR_PLIST (attrs) |
|
7dbbe692f70c
* coding.c (QCcategory): New variable.
Kenichi Handa <handa@m17n.org>
parents:
89467
diff
changeset
|
8708 = Fcons (QCcategory, Fcons (AREF (Vcoding_category_table, category), |
|
7dbbe692f70c
* coding.c (QCcategory): New variable.
Kenichi Handa <handa@m17n.org>
parents:
89467
diff
changeset
|
8709 CODING_ATTR_PLIST (attrs))); |
| 88365 | 8710 |
| 8711 eol_type = args[coding_arg_eol_type]; | |
| 8712 if (! NILP (eol_type) | |
| 8713 && ! EQ (eol_type, Qunix) | |
| 8714 && ! EQ (eol_type, Qdos) | |
| 8715 && ! EQ (eol_type, Qmac)) | |
| 8716 error ("Invalid eol-type"); | |
| 8717 | |
| 8718 aliases = Fcons (name, Qnil); | |
| 8719 | |
| 8720 if (NILP (eol_type)) | |
| 8721 { | |
| 8722 eol_type = make_subsidiaries (name); | |
| 8723 for (i = 0; i < 3; i++) | |
|
22874
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
8724 { |
| 88365 | 8725 Lisp_Object this_spec, this_name, this_aliases, this_eol_type; |
| 8726 | |
| 8727 this_name = AREF (eol_type, i); | |
| 8728 this_aliases = Fcons (this_name, Qnil); | |
| 8729 this_eol_type = (i == 0 ? Qunix : i == 1 ? Qdos : Qmac); | |
| 8730 this_spec = Fmake_vector (make_number (3), attrs); | |
| 8731 ASET (this_spec, 1, this_aliases); | |
| 8732 ASET (this_spec, 2, this_eol_type); | |
| 8733 Fputhash (this_name, this_spec, Vcoding_system_hash_table); | |
| 8734 Vcoding_system_list = Fcons (this_name, Vcoding_system_list); | |
| 8735 Vcoding_system_alist = Fcons (Fcons (Fsymbol_name (this_name), Qnil), | |
| 8736 Vcoding_system_alist); | |
|
22874
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
8737 } |
|
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
8738 } |
|
22874
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
8739 |
| 88365 | 8740 spec_vec = Fmake_vector (make_number (3), attrs); |
| 8741 ASET (spec_vec, 1, aliases); | |
| 8742 ASET (spec_vec, 2, eol_type); | |
| 8743 | |
| 8744 Fputhash (name, spec_vec, Vcoding_system_hash_table); | |
| 8745 Vcoding_system_list = Fcons (name, Vcoding_system_list); | |
| 8746 Vcoding_system_alist = Fcons (Fcons (Fsymbol_name (name), Qnil), | |
| 8747 Vcoding_system_alist); | |
| 8748 | |
| 8749 { | |
| 8750 int id = coding_categories[category].id; | |
| 8751 | |
| 8752 if (id < 0 || EQ (name, CODING_ID_NAME (id))) | |
| 8753 setup_coding_system (name, &coding_categories[category]); | |
| 8754 } | |
| 8755 | |
| 8756 return Qnil; | |
| 8757 | |
| 8758 short_args: | |
| 8759 return Fsignal (Qwrong_number_of_arguments, | |
| 8760 Fcons (intern ("define-coding-system-internal"), | |
| 8761 make_number (nargs))); | |
| 8762 } | |
| 8763 | |
|
89571
242f2cc0134b
(Fdefine_coding_system_alias): Update Vcoding_system_list.
Kenichi Handa <handa@m17n.org>
parents:
89562
diff
changeset
|
8764 |
|
89759
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
8765 DEFUN ("coding-system-put", Fcoding_system_put, Scoding_system_put, |
|
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
8766 3, 3, 0, |
|
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
8767 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
|
8768 (coding_system, prop, val) |
|
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
8769 Lisp_Object coding_system, prop, val; |
|
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
8770 { |
|
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
8771 Lisp_Object spec, attrs, plist; |
|
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
8772 |
|
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
8773 CHECK_CODING_SYSTEM_GET_SPEC (coding_system, spec); |
|
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
8774 attrs = AREF (spec, 0); |
|
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
8775 if (EQ (prop, QCmnemonic)) |
|
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
8776 { |
|
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
8777 if (! STRINGP (val)) |
|
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
8778 CHECK_CHARACTER (val); |
|
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
8779 CODING_ATTR_MNEMONIC (attrs) = val; |
|
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
8780 } |
|
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
8781 else if (EQ (prop, QCdefalut_char)) |
|
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
8782 { |
|
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
8783 if (NILP (val)) |
|
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
8784 val = make_number (' '); |
|
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
8785 else |
|
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
8786 CHECK_CHARACTER (val); |
|
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
8787 CODING_ATTR_DEFAULT_CHAR (attrs) = val; |
|
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
8788 } |
|
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
8789 else if (EQ (prop, QCdecode_translation_table)) |
|
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
8790 { |
|
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
8791 if (! CHAR_TABLE_P (val) && ! CONSP (val)) |
|
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
8792 CHECK_SYMBOL (val); |
|
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
8793 CODING_ATTR_DECODE_TBL (attrs) = val; |
|
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
8794 } |
|
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
8795 else if (EQ (prop, QCencode_translation_table)) |
|
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
8796 { |
|
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
8797 if (! CHAR_TABLE_P (val) && ! CONSP (val)) |
|
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
8798 CHECK_SYMBOL (val); |
|
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
8799 CODING_ATTR_ENCODE_TBL (attrs) = val; |
|
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
8800 } |
|
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
8801 else if (EQ (prop, QCpost_read_conversion)) |
|
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
8802 { |
|
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
8803 CHECK_SYMBOL (val); |
|
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
8804 CODING_ATTR_POST_READ (attrs) = val; |
|
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
8805 } |
|
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
8806 else if (EQ (prop, QCpre_write_conversion)) |
|
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
8807 { |
|
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
8808 CHECK_SYMBOL (val); |
|
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
8809 CODING_ATTR_PRE_WRITE (attrs) = val; |
|
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
8810 } |
|
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
8811 |
|
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
8812 CODING_ATTR_PLIST (attrs) |
|
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
8813 = Fplist_put (CODING_ATTR_PLIST (attrs), prop, val); |
|
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
8814 return val; |
|
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
8815 } |
|
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
8816 |
|
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
8817 |
| 88365 | 8818 DEFUN ("define-coding-system-alias", Fdefine_coding_system_alias, |
| 8819 Sdefine_coding_system_alias, 2, 2, 0, | |
| 8820 doc: /* Define ALIAS as an alias for CODING-SYSTEM. */) | |
| 8821 (alias, coding_system) | |
| 8822 Lisp_Object alias, coding_system; | |
| 8823 { | |
| 8824 Lisp_Object spec, aliases, eol_type; | |
| 8825 | |
| 8826 CHECK_SYMBOL (alias); | |
| 8827 CHECK_CODING_SYSTEM_GET_SPEC (coding_system, spec); | |
| 8828 aliases = AREF (spec, 1); | |
|
89571
242f2cc0134b
(Fdefine_coding_system_alias): Update Vcoding_system_list.
Kenichi Handa <handa@m17n.org>
parents:
89562
diff
changeset
|
8829 /* 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
|
8830 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
|
8831 list. */ |
| 88365 | 8832 while (!NILP (XCDR (aliases))) |
| 8833 aliases = XCDR (aliases); | |
| 89483 | 8834 XSETCDR (aliases, Fcons (alias, Qnil)); |
| 88365 | 8835 |
| 8836 eol_type = AREF (spec, 2); | |
| 8837 if (VECTORP (eol_type)) | |
| 8838 { | |
| 8839 Lisp_Object subsidiaries; | |
| 8840 int i; | |
| 8841 | |
| 8842 subsidiaries = make_subsidiaries (alias); | |
| 8843 for (i = 0; i < 3; i++) | |
| 8844 Fdefine_coding_system_alias (AREF (subsidiaries, i), | |
| 8845 AREF (eol_type, i)); | |
| 8846 } | |
| 8847 | |
| 8848 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
|
8849 Vcoding_system_list = Fcons (alias, Vcoding_system_list); |
| 88485 | 8850 Vcoding_system_alist = Fcons (Fcons (Fsymbol_name (alias), Qnil), |
| 8851 Vcoding_system_alist); | |
| 88365 | 8852 |
|
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
8853 return Qnil; |
|
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
8854 } |
|
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
8855 |
| 88365 | 8856 DEFUN ("coding-system-base", Fcoding_system_base, Scoding_system_base, |
| 8857 1, 1, 0, | |
| 8858 doc: /* Return the base of CODING-SYSTEM. | |
| 88645 | 8859 Any alias or subsidiary coding system is not a base coding system. */) |
| 88365 | 8860 (coding_system) |
| 8861 Lisp_Object coding_system; | |
| 8862 { | |
| 8863 Lisp_Object spec, attrs; | |
| 8864 | |
| 8865 if (NILP (coding_system)) | |
| 8866 return (Qno_conversion); | |
| 8867 CHECK_CODING_SYSTEM_GET_SPEC (coding_system, spec); | |
| 8868 attrs = AREF (spec, 0); | |
| 8869 return CODING_ATTR_BASE_NAME (attrs); | |
| 8870 } | |
| 8871 | |
| 8872 DEFUN ("coding-system-plist", Fcoding_system_plist, Scoding_system_plist, | |
| 8873 1, 1, 0, | |
| 8874 doc: "Return the property list of CODING-SYSTEM.") | |
| 8875 (coding_system) | |
| 8876 Lisp_Object coding_system; | |
|
22226
557fac086b1b
(ascii_skip_code): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22186
diff
changeset
|
8877 { |
| 88365 | 8878 Lisp_Object spec, attrs; |
| 8879 | |
| 8880 if (NILP (coding_system)) | |
| 8881 coding_system = Qno_conversion; | |
| 8882 CHECK_CODING_SYSTEM_GET_SPEC (coding_system, spec); | |
| 8883 attrs = AREF (spec, 0); | |
| 8884 return CODING_ATTR_PLIST (attrs); | |
| 8885 } | |
| 8886 | |
| 8887 | |
| 8888 DEFUN ("coding-system-aliases", Fcoding_system_aliases, Scoding_system_aliases, | |
| 8889 1, 1, 0, | |
| 88645 | 8890 doc: /* Return the list of aliases of CODING-SYSTEM. */) |
| 88365 | 8891 (coding_system) |
| 8892 Lisp_Object coding_system; | |
| 8893 { | |
| 8894 Lisp_Object spec; | |
| 8895 | |
| 8896 if (NILP (coding_system)) | |
| 8897 coding_system = Qno_conversion; | |
| 8898 CHECK_CODING_SYSTEM_GET_SPEC (coding_system, spec); | |
| 88645 | 8899 return AREF (spec, 1); |
| 88365 | 8900 } |
| 8901 | |
| 8902 DEFUN ("coding-system-eol-type", Fcoding_system_eol_type, | |
| 8903 Scoding_system_eol_type, 1, 1, 0, | |
| 8904 doc: /* Return eol-type of CODING-SYSTEM. | |
| 8905 An eol-type is integer 0, 1, 2, or a vector of coding systems. | |
| 8906 | |
| 8907 Integer values 0, 1, and 2 indicate a format of end-of-line; LF, CRLF, | |
| 8908 and CR respectively. | |
| 8909 | |
| 8910 A vector value indicates that a format of end-of-line should be | |
| 8911 detected automatically. Nth element of the vector is the subsidiary | |
| 8912 coding system whose eol-type is N. */) | |
| 8913 (coding_system) | |
| 8914 Lisp_Object coding_system; | |
| 8915 { | |
| 8916 Lisp_Object spec, eol_type; | |
| 8917 int n; | |
| 8918 | |
| 8919 if (NILP (coding_system)) | |
| 8920 coding_system = Qno_conversion; | |
| 8921 if (! CODING_SYSTEM_P (coding_system)) | |
| 8922 return Qnil; | |
| 8923 spec = CODING_SYSTEM_SPEC (coding_system); | |
| 8924 eol_type = AREF (spec, 2); | |
| 8925 if (VECTORP (eol_type)) | |
| 8926 return Fcopy_sequence (eol_type); | |
| 8927 n = EQ (eol_type, Qunix) ? 0 : EQ (eol_type, Qdos) ? 1 : 2; | |
| 8928 return make_number (n); | |
|
22226
557fac086b1b
(ascii_skip_code): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22186
diff
changeset
|
8929 } |
|
557fac086b1b
(ascii_skip_code): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22186
diff
changeset
|
8930 |
| 17052 | 8931 #endif /* emacs */ |
| 8932 | |
| 8933 | |
|
22874
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
8934 /*** 9. Post-amble ***/ |
| 17052 | 8935 |
| 21514 | 8936 void |
| 17052 | 8937 init_coding_once () |
| 8938 { | |
| 8939 int i; | |
| 8940 | |
| 88365 | 8941 for (i = 0; i < coding_category_max; i++) |
| 8942 { | |
| 8943 coding_categories[i].id = -1; | |
| 8944 coding_priorities[i] = i; | |
| 8945 } | |
| 17052 | 8946 |
| 8947 /* ISO2022 specific initialize routine. */ | |
| 8948 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
|
8949 iso_code_class[i] = ISO_control_0; |
| 17052 | 8950 for (i = 0x21; i < 0x7F; i++) |
| 8951 iso_code_class[i] = ISO_graphic_plane_0; | |
| 8952 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
|
8953 iso_code_class[i] = ISO_control_1; |
| 17052 | 8954 for (i = 0xA1; i < 0xFF; i++) |
| 8955 iso_code_class[i] = ISO_graphic_plane_1; | |
| 8956 iso_code_class[0x20] = iso_code_class[0x7F] = ISO_0x20_or_0x7F; | |
| 8957 iso_code_class[0xA0] = iso_code_class[0xFF] = ISO_0xA0_or_0xFF; | |
| 8958 iso_code_class[ISO_CODE_SO] = ISO_shift_out; | |
| 8959 iso_code_class[ISO_CODE_SI] = ISO_shift_in; | |
| 8960 iso_code_class[ISO_CODE_SS2_7] = ISO_single_shift_2_7; | |
| 8961 iso_code_class[ISO_CODE_ESC] = ISO_escape; | |
| 8962 iso_code_class[ISO_CODE_SS2] = ISO_single_shift_2; | |
| 8963 iso_code_class[ISO_CODE_SS3] = ISO_single_shift_3; | |
| 8964 iso_code_class[ISO_CODE_CSI] = ISO_control_sequence_introducer; | |
| 8965 | |
| 88365 | 8966 for (i = 0; i < 256; i++) |
| 8967 { | |
| 8968 emacs_mule_bytes[i] = 1; | |
| 8969 } | |
|
88876
af9012fdad56
(LEADING_CODE_PRIVATE_11, LEADING_CODE_PRIVATE_12,
Kenichi Handa <handa@m17n.org>
parents:
88862
diff
changeset
|
8970 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
|
8971 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
|
8972 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
|
8973 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
|
8974 } |
|
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
8975 |
|
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
8976 #ifdef emacs |
|
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
8977 |
| 21514 | 8978 void |
|
17119
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
8979 syms_of_coding () |
|
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
8980 { |
| 88365 | 8981 staticpro (&Vcoding_system_hash_table); |
| 89483 | 8982 { |
| 8983 Lisp_Object args[2]; | |
| 8984 args[0] = QCtest; | |
| 8985 args[1] = Qeq; | |
| 8986 Vcoding_system_hash_table = Fmake_hash_table (2, args); | |
| 8987 } | |
| 88365 | 8988 |
| 8989 staticpro (&Vsjis_coding_system); | |
| 8990 Vsjis_coding_system = Qnil; | |
| 8991 | |
| 8992 staticpro (&Vbig5_coding_system); | |
| 8993 Vbig5_coding_system = Qnil; | |
| 8994 | |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
8995 staticpro (&Vcode_conversion_reused_workbuf); |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
8996 Vcode_conversion_reused_workbuf = Qnil; |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
8997 |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
8998 staticpro (&Vcode_conversion_workbuf_name); |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
8999 Vcode_conversion_workbuf_name = build_string (" *code-conversion-work*"); |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
9000 |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
9001 reused_workbuf_in_use = 0; |
| 88365 | 9002 |
| 9003 DEFSYM (Qcharset, "charset"); | |
| 9004 DEFSYM (Qtarget_idx, "target-idx"); | |
| 9005 DEFSYM (Qcoding_system_history, "coding-system-history"); | |
|
19750
95e4e1cba6ac
(Qcoding_system_history): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
19747
diff
changeset
|
9006 Fset (Qcoding_system_history, Qnil); |
|
95e4e1cba6ac
(Qcoding_system_history): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
19747
diff
changeset
|
9007 |
|
18650
aa3f2820e2ac
(Qemacs_mule, inhibit_eol_conversion): New variables.
Kenichi Handa <handa@m17n.org>
parents:
18613
diff
changeset
|
9008 /* 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
|
9009 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
|
9010 /* 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
|
9011 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
|
9012 |
| 88365 | 9013 DEFSYM (Qcall_process, "call-process"); |
|
18650
aa3f2820e2ac
(Qemacs_mule, inhibit_eol_conversion): New variables.
Kenichi Handa <handa@m17n.org>
parents:
18613
diff
changeset
|
9014 /* 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
|
9015 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
|
9016 |
| 88365 | 9017 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
|
9018 /* 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
|
9019 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
|
9020 |
| 88365 | 9021 DEFSYM (Qstart_process, "start-process"); |
|
18650
aa3f2820e2ac
(Qemacs_mule, inhibit_eol_conversion): New variables.
Kenichi Handa <handa@m17n.org>
parents:
18613
diff
changeset
|
9022 /* 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
|
9023 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
|
9024 |
| 88365 | 9025 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
|
9026 /* 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
|
9027 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
|
9028 |
| 88365 | 9029 DEFSYM (Qcoding_system, "coding-system"); |
| 9030 DEFSYM (Qcoding_aliases, "coding-aliases"); | |
| 9031 | |
| 9032 DEFSYM (Qeol_type, "eol-type"); | |
| 9033 DEFSYM (Qunix, "unix"); | |
| 9034 DEFSYM (Qdos, "dos"); | |
| 9035 | |
| 9036 DEFSYM (Qbuffer_file_coding_system, "buffer-file-coding-system"); | |
| 9037 DEFSYM (Qpost_read_conversion, "post-read-conversion"); | |
| 9038 DEFSYM (Qpre_write_conversion, "pre-write-conversion"); | |
| 9039 DEFSYM (Qdefault_char, "default-char"); | |
| 9040 DEFSYM (Qundecided, "undecided"); | |
| 9041 DEFSYM (Qno_conversion, "no-conversion"); | |
| 9042 DEFSYM (Qraw_text, "raw-text"); | |
| 9043 | |
| 9044 DEFSYM (Qiso_2022, "iso-2022"); | |
| 9045 | |
| 9046 DEFSYM (Qutf_8, "utf-8"); | |
| 89483 | 9047 DEFSYM (Qutf_8_emacs, "utf-8-emacs"); |
| 88365 | 9048 |
| 9049 DEFSYM (Qutf_16, "utf-16"); | |
| 9050 DEFSYM (Qbig, "big"); | |
| 9051 DEFSYM (Qlittle, "little"); | |
| 9052 | |
| 9053 DEFSYM (Qshift_jis, "shift-jis"); | |
| 9054 DEFSYM (Qbig5, "big5"); | |
| 9055 | |
| 9056 DEFSYM (Qcoding_system_p, "coding-system-p"); | |
| 9057 | |
| 9058 DEFSYM (Qcoding_system_error, "coding-system-error"); | |
| 17052 | 9059 Fput (Qcoding_system_error, Qerror_conditions, |
| 9060 Fcons (Qcoding_system_error, Fcons (Qerror, Qnil))); | |
| 9061 Fput (Qcoding_system_error, Qerror_message, | |
|
18650
aa3f2820e2ac
(Qemacs_mule, inhibit_eol_conversion): New variables.
Kenichi Handa <handa@m17n.org>
parents:
18613
diff
changeset
|
9062 build_string ("Invalid coding system")); |
| 17052 | 9063 |
|
30487
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
9064 /* 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
|
9065 Setting this variable twice is harmless. |
|
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
9066 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
|
9067 Qchar_table_extra_slots = intern ("char-table-extra-slots"); |
| 88365 | 9068 |
| 9069 DEFSYM (Qtranslation_table, "translation-table"); | |
|
89856
18b52da60a76
(get_translation): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89852
diff
changeset
|
9070 Fput (Qtranslation_table, Qchar_table_extra_slots, make_number (2)); |
| 88365 | 9071 DEFSYM (Qtranslation_table_id, "translation-table-id"); |
| 9072 DEFSYM (Qtranslation_table_for_decode, "translation-table-for-decode"); | |
| 9073 DEFSYM (Qtranslation_table_for_encode, "translation-table-for-encode"); | |
| 9074 | |
| 9075 DEFSYM (Qvalid_codes, "valid-codes"); | |
| 9076 | |
| 9077 DEFSYM (Qemacs_mule, "emacs-mule"); | |
| 9078 | |
|
89468
7dbbe692f70c
* coding.c (QCcategory): New variable.
Kenichi Handa <handa@m17n.org>
parents:
89467
diff
changeset
|
9079 DEFSYM (QCcategory, ":category"); |
|
89759
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
9080 DEFSYM (QCmnemonic, ":mnemonic"); |
|
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
9081 DEFSYM (QCdefalut_char, ":default-char"); |
|
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
9082 DEFSYM (QCdecode_translation_table, ":decode-translation-table"); |
|
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
9083 DEFSYM (QCencode_translation_table, ":encode-translation-table"); |
|
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
9084 DEFSYM (QCpost_read_conversion, ":post-read-conversion"); |
|
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
9085 DEFSYM (QCpre_write_conversion, ":pre-write-conversion"); |
|
89468
7dbbe692f70c
* coding.c (QCcategory): New variable.
Kenichi Handa <handa@m17n.org>
parents:
89467
diff
changeset
|
9086 |
| 88365 | 9087 Vcoding_category_table |
| 9088 = Fmake_vector (make_number (coding_category_max), Qnil); | |
| 9089 staticpro (&Vcoding_category_table); | |
| 9090 /* Followings are target of code detection. */ | |
| 9091 ASET (Vcoding_category_table, coding_category_iso_7, | |
| 9092 intern ("coding-category-iso-7")); | |
| 9093 ASET (Vcoding_category_table, coding_category_iso_7_tight, | |
| 9094 intern ("coding-category-iso-7-tight")); | |
| 9095 ASET (Vcoding_category_table, coding_category_iso_8_1, | |
| 9096 intern ("coding-category-iso-8-1")); | |
| 9097 ASET (Vcoding_category_table, coding_category_iso_8_2, | |
| 9098 intern ("coding-category-iso-8-2")); | |
| 9099 ASET (Vcoding_category_table, coding_category_iso_7_else, | |
| 9100 intern ("coding-category-iso-7-else")); | |
| 9101 ASET (Vcoding_category_table, coding_category_iso_8_else, | |
| 9102 intern ("coding-category-iso-8-else")); | |
| 9103 ASET (Vcoding_category_table, coding_category_utf_8, | |
| 9104 intern ("coding-category-utf-8")); | |
| 9105 ASET (Vcoding_category_table, coding_category_utf_16_be, | |
| 9106 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
|
9107 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
|
9108 intern ("coding-category-utf-16-auto")); |
| 88365 | 9109 ASET (Vcoding_category_table, coding_category_utf_16_le, |
| 9110 intern ("coding-category-utf-16-le")); | |
| 9111 ASET (Vcoding_category_table, coding_category_utf_16_be_nosig, | |
| 9112 intern ("coding-category-utf-16-be-nosig")); | |
| 9113 ASET (Vcoding_category_table, coding_category_utf_16_le_nosig, | |
| 9114 intern ("coding-category-utf-16-le-nosig")); | |
| 9115 ASET (Vcoding_category_table, coding_category_charset, | |
| 9116 intern ("coding-category-charset")); | |
| 9117 ASET (Vcoding_category_table, coding_category_sjis, | |
| 9118 intern ("coding-category-sjis")); | |
| 9119 ASET (Vcoding_category_table, coding_category_big5, | |
| 9120 intern ("coding-category-big5")); | |
| 9121 ASET (Vcoding_category_table, coding_category_ccl, | |
| 9122 intern ("coding-category-ccl")); | |
| 9123 ASET (Vcoding_category_table, coding_category_emacs_mule, | |
| 9124 intern ("coding-category-emacs-mule")); | |
| 9125 /* Followings are NOT target of code detection. */ | |
| 9126 ASET (Vcoding_category_table, coding_category_raw_text, | |
| 9127 intern ("coding-category-raw-text")); | |
| 9128 ASET (Vcoding_category_table, coding_category_undecided, | |
| 9129 intern ("coding-category-undecided")); | |
| 9130 | |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
9131 DEFSYM (Qinsufficient_source, "insufficient-source"); |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
9132 DEFSYM (Qinconsistent_eol, "inconsistent-eol"); |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
9133 DEFSYM (Qinvalid_source, "invalid-source"); |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
9134 DEFSYM (Qinterrupted, "interrupted"); |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
9135 DEFSYM (Qinsufficient_memory, "insufficient-memory"); |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
9136 |
| 17052 | 9137 defsubr (&Scoding_system_p); |
| 9138 defsubr (&Sread_coding_system); | |
| 9139 defsubr (&Sread_non_nil_coding_system); | |
| 9140 defsubr (&Scheck_coding_system); | |
| 9141 defsubr (&Sdetect_coding_region); | |
|
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
9142 defsubr (&Sdetect_coding_string); |
|
30487
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
9143 defsubr (&Sfind_coding_systems_region_internal); |
|
46859
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
9144 defsubr (&Sunencodable_char_position); |
| 88365 | 9145 defsubr (&Scheck_coding_systems_region); |
| 17052 | 9146 defsubr (&Sdecode_coding_region); |
| 9147 defsubr (&Sencode_coding_region); | |
| 9148 defsubr (&Sdecode_coding_string); | |
| 9149 defsubr (&Sencode_coding_string); | |
| 9150 defsubr (&Sdecode_sjis_char); | |
| 9151 defsubr (&Sencode_sjis_char); | |
| 9152 defsubr (&Sdecode_big5_char); | |
| 9153 defsubr (&Sencode_big5_char); | |
|
18002
a14261786239
(encode_invocation_designation): Use macro
Kenichi Handa <handa@m17n.org>
parents:
17835
diff
changeset
|
9154 defsubr (&Sset_terminal_coding_system_internal); |
|
19280
e755044718ee
(ENCODE_ISO_CHARACTER_DIMENSION1): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
19193
diff
changeset
|
9155 defsubr (&Sset_safe_terminal_coding_system_internal); |
| 17052 | 9156 defsubr (&Sterminal_coding_system); |
|
18002
a14261786239
(encode_invocation_designation): Use macro
Kenichi Handa <handa@m17n.org>
parents:
17835
diff
changeset
|
9157 defsubr (&Sset_keyboard_coding_system_internal); |
| 17052 | 9158 defsubr (&Skeyboard_coding_system); |
|
18536
69c0e220b626
(Vstandard_character_unification_table_for_decode):
Kenichi Handa <handa@m17n.org>
parents:
18523
diff
changeset
|
9159 defsubr (&Sfind_operation_coding_system); |
| 88365 | 9160 defsubr (&Sset_coding_system_priority); |
| 9161 defsubr (&Sdefine_coding_system_internal); | |
| 9162 defsubr (&Sdefine_coding_system_alias); | |
|
89759
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
9163 defsubr (&Scoding_system_put); |
| 88365 | 9164 defsubr (&Scoding_system_base); |
| 9165 defsubr (&Scoding_system_plist); | |
| 9166 defsubr (&Scoding_system_aliases); | |
| 9167 defsubr (&Scoding_system_eol_type); | |
| 9168 defsubr (&Scoding_system_priority_list); | |
| 17052 | 9169 |
|
20105
c017642863c2
(Qcoding_system_spec): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
19824
diff
changeset
|
9170 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
|
9171 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
|
9172 |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
9173 Do not alter the value of this variable manually. This variable should be |
| 88365 | 9174 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
|
9175 `define-coding-system-alias'. */); |
|
20105
c017642863c2
(Qcoding_system_spec): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
19824
diff
changeset
|
9176 Vcoding_system_list = Qnil; |
|
c017642863c2
(Qcoding_system_spec): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
19824
diff
changeset
|
9177 |
|
c017642863c2
(Qcoding_system_spec): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
19824
diff
changeset
|
9178 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
|
9179 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
|
9180 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
|
9181 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
|
9182 |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
9183 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
|
9184 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
|
9185 `define-coding-system-alias'. */); |
|
20105
c017642863c2
(Qcoding_system_spec): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
19824
diff
changeset
|
9186 Vcoding_system_alist = Qnil; |
|
c017642863c2
(Qcoding_system_spec): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
19824
diff
changeset
|
9187 |
| 17052 | 9188 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
|
9189 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
|
9190 |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
9191 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
|
9192 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
|
9193 one algorithm agrees with a byte sequence of source text, the coding |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
9194 system bound to the corresponding coding-category is selected. */); |
| 17052 | 9195 { |
| 9196 int i; | |
| 9197 | |
| 9198 Vcoding_category_list = Qnil; | |
| 88365 | 9199 for (i = coding_category_max - 1; i >= 0; i--) |
| 17052 | 9200 Vcoding_category_list |
|
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
9201 = Fcons (XVECTOR (Vcoding_category_table)->contents[i], |
|
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
9202 Vcoding_category_list); |
| 17052 | 9203 } |
| 9204 | |
| 9205 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
|
9206 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
|
9207 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
|
9208 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
|
9209 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
|
9210 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
|
9211 `process-coding-system-alist', and `network-coding-system-alist'. */); |
| 17052 | 9212 Vcoding_system_for_read = Qnil; |
| 9213 | |
| 9214 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
|
9215 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
|
9216 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
|
9217 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
|
9218 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
|
9219 |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
9220 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
|
9221 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
|
9222 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
|
9223 `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
|
9224 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
|
9225 the value of `buffer-file-coding-system' is used. */); |
| 17052 | 9226 Vcoding_system_for_write = Qnil; |
| 9227 | |
| 9228 DEFVAR_LISP ("last-coding-system-used", &Vlast_coding_system_used, | |
| 88365 | 9229 doc: /* |
| 9230 Coding system used in the latest file or process I/O. */); | |
| 17052 | 9231 Vlast_coding_system_used = Qnil; |
| 9232 | |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
9233 DEFVAR_LISP ("last-code-conversion-error", &Vlast_code_conversion_error, |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
9234 doc: /* |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
9235 Error status of the last code conversion. |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
9236 |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
9237 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
|
9238 is set to one of the following symbols. |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
9239 `insufficient-source' |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
9240 `inconsistent-eol' |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
9241 `invalid-source' |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
9242 `interrupted' |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
9243 `insufficient-memory' |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
9244 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
|
9245 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
|
9246 explicitly set this variable to nil before performing code |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
9247 conversion. */); |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
9248 Vlast_code_conversion_error = Qnil; |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
9249 |
|
18650
aa3f2820e2ac
(Qemacs_mule, inhibit_eol_conversion): New variables.
Kenichi Handa <handa@m17n.org>
parents:
18613
diff
changeset
|
9250 DEFVAR_BOOL ("inhibit-eol-conversion", &inhibit_eol_conversion, |
| 88365 | 9251 doc: /* |
| 9252 *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
|
9253 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
|
9254 such conversion. */); |
|
18650
aa3f2820e2ac
(Qemacs_mule, inhibit_eol_conversion): New variables.
Kenichi Handa <handa@m17n.org>
parents:
18613
diff
changeset
|
9255 inhibit_eol_conversion = 0; |
|
aa3f2820e2ac
(Qemacs_mule, inhibit_eol_conversion): New variables.
Kenichi Handa <handa@m17n.org>
parents:
18613
diff
changeset
|
9256 |
|
21574
30394e3ae7f8
(syms_of_coding): Declare and define inherit-process-coding-system.
Eli Zaretskii <eliz@gnu.org>
parents:
21520
diff
changeset
|
9257 DEFVAR_BOOL ("inherit-process-coding-system", &inherit_process_coding_system, |
| 88365 | 9258 doc: /* |
| 9259 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
|
9260 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
|
9261 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
|
9262 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
|
9263 |
|
18180
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
9264 DEFVAR_LISP ("file-coding-system-alist", &Vfile_coding_system_alist, |
| 88365 | 9265 doc: /* |
| 9266 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
|
9267 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
|
9268 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
|
9269 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
|
9270 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
|
9271 the file contents. |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
9272 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
|
9273 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
|
9274 If VAL is a function symbol, the function must return a coding system |
|
41678
5aa97e545399
(syms_of_coding) <Qchar_coding_system>: Give it an
Dave Love <fx@gnu.org>
parents:
41624
diff
changeset
|
9275 or a cons of coding systems which are used as above. The function gets |
|
5aa97e545399
(syms_of_coding) <Qchar_coding_system>: Give it an
Dave Love <fx@gnu.org>
parents:
41624
diff
changeset
|
9276 the arguments with which `find-operation-coding-systems' was called. |
|
40713
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
9277 |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
9278 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
|
9279 and the variable `auto-coding-alist'. */); |
|
18180
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
9280 Vfile_coding_system_alist = Qnil; |
|
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
9281 |
|
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
9282 DEFVAR_LISP ("process-coding-system-alist", &Vprocess_coding_system_alist, |
| 88365 | 9283 doc: /* |
| 9284 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
|
9285 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
|
9286 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
|
9287 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
|
9288 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
|
9289 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
|
9290 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
|
9291 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
|
9292 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
|
9293 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
|
9294 |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
9295 See also the function `find-operation-coding-system'. */); |
|
18180
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
9296 Vprocess_coding_system_alist = Qnil; |
|
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
9297 |
|
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
9298 DEFVAR_LISP ("network-coding-system-alist", &Vnetwork_coding_system_alist, |
| 88365 | 9299 doc: /* |
| 9300 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
|
9301 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
|
9302 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
|
9303 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
|
9304 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
|
9305 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
|
9306 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
|
9307 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
|
9308 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
|
9309 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
|
9310 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
|
9311 |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
9312 See also the function `find-operation-coding-system'. */); |
|
18180
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
9313 Vnetwork_coding_system_alist = Qnil; |
| 17052 | 9314 |
|
26088
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
26067
diff
changeset
|
9315 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
|
9316 doc: /* Coding system to use with system messages. |
|
6f20449b7e12
(syms_of_coding): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
41006
diff
changeset
|
9317 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
|
9318 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
|
9319 |
|
29182
1d1c27067af4
(encode_eol): Add null statement after label.
Dave Love <fx@gnu.org>
parents:
29172
diff
changeset
|
9320 /* 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
|
9321 DEFVAR_LISP ("eol-mnemonic-unix", &eol_mnemonic_unix, |
| 88365 | 9322 doc: /* |
| 9323 *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
|
9324 eol_mnemonic_unix = build_string (":"); |
|
b9d9fccad516
(syms_of_coding): eol-mnemonic-* variables are now
Eli Zaretskii <eliz@gnu.org>
parents:
24178
diff
changeset
|
9325 |
|
b9d9fccad516
(syms_of_coding): eol-mnemonic-* variables are now
Eli Zaretskii <eliz@gnu.org>
parents:
24178
diff
changeset
|
9326 DEFVAR_LISP ("eol-mnemonic-dos", &eol_mnemonic_dos, |
| 88365 | 9327 doc: /* |
| 9328 *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
|
9329 eol_mnemonic_dos = build_string ("\\"); |
|
b9d9fccad516
(syms_of_coding): eol-mnemonic-* variables are now
Eli Zaretskii <eliz@gnu.org>
parents:
24178
diff
changeset
|
9330 |
|
b9d9fccad516
(syms_of_coding): eol-mnemonic-* variables are now
Eli Zaretskii <eliz@gnu.org>
parents:
24178
diff
changeset
|
9331 DEFVAR_LISP ("eol-mnemonic-mac", &eol_mnemonic_mac, |
| 88365 | 9332 doc: /* |
| 9333 *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
|
9334 eol_mnemonic_mac = build_string ("/"); |
|
b9d9fccad516
(syms_of_coding): eol-mnemonic-* variables are now
Eli Zaretskii <eliz@gnu.org>
parents:
24178
diff
changeset
|
9335 |
|
b9d9fccad516
(syms_of_coding): eol-mnemonic-* variables are now
Eli Zaretskii <eliz@gnu.org>
parents:
24178
diff
changeset
|
9336 DEFVAR_LISP ("eol-mnemonic-undecided", &eol_mnemonic_undecided, |
| 88365 | 9337 doc: /* |
| 9338 *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
|
9339 eol_mnemonic_undecided = build_string (":"); |
| 17052 | 9340 |
|
22119
592bb8b9bcfd
Change terms unify/unification to
Kenichi Handa <handa@m17n.org>
parents:
22020
diff
changeset
|
9341 DEFVAR_LISP ("enable-character-translation", &Venable_character_translation, |
| 88365 | 9342 doc: /* |
| 9343 *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
|
9344 Venable_character_translation = Qt; |
|
592bb8b9bcfd
Change terms unify/unification to
Kenichi Handa <handa@m17n.org>
parents:
22020
diff
changeset
|
9345 |
|
22186
fc4aaf1b1772
Change term "character translation table" to "translation table".
Kenichi Handa <handa@m17n.org>
parents:
22166
diff
changeset
|
9346 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
|
9347 &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
|
9348 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
|
9349 Vstandard_translation_table_for_decode = Qnil; |
|
fc4aaf1b1772
Change term "character translation table" to "translation table".
Kenichi Handa <handa@m17n.org>
parents:
22166
diff
changeset
|
9350 |
|
fc4aaf1b1772
Change term "character translation table" to "translation table".
Kenichi Handa <handa@m17n.org>
parents:
22166
diff
changeset
|
9351 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
|
9352 &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
|
9353 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
|
9354 Vstandard_translation_table_for_encode = Qnil; |
| 17052 | 9355 |
| 88365 | 9356 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
|
9357 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
|
9358 While encoding, if a charset (car part of an element) is found, |
| 88365 | 9359 designate it with the escape sequence identifying revision (cdr part |
| 9360 of the element). */); | |
| 9361 Vcharset_revision_table = Qnil; | |
|
18180
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
9362 |
|
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
9363 DEFVAR_LISP ("default-process-coding-system", |
|
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
9364 &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
|
9365 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
|
9366 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
|
9367 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
|
9368 Vdefault_process_coding_system = Qnil; |
|
19280
e755044718ee
(ENCODE_ISO_CHARACTER_DIMENSION1): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
19193
diff
changeset
|
9369 |
|
19365
d9374f5ebd3a
(CODING_FLAG_ISO_LATIN_EXTRA): New macro.
Kenichi Handa <handa@m17n.org>
parents:
19285
diff
changeset
|
9370 DEFVAR_LISP ("latin-extra-code-table", &Vlatin_extra_code_table, |
| 88365 | 9371 doc: /* |
| 9372 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
|
9373 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
|
9374 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
|
9375 \(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
|
9376 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
|
9377 `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
|
9378 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
|
9379 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
|
9380 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
|
9381 |
|
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
9382 DEFVAR_LISP ("select-safe-coding-system-function", |
|
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
9383 &Vselect_safe_coding_system_function, |
| 88365 | 9384 doc: /* |
| 9385 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
|
9386 |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
9387 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
|
9388 coding system which can encode the text in the case that a default |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
9389 coding system used in each operation can't encode the text. |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
9390 |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
9391 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
|
9392 Vselect_safe_coding_system_function = Qnil; |
|
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
9393 |
|
48874
3002a87cc629
(coding_system_require_warning): New variable.
Kenichi Handa <handa@m17n.org>
parents:
48829
diff
changeset
|
9394 DEFVAR_BOOL ("coding-system-require-warning", |
|
3002a87cc629
(coding_system_require_warning): New variable.
Kenichi Handa <handa@m17n.org>
parents:
48829
diff
changeset
|
9395 &coding_system_require_warning, |
|
3002a87cc629
(coding_system_require_warning): New variable.
Kenichi Handa <handa@m17n.org>
parents:
48829
diff
changeset
|
9396 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
|
9397 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
|
9398 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
|
9399 `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
|
9400 coding_system_require_warning = 0; |
|
3002a87cc629
(coding_system_require_warning): New variable.
Kenichi Handa <handa@m17n.org>
parents:
48829
diff
changeset
|
9401 |
|
3002a87cc629
(coding_system_require_warning): New variable.
Kenichi Handa <handa@m17n.org>
parents:
48829
diff
changeset
|
9402 |
|
30292
14a9937df1f5
(syms_of_coding): Fix typo in spelling of variable
Gerd Moellmann <gerd@gnu.org>
parents:
30263
diff
changeset
|
9403 DEFVAR_BOOL ("inhibit-iso-escape-detection", |
|
30204
35aec8514228
(inhibit_iso_escape_detection): New variable.
Kenichi Handa <handa@m17n.org>
parents:
29985
diff
changeset
|
9404 &inhibit_iso_escape_detection, |
| 88365 | 9405 doc: /* |
| 9406 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
|
9407 |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
9408 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
|
9409 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
|
9410 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
|
9411 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
|
9412 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
|
9413 |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
9414 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
|
9415 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
|
9416 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
|
9417 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
|
9418 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
|
9419 |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
9420 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
|
9421 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
|
9422 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
|
9423 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
|
9424 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
|
9425 |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
9426 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
|
9427 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
|
9428 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
|
9429 inhibit_iso_escape_detection = 0; |
|
88456
a7b309f72920
(coding_alloc_by_making_gap): Check the case that the
Kenichi Handa <handa@m17n.org>
parents:
88443
diff
changeset
|
9430 |
|
48182
9474e269efd1
Reformat some DEFUNs so that etags works.
Dave Love <fx@gnu.org>
parents:
48125
diff
changeset
|
9431 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
|
9432 doc: /* Char table for translating self-inserting characters. |
|
c2ce8280fb97
(Vtranslation_table_for_input): New.
Dave Love <fx@gnu.org>
parents:
48182
diff
changeset
|
9433 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
|
9434 `keyboard-translate-table'. */); |
|
48182
9474e269efd1
Reformat some DEFUNs so that etags works.
Dave Love <fx@gnu.org>
parents:
48125
diff
changeset
|
9435 Vtranslation_table_for_input = Qnil; |
| 89483 | 9436 |
|
88456
a7b309f72920
(coding_alloc_by_making_gap): Check the case that the
Kenichi Handa <handa@m17n.org>
parents:
88443
diff
changeset
|
9437 { |
|
a7b309f72920
(coding_alloc_by_making_gap): Check the case that the
Kenichi Handa <handa@m17n.org>
parents:
88443
diff
changeset
|
9438 Lisp_Object args[coding_arg_max]; |
| 89483 | 9439 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
|
9440 int i; |
|
a7b309f72920
(coding_alloc_by_making_gap): Check the case that the
Kenichi Handa <handa@m17n.org>
parents:
88443
diff
changeset
|
9441 |
|
a7b309f72920
(coding_alloc_by_making_gap): Check the case that the
Kenichi Handa <handa@m17n.org>
parents:
88443
diff
changeset
|
9442 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
|
9443 args[i] = Qnil; |
|
a7b309f72920
(coding_alloc_by_making_gap): Check the case that the
Kenichi Handa <handa@m17n.org>
parents:
88443
diff
changeset
|
9444 |
|
a7b309f72920
(coding_alloc_by_making_gap): Check the case that the
Kenichi Handa <handa@m17n.org>
parents:
88443
diff
changeset
|
9445 plist[0] = intern (":name"); |
|
a7b309f72920
(coding_alloc_by_making_gap): Check the case that the
Kenichi Handa <handa@m17n.org>
parents:
88443
diff
changeset
|
9446 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
|
9447 plist[2] = intern (":mnemonic"); |
|
a7b309f72920
(coding_alloc_by_making_gap): Check the case that the
Kenichi Handa <handa@m17n.org>
parents:
88443
diff
changeset
|
9448 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
|
9449 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
|
9450 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
|
9451 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
|
9452 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
|
9453 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
|
9454 plist[9] = args[coding_arg_default_char] = make_number (0); |
| 89483 | 9455 plist[10] = intern (":for-unibyte"); |
| 9456 plist[11] = args[coding_arg_for_unibyte] = Qt; | |
| 9457 plist[12] = intern (":docstring"); | |
| 9458 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
|
9459 \n\ |
|
a7b309f72920
(coding_alloc_by_making_gap): Check the case that the
Kenichi Handa <handa@m17n.org>
parents:
88443
diff
changeset
|
9460 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
|
9461 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
|
9462 character."); |
| 89483 | 9463 plist[14] = intern (":eol-type"); |
| 9464 plist[15] = args[coding_arg_eol_type] = Qunix; | |
| 9465 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
|
9466 Fdefine_coding_system_internal (coding_arg_max, args); |
|
a7b309f72920
(coding_alloc_by_making_gap): Check the case that the
Kenichi Handa <handa@m17n.org>
parents:
88443
diff
changeset
|
9467 } |
|
a7b309f72920
(coding_alloc_by_making_gap): Check the case that the
Kenichi Handa <handa@m17n.org>
parents:
88443
diff
changeset
|
9468 |
|
a7b309f72920
(coding_alloc_by_making_gap): Check the case that the
Kenichi Handa <handa@m17n.org>
parents:
88443
diff
changeset
|
9469 setup_coding_system (Qno_conversion, &keyboard_coding); |
|
a7b309f72920
(coding_alloc_by_making_gap): Check the case that the
Kenichi Handa <handa@m17n.org>
parents:
88443
diff
changeset
|
9470 setup_coding_system (Qno_conversion, &terminal_coding); |
|
a7b309f72920
(coding_alloc_by_making_gap): Check the case that the
Kenichi Handa <handa@m17n.org>
parents:
88443
diff
changeset
|
9471 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
|
9472 |
|
e911ca706166
(Fset_coding_system_priority): Doc fix. Update values
Kenichi Handa <handa@m17n.org>
parents:
89462
diff
changeset
|
9473 { |
|
e911ca706166
(Fset_coding_system_priority): Doc fix. Update values
Kenichi Handa <handa@m17n.org>
parents:
89462
diff
changeset
|
9474 int i; |
|
e911ca706166
(Fset_coding_system_priority): Doc fix. Update values
Kenichi Handa <handa@m17n.org>
parents:
89462
diff
changeset
|
9475 |
|
e911ca706166
(Fset_coding_system_priority): Doc fix. Update values
Kenichi Handa <handa@m17n.org>
parents:
89462
diff
changeset
|
9476 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
|
9477 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
|
9478 } |
| 17052 | 9479 } |
| 9480 | |
|
26088
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
26067
diff
changeset
|
9481 char * |
|
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
26067
diff
changeset
|
9482 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
|
9483 int error_number; |
|
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
26067
diff
changeset
|
9484 { |
|
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
26067
diff
changeset
|
9485 char *str; |
|
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
26067
diff
changeset
|
9486 |
|
26526
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26240
diff
changeset
|
9487 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
|
9488 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
|
9489 |
|
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
26067
diff
changeset
|
9490 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
|
9491 { |
|
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
26067
diff
changeset
|
9492 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
|
9493 Vlocale_coding_system, |
|
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
26067
diff
changeset
|
9494 0); |
|
46370
40db0673e6f0
Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents:
46293
diff
changeset
|
9495 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
|
9496 } |
|
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
26067
diff
changeset
|
9497 |
|
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
26067
diff
changeset
|
9498 return str; |
|
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
26067
diff
changeset
|
9499 } |
|
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
26067
diff
changeset
|
9500 |
| 17052 | 9501 #endif /* emacs */ |
