Mercurial > emacs
annotate src/coding.c @ 89873:9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
goto invalid_code.
(decode_coding_iso_2022): Fix handling of invalid designation.
| author | Kenichi Handa <handa@m17n.org> |
|---|---|
| date | Tue, 30 Mar 2004 13:09:38 +0000 |
| parents | 428fc37b2ae6 |
| children | a2109a2c25d5 |
| 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 | |
| 414 /* ISO2022 section */ | |
| 415 | |
| 416 #define CODING_ISO_INITIAL(coding, reg) \ | |
| 417 (XINT (AREF (AREF (CODING_ID_ATTRS ((coding)->id), \ | |
| 418 coding_attr_iso_initial), \ | |
| 419 reg))) | |
| 420 | |
| 421 | |
| 422 #define CODING_ISO_REQUEST(coding, charset_id) \ | |
| 423 ((charset_id <= (coding)->max_charset_id \ | |
| 424 ? (coding)->safe_charsets[charset_id] \ | |
| 425 : -1)) | |
| 426 | |
| 427 | |
| 428 #define CODING_ISO_FLAGS(coding) \ | |
| 429 ((coding)->spec.iso_2022.flags) | |
| 430 #define CODING_ISO_DESIGNATION(coding, reg) \ | |
| 431 ((coding)->spec.iso_2022.current_designation[reg]) | |
| 432 #define CODING_ISO_INVOCATION(coding, plane) \ | |
| 433 ((coding)->spec.iso_2022.current_invocation[plane]) | |
| 434 #define CODING_ISO_SINGLE_SHIFTING(coding) \ | |
| 435 ((coding)->spec.iso_2022.single_shifting) | |
| 436 #define CODING_ISO_BOL(coding) \ | |
| 437 ((coding)->spec.iso_2022.bol) | |
| 438 #define CODING_ISO_INVOKED_CHARSET(coding, plane) \ | |
| 439 CODING_ISO_DESIGNATION ((coding), CODING_ISO_INVOCATION ((coding), (plane))) | |
| 440 | |
| 441 /* Control characters of ISO2022. */ | |
| 442 /* code */ /* function */ | |
| 443 #define ISO_CODE_LF 0x0A /* line-feed */ | |
| 444 #define ISO_CODE_CR 0x0D /* carriage-return */ | |
| 445 #define ISO_CODE_SO 0x0E /* shift-out */ | |
| 446 #define ISO_CODE_SI 0x0F /* shift-in */ | |
| 447 #define ISO_CODE_SS2_7 0x19 /* single-shift-2 for 7-bit code */ | |
| 448 #define ISO_CODE_ESC 0x1B /* escape */ | |
| 449 #define ISO_CODE_SS2 0x8E /* single-shift-2 */ | |
| 450 #define ISO_CODE_SS3 0x8F /* single-shift-3 */ | |
| 451 #define ISO_CODE_CSI 0x9B /* control-sequence-introducer */ | |
| 452 | |
| 453 /* All code (1-byte) of ISO2022 is classified into one of the | |
| 454 followings. */ | |
| 455 enum iso_code_class_type | |
| 456 { | |
| 457 ISO_control_0, /* Control codes in the range | |
| 458 0x00..0x1F and 0x7F, except for the | |
| 459 following 5 codes. */ | |
| 460 ISO_shift_out, /* ISO_CODE_SO (0x0E) */ | |
| 461 ISO_shift_in, /* ISO_CODE_SI (0x0F) */ | |
| 462 ISO_single_shift_2_7, /* ISO_CODE_SS2_7 (0x19) */ | |
| 463 ISO_escape, /* ISO_CODE_SO (0x1B) */ | |
| 464 ISO_control_1, /* Control codes in the range | |
| 465 0x80..0x9F, except for the | |
| 466 following 3 codes. */ | |
| 467 ISO_single_shift_2, /* ISO_CODE_SS2 (0x8E) */ | |
| 468 ISO_single_shift_3, /* ISO_CODE_SS3 (0x8F) */ | |
| 469 ISO_control_sequence_introducer, /* ISO_CODE_CSI (0x9B) */ | |
| 470 ISO_0x20_or_0x7F, /* Codes of the values 0x20 or 0x7F. */ | |
| 471 ISO_graphic_plane_0, /* Graphic codes in the range 0x21..0x7E. */ | |
| 472 ISO_0xA0_or_0xFF, /* Codes of the values 0xA0 or 0xFF. */ | |
| 473 ISO_graphic_plane_1 /* Graphic codes in the range 0xA1..0xFE. */ | |
| 474 }; | |
| 475 | |
| 476 /** The macros CODING_ISO_FLAG_XXX defines a flag bit of the | |
| 477 `iso-flags' attribute of an iso2022 coding system. */ | |
| 478 | |
| 479 /* If set, produce long-form designation sequence (e.g. ESC $ ( A) | |
| 480 instead of the correct short-form sequence (e.g. ESC $ A). */ | |
| 481 #define CODING_ISO_FLAG_LONG_FORM 0x0001 | |
| 482 | |
| 483 /* If set, reset graphic planes and registers at end-of-line to the | |
| 484 initial state. */ | |
| 485 #define CODING_ISO_FLAG_RESET_AT_EOL 0x0002 | |
| 486 | |
| 487 /* If set, reset graphic planes and registers before any control | |
| 488 characters to the initial state. */ | |
| 489 #define CODING_ISO_FLAG_RESET_AT_CNTL 0x0004 | |
| 490 | |
| 491 /* If set, encode by 7-bit environment. */ | |
| 492 #define CODING_ISO_FLAG_SEVEN_BITS 0x0008 | |
| 493 | |
| 494 /* If set, use locking-shift function. */ | |
| 495 #define CODING_ISO_FLAG_LOCKING_SHIFT 0x0010 | |
| 496 | |
| 497 /* If set, use single-shift function. Overwrite | |
| 498 CODING_ISO_FLAG_LOCKING_SHIFT. */ | |
| 499 #define CODING_ISO_FLAG_SINGLE_SHIFT 0x0020 | |
| 500 | |
| 501 /* If set, use designation escape sequence. */ | |
| 502 #define CODING_ISO_FLAG_DESIGNATION 0x0040 | |
| 503 | |
| 504 /* If set, produce revision number sequence. */ | |
| 505 #define CODING_ISO_FLAG_REVISION 0x0080 | |
| 506 | |
| 507 /* If set, produce ISO6429's direction specifying sequence. */ | |
| 508 #define CODING_ISO_FLAG_DIRECTION 0x0100 | |
| 509 | |
| 510 /* If set, assume designation states are reset at beginning of line on | |
| 511 output. */ | |
| 512 #define CODING_ISO_FLAG_INIT_AT_BOL 0x0200 | |
| 513 | |
| 514 /* If set, designation sequence should be placed at beginning of line | |
| 515 on output. */ | |
| 516 #define CODING_ISO_FLAG_DESIGNATE_AT_BOL 0x0400 | |
| 517 | |
| 518 /* If set, do not encode unsafe charactes on output. */ | |
| 519 #define CODING_ISO_FLAG_SAFE 0x0800 | |
| 520 | |
| 521 /* If set, extra latin codes (128..159) are accepted as a valid code | |
| 522 on input. */ | |
| 523 #define CODING_ISO_FLAG_LATIN_EXTRA 0x1000 | |
| 524 | |
| 525 #define CODING_ISO_FLAG_COMPOSITION 0x2000 | |
| 526 | |
| 527 #define CODING_ISO_FLAG_EUC_TW_SHIFT 0x4000 | |
| 528 | |
|
88681
2cdfbffa8a0d
(CODING_ISO_FLAG_USE_ROMAN): New macro
Kenichi Handa <handa@m17n.org>
parents:
88669
diff
changeset
|
529 #define CODING_ISO_FLAG_USE_ROMAN 0x8000 |
|
2cdfbffa8a0d
(CODING_ISO_FLAG_USE_ROMAN): New macro
Kenichi Handa <handa@m17n.org>
parents:
88669
diff
changeset
|
530 |
|
2cdfbffa8a0d
(CODING_ISO_FLAG_USE_ROMAN): New macro
Kenichi Handa <handa@m17n.org>
parents:
88669
diff
changeset
|
531 #define CODING_ISO_FLAG_USE_OLDJIS 0x10000 |
|
2cdfbffa8a0d
(CODING_ISO_FLAG_USE_ROMAN): New macro
Kenichi Handa <handa@m17n.org>
parents:
88669
diff
changeset
|
532 |
|
2cdfbffa8a0d
(CODING_ISO_FLAG_USE_ROMAN): New macro
Kenichi Handa <handa@m17n.org>
parents:
88669
diff
changeset
|
533 #define CODING_ISO_FLAG_FULL_SUPPORT 0x100000 |
| 88365 | 534 |
| 535 /* A character to be produced on output if encoding of the original | |
| 536 character is prohibited by CODING_ISO_FLAG_SAFE. */ | |
| 537 #define CODING_INHIBIT_CHARACTER_SUBSTITUTION '?' | |
| 538 | |
| 539 | |
| 540 /* UTF-16 section */ | |
| 541 #define CODING_UTF_16_BOM(coding) \ | |
| 542 ((coding)->spec.utf_16.bom) | |
| 543 | |
| 544 #define CODING_UTF_16_ENDIAN(coding) \ | |
| 545 ((coding)->spec.utf_16.endian) | |
| 546 | |
| 547 #define CODING_UTF_16_SURROGATE(coding) \ | |
| 548 ((coding)->spec.utf_16.surrogate) | |
| 549 | |
| 550 | |
| 551 /* CCL section */ | |
| 552 #define CODING_CCL_DECODER(coding) \ | |
| 553 AREF (CODING_ID_ATTRS ((coding)->id), coding_attr_ccl_decoder) | |
| 554 #define CODING_CCL_ENCODER(coding) \ | |
| 555 AREF (CODING_ID_ATTRS ((coding)->id), coding_attr_ccl_encoder) | |
| 556 #define CODING_CCL_VALIDS(coding) \ | |
| 89483 | 557 (SDATA (AREF (CODING_ID_ATTRS ((coding)->id), coding_attr_ccl_valids))) |
| 88365 | 558 |
| 88771 | 559 /* Index for each coding category in `coding_categories' */ |
| 88365 | 560 |
| 561 enum coding_category | |
| 562 { | |
| 563 coding_category_iso_7, | |
| 564 coding_category_iso_7_tight, | |
| 565 coding_category_iso_8_1, | |
| 566 coding_category_iso_8_2, | |
| 567 coding_category_iso_7_else, | |
| 568 coding_category_iso_8_else, | |
| 569 coding_category_utf_8, | |
| 570 coding_category_utf_16_auto, | |
| 571 coding_category_utf_16_be, | |
| 572 coding_category_utf_16_le, | |
| 573 coding_category_utf_16_be_nosig, | |
| 574 coding_category_utf_16_le_nosig, | |
| 575 coding_category_charset, | |
| 576 coding_category_sjis, | |
| 577 coding_category_big5, | |
| 578 coding_category_ccl, | |
| 579 coding_category_emacs_mule, | |
| 580 /* All above are targets of code detection. */ | |
| 581 coding_category_raw_text, | |
| 582 coding_category_undecided, | |
| 583 coding_category_max | |
| 584 }; | |
| 585 | |
| 586 /* Definitions of flag bits used in detect_coding_XXXX. */ | |
| 587 #define CATEGORY_MASK_ISO_7 (1 << coding_category_iso_7) | |
| 588 #define CATEGORY_MASK_ISO_7_TIGHT (1 << coding_category_iso_7_tight) | |
| 589 #define CATEGORY_MASK_ISO_8_1 (1 << coding_category_iso_8_1) | |
| 590 #define CATEGORY_MASK_ISO_8_2 (1 << coding_category_iso_8_2) | |
| 591 #define CATEGORY_MASK_ISO_7_ELSE (1 << coding_category_iso_7_else) | |
| 592 #define CATEGORY_MASK_ISO_8_ELSE (1 << coding_category_iso_8_else) | |
| 593 #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
|
594 #define CATEGORY_MASK_UTF_16_AUTO (1 << coding_category_utf_16_auto) |
| 88365 | 595 #define CATEGORY_MASK_UTF_16_BE (1 << coding_category_utf_16_be) |
| 596 #define CATEGORY_MASK_UTF_16_LE (1 << coding_category_utf_16_le) | |
| 597 #define CATEGORY_MASK_UTF_16_BE_NOSIG (1 << coding_category_utf_16_be_nosig) | |
| 598 #define CATEGORY_MASK_UTF_16_LE_NOSIG (1 << coding_category_utf_16_le_nosig) | |
| 599 #define CATEGORY_MASK_CHARSET (1 << coding_category_charset) | |
| 600 #define CATEGORY_MASK_SJIS (1 << coding_category_sjis) | |
| 601 #define CATEGORY_MASK_BIG5 (1 << coding_category_big5) | |
| 602 #define CATEGORY_MASK_CCL (1 << coding_category_ccl) | |
| 603 #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
|
604 #define CATEGORY_MASK_RAW_TEXT (1 << coding_category_raw_text) |
| 88365 | 605 |
| 606 /* This value is returned if detect_coding_mask () find nothing other | |
| 607 than ASCII characters. */ | |
| 608 #define CATEGORY_MASK_ANY \ | |
| 609 (CATEGORY_MASK_ISO_7 \ | |
| 610 | CATEGORY_MASK_ISO_7_TIGHT \ | |
| 611 | CATEGORY_MASK_ISO_8_1 \ | |
| 612 | CATEGORY_MASK_ISO_8_2 \ | |
| 613 | CATEGORY_MASK_ISO_7_ELSE \ | |
| 614 | CATEGORY_MASK_ISO_8_ELSE \ | |
| 615 | CATEGORY_MASK_UTF_8 \ | |
| 616 | CATEGORY_MASK_UTF_16_BE \ | |
| 617 | CATEGORY_MASK_UTF_16_LE \ | |
| 618 | CATEGORY_MASK_UTF_16_BE_NOSIG \ | |
| 619 | CATEGORY_MASK_UTF_16_LE_NOSIG \ | |
| 620 | CATEGORY_MASK_CHARSET \ | |
| 621 | CATEGORY_MASK_SJIS \ | |
| 622 | CATEGORY_MASK_BIG5 \ | |
| 623 | CATEGORY_MASK_CCL \ | |
| 624 | CATEGORY_MASK_EMACS_MULE) | |
| 625 | |
| 626 | |
| 627 #define CATEGORY_MASK_ISO_7BIT \ | |
| 628 (CATEGORY_MASK_ISO_7 | CATEGORY_MASK_ISO_7_TIGHT) | |
| 629 | |
| 630 #define CATEGORY_MASK_ISO_8BIT \ | |
| 631 (CATEGORY_MASK_ISO_8_1 | CATEGORY_MASK_ISO_8_2) | |
| 632 | |
| 633 #define CATEGORY_MASK_ISO_ELSE \ | |
| 634 (CATEGORY_MASK_ISO_7_ELSE | CATEGORY_MASK_ISO_8_ELSE) | |
| 635 | |
| 636 #define CATEGORY_MASK_ISO_ESCAPE \ | |
| 637 (CATEGORY_MASK_ISO_7 \ | |
| 638 | CATEGORY_MASK_ISO_7_TIGHT \ | |
| 639 | CATEGORY_MASK_ISO_7_ELSE \ | |
| 640 | CATEGORY_MASK_ISO_8_ELSE) | |
| 641 | |
| 642 #define CATEGORY_MASK_ISO \ | |
| 643 ( CATEGORY_MASK_ISO_7BIT \ | |
| 644 | CATEGORY_MASK_ISO_8BIT \ | |
| 645 | CATEGORY_MASK_ISO_ELSE) | |
| 646 | |
| 647 #define CATEGORY_MASK_UTF_16 \ | |
| 648 (CATEGORY_MASK_UTF_16_BE \ | |
| 649 | CATEGORY_MASK_UTF_16_LE \ | |
| 650 | CATEGORY_MASK_UTF_16_BE_NOSIG \ | |
| 651 | CATEGORY_MASK_UTF_16_LE_NOSIG) | |
| 652 | |
| 653 | |
| 654 /* List of symbols `coding-category-xxx' ordered by priority. This | |
| 655 variable is exposed to Emacs Lisp. */ | |
| 656 static Lisp_Object Vcoding_category_list; | |
| 657 | |
| 658 /* Table of coding categories (Lisp symbols). This variable is for | |
| 659 internal use oly. */ | |
| 660 static Lisp_Object Vcoding_category_table; | |
| 661 | |
| 662 /* Table of coding-categories ordered by priority. */ | |
| 663 static enum coding_category coding_priorities[coding_category_max]; | |
| 664 | |
| 665 /* Nth element is a coding context for the coding system bound to the | |
| 666 Nth coding category. */ | |
| 667 static struct coding_system coding_categories[coding_category_max]; | |
| 668 | |
| 669 /*** Commonly used macros and functions ***/ | |
| 670 | |
| 671 #ifndef min | |
| 672 #define min(a, b) ((a) < (b) ? (a) : (b)) | |
| 673 #endif | |
| 674 #ifndef max | |
| 675 #define max(a, b) ((a) > (b) ? (a) : (b)) | |
| 676 #endif | |
| 677 | |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
678 #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
|
679 do { \ |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
680 (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
|
681 (charset_list) = CODING_ATTR_CHARSET_LIST (attrs); \ |
| 88365 | 682 } while (0) |
| 683 | |
| 684 | |
| 685 /* Safely get one byte from the source text pointed by SRC which ends | |
| 686 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
|
687 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
|
688 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
|
689 negative value of the character code. The caller should declare |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
690 and set these variables appropriately in advance: |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
691 src, src_end, multibytep */ |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
692 |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
693 #define ONE_MORE_BYTE(c) \ |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
694 do { \ |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
695 if (src == src_end) \ |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
696 { \ |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
697 if (src_base < src) \ |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
698 record_conversion_result \ |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
699 (coding, CODING_RESULT_INSUFFICIENT_SRC); \ |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
700 goto no_more_source; \ |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
701 } \ |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
702 c = *src++; \ |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
703 if (multibytep && (c & 0x80)) \ |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
704 { \ |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
705 if ((c & 0xFE) == 0xC0) \ |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
706 c = ((c & 1) << 6) | *src++; \ |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
707 else \ |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
708 { \ |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
709 c = - string_char (--src, &src, NULL); \ |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
710 record_conversion_result \ |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
711 (coding, CODING_RESULT_INVALID_SRC); \ |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
712 } \ |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
713 } \ |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
714 consumed_chars++; \ |
| 88365 | 715 } while (0) |
| 716 | |
| 717 | |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
718 #define ONE_MORE_BYTE_NO_CHECK(c) \ |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
719 do { \ |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
720 c = *src++; \ |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
721 if (multibytep && (c & 0x80)) \ |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
722 { \ |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
723 if ((c & 0xFE) == 0xC0) \ |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
724 c = ((c & 1) << 6) | *src++; \ |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
725 else \ |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
726 { \ |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
727 c = - string_char (--src, &src, NULL); \ |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
728 record_conversion_result \ |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
729 (coding, CODING_RESULT_INVALID_SRC); \ |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
730 } \ |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
731 } \ |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
732 consumed_chars++; \ |
| 88365 | 733 } while (0) |
| 734 | |
| 735 | |
| 736 /* Store a byte C in the place pointed by DST and increment DST to the | |
| 737 next free point, and increment PRODUCED_CHARS. The caller should | |
| 738 assure that C is 0..127, and declare and set the variable `dst' | |
| 739 appropriately in advance. | |
| 740 */ | |
| 741 | |
| 742 | |
| 743 #define EMIT_ONE_ASCII_BYTE(c) \ | |
| 744 do { \ | |
| 745 produced_chars++; \ | |
| 746 *dst++ = (c); \ | |
| 747 } while (0) | |
| 748 | |
| 749 | |
| 750 /* Like EMIT_ONE_ASCII_BYTE byt store two bytes; C1 and C2. */ | |
| 751 | |
| 752 #define EMIT_TWO_ASCII_BYTES(c1, c2) \ | |
| 753 do { \ | |
| 754 produced_chars += 2; \ | |
| 755 *dst++ = (c1), *dst++ = (c2); \ | |
| 756 } while (0) | |
| 757 | |
| 758 | |
| 759 /* Store a byte C in the place pointed by DST and increment DST to the | |
| 760 next free point, and increment PRODUCED_CHARS. If MULTIBYTEP is | |
| 761 nonzero, store in an appropriate multibyte from. The caller should | |
| 762 declare and set the variables `dst' and `multibytep' appropriately | |
| 763 in advance. */ | |
| 764 | |
| 765 #define EMIT_ONE_BYTE(c) \ | |
| 766 do { \ | |
| 767 produced_chars++; \ | |
| 768 if (multibytep) \ | |
| 769 { \ | |
| 770 int ch = (c); \ | |
| 771 if (ch >= 0x80) \ | |
| 772 ch = BYTE8_TO_CHAR (ch); \ | |
| 773 CHAR_STRING_ADVANCE (ch, dst); \ | |
| 774 } \ | |
| 775 else \ | |
| 776 *dst++ = (c); \ | |
| 777 } while (0) | |
| 778 | |
| 779 | |
| 780 /* Like EMIT_ONE_BYTE, but emit two bytes; C1 and C2. */ | |
| 781 | |
|
88438
3a34b722dd71
(encode_coding_utf_8): Initialize produced_chars to 0.
Kenichi Handa <handa@m17n.org>
parents:
88430
diff
changeset
|
782 #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
|
783 do { \ |
|
3a34b722dd71
(encode_coding_utf_8): Initialize produced_chars to 0.
Kenichi Handa <handa@m17n.org>
parents:
88430
diff
changeset
|
784 produced_chars += 2; \ |
|
3a34b722dd71
(encode_coding_utf_8): Initialize produced_chars to 0.
Kenichi Handa <handa@m17n.org>
parents:
88430
diff
changeset
|
785 if (multibytep) \ |
|
3a34b722dd71
(encode_coding_utf_8): Initialize produced_chars to 0.
Kenichi Handa <handa@m17n.org>
parents:
88430
diff
changeset
|
786 { \ |
|
3a34b722dd71
(encode_coding_utf_8): Initialize produced_chars to 0.
Kenichi Handa <handa@m17n.org>
parents:
88430
diff
changeset
|
787 int ch; \ |
|
3a34b722dd71
(encode_coding_utf_8): Initialize produced_chars to 0.
Kenichi Handa <handa@m17n.org>
parents:
88430
diff
changeset
|
788 \ |
|
3a34b722dd71
(encode_coding_utf_8): Initialize produced_chars to 0.
Kenichi Handa <handa@m17n.org>
parents:
88430
diff
changeset
|
789 ch = (c1); \ |
|
3a34b722dd71
(encode_coding_utf_8): Initialize produced_chars to 0.
Kenichi Handa <handa@m17n.org>
parents:
88430
diff
changeset
|
790 if (ch >= 0x80) \ |
|
3a34b722dd71
(encode_coding_utf_8): Initialize produced_chars to 0.
Kenichi Handa <handa@m17n.org>
parents:
88430
diff
changeset
|
791 ch = BYTE8_TO_CHAR (ch); \ |
|
3a34b722dd71
(encode_coding_utf_8): Initialize produced_chars to 0.
Kenichi Handa <handa@m17n.org>
parents:
88430
diff
changeset
|
792 CHAR_STRING_ADVANCE (ch, dst); \ |
|
3a34b722dd71
(encode_coding_utf_8): Initialize produced_chars to 0.
Kenichi Handa <handa@m17n.org>
parents:
88430
diff
changeset
|
793 ch = (c2); \ |
|
3a34b722dd71
(encode_coding_utf_8): Initialize produced_chars to 0.
Kenichi Handa <handa@m17n.org>
parents:
88430
diff
changeset
|
794 if (ch >= 0x80) \ |
|
3a34b722dd71
(encode_coding_utf_8): Initialize produced_chars to 0.
Kenichi Handa <handa@m17n.org>
parents:
88430
diff
changeset
|
795 ch = BYTE8_TO_CHAR (ch); \ |
|
3a34b722dd71
(encode_coding_utf_8): Initialize produced_chars to 0.
Kenichi Handa <handa@m17n.org>
parents:
88430
diff
changeset
|
796 CHAR_STRING_ADVANCE (ch, dst); \ |
|
3a34b722dd71
(encode_coding_utf_8): Initialize produced_chars to 0.
Kenichi Handa <handa@m17n.org>
parents:
88430
diff
changeset
|
797 } \ |
|
3a34b722dd71
(encode_coding_utf_8): Initialize produced_chars to 0.
Kenichi Handa <handa@m17n.org>
parents:
88430
diff
changeset
|
798 else \ |
|
3a34b722dd71
(encode_coding_utf_8): Initialize produced_chars to 0.
Kenichi Handa <handa@m17n.org>
parents:
88430
diff
changeset
|
799 { \ |
|
3a34b722dd71
(encode_coding_utf_8): Initialize produced_chars to 0.
Kenichi Handa <handa@m17n.org>
parents:
88430
diff
changeset
|
800 *dst++ = (c1); \ |
|
3a34b722dd71
(encode_coding_utf_8): Initialize produced_chars to 0.
Kenichi Handa <handa@m17n.org>
parents:
88430
diff
changeset
|
801 *dst++ = (c2); \ |
|
3a34b722dd71
(encode_coding_utf_8): Initialize produced_chars to 0.
Kenichi Handa <handa@m17n.org>
parents:
88430
diff
changeset
|
802 } \ |
| 88365 | 803 } while (0) |
| 804 | |
| 805 | |
| 806 #define EMIT_THREE_BYTES(c1, c2, c3) \ | |
| 807 do { \ | |
| 808 EMIT_ONE_BYTE (c1); \ | |
| 809 EMIT_TWO_BYTES (c2, c3); \ | |
| 810 } while (0) | |
| 811 | |
| 812 | |
| 813 #define EMIT_FOUR_BYTES(c1, c2, c3, c4) \ | |
| 814 do { \ | |
| 815 EMIT_TWO_BYTES (c1, c2); \ | |
| 816 EMIT_TWO_BYTES (c3, c4); \ | |
| 817 } while (0) | |
| 818 | |
| 819 | |
|
89863
428fc37b2ae6
Add many prototypes for static functions.
Kenichi Handa <handa@m17n.org>
parents:
89861
diff
changeset
|
820 /* Prototypes for static functions. */ |
|
428fc37b2ae6
Add many prototypes for static functions.
Kenichi Handa <handa@m17n.org>
parents:
89861
diff
changeset
|
821 static void record_conversion_result P_ ((struct coding_system *coding, |
|
428fc37b2ae6
Add many prototypes for static functions.
Kenichi Handa <handa@m17n.org>
parents:
89861
diff
changeset
|
822 enum coding_result_code result)); |
|
428fc37b2ae6
Add many prototypes for static functions.
Kenichi Handa <handa@m17n.org>
parents:
89861
diff
changeset
|
823 static int detect_coding_utf_8 P_ ((struct coding_system *, |
|
428fc37b2ae6
Add many prototypes for static functions.
Kenichi Handa <handa@m17n.org>
parents:
89861
diff
changeset
|
824 struct coding_detection_info *info)); |
|
428fc37b2ae6
Add many prototypes for static functions.
Kenichi Handa <handa@m17n.org>
parents:
89861
diff
changeset
|
825 static void decode_coding_utf_8 P_ ((struct coding_system *)); |
|
428fc37b2ae6
Add many prototypes for static functions.
Kenichi Handa <handa@m17n.org>
parents:
89861
diff
changeset
|
826 static int encode_coding_utf_8 P_ ((struct coding_system *)); |
|
428fc37b2ae6
Add many prototypes for static functions.
Kenichi Handa <handa@m17n.org>
parents:
89861
diff
changeset
|
827 |
|
428fc37b2ae6
Add many prototypes for static functions.
Kenichi Handa <handa@m17n.org>
parents:
89861
diff
changeset
|
828 static int detect_coding_utf_16 P_ ((struct coding_system *, |
|
428fc37b2ae6
Add many prototypes for static functions.
Kenichi Handa <handa@m17n.org>
parents:
89861
diff
changeset
|
829 struct coding_detection_info *info)); |
|
428fc37b2ae6
Add many prototypes for static functions.
Kenichi Handa <handa@m17n.org>
parents:
89861
diff
changeset
|
830 static void decode_coding_utf_16 P_ ((struct coding_system *)); |
|
428fc37b2ae6
Add many prototypes for static functions.
Kenichi Handa <handa@m17n.org>
parents:
89861
diff
changeset
|
831 static int encode_coding_utf_16 P_ ((struct coding_system *)); |
|
428fc37b2ae6
Add many prototypes for static functions.
Kenichi Handa <handa@m17n.org>
parents:
89861
diff
changeset
|
832 |
|
428fc37b2ae6
Add many prototypes for static functions.
Kenichi Handa <handa@m17n.org>
parents:
89861
diff
changeset
|
833 static int detect_coding_iso_2022 P_ ((struct coding_system *, |
|
428fc37b2ae6
Add many prototypes for static functions.
Kenichi Handa <handa@m17n.org>
parents:
89861
diff
changeset
|
834 struct coding_detection_info *info)); |
|
428fc37b2ae6
Add many prototypes for static functions.
Kenichi Handa <handa@m17n.org>
parents:
89861
diff
changeset
|
835 static void decode_coding_iso_2022 P_ ((struct coding_system *)); |
|
428fc37b2ae6
Add many prototypes for static functions.
Kenichi Handa <handa@m17n.org>
parents:
89861
diff
changeset
|
836 static int encode_coding_iso_2022 P_ ((struct coding_system *)); |
|
428fc37b2ae6
Add many prototypes for static functions.
Kenichi Handa <handa@m17n.org>
parents:
89861
diff
changeset
|
837 |
|
428fc37b2ae6
Add many prototypes for static functions.
Kenichi Handa <handa@m17n.org>
parents:
89861
diff
changeset
|
838 static int detect_coding_emacs_mule P_ ((struct coding_system *, |
|
428fc37b2ae6
Add many prototypes for static functions.
Kenichi Handa <handa@m17n.org>
parents:
89861
diff
changeset
|
839 struct coding_detection_info *info)); |
|
428fc37b2ae6
Add many prototypes for static functions.
Kenichi Handa <handa@m17n.org>
parents:
89861
diff
changeset
|
840 static void decode_coding_emacs_mule P_ ((struct coding_system *)); |
|
428fc37b2ae6
Add many prototypes for static functions.
Kenichi Handa <handa@m17n.org>
parents:
89861
diff
changeset
|
841 static int encode_coding_emacs_mule P_ ((struct coding_system *)); |
|
428fc37b2ae6
Add many prototypes for static functions.
Kenichi Handa <handa@m17n.org>
parents:
89861
diff
changeset
|
842 |
|
428fc37b2ae6
Add many prototypes for static functions.
Kenichi Handa <handa@m17n.org>
parents:
89861
diff
changeset
|
843 static int detect_coding_sjis P_ ((struct coding_system *, |
|
428fc37b2ae6
Add many prototypes for static functions.
Kenichi Handa <handa@m17n.org>
parents:
89861
diff
changeset
|
844 struct coding_detection_info *info)); |
|
428fc37b2ae6
Add many prototypes for static functions.
Kenichi Handa <handa@m17n.org>
parents:
89861
diff
changeset
|
845 static void decode_coding_sjis P_ ((struct coding_system *)); |
|
428fc37b2ae6
Add many prototypes for static functions.
Kenichi Handa <handa@m17n.org>
parents:
89861
diff
changeset
|
846 static int encode_coding_sjis P_ ((struct coding_system *)); |
|
428fc37b2ae6
Add many prototypes for static functions.
Kenichi Handa <handa@m17n.org>
parents:
89861
diff
changeset
|
847 |
|
428fc37b2ae6
Add many prototypes for static functions.
Kenichi Handa <handa@m17n.org>
parents:
89861
diff
changeset
|
848 static int detect_coding_big5 P_ ((struct coding_system *, |
|
428fc37b2ae6
Add many prototypes for static functions.
Kenichi Handa <handa@m17n.org>
parents:
89861
diff
changeset
|
849 struct coding_detection_info *info)); |
|
428fc37b2ae6
Add many prototypes for static functions.
Kenichi Handa <handa@m17n.org>
parents:
89861
diff
changeset
|
850 static void decode_coding_big5 P_ ((struct coding_system *)); |
|
428fc37b2ae6
Add many prototypes for static functions.
Kenichi Handa <handa@m17n.org>
parents:
89861
diff
changeset
|
851 static int encode_coding_big5 P_ ((struct coding_system *)); |
|
428fc37b2ae6
Add many prototypes for static functions.
Kenichi Handa <handa@m17n.org>
parents:
89861
diff
changeset
|
852 |
|
428fc37b2ae6
Add many prototypes for static functions.
Kenichi Handa <handa@m17n.org>
parents:
89861
diff
changeset
|
853 static int detect_coding_ccl P_ ((struct coding_system *, |
|
428fc37b2ae6
Add many prototypes for static functions.
Kenichi Handa <handa@m17n.org>
parents:
89861
diff
changeset
|
854 struct coding_detection_info *info)); |
|
428fc37b2ae6
Add many prototypes for static functions.
Kenichi Handa <handa@m17n.org>
parents:
89861
diff
changeset
|
855 static void decode_coding_ccl P_ ((struct coding_system *)); |
|
428fc37b2ae6
Add many prototypes for static functions.
Kenichi Handa <handa@m17n.org>
parents:
89861
diff
changeset
|
856 static int encode_coding_ccl P_ ((struct coding_system *)); |
|
428fc37b2ae6
Add many prototypes for static functions.
Kenichi Handa <handa@m17n.org>
parents:
89861
diff
changeset
|
857 |
|
428fc37b2ae6
Add many prototypes for static functions.
Kenichi Handa <handa@m17n.org>
parents:
89861
diff
changeset
|
858 static void decode_coding_raw_text P_ ((struct coding_system *)); |
|
428fc37b2ae6
Add many prototypes for static functions.
Kenichi Handa <handa@m17n.org>
parents:
89861
diff
changeset
|
859 static int encode_coding_raw_text P_ ((struct coding_system *)); |
|
428fc37b2ae6
Add many prototypes for static functions.
Kenichi Handa <handa@m17n.org>
parents:
89861
diff
changeset
|
860 |
|
428fc37b2ae6
Add many prototypes for static functions.
Kenichi Handa <handa@m17n.org>
parents:
89861
diff
changeset
|
861 static void coding_set_source P_ ((struct coding_system *)); |
|
428fc37b2ae6
Add many prototypes for static functions.
Kenichi Handa <handa@m17n.org>
parents:
89861
diff
changeset
|
862 static void coding_set_destination P_ ((struct coding_system *)); |
|
428fc37b2ae6
Add many prototypes for static functions.
Kenichi Handa <handa@m17n.org>
parents:
89861
diff
changeset
|
863 static void coding_alloc_by_realloc P_ ((struct coding_system *, EMACS_INT)); |
|
428fc37b2ae6
Add many prototypes for static functions.
Kenichi Handa <handa@m17n.org>
parents:
89861
diff
changeset
|
864 static void coding_alloc_by_making_gap P_ ((struct coding_system *, |
|
428fc37b2ae6
Add many prototypes for static functions.
Kenichi Handa <handa@m17n.org>
parents:
89861
diff
changeset
|
865 EMACS_INT)); |
|
428fc37b2ae6
Add many prototypes for static functions.
Kenichi Handa <handa@m17n.org>
parents:
89861
diff
changeset
|
866 static unsigned char *alloc_destination P_ ((struct coding_system *, |
|
428fc37b2ae6
Add many prototypes for static functions.
Kenichi Handa <handa@m17n.org>
parents:
89861
diff
changeset
|
867 EMACS_INT, unsigned char *)); |
|
428fc37b2ae6
Add many prototypes for static functions.
Kenichi Handa <handa@m17n.org>
parents:
89861
diff
changeset
|
868 static void setup_iso_safe_charsets P_ ((Lisp_Object)); |
|
428fc37b2ae6
Add many prototypes for static functions.
Kenichi Handa <handa@m17n.org>
parents:
89861
diff
changeset
|
869 static unsigned char *encode_designation_at_bol P_ ((struct coding_system *, |
|
428fc37b2ae6
Add many prototypes for static functions.
Kenichi Handa <handa@m17n.org>
parents:
89861
diff
changeset
|
870 int *, int *, |
|
428fc37b2ae6
Add many prototypes for static functions.
Kenichi Handa <handa@m17n.org>
parents:
89861
diff
changeset
|
871 unsigned char *)); |
|
428fc37b2ae6
Add many prototypes for static functions.
Kenichi Handa <handa@m17n.org>
parents:
89861
diff
changeset
|
872 static int detect_eol P_ ((const unsigned char *, |
|
428fc37b2ae6
Add many prototypes for static functions.
Kenichi Handa <handa@m17n.org>
parents:
89861
diff
changeset
|
873 EMACS_INT, enum coding_category)); |
|
428fc37b2ae6
Add many prototypes for static functions.
Kenichi Handa <handa@m17n.org>
parents:
89861
diff
changeset
|
874 static Lisp_Object adjust_coding_eol_type P_ ((struct coding_system *, int)); |
|
428fc37b2ae6
Add many prototypes for static functions.
Kenichi Handa <handa@m17n.org>
parents:
89861
diff
changeset
|
875 static void decode_eol P_ ((struct coding_system *)); |
|
428fc37b2ae6
Add many prototypes for static functions.
Kenichi Handa <handa@m17n.org>
parents:
89861
diff
changeset
|
876 static Lisp_Object get_translation_table P_ ((Lisp_Object, int, int *)); |
|
428fc37b2ae6
Add many prototypes for static functions.
Kenichi Handa <handa@m17n.org>
parents:
89861
diff
changeset
|
877 static Lisp_Object get_translation P_ ((Lisp_Object, int *, int *, |
|
428fc37b2ae6
Add many prototypes for static functions.
Kenichi Handa <handa@m17n.org>
parents:
89861
diff
changeset
|
878 int, int *, int *)); |
|
428fc37b2ae6
Add many prototypes for static functions.
Kenichi Handa <handa@m17n.org>
parents:
89861
diff
changeset
|
879 static int produce_chars P_ ((struct coding_system *, Lisp_Object, int)); |
|
428fc37b2ae6
Add many prototypes for static functions.
Kenichi Handa <handa@m17n.org>
parents:
89861
diff
changeset
|
880 static INLINE void produce_composition P_ ((struct coding_system *, int *, |
|
428fc37b2ae6
Add many prototypes for static functions.
Kenichi Handa <handa@m17n.org>
parents:
89861
diff
changeset
|
881 EMACS_INT)); |
|
428fc37b2ae6
Add many prototypes for static functions.
Kenichi Handa <handa@m17n.org>
parents:
89861
diff
changeset
|
882 static INLINE void produce_charset P_ ((struct coding_system *, int *, |
|
428fc37b2ae6
Add many prototypes for static functions.
Kenichi Handa <handa@m17n.org>
parents:
89861
diff
changeset
|
883 EMACS_INT)); |
|
428fc37b2ae6
Add many prototypes for static functions.
Kenichi Handa <handa@m17n.org>
parents:
89861
diff
changeset
|
884 static void produce_annotation P_ ((struct coding_system *, EMACS_INT)); |
|
428fc37b2ae6
Add many prototypes for static functions.
Kenichi Handa <handa@m17n.org>
parents:
89861
diff
changeset
|
885 static int decode_coding P_ ((struct coding_system *)); |
|
428fc37b2ae6
Add many prototypes for static functions.
Kenichi Handa <handa@m17n.org>
parents:
89861
diff
changeset
|
886 static INLINE int *handle_composition_annotation P_ ((EMACS_INT, EMACS_INT, |
|
428fc37b2ae6
Add many prototypes for static functions.
Kenichi Handa <handa@m17n.org>
parents:
89861
diff
changeset
|
887 struct coding_system *, |
|
428fc37b2ae6
Add many prototypes for static functions.
Kenichi Handa <handa@m17n.org>
parents:
89861
diff
changeset
|
888 int *, EMACS_INT *)); |
|
428fc37b2ae6
Add many prototypes for static functions.
Kenichi Handa <handa@m17n.org>
parents:
89861
diff
changeset
|
889 static INLINE int *handle_charset_annotation P_ ((EMACS_INT, EMACS_INT, |
|
428fc37b2ae6
Add many prototypes for static functions.
Kenichi Handa <handa@m17n.org>
parents:
89861
diff
changeset
|
890 struct coding_system *, |
|
428fc37b2ae6
Add many prototypes for static functions.
Kenichi Handa <handa@m17n.org>
parents:
89861
diff
changeset
|
891 int *, EMACS_INT *)); |
|
428fc37b2ae6
Add many prototypes for static functions.
Kenichi Handa <handa@m17n.org>
parents:
89861
diff
changeset
|
892 static void consume_chars P_ ((struct coding_system *, Lisp_Object, int)); |
|
428fc37b2ae6
Add many prototypes for static functions.
Kenichi Handa <handa@m17n.org>
parents:
89861
diff
changeset
|
893 static int encode_coding P_ ((struct coding_system *)); |
|
428fc37b2ae6
Add many prototypes for static functions.
Kenichi Handa <handa@m17n.org>
parents:
89861
diff
changeset
|
894 static Lisp_Object make_conversion_work_buffer P_ ((int)); |
|
428fc37b2ae6
Add many prototypes for static functions.
Kenichi Handa <handa@m17n.org>
parents:
89861
diff
changeset
|
895 static Lisp_Object code_conversion_restore P_ ((Lisp_Object)); |
|
428fc37b2ae6
Add many prototypes for static functions.
Kenichi Handa <handa@m17n.org>
parents:
89861
diff
changeset
|
896 static INLINE int char_encodable_p P_ ((int, Lisp_Object)); |
|
428fc37b2ae6
Add many prototypes for static functions.
Kenichi Handa <handa@m17n.org>
parents:
89861
diff
changeset
|
897 static Lisp_Object make_subsidiaries P_ ((Lisp_Object)); |
|
428fc37b2ae6
Add many prototypes for static functions.
Kenichi Handa <handa@m17n.org>
parents:
89861
diff
changeset
|
898 |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
899 static void |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
900 record_conversion_result (struct coding_system *coding, |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
901 enum coding_result_code result) |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
902 { |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
903 coding->result = result; |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
904 switch (result) |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
905 { |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
906 case CODING_RESULT_INSUFFICIENT_SRC: |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
907 Vlast_code_conversion_error = Qinsufficient_source; |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
908 break; |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
909 case CODING_RESULT_INCONSISTENT_EOL: |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
910 Vlast_code_conversion_error = Qinconsistent_eol; |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
911 break; |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
912 case CODING_RESULT_INVALID_SRC: |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
913 Vlast_code_conversion_error = Qinvalid_source; |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
914 break; |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
915 case CODING_RESULT_INTERRUPT: |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
916 Vlast_code_conversion_error = Qinterrupted; |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
917 break; |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
918 case CODING_RESULT_INSUFFICIENT_MEM: |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
919 Vlast_code_conversion_error = Qinsufficient_memory; |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
920 break; |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
921 } |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
922 } |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
923 |
| 88365 | 924 #define CODING_DECODE_CHAR(coding, src, src_base, src_end, charset, code, c) \ |
| 925 do { \ | |
| 926 charset_map_loaded = 0; \ | |
| 927 c = DECODE_CHAR (charset, code); \ | |
| 928 if (charset_map_loaded) \ | |
| 929 { \ | |
| 89483 | 930 const unsigned char *orig = coding->source; \ |
| 88365 | 931 EMACS_INT offset; \ |
| 932 \ | |
| 933 coding_set_source (coding); \ | |
| 934 offset = coding->source - orig; \ | |
| 935 src += offset; \ | |
| 936 src_base += offset; \ | |
| 937 src_end += offset; \ | |
| 938 } \ | |
| 939 } while (0) | |
| 940 | |
| 941 | |
| 942 #define ASSURE_DESTINATION(bytes) \ | |
| 943 do { \ | |
| 944 if (dst + (bytes) >= dst_end) \ | |
| 945 { \ | |
| 946 int more_bytes = charbuf_end - charbuf + (bytes); \ | |
| 947 \ | |
| 948 dst = alloc_destination (coding, more_bytes, dst); \ | |
| 949 dst_end = coding->destination + coding->dst_bytes; \ | |
| 950 } \ | |
| 951 } while (0) | |
| 952 | |
| 953 | |
| 954 | |
| 955 static void | |
| 956 coding_set_source (coding) | |
| 957 struct coding_system *coding; | |
| 958 { | |
| 959 if (BUFFERP (coding->src_object)) | |
| 960 { | |
|
89418
a9c2b3712863
(coding_set_source): Fix for the case that the current
Kenichi Handa <handa@m17n.org>
parents:
89404
diff
changeset
|
961 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
|
962 |
| 88365 | 963 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
|
964 coding->source = BUF_GAP_END_ADDR (buf) + coding->src_pos_byte; |
| 88365 | 965 else |
|
89418
a9c2b3712863
(coding_set_source): Fix for the case that the current
Kenichi Handa <handa@m17n.org>
parents:
89404
diff
changeset
|
966 coding->source = BUF_BYTE_ADDRESS (buf, coding->src_pos_byte); |
| 88365 | 967 } |
| 968 else if (STRINGP (coding->src_object)) | |
| 969 { | |
| 89483 | 970 coding->source = SDATA (coding->src_object) + coding->src_pos_byte; |
| 88365 | 971 } |
| 972 else | |
| 973 /* Otherwise, the source is C string and is never relocated | |
| 974 automatically. Thus we don't have to update anything. */ | |
| 975 ; | |
| 976 } | |
| 977 | |
| 978 static void | |
| 979 coding_set_destination (coding) | |
|
30487
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
980 struct coding_system *coding; |
|
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
981 { |
| 88365 | 982 if (BUFFERP (coding->dst_object)) |
| 983 { | |
| 984 if (coding->src_pos < 0) | |
|
89042
2b9f8973f240
(coding_set_destination): Fix coding->destination for
Kenichi Handa <handa@m17n.org>
parents:
88977
diff
changeset
|
985 { |
|
2b9f8973f240
(coding_set_destination): Fix coding->destination for
Kenichi Handa <handa@m17n.org>
parents:
88977
diff
changeset
|
986 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
|
987 coding->dst_bytes = (GAP_END_ADDR |
|
2b9f8973f240
(coding_set_destination): Fix coding->destination for
Kenichi Handa <handa@m17n.org>
parents:
88977
diff
changeset
|
988 - (coding->src_bytes - coding->consumed) |
|
2b9f8973f240
(coding_set_destination): Fix coding->destination for
Kenichi Handa <handa@m17n.org>
parents:
88977
diff
changeset
|
989 - coding->destination); |
|
2b9f8973f240
(coding_set_destination): Fix coding->destination for
Kenichi Handa <handa@m17n.org>
parents:
88977
diff
changeset
|
990 } |
| 88365 | 991 else |
|
89042
2b9f8973f240
(coding_set_destination): Fix coding->destination for
Kenichi Handa <handa@m17n.org>
parents:
88977
diff
changeset
|
992 { |
|
2b9f8973f240
(coding_set_destination): Fix coding->destination for
Kenichi Handa <handa@m17n.org>
parents:
88977
diff
changeset
|
993 /* 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
|
994 of the buffer. */ |
|
2b9f8973f240
(coding_set_destination): Fix coding->destination for
Kenichi Handa <handa@m17n.org>
parents:
88977
diff
changeset
|
995 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
|
996 + coding->dst_pos_byte - 1); |
|
2b9f8973f240
(coding_set_destination): Fix coding->destination for
Kenichi Handa <handa@m17n.org>
parents:
88977
diff
changeset
|
997 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
|
998 - coding->destination); |
|
2b9f8973f240
(coding_set_destination): Fix coding->destination for
Kenichi Handa <handa@m17n.org>
parents:
88977
diff
changeset
|
999 } |
| 88365 | 1000 } |
| 1001 else | |
| 1002 /* Otherwise, the destination is C string and is never relocated | |
| 1003 automatically. Thus we don't have to update anything. */ | |
| 1004 ; | |
| 1005 } | |
| 1006 | |
| 1007 | |
| 1008 static void | |
| 1009 coding_alloc_by_realloc (coding, bytes) | |
| 1010 struct coding_system *coding; | |
| 1011 EMACS_INT bytes; | |
| 1012 { | |
| 1013 coding->destination = (unsigned char *) xrealloc (coding->destination, | |
| 1014 coding->dst_bytes + bytes); | |
| 1015 coding->dst_bytes += bytes; | |
|
30487
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
1016 } |
|
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
1017 |
| 88365 | 1018 static void |
| 1019 coding_alloc_by_making_gap (coding, bytes) | |
| 1020 struct coding_system *coding; | |
| 1021 EMACS_INT bytes; | |
| 1022 { | |
|
88456
a7b309f72920
(coding_alloc_by_making_gap): Check the case that the
Kenichi Handa <handa@m17n.org>
parents:
88443
diff
changeset
|
1023 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
|
1024 && EQ (coding->src_object, coding->dst_object)) |
| 88365 | 1025 { |
| 1026 EMACS_INT add = coding->src_bytes - coding->consumed; | |
| 1027 | |
| 1028 GAP_SIZE -= add; ZV += add; Z += add; ZV_BYTE += add; Z_BYTE += add; | |
| 1029 make_gap (bytes); | |
| 1030 GAP_SIZE += add; ZV -= add; Z -= add; ZV_BYTE -= add; Z_BYTE -= add; | |
| 1031 } | |
| 1032 else | |
| 1033 { | |
|
88456
a7b309f72920
(coding_alloc_by_making_gap): Check the case that the
Kenichi Handa <handa@m17n.org>
parents:
88443
diff
changeset
|
1034 Lisp_Object this_buffer; |
|
a7b309f72920
(coding_alloc_by_making_gap): Check the case that the
Kenichi Handa <handa@m17n.org>
parents:
88443
diff
changeset
|
1035 |
|
a7b309f72920
(coding_alloc_by_making_gap): Check the case that the
Kenichi Handa <handa@m17n.org>
parents:
88443
diff
changeset
|
1036 this_buffer = Fcurrent_buffer (); |
| 88365 | 1037 set_buffer_internal (XBUFFER (coding->dst_object)); |
| 1038 make_gap (bytes); | |
| 1039 set_buffer_internal (XBUFFER (this_buffer)); | |
| 1040 } | |
| 1041 } | |
| 89483 | 1042 |
| 88365 | 1043 |
| 1044 static unsigned char * | |
| 1045 alloc_destination (coding, nbytes, dst) | |
| 1046 struct coding_system *coding; | |
|
89545
4f394eed6ff2
(inhibit_pre_post_conversion): Removed (unused).
Dave Love <fx@gnu.org>
parents:
89519
diff
changeset
|
1047 EMACS_INT nbytes; |
| 88365 | 1048 unsigned char *dst; |
| 1049 { | |
| 1050 EMACS_INT offset = dst - coding->destination; | |
| 1051 | |
| 1052 if (BUFFERP (coding->dst_object)) | |
| 1053 coding_alloc_by_making_gap (coding, nbytes); | |
| 1054 else | |
| 1055 coding_alloc_by_realloc (coding, nbytes); | |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1056 record_conversion_result (coding, CODING_RESULT_SUCCESS); |
| 88365 | 1057 coding_set_destination (coding); |
| 1058 dst = coding->destination + offset; | |
| 1059 return dst; | |
| 1060 } | |
| 1061 | |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1062 /** Macros for annotations. */ |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1063 |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1064 /* 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
|
1065 composition and charset). */ |
|
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
1066 #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
|
1067 |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1068 /* 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
|
1069 format: |
|
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
1070 [ -LENGTH ANNOTATION_MASK NCHARS ... ] |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1071 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
|
1072 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
|
1073 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
|
1074 |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1075 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
|
1076 |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1077 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
|
1078 follows: |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1079 ... METHOD [ COMPOSITION-COMPONENTS ... ] |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1080 METHOD is one of enum composition_method. |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1081 Optionnal COMPOSITION-COMPONENTS are characters and composition |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1082 rules. |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1083 |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1084 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
|
1085 follows. */ |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1086 |
|
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
1087 #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
|
1088 do { \ |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1089 *(buf)++ = -(len); \ |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1090 *(buf)++ = (mask); \ |
|
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
1091 *(buf)++ = (nchars); \ |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1092 coding->annotated = 1; \ |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1093 } while (0); |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1094 |
|
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
1095 #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
|
1096 do { \ |
|
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
1097 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
|
1098 *buf++ = method; \ |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1099 } while (0) |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1100 |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1101 |
|
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
1102 #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
|
1103 do { \ |
|
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
1104 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
|
1105 *buf++ = id; \ |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1106 } while (0) |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1107 |
| 88365 | 1108 |
| 1109 /*** 2. Emacs' internal format (emacs-utf-8) ***/ | |
| 1110 | |
| 1111 | |
|
30487
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
1112 |
| 17052 | 1113 |
| 88365 | 1114 /*** 3. UTF-8 ***/ |
| 1115 | |
| 1116 /* 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
|
1117 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
|
1118 return 0. */ |
| 88365 | 1119 |
| 1120 #define UTF_8_1_OCTET_P(c) ((c) < 0x80) | |
| 1121 #define UTF_8_EXTRA_OCTET_P(c) (((c) & 0xC0) == 0x80) | |
| 1122 #define UTF_8_2_OCTET_LEADING_P(c) (((c) & 0xE0) == 0xC0) | |
| 1123 #define UTF_8_3_OCTET_LEADING_P(c) (((c) & 0xF0) == 0xE0) | |
| 1124 #define UTF_8_4_OCTET_LEADING_P(c) (((c) & 0xF8) == 0xF0) | |
| 1125 #define UTF_8_5_OCTET_LEADING_P(c) (((c) & 0xFC) == 0xF8) | |
| 1126 | |
| 1127 static int | |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1128 detect_coding_utf_8 (coding, detect_info) |
| 88365 | 1129 struct coding_system *coding; |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1130 struct coding_detection_info *detect_info; |
| 88365 | 1131 { |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1132 const unsigned char *src = coding->source, *src_base; |
| 89483 | 1133 const unsigned char *src_end = coding->source + coding->src_bytes; |
| 88365 | 1134 int multibytep = coding->src_multibyte; |
| 1135 int consumed_chars = 0; | |
| 1136 int found = 0; | |
| 1137 | |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1138 detect_info->checked |= CATEGORY_MASK_UTF_8; |
| 88365 | 1139 /* A coding system of this category is always ASCII compatible. */ |
| 1140 src += coding->head_ascii; | |
| 1141 | |
| 1142 while (1) | |
| 1143 { | |
| 1144 int c, c1, c2, c3, c4; | |
| 1145 | |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1146 src_base = src; |
| 88365 | 1147 ONE_MORE_BYTE (c); |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1148 if (c < 0 || UTF_8_1_OCTET_P (c)) |
| 88365 | 1149 continue; |
| 1150 ONE_MORE_BYTE (c1); | |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1151 if (c1 < 0 || ! UTF_8_EXTRA_OCTET_P (c1)) |
| 88365 | 1152 break; |
| 1153 if (UTF_8_2_OCTET_LEADING_P (c)) | |
| 1154 { | |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1155 found = CATEGORY_MASK_UTF_8; |
| 88365 | 1156 continue; |
| 1157 } | |
| 1158 ONE_MORE_BYTE (c2); | |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1159 if (c2 < 0 || ! UTF_8_EXTRA_OCTET_P (c2)) |
| 88365 | 1160 break; |
| 1161 if (UTF_8_3_OCTET_LEADING_P (c)) | |
| 1162 { | |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1163 found = CATEGORY_MASK_UTF_8; |
| 88365 | 1164 continue; |
| 1165 } | |
| 1166 ONE_MORE_BYTE (c3); | |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1167 if (c3 < 0 || ! UTF_8_EXTRA_OCTET_P (c3)) |
| 88365 | 1168 break; |
| 1169 if (UTF_8_4_OCTET_LEADING_P (c)) | |
| 1170 { | |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1171 found = CATEGORY_MASK_UTF_8; |
| 88365 | 1172 continue; |
| 1173 } | |
| 1174 ONE_MORE_BYTE (c4); | |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1175 if (c4 < 0 || ! UTF_8_EXTRA_OCTET_P (c4)) |
| 88365 | 1176 break; |
| 1177 if (UTF_8_5_OCTET_LEADING_P (c)) | |
| 1178 { | |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1179 found = CATEGORY_MASK_UTF_8; |
| 88365 | 1180 continue; |
| 1181 } | |
| 1182 break; | |
| 1183 } | |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1184 detect_info->rejected |= CATEGORY_MASK_UTF_8; |
| 88365 | 1185 return 0; |
| 1186 | |
| 1187 no_more_source: | |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1188 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
|
1189 { |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1190 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
|
1191 return 0; |
|
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
1192 } |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1193 detect_info->found |= found; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1194 return 1; |
| 88365 | 1195 } |
| 1196 | |
| 1197 | |
| 1198 static void | |
| 1199 decode_coding_utf_8 (coding) | |
| 1200 struct coding_system *coding; | |
| 1201 { | |
| 89483 | 1202 const unsigned char *src = coding->source + coding->consumed; |
| 1203 const unsigned char *src_end = coding->source + coding->src_bytes; | |
| 1204 const unsigned char *src_base; | |
|
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
1205 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
|
1206 int *charbuf_end = coding->charbuf + coding->charbuf_size; |
| 88365 | 1207 int consumed_chars = 0, consumed_chars_base; |
| 1208 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
|
1209 Lisp_Object attr, charset_list; |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
1210 |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
1211 CODING_GET_INFO (coding, attr, charset_list); |
| 88365 | 1212 |
| 1213 while (1) | |
| 1214 { | |
| 1215 int c, c1, c2, c3, c4, c5; | |
| 1216 | |
| 1217 src_base = src; | |
| 1218 consumed_chars_base = consumed_chars; | |
| 1219 | |
| 1220 if (charbuf >= charbuf_end) | |
| 1221 break; | |
| 1222 | |
| 1223 ONE_MORE_BYTE (c1); | |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1224 if (c1 < 0) |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1225 { |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1226 c = - c1; |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1227 } |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1228 else if (UTF_8_1_OCTET_P(c1)) |
| 88365 | 1229 { |
| 1230 c = c1; | |
| 1231 } | |
| 1232 else | |
| 1233 { | |
| 1234 ONE_MORE_BYTE (c2); | |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1235 if (c2 < 0 || ! UTF_8_EXTRA_OCTET_P (c2)) |
| 88365 | 1236 goto invalid_code; |
| 1237 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
|
1238 { |
|
0bc5868f9f61
(decode_coding_utf_8): Reject overlong sequences.
Dave Love <fx@gnu.org>
parents:
88646
diff
changeset
|
1239 c = ((c1 & 0x1F) << 6) | (c2 & 0x3F); |
|
0bc5868f9f61
(decode_coding_utf_8): Reject overlong sequences.
Dave Love <fx@gnu.org>
parents:
88646
diff
changeset
|
1240 /* Reject overlong sequences here and below. Encoders |
|
0bc5868f9f61
(decode_coding_utf_8): Reject overlong sequences.
Dave Love <fx@gnu.org>
parents:
88646
diff
changeset
|
1241 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
|
1242 and they mess up read/write invariance. */ |
|
0bc5868f9f61
(decode_coding_utf_8): Reject overlong sequences.
Dave Love <fx@gnu.org>
parents:
88646
diff
changeset
|
1243 if (c < 128) |
|
0bc5868f9f61
(decode_coding_utf_8): Reject overlong sequences.
Dave Love <fx@gnu.org>
parents:
88646
diff
changeset
|
1244 goto invalid_code; |
|
0bc5868f9f61
(decode_coding_utf_8): Reject overlong sequences.
Dave Love <fx@gnu.org>
parents:
88646
diff
changeset
|
1245 } |
| 88365 | 1246 else |
| 1247 { | |
| 1248 ONE_MORE_BYTE (c3); | |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1249 if (c3 < 0 || ! UTF_8_EXTRA_OCTET_P (c3)) |
| 88365 | 1250 goto invalid_code; |
| 1251 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
|
1252 { |
|
0bc5868f9f61
(decode_coding_utf_8): Reject overlong sequences.
Dave Love <fx@gnu.org>
parents:
88646
diff
changeset
|
1253 c = (((c1 & 0xF) << 12) |
|
0bc5868f9f61
(decode_coding_utf_8): Reject overlong sequences.
Dave Love <fx@gnu.org>
parents:
88646
diff
changeset
|
1254 | ((c2 & 0x3F) << 6) | (c3 & 0x3F)); |
|
89184
88a9e962e183
(decode_coding_utf_8): Treat surrogates as invalid.
Dave Love <fx@gnu.org>
parents:
89042
diff
changeset
|
1255 if (c < 0x800 |
|
88a9e962e183
(decode_coding_utf_8): Treat surrogates as invalid.
Dave Love <fx@gnu.org>
parents:
89042
diff
changeset
|
1256 || (c >= 0xd800 && c < 0xe000)) /* surrogates (invalid) */ |
|
88669
0bc5868f9f61
(decode_coding_utf_8): Reject overlong sequences.
Dave Love <fx@gnu.org>
parents:
88646
diff
changeset
|
1257 goto invalid_code; |
|
0bc5868f9f61
(decode_coding_utf_8): Reject overlong sequences.
Dave Love <fx@gnu.org>
parents:
88646
diff
changeset
|
1258 } |
| 88365 | 1259 else |
| 1260 { | |
| 1261 ONE_MORE_BYTE (c4); | |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1262 if (c4 < 0 || ! UTF_8_EXTRA_OCTET_P (c4)) |
| 88365 | 1263 goto invalid_code; |
| 1264 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
|
1265 { |
| 88365 | 1266 c = (((c1 & 0x7) << 18) | ((c2 & 0x3F) << 12) |
| 1267 | ((c3 & 0x3F) << 6) | (c4 & 0x3F)); | |
|
88669
0bc5868f9f61
(decode_coding_utf_8): Reject overlong sequences.
Dave Love <fx@gnu.org>
parents:
88646
diff
changeset
|
1268 if (c < 0x10000) |
|
0bc5868f9f61
(decode_coding_utf_8): Reject overlong sequences.
Dave Love <fx@gnu.org>
parents:
88646
diff
changeset
|
1269 goto invalid_code; |
|
0bc5868f9f61
(decode_coding_utf_8): Reject overlong sequences.
Dave Love <fx@gnu.org>
parents:
88646
diff
changeset
|
1270 } |
| 88365 | 1271 else |
| 1272 { | |
| 1273 ONE_MORE_BYTE (c5); | |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1274 if (c5 < 0 || ! UTF_8_EXTRA_OCTET_P (c5)) |
| 88365 | 1275 goto invalid_code; |
| 1276 if (UTF_8_5_OCTET_LEADING_P (c1)) | |
| 1277 { | |
| 1278 c = (((c1 & 0x3) << 24) | ((c2 & 0x3F) << 18) | |
| 1279 | ((c3 & 0x3F) << 12) | ((c4 & 0x3F) << 6) | |
| 1280 | (c5 & 0x3F)); | |
|
88669
0bc5868f9f61
(decode_coding_utf_8): Reject overlong sequences.
Dave Love <fx@gnu.org>
parents:
88646
diff
changeset
|
1281 if ((c > MAX_CHAR) || (c < 0x200000)) |
| 88365 | 1282 goto invalid_code; |
| 1283 } | |
| 1284 else | |
| 1285 goto invalid_code; | |
| 1286 } | |
| 1287 } | |
| 1288 } | |
| 1289 } | |
| 1290 | |
| 1291 *charbuf++ = c; | |
| 1292 continue; | |
| 1293 | |
| 1294 invalid_code: | |
| 1295 src = src_base; | |
| 1296 consumed_chars = consumed_chars_base; | |
| 1297 ONE_MORE_BYTE (c); | |
| 1298 *charbuf++ = ASCII_BYTE_P (c) ? c : BYTE8_TO_CHAR (c); | |
| 1299 coding->errors++; | |
| 1300 } | |
| 1301 | |
| 1302 no_more_source: | |
| 1303 coding->consumed_char += consumed_chars_base; | |
| 1304 coding->consumed = src_base - coding->source; | |
| 1305 coding->charbuf_used = charbuf - coding->charbuf; | |
| 1306 } | |
| 1307 | |
| 1308 | |
| 1309 static int | |
| 1310 encode_coding_utf_8 (coding) | |
| 1311 struct coding_system *coding; | |
| 1312 { | |
| 1313 int multibytep = coding->dst_multibyte; | |
| 1314 int *charbuf = coding->charbuf; | |
| 1315 int *charbuf_end = charbuf + coding->charbuf_used; | |
| 1316 unsigned char *dst = coding->destination + coding->produced; | |
| 1317 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
|
1318 int produced_chars = 0; |
| 88365 | 1319 int c; |
| 1320 | |
| 1321 if (multibytep) | |
| 1322 { | |
| 1323 int safe_room = MAX_MULTIBYTE_LENGTH * 2; | |
| 1324 | |
| 1325 while (charbuf < charbuf_end) | |
| 1326 { | |
| 1327 unsigned char str[MAX_MULTIBYTE_LENGTH], *p, *pend = str; | |
| 89483 | 1328 |
| 88365 | 1329 ASSURE_DESTINATION (safe_room); |
| 1330 c = *charbuf++; | |
|
89042
2b9f8973f240
(coding_set_destination): Fix coding->destination for
Kenichi Handa <handa@m17n.org>
parents:
88977
diff
changeset
|
1331 if (CHAR_BYTE8_P (c)) |
|
2b9f8973f240
(coding_set_destination): Fix coding->destination for
Kenichi Handa <handa@m17n.org>
parents:
88977
diff
changeset
|
1332 { |
|
2b9f8973f240
(coding_set_destination): Fix coding->destination for
Kenichi Handa <handa@m17n.org>
parents:
88977
diff
changeset
|
1333 c = CHAR_TO_BYTE8 (c); |
|
2b9f8973f240
(coding_set_destination): Fix coding->destination for
Kenichi Handa <handa@m17n.org>
parents:
88977
diff
changeset
|
1334 EMIT_ONE_BYTE (c); |
|
2b9f8973f240
(coding_set_destination): Fix coding->destination for
Kenichi Handa <handa@m17n.org>
parents:
88977
diff
changeset
|
1335 } |
|
2b9f8973f240
(coding_set_destination): Fix coding->destination for
Kenichi Handa <handa@m17n.org>
parents:
88977
diff
changeset
|
1336 else |
|
2b9f8973f240
(coding_set_destination): Fix coding->destination for
Kenichi Handa <handa@m17n.org>
parents:
88977
diff
changeset
|
1337 { |
|
2b9f8973f240
(coding_set_destination): Fix coding->destination for
Kenichi Handa <handa@m17n.org>
parents:
88977
diff
changeset
|
1338 CHAR_STRING_ADVANCE (c, pend); |
|
2b9f8973f240
(coding_set_destination): Fix coding->destination for
Kenichi Handa <handa@m17n.org>
parents:
88977
diff
changeset
|
1339 for (p = str; p < pend; p++) |
|
2b9f8973f240
(coding_set_destination): Fix coding->destination for
Kenichi Handa <handa@m17n.org>
parents:
88977
diff
changeset
|
1340 EMIT_ONE_BYTE (*p); |
|
2b9f8973f240
(coding_set_destination): Fix coding->destination for
Kenichi Handa <handa@m17n.org>
parents:
88977
diff
changeset
|
1341 } |
| 88365 | 1342 } |
| 1343 } | |
| 1344 else | |
| 1345 { | |
| 1346 int safe_room = MAX_MULTIBYTE_LENGTH; | |
| 1347 | |
| 1348 while (charbuf < charbuf_end) | |
| 1349 { | |
| 1350 ASSURE_DESTINATION (safe_room); | |
| 1351 c = *charbuf++; | |
| 1352 dst += CHAR_STRING (c, dst); | |
| 1353 produced_chars++; | |
| 1354 } | |
| 1355 } | |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1356 record_conversion_result (coding, CODING_RESULT_SUCCESS); |
| 88365 | 1357 coding->produced_char += produced_chars; |
| 1358 coding->produced = dst - coding->destination; | |
| 1359 return 0; | |
| 1360 } | |
| 1361 | |
| 1362 | |
| 1363 /* 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
|
1364 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
|
1365 If it is, return 1, else return 0. */ |
| 88365 | 1366 |
| 1367 #define UTF_16_HIGH_SURROGATE_P(val) \ | |
| 1368 (((val) & 0xFC00) == 0xD800) | |
| 1369 | |
| 1370 #define UTF_16_LOW_SURROGATE_P(val) \ | |
| 1371 (((val) & 0xFC00) == 0xDC00) | |
| 1372 | |
| 1373 #define UTF_16_INVALID_P(val) \ | |
| 1374 (((val) == 0xFFFE) \ | |
| 1375 || ((val) == 0xFFFF) \ | |
| 1376 || UTF_16_LOW_SURROGATE_P (val)) | |
| 1377 | |
| 1378 | |
| 1379 static int | |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1380 detect_coding_utf_16 (coding, detect_info) |
| 88365 | 1381 struct coding_system *coding; |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1382 struct coding_detection_info *detect_info; |
| 88365 | 1383 { |
| 89483 | 1384 const unsigned char *src = coding->source, *src_base = src; |
| 1385 const unsigned char *src_end = coding->source + coding->src_bytes; | |
| 88365 | 1386 int multibytep = coding->src_multibyte; |
| 1387 int consumed_chars = 0; | |
| 1388 int c1, c2; | |
| 1389 | |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1390 detect_info->checked |= CATEGORY_MASK_UTF_16; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1391 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
|
1392 && (coding->src_chars & 1)) |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1393 { |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1394 detect_info->rejected |= CATEGORY_MASK_UTF_16; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1395 return 0; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1396 } |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
1397 |
| 88365 | 1398 ONE_MORE_BYTE (c1); |
| 1399 ONE_MORE_BYTE (c2); | |
| 1400 if ((c1 == 0xFF) && (c2 == 0xFE)) | |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1401 { |
|
89420
c3e67ce6ee0f
(Qsignature, Qendian): Delete these variables.
Kenichi Handa <handa@m17n.org>
parents:
89418
diff
changeset
|
1402 detect_info->found |= (CATEGORY_MASK_UTF_16_LE |
|
c3e67ce6ee0f
(Qsignature, Qendian): Delete these variables.
Kenichi Handa <handa@m17n.org>
parents:
89418
diff
changeset
|
1403 | 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
|
1404 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
|
1405 | 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
|
1406 | CATEGORY_MASK_UTF_16_LE_NOSIG); |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1407 } |
| 88365 | 1408 else if ((c1 == 0xFE) && (c2 == 0xFF)) |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1409 { |
|
89420
c3e67ce6ee0f
(Qsignature, Qendian): Delete these variables.
Kenichi Handa <handa@m17n.org>
parents:
89418
diff
changeset
|
1410 detect_info->found |= (CATEGORY_MASK_UTF_16_BE |
|
c3e67ce6ee0f
(Qsignature, Qendian): Delete these variables.
Kenichi Handa <handa@m17n.org>
parents:
89418
diff
changeset
|
1411 | 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
|
1412 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
|
1413 | 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
|
1414 | 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
|
1415 } |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1416 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
|
1417 { |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
1418 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
|
1419 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
|
1420 int n; |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
1421 |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
1422 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
|
1423 b1[c1]++, b2[c2]++; |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
1424 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
|
1425 { |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1426 src_base = src; |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
1427 ONE_MORE_BYTE (c1); |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
1428 ONE_MORE_BYTE (c2); |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1429 if (c1 < 0 || c2 < 0) |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1430 break; |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
1431 if (! b1[c1++]) b1_variants++; |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
1432 if (! b2[c2++]) b2_variants++; |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
1433 } |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
1434 if (b1_variants < b2_variants) |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
1435 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
|
1436 else |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
1437 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
|
1438 detect_info->rejected |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
1439 |= (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
|
1440 } |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1441 no_more_source: |
|
89193
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
1442 return 1; |
| 88365 | 1443 } |
| 1444 | |
| 1445 static void | |
| 1446 decode_coding_utf_16 (coding) | |
| 1447 struct coding_system *coding; | |
| 1448 { | |
| 89483 | 1449 const unsigned char *src = coding->source + coding->consumed; |
| 1450 const unsigned char *src_end = coding->source + coding->src_bytes; | |
| 1451 const unsigned char *src_base; | |
|
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
1452 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
|
1453 int *charbuf_end = coding->charbuf + coding->charbuf_size; |
| 88365 | 1454 int consumed_chars = 0, consumed_chars_base; |
| 1455 int multibytep = coding->src_multibyte; | |
| 1456 enum utf_16_bom_type bom = CODING_UTF_16_BOM (coding); | |
| 1457 enum utf_16_endian_type endian = CODING_UTF_16_ENDIAN (coding); | |
| 1458 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
|
1459 Lisp_Object attr, charset_list; |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
1460 |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
1461 CODING_GET_INFO (coding, attr, charset_list); |
| 88365 | 1462 |
|
89420
c3e67ce6ee0f
(Qsignature, Qendian): Delete these variables.
Kenichi Handa <handa@m17n.org>
parents:
89418
diff
changeset
|
1463 if (bom == utf_16_with_bom) |
| 88365 | 1464 { |
| 1465 int c, c1, c2; | |
| 1466 | |
| 1467 src_base = src; | |
| 1468 ONE_MORE_BYTE (c1); | |
| 1469 ONE_MORE_BYTE (c2); | |
|
88438
3a34b722dd71
(encode_coding_utf_8): Initialize produced_chars to 0.
Kenichi Handa <handa@m17n.org>
parents:
88430
diff
changeset
|
1470 c = (c1 << 8) | c2; |
|
89420
c3e67ce6ee0f
(Qsignature, Qendian): Delete these variables.
Kenichi Handa <handa@m17n.org>
parents:
89418
diff
changeset
|
1471 |
|
c3e67ce6ee0f
(Qsignature, Qendian): Delete these variables.
Kenichi Handa <handa@m17n.org>
parents:
89418
diff
changeset
|
1472 if (endian == utf_16_big_endian |
|
c3e67ce6ee0f
(Qsignature, Qendian): Delete these variables.
Kenichi Handa <handa@m17n.org>
parents:
89418
diff
changeset
|
1473 ? c != 0xFEFF : c != 0xFFFE) |
| 88365 | 1474 { |
|
89420
c3e67ce6ee0f
(Qsignature, Qendian): Delete these variables.
Kenichi Handa <handa@m17n.org>
parents:
89418
diff
changeset
|
1475 /* 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
|
1476 for a normal character. */ |
|
c3e67ce6ee0f
(Qsignature, Qendian): Delete these variables.
Kenichi Handa <handa@m17n.org>
parents:
89418
diff
changeset
|
1477 src = src_base; |
|
c3e67ce6ee0f
(Qsignature, Qendian): Delete these variables.
Kenichi Handa <handa@m17n.org>
parents:
89418
diff
changeset
|
1478 coding->errors++; |
| 88365 | 1479 } |
|
89420
c3e67ce6ee0f
(Qsignature, Qendian): Delete these variables.
Kenichi Handa <handa@m17n.org>
parents:
89418
diff
changeset
|
1480 CODING_UTF_16_BOM (coding) = utf_16_without_bom; |
|
c3e67ce6ee0f
(Qsignature, Qendian): Delete these variables.
Kenichi Handa <handa@m17n.org>
parents:
89418
diff
changeset
|
1481 } |
|
c3e67ce6ee0f
(Qsignature, Qendian): Delete these variables.
Kenichi Handa <handa@m17n.org>
parents:
89418
diff
changeset
|
1482 else if (bom == utf_16_detect_bom) |
|
c3e67ce6ee0f
(Qsignature, Qendian): Delete these variables.
Kenichi Handa <handa@m17n.org>
parents:
89418
diff
changeset
|
1483 { |
|
c3e67ce6ee0f
(Qsignature, Qendian): Delete these variables.
Kenichi Handa <handa@m17n.org>
parents:
89418
diff
changeset
|
1484 /* 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
|
1485 detect_coding. */ |
|
c3e67ce6ee0f
(Qsignature, Qendian): Delete these variables.
Kenichi Handa <handa@m17n.org>
parents:
89418
diff
changeset
|
1486 CODING_UTF_16_BOM (coding) = utf_16_without_bom; |
| 88365 | 1487 } |
| 1488 | |
| 1489 while (1) | |
| 1490 { | |
| 1491 int c, c1, c2; | |
| 1492 | |
| 1493 src_base = src; | |
| 1494 consumed_chars_base = consumed_chars; | |
| 1495 | |
| 1496 if (charbuf + 2 >= charbuf_end) | |
| 1497 break; | |
| 1498 | |
| 1499 ONE_MORE_BYTE (c1); | |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1500 if (c1 < 0) |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1501 { |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1502 *charbuf++ = -c1; |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1503 continue; |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1504 } |
| 88365 | 1505 ONE_MORE_BYTE (c2); |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1506 if (c2 < 0) |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1507 { |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1508 *charbuf++ = ASCII_BYTE_P (c1) ? c1 : BYTE8_TO_CHAR (c1); |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1509 *charbuf++ = -c2; |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1510 continue; |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1511 } |
| 88365 | 1512 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
|
1513 ? ((c1 << 8) | c2) : ((c2 << 8) | c1)); |
| 88365 | 1514 if (surrogate) |
| 1515 { | |
| 1516 if (! UTF_16_LOW_SURROGATE_P (c)) | |
| 1517 { | |
| 1518 if (endian == utf_16_big_endian) | |
| 1519 c1 = surrogate >> 8, c2 = surrogate & 0xFF; | |
| 1520 else | |
| 1521 c1 = surrogate & 0xFF, c2 = surrogate >> 8; | |
| 1522 *charbuf++ = c1; | |
| 1523 *charbuf++ = c2; | |
| 1524 coding->errors++; | |
| 1525 if (UTF_16_HIGH_SURROGATE_P (c)) | |
| 1526 CODING_UTF_16_SURROGATE (coding) = surrogate = c; | |
| 1527 else | |
| 1528 *charbuf++ = c; | |
| 1529 } | |
| 1530 else | |
| 1531 { | |
| 1532 c = ((surrogate - 0xD800) << 10) | (c - 0xDC00); | |
| 1533 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
|
1534 *charbuf++ = 0x10000 + c; |
| 88365 | 1535 } |
| 1536 } | |
| 1537 else | |
| 1538 { | |
| 1539 if (UTF_16_HIGH_SURROGATE_P (c)) | |
| 1540 CODING_UTF_16_SURROGATE (coding) = surrogate = c; | |
| 1541 else | |
| 1542 *charbuf++ = c; | |
| 89483 | 1543 } |
| 88365 | 1544 } |
| 1545 | |
| 1546 no_more_source: | |
| 1547 coding->consumed_char += consumed_chars_base; | |
| 1548 coding->consumed = src_base - coding->source; | |
| 1549 coding->charbuf_used = charbuf - coding->charbuf; | |
| 1550 } | |
| 1551 | |
| 1552 static int | |
| 1553 encode_coding_utf_16 (coding) | |
| 1554 struct coding_system *coding; | |
| 1555 { | |
| 1556 int multibytep = coding->dst_multibyte; | |
| 1557 int *charbuf = coding->charbuf; | |
| 1558 int *charbuf_end = charbuf + coding->charbuf_used; | |
| 1559 unsigned char *dst = coding->destination + coding->produced; | |
| 1560 unsigned char *dst_end = coding->destination + coding->dst_bytes; | |
| 1561 int safe_room = 8; | |
| 1562 enum utf_16_bom_type bom = CODING_UTF_16_BOM (coding); | |
| 1563 int big_endian = CODING_UTF_16_ENDIAN (coding) == utf_16_big_endian; | |
| 1564 int produced_chars = 0; | |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
1565 Lisp_Object attrs, charset_list; |
| 88365 | 1566 int c; |
| 1567 | |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
1568 CODING_GET_INFO (coding, attrs, charset_list); |
| 88365 | 1569 |
|
89420
c3e67ce6ee0f
(Qsignature, Qendian): Delete these variables.
Kenichi Handa <handa@m17n.org>
parents:
89418
diff
changeset
|
1570 if (bom != utf_16_without_bom) |
| 88365 | 1571 { |
| 1572 ASSURE_DESTINATION (safe_room); | |
| 1573 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
|
1574 EMIT_TWO_BYTES (0xFE, 0xFF); |
| 88365 | 1575 else |
|
89404
3e1d187b52c3
(Qutf_16_be_nosig, Qutf_16_be, Qutf_16_le_nosig)
Kenichi Handa <handa@m17n.org>
parents:
89394
diff
changeset
|
1576 EMIT_TWO_BYTES (0xFF, 0xFE); |
| 88365 | 1577 CODING_UTF_16_BOM (coding) = utf_16_without_bom; |
| 1578 } | |
| 1579 | |
| 1580 while (charbuf < charbuf_end) | |
| 1581 { | |
| 1582 ASSURE_DESTINATION (safe_room); | |
| 1583 c = *charbuf++; | |
|
88438
3a34b722dd71
(encode_coding_utf_8): Initialize produced_chars to 0.
Kenichi Handa <handa@m17n.org>
parents:
88430
diff
changeset
|
1584 if (c >= MAX_UNICODE_CHAR) |
|
3a34b722dd71
(encode_coding_utf_8): Initialize produced_chars to 0.
Kenichi Handa <handa@m17n.org>
parents:
88430
diff
changeset
|
1585 c = coding->default_char; |
| 88365 | 1586 |
| 1587 if (c < 0x10000) | |
| 1588 { | |
| 1589 if (big_endian) | |
| 1590 EMIT_TWO_BYTES (c >> 8, c & 0xFF); | |
| 1591 else | |
| 1592 EMIT_TWO_BYTES (c & 0xFF, c >> 8); | |
| 1593 } | |
| 1594 else | |
| 1595 { | |
| 1596 int c1, c2; | |
| 1597 | |
| 1598 c -= 0x10000; | |
| 1599 c1 = (c >> 10) + 0xD800; | |
| 1600 c2 = (c & 0x3FF) + 0xDC00; | |
| 1601 if (big_endian) | |
| 1602 EMIT_FOUR_BYTES (c1 >> 8, c1 & 0xFF, c2 >> 8, c2 & 0xFF); | |
| 1603 else | |
| 1604 EMIT_FOUR_BYTES (c1 & 0xFF, c1 >> 8, c2 & 0xFF, c2 >> 8); | |
| 1605 } | |
| 1606 } | |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1607 record_conversion_result (coding, CODING_RESULT_SUCCESS); |
| 88365 | 1608 coding->produced = dst - coding->destination; |
| 1609 coding->produced_char += produced_chars; | |
| 1610 return 0; | |
| 1611 } | |
| 1612 | |
| 1613 | |
| 1614 /*** 6. Old Emacs' internal format (emacs-mule) ***/ | |
| 17052 | 1615 |
|
34888
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1616 /* Emacs' internal format for representation of multiple character |
|
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1617 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
|
1618 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
|
1619 |
|
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1620 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
|
1621 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
|
1622 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
|
1623 |
|
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1624 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
|
1625 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
|
1626 code + 0x20). |
|
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1627 |
|
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1628 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
|
1629 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
|
1630 |
|
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1631 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
|
1632 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
|
1633 `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
|
1634 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
|
1635 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
|
1636 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
|
1637 and position-code. |
| 18766 | 1638 |
| 17052 | 1639 --- 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
|
1640 character set range |
|
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1641 ------------- ----- |
|
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1642 ascii 0x00..0x7F |
|
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1643 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
|
1644 eight-bit-graphic 0xA0..0xBF |
|
34888
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1645 ELSE 0x81..0x9D + [0xA0..0xFF]+ |
| 17052 | 1646 --------------------------------------------- |
| 1647 | |
|
34888
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1648 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
|
1649 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
|
1650 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
|
1651 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
|
1652 |
|
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1653 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
|
1654 form. |
|
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1655 |
| 88365 | 1656 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
|
1657 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
|
1658 |
|
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1659 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
|
1660 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
|
1661 where, |
|
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1662 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
|
1663 composition_method), |
|
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1664 |
| 88365 | 1665 BYTES is 0xA0 plus a byte length of this composition data, |
| 1666 | |
| 1667 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
|
1668 data, |
|
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1669 |
| 88365 | 1670 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
|
1671 rules encoded by two-byte of ASCII codes. |
|
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1672 |
|
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1673 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
|
1674 also recognized as composition data on decoding. |
|
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1675 |
|
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1676 0x80 MSEQ ... |
|
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1677 0x80 0xFF MSEQ RULE MSEQ RULE ... MSEQ |
|
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1678 |
|
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1679 Here, |
|
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1680 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
|
1681 ASCII: 0xA0 ASCII_CODE+0x80, |
|
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1682 other: LEADING_CODE+0x20 FOLLOWING-BYTE ..., |
|
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1683 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
|
1684 represents a composition rule. |
| 17052 | 1685 */ |
| 1686 | |
| 88365 | 1687 char emacs_mule_bytes[256]; |
| 1688 | |
| 1689 int | |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1690 emacs_mule_char (coding, src, nbytes, nchars, id) |
| 88365 | 1691 struct coding_system *coding; |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1692 const unsigned char *src; |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1693 int *nbytes, *nchars, *id; |
| 88365 | 1694 { |
| 89483 | 1695 const unsigned char *src_end = coding->source + coding->src_bytes; |
| 1696 const unsigned char *src_base = src; | |
| 88365 | 1697 int multibytep = coding->src_multibyte; |
| 1698 struct charset *charset; | |
| 1699 unsigned code; | |
| 1700 int c; | |
| 1701 int consumed_chars = 0; | |
| 1702 | |
| 1703 ONE_MORE_BYTE (c); | |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1704 if (c < 0) |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1705 { |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1706 c = -c; |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1707 charset = emacs_mule_charset[0]; |
|
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 else |
|
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 switch (emacs_mule_bytes[c]) |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1712 { |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1713 case 2: |
| 88365 | 1714 if (! (charset = emacs_mule_charset[c])) |
| 1715 goto invalid_code; | |
| 1716 ONE_MORE_BYTE (c); | |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1717 if (c < 0) |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1718 goto invalid_code; |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1719 code = c & 0x7F; |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1720 break; |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1721 |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1722 case 3: |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1723 if (c == EMACS_MULE_LEADING_CODE_PRIVATE_11 |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1724 || c == EMACS_MULE_LEADING_CODE_PRIVATE_12) |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1725 { |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1726 ONE_MORE_BYTE (c); |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1727 if (c < 0 || ! (charset = emacs_mule_charset[c])) |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1728 goto invalid_code; |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1729 ONE_MORE_BYTE (c); |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1730 if (c < 0) |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1731 goto invalid_code; |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1732 code = c & 0x7F; |
|
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 else |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1735 { |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1736 if (! (charset = emacs_mule_charset[c])) |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1737 goto invalid_code; |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1738 ONE_MORE_BYTE (c); |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1739 if (c < 0) |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1740 goto invalid_code; |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1741 code = (c & 0x7F) << 8; |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1742 ONE_MORE_BYTE (c); |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1743 if (c < 0) |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1744 goto invalid_code; |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1745 code |= c & 0x7F; |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1746 } |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1747 break; |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1748 |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1749 case 4: |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1750 ONE_MORE_BYTE (c); |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1751 if (c < 0 || ! (charset = emacs_mule_charset[c])) |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1752 goto invalid_code; |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1753 ONE_MORE_BYTE (c); |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1754 if (c < 0) |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1755 goto invalid_code; |
|
88585
c7772f702227
(ONE_MORE_BYTE_NO_CHECK): Increment consumed_chars.
Kenichi Handa <handa@m17n.org>
parents:
88573
diff
changeset
|
1756 code = (c & 0x7F) << 8; |
| 88365 | 1757 ONE_MORE_BYTE (c); |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1758 if (c < 0) |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1759 goto invalid_code; |
| 88365 | 1760 code |= c & 0x7F; |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1761 break; |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1762 |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1763 case 1: |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1764 code = c; |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1765 charset = CHARSET_FROM_ID (ASCII_BYTE_P (code) |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1766 ? charset_ascii : charset_eight_bit); |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1767 break; |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1768 |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1769 default: |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1770 abort (); |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1771 } |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1772 c = DECODE_CHAR (charset, code); |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1773 if (c < 0) |
| 88365 | 1774 goto invalid_code; |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1775 } |
| 88365 | 1776 *nbytes = src - src_base; |
| 1777 *nchars = consumed_chars; | |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1778 if (id) |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1779 *id = charset->id; |
| 88365 | 1780 return c; |
| 1781 | |
| 1782 no_more_source: | |
| 1783 return -2; | |
| 1784 | |
| 1785 invalid_code: | |
| 1786 return -1; | |
| 1787 } | |
| 1788 | |
| 17052 | 1789 |
| 1790 /* 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
|
1791 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
|
1792 else return 0. */ |
| 17052 | 1793 |
|
34531
37f85e931855
(ONE_MORE_BYTE_CHECK_MULTIBYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34197
diff
changeset
|
1794 static int |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1795 detect_coding_emacs_mule (coding, detect_info) |
| 88365 | 1796 struct coding_system *coding; |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1797 struct coding_detection_info *detect_info; |
| 17052 | 1798 { |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1799 const unsigned char *src = coding->source, *src_base; |
| 89483 | 1800 const unsigned char *src_end = coding->source + coding->src_bytes; |
| 88365 | 1801 int multibytep = coding->src_multibyte; |
| 1802 int consumed_chars = 0; | |
| 1803 int c; | |
| 1804 int found = 0; | |
| 1805 | |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1806 detect_info->checked |= CATEGORY_MASK_EMACS_MULE; |
| 88365 | 1807 /* A coding system of this category is always ASCII compatible. */ |
| 1808 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
|
1809 |
|
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1810 while (1) |
| 17052 | 1811 { |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1812 src_base = src; |
| 88365 | 1813 ONE_MORE_BYTE (c); |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1814 if (c < 0) |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1815 continue; |
| 88365 | 1816 if (c == 0x80) |
| 17052 | 1817 { |
| 88365 | 1818 /* Perhaps the start of composite character. We simple skip |
| 1819 it because analyzing it is too heavy for detecting. But, | |
| 1820 at least, we check that the composite character | |
| 1821 constitues of more than 4 bytes. */ | |
| 89483 | 1822 const unsigned char *src_base; |
| 88365 | 1823 |
| 1824 repeat: | |
| 1825 src_base = src; | |
| 1826 do | |
| 1827 { | |
| 1828 ONE_MORE_BYTE (c); | |
| 1829 } | |
| 1830 while (c >= 0xA0); | |
| 1831 | |
| 1832 if (src - src_base <= 4) | |
| 1833 break; | |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1834 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
|
1835 if (c == 0x80) |
| 88365 | 1836 goto repeat; |
|
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1837 } |
| 88365 | 1838 |
| 1839 if (c < 0x80) | |
| 1840 { | |
| 1841 if (c < 0x20 | |
| 1842 && (c == ISO_CODE_ESC || c == ISO_CODE_SI || c == ISO_CODE_SO)) | |
| 1843 break; | |
| 1844 } | |
| 1845 else | |
| 1846 { | |
|
89848
3edfa038a435
(detect_coding_emacs_mule): Fix counting of encoded
Kenichi Handa <handa@m17n.org>
parents:
89842
diff
changeset
|
1847 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
|
1848 |
|
3edfa038a435
(detect_coding_emacs_mule): Fix counting of encoded
Kenichi Handa <handa@m17n.org>
parents:
89842
diff
changeset
|
1849 while (more_bytes > 0) |
| 88365 | 1850 { |
| 1851 ONE_MORE_BYTE (c); | |
|
89848
3edfa038a435
(detect_coding_emacs_mule): Fix counting of encoded
Kenichi Handa <handa@m17n.org>
parents:
89842
diff
changeset
|
1852 if (c < 0xA0) |
|
3edfa038a435
(detect_coding_emacs_mule): Fix counting of encoded
Kenichi Handa <handa@m17n.org>
parents:
89842
diff
changeset
|
1853 { |
|
3edfa038a435
(detect_coding_emacs_mule): Fix counting of encoded
Kenichi Handa <handa@m17n.org>
parents:
89842
diff
changeset
|
1854 src--; /* Unread the last byte. */ |
|
3edfa038a435
(detect_coding_emacs_mule): Fix counting of encoded
Kenichi Handa <handa@m17n.org>
parents:
89842
diff
changeset
|
1855 break; |
|
3edfa038a435
(detect_coding_emacs_mule): Fix counting of encoded
Kenichi Handa <handa@m17n.org>
parents:
89842
diff
changeset
|
1856 } |
|
3edfa038a435
(detect_coding_emacs_mule): Fix counting of encoded
Kenichi Handa <handa@m17n.org>
parents:
89842
diff
changeset
|
1857 more_bytes--; |
| 88365 | 1858 } |
|
89848
3edfa038a435
(detect_coding_emacs_mule): Fix counting of encoded
Kenichi Handa <handa@m17n.org>
parents:
89842
diff
changeset
|
1859 if (more_bytes != 0) |
| 88365 | 1860 break; |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1861 found = CATEGORY_MASK_EMACS_MULE; |
| 88365 | 1862 } |
| 1863 } | |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1864 detect_info->rejected |= CATEGORY_MASK_EMACS_MULE; |
| 88365 | 1865 return 0; |
| 1866 | |
| 1867 no_more_source: | |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1868 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
|
1869 { |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1870 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
|
1871 return 0; |
|
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
1872 } |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1873 detect_info->found |= found; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1874 return 1; |
|
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1875 } |
|
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1876 |
|
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
1877 |
| 88365 | 1878 /* 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
|
1879 |
|
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1880 /* Decode a character represented as a component of composition |
| 88365 | 1881 sequence of Emacs 20/21 style at SRC. Set C to that character and |
| 1882 update SRC to the head of next character (or an encoded composition | |
| 1883 rule). If SRC doesn't points a composition component, set C to -1. | |
| 1884 If SRC points an invalid byte sequence, global exit by a return | |
| 1885 value 0. */ | |
| 1886 | |
| 1887 #define DECODE_EMACS_MULE_COMPOSITION_CHAR(buf) \ | |
| 1888 if (1) \ | |
| 1889 { \ | |
| 1890 int c; \ | |
| 1891 int nbytes, nchars; \ | |
|
34888
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1892 \ |
| 88365 | 1893 if (src == src_end) \ |
| 1894 break; \ | |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
1895 c = emacs_mule_char (coding, src, &nbytes, &nchars, NULL);\ |
| 88365 | 1896 if (c < 0) \ |
| 1897 { \ | |
| 1898 if (c == -2) \ | |
| 1899 break; \ | |
| 1900 goto invalid_code; \ | |
| 1901 } \ | |
| 1902 *buf++ = c; \ | |
| 1903 src += nbytes; \ | |
| 1904 consumed_chars += nchars; \ | |
| 1905 } \ | |
| 1906 else | |
|
34888
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1907 |
|
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1908 |
|
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1909 /* 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
|
1910 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
|
1911 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
|
1912 to -1. */ |
|
c7772f702227
(ONE_MORE_BYTE_NO_CHECK): Increment consumed_chars.
Kenichi Handa <handa@m17n.org>
parents:
88573
diff
changeset
|
1913 |
|
c7772f702227
(ONE_MORE_BYTE_NO_CHECK): Increment consumed_chars.
Kenichi Handa <handa@m17n.org>
parents:
88573
diff
changeset
|
1914 #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
|
1915 do { \ |
| 88365 | 1916 int c, gref, nref; \ |
| 1917 \ | |
|
88585
c7772f702227
(ONE_MORE_BYTE_NO_CHECK): Increment consumed_chars.
Kenichi Handa <handa@m17n.org>
parents:
88573
diff
changeset
|
1918 if (src >= src_end) \ |
| 88365 | 1919 goto invalid_code; \ |
| 1920 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
|
1921 c -= 0x20; \ |
|
34888
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
1922 if (c < 0 || c >= 81) \ |
| 88365 | 1923 goto invalid_code; \ |
| 1924 \ | |
| 1925 gref = c / 9, nref = c % 9; \ | |
| 1926 *buf++ = COMPOSITION_ENCODE_RULE (gref, nref); \ | |
| 1927 } while (0) | |
| 1928 | |
| 1929 | |
|
88585
c7772f702227
(ONE_MORE_BYTE_NO_CHECK): Increment consumed_chars.
Kenichi Handa <handa@m17n.org>
parents:
88573
diff
changeset
|
1930 /* 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
|
1931 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
|
1932 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
|
1933 to -1. */ |
|
c7772f702227
(ONE_MORE_BYTE_NO_CHECK): Increment consumed_chars.
Kenichi Handa <handa@m17n.org>
parents:
88573
diff
changeset
|
1934 |
|
c7772f702227
(ONE_MORE_BYTE_NO_CHECK): Increment consumed_chars.
Kenichi Handa <handa@m17n.org>
parents:
88573
diff
changeset
|
1935 #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
|
1936 do { \ |
|
c7772f702227
(ONE_MORE_BYTE_NO_CHECK): Increment consumed_chars.
Kenichi Handa <handa@m17n.org>
parents:
88573
diff
changeset
|
1937 int gref, nref; \ |
|
c7772f702227
(ONE_MORE_BYTE_NO_CHECK): Increment consumed_chars.
Kenichi Handa <handa@m17n.org>
parents:
88573
diff
changeset
|
1938 \ |
|
c7772f702227
(ONE_MORE_BYTE_NO_CHECK): Increment consumed_chars.
Kenichi Handa <handa@m17n.org>
parents:
88573
diff
changeset
|
1939 if (src + 1>= src_end) \ |
|
c7772f702227
(ONE_MORE_BYTE_NO_CHECK): Increment consumed_chars.
Kenichi Handa <handa@m17n.org>
parents:
88573
diff
changeset
|
1940 goto invalid_code; \ |
|
c7772f702227
(ONE_MORE_BYTE_NO_CHECK): Increment consumed_chars.
Kenichi Handa <handa@m17n.org>
parents:
88573
diff
changeset
|
1941 ONE_MORE_BYTE_NO_CHECK (gref); \ |
|
c7772f702227
(ONE_MORE_BYTE_NO_CHECK): Increment consumed_chars.
Kenichi Handa <handa@m17n.org>
parents:
88573
diff
changeset
|
1942 gref -= 0x20; \ |
|
c7772f702227
(ONE_MORE_BYTE_NO_CHECK): Increment consumed_chars.
Kenichi Handa <handa@m17n.org>
parents:
88573
diff
changeset
|
1943 ONE_MORE_BYTE_NO_CHECK (nref); \ |
|
c7772f702227
(ONE_MORE_BYTE_NO_CHECK): Increment consumed_chars.
Kenichi Handa <handa@m17n.org>
parents:
88573
diff
changeset
|
1944 nref -= 0x20; \ |
|
c7772f702227
(ONE_MORE_BYTE_NO_CHECK): Increment consumed_chars.
Kenichi Handa <handa@m17n.org>
parents:
88573
diff
changeset
|
1945 if (gref < 0 || gref >= 81 \ |
|
c7772f702227
(ONE_MORE_BYTE_NO_CHECK): Increment consumed_chars.
Kenichi Handa <handa@m17n.org>
parents:
88573
diff
changeset
|
1946 || nref < 0 || nref >= 81) \ |
|
c7772f702227
(ONE_MORE_BYTE_NO_CHECK): Increment consumed_chars.
Kenichi Handa <handa@m17n.org>
parents:
88573
diff
changeset
|
1947 goto invalid_code; \ |
|
c7772f702227
(ONE_MORE_BYTE_NO_CHECK): Increment consumed_chars.
Kenichi Handa <handa@m17n.org>
parents:
88573
diff
changeset
|
1948 *buf++ = COMPOSITION_ENCODE_RULE (gref, nref); \ |
|
c7772f702227
(ONE_MORE_BYTE_NO_CHECK): Increment consumed_chars.
Kenichi Handa <handa@m17n.org>
parents:
88573
diff
changeset
|
1949 } while (0) |
|
c7772f702227
(ONE_MORE_BYTE_NO_CHECK): Increment consumed_chars.
Kenichi Handa <handa@m17n.org>
parents:
88573
diff
changeset
|
1950 |
|
c7772f702227
(ONE_MORE_BYTE_NO_CHECK): Increment consumed_chars.
Kenichi Handa <handa@m17n.org>
parents:
88573
diff
changeset
|
1951 |
| 88365 | 1952 #define DECODE_EMACS_MULE_21_COMPOSITION(c) \ |
| 1953 do { \ | |
| 1954 /* 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
|
1955 (METHOD - 0xF2), (BYTES - 0xA0), (CHARS - 0xA0), where BYTES is \ |
| 88365 | 1956 the byte length of this composition information, CHARS is the \ |
| 1957 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
|
1958 enum composition_method method = c - 0xF2; \ |
|
c7772f702227
(ONE_MORE_BYTE_NO_CHECK): Increment consumed_chars.
Kenichi Handa <handa@m17n.org>
parents:
88573
diff
changeset
|
1959 int *charbuf_base = charbuf; \ |
| 88365 | 1960 int consumed_chars_limit; \ |
| 1961 int nbytes, nchars; \ | |
| 1962 \ | |
| 1963 ONE_MORE_BYTE (c); \ | |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1964 if (c < 0) \ |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1965 goto invalid_code; \ |
| 88365 | 1966 nbytes = c - 0xA0; \ |
| 1967 if (nbytes < 3) \ | |
| 1968 goto invalid_code; \ | |
| 1969 ONE_MORE_BYTE (c); \ | |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1970 if (c < 0) \ |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
1971 goto invalid_code; \ |
| 88365 | 1972 nchars = c - 0xA0; \ |
|
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
1973 ADD_COMPOSITION_DATA (charbuf, nchars, method); \ |
| 88365 | 1974 consumed_chars_limit = consumed_chars_base + nbytes; \ |
| 1975 if (method != COMPOSITION_RELATIVE) \ | |
| 1976 { \ | |
| 1977 int i = 0; \ | |
| 1978 while (consumed_chars < consumed_chars_limit) \ | |
| 1979 { \ | |
| 1980 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
|
1981 DECODE_EMACS_MULE_COMPOSITION_RULE_21 (charbuf); \ |
| 88365 | 1982 else \ |
| 1983 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
|
1984 i++; \ |
| 88365 | 1985 } \ |
| 1986 if (consumed_chars < consumed_chars_limit) \ | |
| 1987 goto invalid_code; \ | |
|
88585
c7772f702227
(ONE_MORE_BYTE_NO_CHECK): Increment consumed_chars.
Kenichi Handa <handa@m17n.org>
parents:
88573
diff
changeset
|
1988 charbuf_base[0] -= i; \ |
| 88365 | 1989 } \ |
| 1990 } while (0) | |
| 1991 | |
| 1992 | |
| 1993 #define DECODE_EMACS_MULE_20_RELATIVE_COMPOSITION(c) \ | |
| 1994 do { \ | |
| 1995 /* Emacs 20 style format for relative composition. */ \ | |
| 1996 /* 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
|
1997 enum composition_method method = COMPOSITION_RELATIVE; \ |
| 88365 | 1998 int components[MAX_COMPOSITION_COMPONENTS * 2 - 1]; \ |
| 1999 int *buf = components; \ | |
| 2000 int i, j; \ | |
| 2001 \ | |
| 2002 src = src_base; \ | |
| 2003 ONE_MORE_BYTE (c); /* skip 0x80 */ \ | |
| 2004 for (i = 0; i < MAX_COMPOSITION_COMPONENTS; i++) \ | |
| 2005 DECODE_EMACS_MULE_COMPOSITION_CHAR (buf); \ | |
| 2006 if (i < 2) \ | |
| 2007 goto invalid_code; \ | |
|
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
2008 ADD_COMPOSITION_DATA (charbuf, i, method); \ |
| 88365 | 2009 for (j = 0; j < i; j++) \ |
| 2010 *charbuf++ = components[j]; \ | |
| 2011 } while (0) | |
| 2012 | |
| 2013 | |
| 2014 #define DECODE_EMACS_MULE_20_RULEBASE_COMPOSITION(c) \ | |
| 2015 do { \ | |
| 2016 /* Emacs 20 style format for rule-base composition. */ \ | |
| 2017 /* 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
|
2018 enum composition_method method = COMPOSITION_WITH_RULE; \ |
| 88365 | 2019 int components[MAX_COMPOSITION_COMPONENTS * 2 - 1]; \ |
| 2020 int *buf = components; \ | |
| 2021 int i, j; \ | |
| 2022 \ | |
| 2023 DECODE_EMACS_MULE_COMPOSITION_CHAR (buf); \ | |
| 2024 for (i = 0; i < MAX_COMPOSITION_COMPONENTS; i++) \ | |
| 2025 { \ | |
|
88585
c7772f702227
(ONE_MORE_BYTE_NO_CHECK): Increment consumed_chars.
Kenichi Handa <handa@m17n.org>
parents:
88573
diff
changeset
|
2026 DECODE_EMACS_MULE_COMPOSITION_RULE_20 (buf); \ |
| 88365 | 2027 DECODE_EMACS_MULE_COMPOSITION_CHAR (buf); \ |
| 2028 } \ | |
| 2029 if (i < 1 || (buf - components) % 2 == 0) \ | |
| 2030 goto invalid_code; \ | |
| 2031 if (charbuf + i + (i / 2) + 1 < charbuf_end) \ | |
| 2032 goto no_more_source; \ | |
|
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
2033 ADD_COMPOSITION_DATA (buf, i, method); \ |
| 88365 | 2034 for (j = 0; j < i; j++) \ |
| 2035 *charbuf++ = components[j]; \ | |
| 2036 for (j = 0; j < i; j += 2) \ | |
| 2037 *charbuf++ = components[j]; \ | |
| 2038 } while (0) | |
| 2039 | |
|
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2040 |
|
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2041 static void |
| 88365 | 2042 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
|
2043 struct coding_system *coding; |
|
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2044 { |
| 89483 | 2045 const unsigned char *src = coding->source + coding->consumed; |
| 2046 const unsigned char *src_end = coding->source + coding->src_bytes; | |
| 2047 const unsigned char *src_base; | |
|
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
2048 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
|
2049 int *charbuf_end |
|
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
2050 = coding->charbuf + coding->charbuf_size - MAX_ANNOTATION_LENGTH; |
| 88365 | 2051 int consumed_chars = 0, consumed_chars_base; |
| 2052 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
|
2053 Lisp_Object attrs, charset_list; |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2054 int char_offset = coding->produced_char; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2055 int last_offset = char_offset; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2056 int last_id = charset_ascii; |
| 88365 | 2057 |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
2058 CODING_GET_INFO (coding, attrs, charset_list); |
| 88365 | 2059 |
| 2060 while (1) | |
| 2061 { | |
| 2062 int c; | |
| 2063 | |
| 2064 src_base = src; | |
| 2065 consumed_chars_base = consumed_chars; | |
| 2066 | |
| 2067 if (charbuf >= charbuf_end) | |
| 2068 break; | |
| 2069 | |
| 2070 ONE_MORE_BYTE (c); | |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
2071 if (c < 0) |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
2072 { |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
2073 *charbuf++ = -c; |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
2074 char_offset++; |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
2075 } |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
2076 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
|
2077 { |
| 88365 | 2078 *charbuf++ = c; |
| 2079 char_offset++; | |
|
32806
9502d0a5b2ad
(decode_coding_emacs_mule): If coding->eol_type is CR
Eli Zaretskii <eliz@gnu.org>
parents:
32745
diff
changeset
|
2080 } |
| 88365 | 2081 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
|
2082 { |
| 88365 | 2083 ONE_MORE_BYTE (c); |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
2084 if (c < 0) |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
2085 goto invalid_code; |
|
88585
c7772f702227
(ONE_MORE_BYTE_NO_CHECK): Increment consumed_chars.
Kenichi Handa <handa@m17n.org>
parents:
88573
diff
changeset
|
2086 if (c - 0xF2 >= COMPOSITION_RELATIVE |
|
c7772f702227
(ONE_MORE_BYTE_NO_CHECK): Increment consumed_chars.
Kenichi Handa <handa@m17n.org>
parents:
88573
diff
changeset
|
2087 && c - 0xF2 <= COMPOSITION_WITH_RULE_ALTCHARS) |
| 88365 | 2088 DECODE_EMACS_MULE_21_COMPOSITION (c); |
| 2089 else if (c < 0xC0) | |
| 2090 DECODE_EMACS_MULE_20_RELATIVE_COMPOSITION (c); | |
| 2091 else if (c == 0xFF) | |
| 2092 DECODE_EMACS_MULE_20_RULEBASE_COMPOSITION (c); | |
| 2093 else | |
| 2094 goto invalid_code; | |
|
32806
9502d0a5b2ad
(decode_coding_emacs_mule): If coding->eol_type is CR
Eli Zaretskii <eliz@gnu.org>
parents:
32745
diff
changeset
|
2095 } |
| 88365 | 2096 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
|
2097 { |
| 88365 | 2098 int nbytes, nchars; |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2099 int id; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2100 |
|
88585
c7772f702227
(ONE_MORE_BYTE_NO_CHECK): Increment consumed_chars.
Kenichi Handa <handa@m17n.org>
parents:
88573
diff
changeset
|
2101 src = src_base; |
|
c7772f702227
(ONE_MORE_BYTE_NO_CHECK): Increment consumed_chars.
Kenichi Handa <handa@m17n.org>
parents:
88573
diff
changeset
|
2102 consumed_chars = consumed_chars_base; |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2103 c = emacs_mule_char (coding, src, &nbytes, &nchars, &id); |
| 88365 | 2104 if (c < 0) |
|
34888
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
2105 { |
| 88365 | 2106 if (c == -2) |
| 2107 break; | |
| 2108 goto invalid_code; | |
|
34888
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
2109 } |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2110 if (last_id != id) |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2111 { |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2112 if (last_id != charset_ascii) |
|
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
2113 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
|
2114 last_id = id; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2115 last_offset = char_offset; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2116 } |
| 88365 | 2117 *charbuf++ = c; |
|
88585
c7772f702227
(ONE_MORE_BYTE_NO_CHECK): Increment consumed_chars.
Kenichi Handa <handa@m17n.org>
parents:
88573
diff
changeset
|
2118 src += nbytes; |
|
c7772f702227
(ONE_MORE_BYTE_NO_CHECK): Increment consumed_chars.
Kenichi Handa <handa@m17n.org>
parents:
88573
diff
changeset
|
2119 consumed_chars += nchars; |
| 88365 | 2120 char_offset++; |
|
34888
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
2121 } |
| 88365 | 2122 continue; |
| 2123 | |
| 2124 invalid_code: | |
| 2125 src = src_base; | |
| 2126 consumed_chars = consumed_chars_base; | |
| 2127 ONE_MORE_BYTE (c); | |
| 2128 *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
|
2129 char_offset++; |
| 88365 | 2130 coding->errors++; |
| 2131 } | |
| 2132 | |
| 2133 no_more_source: | |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2134 if (last_id != charset_ascii) |
|
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
2135 ADD_CHARSET_DATA (charbuf, char_offset - last_offset, last_id); |
| 88365 | 2136 coding->consumed_char += consumed_chars_base; |
| 2137 coding->consumed = src_base - coding->source; | |
| 2138 coding->charbuf_used = charbuf - coding->charbuf; | |
| 2139 } | |
| 2140 | |
| 2141 | |
| 2142 #define EMACS_MULE_LEADING_CODES(id, codes) \ | |
| 2143 do { \ | |
| 2144 if (id < 0xA0) \ | |
| 2145 codes[0] = id, codes[1] = 0; \ | |
| 2146 else if (id < 0xE0) \ | |
| 2147 codes[0] = 0x9A, codes[1] = id; \ | |
| 2148 else if (id < 0xF0) \ | |
| 2149 codes[0] = 0x9B, codes[1] = id; \ | |
| 2150 else if (id < 0xF5) \ | |
| 2151 codes[0] = 0x9C, codes[1] = id; \ | |
| 2152 else \ | |
| 2153 codes[0] = 0x9D, codes[1] = id; \ | |
| 2154 } while (0); | |
| 2155 | |
| 2156 | |
| 2157 static int | |
| 2158 encode_coding_emacs_mule (coding) | |
| 2159 struct coding_system *coding; | |
| 2160 { | |
| 2161 int multibytep = coding->dst_multibyte; | |
| 2162 int *charbuf = coding->charbuf; | |
| 2163 int *charbuf_end = charbuf + coding->charbuf_used; | |
| 2164 unsigned char *dst = coding->destination + coding->produced; | |
| 2165 unsigned char *dst_end = coding->destination + coding->dst_bytes; | |
| 2166 int safe_room = 8; | |
| 2167 int produced_chars = 0; | |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
2168 Lisp_Object attrs, charset_list; |
| 88365 | 2169 int c; |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2170 int preferred_charset_id = -1; |
| 88365 | 2171 |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
2172 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
|
2173 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
|
2174 { |
|
fc9cda144ffc
(encode_coding_emacs_mule): Resync charset_list to
Kenichi Handa <handa@m17n.org>
parents:
89642
diff
changeset
|
2175 CODING_ATTR_CHARSET_LIST (attrs) |
|
fc9cda144ffc
(encode_coding_emacs_mule): Resync charset_list to
Kenichi Handa <handa@m17n.org>
parents:
89642
diff
changeset
|
2176 = charset_list = Vemacs_mule_charset_list; |
|
fc9cda144ffc
(encode_coding_emacs_mule): Resync charset_list to
Kenichi Handa <handa@m17n.org>
parents:
89642
diff
changeset
|
2177 } |
| 88365 | 2178 |
| 2179 while (charbuf < charbuf_end) | |
| 2180 { | |
| 2181 ASSURE_DESTINATION (safe_room); | |
| 2182 c = *charbuf++; | |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2183 |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2184 if (c < 0) |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2185 { |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2186 /* Handle an annotation. */ |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2187 switch (*charbuf) |
|
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 case CODING_ANNOTATE_COMPOSITION_MASK: |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2190 /* Not yet implemented. */ |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2191 break; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2192 case CODING_ANNOTATE_CHARSET_MASK: |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2193 preferred_charset_id = charbuf[3]; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2194 if (preferred_charset_id >= 0 |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2195 && NILP (Fmemq (make_number (preferred_charset_id), |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2196 charset_list))) |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2197 preferred_charset_id = -1; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2198 break; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2199 default: |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2200 abort (); |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2201 } |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2202 charbuf += -c - 1; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2203 continue; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2204 } |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2205 |
| 88365 | 2206 if (ASCII_CHAR_P (c)) |
| 2207 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
|
2208 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
|
2209 { |
|
7f284ac55b07
(encode_coding_emacs_mule): Pay attention to raw-8-bit chars.
Kenichi Handa <handa@m17n.org>
parents:
88681
diff
changeset
|
2210 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
|
2211 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
|
2212 } |
|
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2213 else |
|
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2214 { |
| 88365 | 2215 struct charset *charset; |
| 2216 unsigned code; | |
| 2217 int dimension; | |
| 2218 int emacs_mule_id; | |
| 2219 unsigned char leading_codes[2]; | |
| 2220 | |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2221 if (preferred_charset_id >= 0) |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2222 { |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2223 charset = CHARSET_FROM_ID (preferred_charset_id); |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2224 if (! CHAR_CHARSET_P (c, charset)) |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2225 charset = char_charset (c, charset_list, NULL); |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2226 } |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2227 else |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2228 charset = char_charset (c, charset_list, &code); |
| 88365 | 2229 if (! charset) |
| 2230 { | |
| 2231 c = coding->default_char; | |
| 2232 if (ASCII_CHAR_P (c)) | |
| 2233 { | |
| 2234 EMIT_ONE_ASCII_BYTE (c); | |
| 2235 continue; | |
| 2236 } | |
| 2237 charset = char_charset (c, charset_list, &code); | |
| 2238 } | |
| 2239 dimension = CHARSET_DIMENSION (charset); | |
| 2240 emacs_mule_id = CHARSET_EMACS_MULE_ID (charset); | |
| 2241 EMACS_MULE_LEADING_CODES (emacs_mule_id, leading_codes); | |
| 2242 EMIT_ONE_BYTE (leading_codes[0]); | |
| 2243 if (leading_codes[1]) | |
| 2244 EMIT_ONE_BYTE (leading_codes[1]); | |
| 2245 if (dimension == 1) | |
|
89642
e97441b6244b
(encode_coding_emacs_mule): Emit bytes with MSB.
Kenichi Handa <handa@m17n.org>
parents:
89575
diff
changeset
|
2246 EMIT_ONE_BYTE (code | 0x80); |
| 88365 | 2247 else |
| 2248 { | |
|
89642
e97441b6244b
(encode_coding_emacs_mule): Emit bytes with MSB.
Kenichi Handa <handa@m17n.org>
parents:
89575
diff
changeset
|
2249 code |= 0x8080; |
| 88365 | 2250 EMIT_ONE_BYTE (code >> 8); |
| 2251 EMIT_ONE_BYTE (code & 0xFF); | |
| 2252 } | |
| 17052 | 2253 } |
| 88365 | 2254 } |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
2255 record_conversion_result (coding, CODING_RESULT_SUCCESS); |
| 88365 | 2256 coding->produced_char += produced_chars; |
| 2257 coding->produced = dst - coding->destination; | |
| 2258 return 0; | |
|
34888
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
2259 } |
|
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2260 |
| 17052 | 2261 |
| 88365 | 2262 /*** 7. ISO2022 handlers ***/ |
| 17052 | 2263 |
| 2264 /* 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
|
2265 Since the intention of this note is to help understand the |
| 88771 | 2266 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
|
2267 SIMPLIFIED. For thorough understanding, please refer to the |
| 88771 | 2268 original document of ISO2022. This is equivalent to the standard |
| 2269 ECMA-35, obtainable from <URL:http://www.ecma.ch/> (*). | |
| 17052 | 2270 |
| 2271 ISO2022 provides many mechanisms to encode several character sets | |
| 88771 | 2272 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
|
2273 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
|
2274 text a little bit longer, but the text passes more easily through |
| 88771 | 2275 several types of gateway, some of which strip off the MSB (Most |
| 2276 Significant Bit). | |
| 2277 | |
| 2278 There are two kinds of character sets: control character sets and | |
| 2279 graphic character sets. The former contain control characters such | |
| 17052 | 2280 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
|
2281 functions are also provided by escape sequences). The latter |
| 88771 | 2282 contain graphic characters such as 'A' and '-'. Emacs recognizes |
| 17052 | 2283 two control character sets and many graphic character sets. |
| 2284 | |
| 2285 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
|
2286 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
|
2287 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
|
2288 - DIMENSION1_CHARS94 |
|
61c6b3be1d51
Comment for ISO 2022 encoding mechanism modified.
Kenichi Handa <handa@m17n.org>
parents:
24344
diff
changeset
|
2289 - DIMENSION1_CHARS96 |
|
61c6b3be1d51
Comment for ISO 2022 encoding mechanism modified.
Kenichi Handa <handa@m17n.org>
parents:
24344
diff
changeset
|
2290 - DIMENSION2_CHARS94 |
|
61c6b3be1d51
Comment for ISO 2022 encoding mechanism modified.
Kenichi Handa <handa@m17n.org>
parents:
24344
diff
changeset
|
2291 - DIMENSION2_CHARS96 |
|
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 In addition, each character set is assigned an identification tag, |
| 88771 | 2294 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
|
2295 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
|
2296 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
|
2297 (0x30..0x3F are for private use only). |
| 17052 | 2298 |
| 2299 Note (*): ECMA = European Computer Manufacturers Association | |
| 2300 | |
| 88771 | 2301 Here are examples of graphic character sets [NAME(<F>)]: |
| 17052 | 2302 o DIMENSION1_CHARS94 -- ASCII('B'), right-half-of-JISX0201('I'), ... |
| 2303 o DIMENSION1_CHARS96 -- right-half-of-ISO8859-1('A'), ... | |
| 2304 o DIMENSION2_CHARS94 -- GB2312('A'), JISX0208('B'), ... | |
| 2305 o DIMENSION2_CHARS96 -- none for the moment | |
| 2306 | |
|
24425
61c6b3be1d51
Comment for ISO 2022 encoding mechanism modified.
Kenichi Handa <handa@m17n.org>
parents:
24344
diff
changeset
|
2307 A code area (1 byte=8 bits) is divided into 4 areas, C0, GL, C1, and GR. |
| 17052 | 2308 C0 [0x00..0x1F] -- control character plane 0 |
| 2309 GL [0x20..0x7F] -- graphic character plane 0 | |
| 2310 C1 [0x80..0x9F] -- control character plane 1 | |
| 2311 GR [0xA0..0xFF] -- graphic character plane 1 | |
| 2312 | |
| 2313 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
|
2314 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
|
2315 - 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
|
2316 - 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
|
2317 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
|
2318 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
|
2319 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
|
2320 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
|
2321 defined to have corresponding escape sequences. |
| 17052 | 2322 |
| 2323 A graphic character set is at first designated to one of four | |
| 2324 graphic registers (G0 through G3), then these graphic registers are | |
| 2325 invoked to GL or GR. These designations and invocations can be | |
| 2326 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
|
2327 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
|
2328 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
|
2329 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
|
2330 |
|
61c6b3be1d51
Comment for ISO 2022 encoding mechanism modified.
Kenichi Handa <handa@m17n.org>
parents:
24344
diff
changeset
|
2331 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
|
2332 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
|
2333 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
|
2334 be used. |
| 17052 | 2335 |
| 2336 There are two ways of invocation: locking-shift and single-shift. | |
| 2337 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
|
2338 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
|
2339 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
|
2340 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
|
2341 escape sequences: |
| 17052 | 2342 |
| 2343 ---------------------------------------------------------------------- | |
|
24425
61c6b3be1d51
Comment for ISO 2022 encoding mechanism modified.
Kenichi Handa <handa@m17n.org>
parents:
24344
diff
changeset
|
2344 abbrev function cntrl escape seq description |
| 17052 | 2345 ---------------------------------------------------------------------- |
|
24425
61c6b3be1d51
Comment for ISO 2022 encoding mechanism modified.
Kenichi Handa <handa@m17n.org>
parents:
24344
diff
changeset
|
2346 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
|
2347 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
|
2348 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
|
2349 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
|
2350 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
|
2351 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
|
2352 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
|
2353 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
|
2354 SS3 (single-shift-3) 0x8F ESC 'O' invoke G3 for one char |
| 17052 | 2355 ---------------------------------------------------------------------- |
|
24425
61c6b3be1d51
Comment for ISO 2022 encoding mechanism modified.
Kenichi Handa <handa@m17n.org>
parents:
24344
diff
changeset
|
2356 (*) 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
|
2357 |
|
61c6b3be1d51
Comment for ISO 2022 encoding mechanism modified.
Kenichi Handa <handa@m17n.org>
parents:
24344
diff
changeset
|
2358 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
|
2359 ISO_CODE_XXX in `coding.h'. |
|
61c6b3be1d51
Comment for ISO 2022 encoding mechanism modified.
Kenichi Handa <handa@m17n.org>
parents:
24344
diff
changeset
|
2360 |
|
61c6b3be1d51
Comment for ISO 2022 encoding mechanism modified.
Kenichi Handa <handa@m17n.org>
parents:
24344
diff
changeset
|
2361 Designations are done by the following escape sequences: |
| 17052 | 2362 ---------------------------------------------------------------------- |
| 2363 escape sequence description | |
| 2364 ---------------------------------------------------------------------- | |
| 2365 ESC '(' <F> designate DIMENSION1_CHARS94<F> to G0 | |
| 2366 ESC ')' <F> designate DIMENSION1_CHARS94<F> to G1 | |
| 2367 ESC '*' <F> designate DIMENSION1_CHARS94<F> to G2 | |
| 2368 ESC '+' <F> designate DIMENSION1_CHARS94<F> to G3 | |
| 2369 ESC ',' <F> designate DIMENSION1_CHARS96<F> to G0 (*) | |
| 2370 ESC '-' <F> designate DIMENSION1_CHARS96<F> to G1 | |
| 2371 ESC '.' <F> designate DIMENSION1_CHARS96<F> to G2 | |
| 2372 ESC '/' <F> designate DIMENSION1_CHARS96<F> to G3 | |
| 2373 ESC '$' '(' <F> designate DIMENSION2_CHARS94<F> to G0 (**) | |
| 2374 ESC '$' ')' <F> designate DIMENSION2_CHARS94<F> to G1 | |
| 2375 ESC '$' '*' <F> designate DIMENSION2_CHARS94<F> to G2 | |
| 2376 ESC '$' '+' <F> designate DIMENSION2_CHARS94<F> to G3 | |
| 2377 ESC '$' ',' <F> designate DIMENSION2_CHARS96<F> to G0 (*) | |
| 2378 ESC '$' '-' <F> designate DIMENSION2_CHARS96<F> to G1 | |
| 2379 ESC '$' '.' <F> designate DIMENSION2_CHARS96<F> to G2 | |
| 2380 ESC '$' '/' <F> designate DIMENSION2_CHARS96<F> to G3 | |
| 2381 ---------------------------------------------------------------------- | |
| 2382 | |
| 2383 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
|
2384 of dimension 1, chars 94, and final character <F>, etc... |
| 17052 | 2385 |
| 2386 Note (*): Although these designations are not allowed in ISO2022, | |
| 2387 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
|
2388 CHARS96 character sets in a coding system which is characterized as |
| 17052 | 2389 7-bit environment, non-locking-shift, and non-single-shift. |
| 2390 | |
| 2391 Note (**): If <F> is '@', 'A', or 'B', the intermediate character | |
| 88365 | 2392 '(' must be omitted. We refer to this as "short-form" hereafter. |
| 2393 | |
| 88771 | 2394 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
|
2395 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
|
2396 coding systems such as Compound Text (used in X11's inter client |
| 88771 | 2397 communication, ISO-2022-JP (used in Japanese Internet), ISO-2022-KR |
| 2398 (used in Korean Internet), EUC (Extended UNIX Code, used in Asian | |
| 17052 | 2399 localized platforms), and all of these are variants of ISO2022. |
| 2400 | |
| 2401 In addition to the above, Emacs handles two more kinds of escape | |
| 2402 sequences: ISO6429's direction specification and Emacs' private | |
| 2403 sequence for specifying character composition. | |
| 2404 | |
|
24425
61c6b3be1d51
Comment for ISO 2022 encoding mechanism modified.
Kenichi Handa <handa@m17n.org>
parents:
24344
diff
changeset
|
2405 ISO6429's direction specification takes the following form: |
| 17052 | 2406 o CSI ']' -- end of the current direction |
| 2407 o CSI '0' ']' -- end of the current direction | |
| 2408 o CSI '1' ']' -- start of left-to-right text | |
| 2409 o CSI '2' ']' -- start of right-to-left text | |
| 2410 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
|
2411 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
|
2412 |
|
61c6b3be1d51
Comment for ISO 2022 encoding mechanism modified.
Kenichi Handa <handa@m17n.org>
parents:
24344
diff
changeset
|
2413 Character composition specification takes the following form: |
| 26847 | 2414 o ESC '0' -- start relative composition |
| 2415 o ESC '1' -- end composition | |
| 2416 o ESC '2' -- start rule-base composition (*) | |
| 2417 o ESC '3' -- start relative composition with alternate chars (**) | |
| 2418 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
|
2419 Since these are not standard escape sequences of any ISO standard, |
| 88771 | 2420 the use of them with these meanings is restricted to Emacs only. |
| 2421 | |
| 2422 (*) This form is used only in Emacs 20.7 and older versions, | |
| 2423 but newer versions can safely decode it. | |
| 2424 (**) This form is used only in Emacs 21.1 and newer versions, | |
| 2425 and older versions can't decode it. | |
| 2426 | |
| 2427 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
|
2428 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
|
2429 |
|
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2430 COMPOSITION_RELATIVE: |
| 26847 | 2431 ESC 0 CHAR [ CHAR ] ESC 1 |
| 88771 | 2432 COMPOSITION_WITH_RULE: |
| 26847 | 2433 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
|
2434 COMPOSITION_WITH_ALTCHARS: |
| 26847 | 2435 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
|
2436 COMPOSITION_WITH_RULE_ALTCHARS: |
| 26847 | 2437 ESC 4 ALTCHAR [ RULE ALTCHAR ] ESC 0 CHAR [ CHAR ] ESC 1 */ |
| 17052 | 2438 |
| 2439 enum iso_code_class_type iso_code_class[256]; | |
| 2440 | |
| 88365 | 2441 #define SAFE_CHARSET_P(coding, id) \ |
| 2442 ((id) <= (coding)->max_charset_id \ | |
| 2443 && (coding)->safe_charsets[id] >= 0) | |
| 2444 | |
| 2445 | |
| 2446 #define SHIFT_OUT_OK(category) \ | |
| 2447 (CODING_ISO_INITIAL (&coding_categories[category], 1) >= 0) | |
| 2448 | |
| 2449 static void | |
|
88631
780b91d4a7e5
(setup_iso_safe_charsets): Fix arg decl for K&R.
Dave Love <fx@gnu.org>
parents:
88607
diff
changeset
|
2450 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
|
2451 Lisp_Object attrs; |
| 88365 | 2452 { |
| 2453 Lisp_Object charset_list, safe_charsets; | |
| 2454 Lisp_Object request; | |
| 2455 Lisp_Object reg_usage; | |
| 2456 Lisp_Object tail; | |
| 2457 int reg94, reg96; | |
| 2458 int flags = XINT (AREF (attrs, coding_attr_iso_flags)); | |
| 2459 int max_charset_id; | |
| 2460 | |
| 2461 charset_list = CODING_ATTR_CHARSET_LIST (attrs); | |
| 2462 if ((flags & CODING_ISO_FLAG_FULL_SUPPORT) | |
| 2463 && ! EQ (charset_list, Viso_2022_charset_list)) | |
| 2464 { | |
| 2465 CODING_ATTR_CHARSET_LIST (attrs) | |
| 2466 = charset_list = Viso_2022_charset_list; | |
| 2467 ASET (attrs, coding_attr_safe_charsets, Qnil); | |
| 2468 } | |
| 2469 | |
| 2470 if (STRINGP (AREF (attrs, coding_attr_safe_charsets))) | |
| 2471 return; | |
| 2472 | |
| 2473 max_charset_id = 0; | |
| 2474 for (tail = charset_list; CONSP (tail); tail = XCDR (tail)) | |
| 2475 { | |
| 2476 int id = XINT (XCAR (tail)); | |
| 2477 if (max_charset_id < id) | |
| 2478 max_charset_id = id; | |
| 2479 } | |
| 2480 | |
| 2481 safe_charsets = Fmake_string (make_number (max_charset_id + 1), | |
| 2482 make_number (255)); | |
| 2483 request = AREF (attrs, coding_attr_iso_request); | |
| 2484 reg_usage = AREF (attrs, coding_attr_iso_usage); | |
| 2485 reg94 = XINT (XCAR (reg_usage)); | |
| 2486 reg96 = XINT (XCDR (reg_usage)); | |
| 2487 | |
| 2488 for (tail = charset_list; CONSP (tail); tail = XCDR (tail)) | |
| 2489 { | |
| 2490 Lisp_Object id; | |
| 2491 Lisp_Object reg; | |
| 2492 struct charset *charset; | |
| 2493 | |
| 2494 id = XCAR (tail); | |
| 2495 charset = CHARSET_FROM_ID (XINT (id)); | |
|
88681
2cdfbffa8a0d
(CODING_ISO_FLAG_USE_ROMAN): New macro
Kenichi Handa <handa@m17n.org>
parents:
88669
diff
changeset
|
2496 reg = Fcdr (Fassq (id, request)); |
| 88365 | 2497 if (! NILP (reg)) |
| 89483 | 2498 SSET (safe_charsets, XINT (id), XINT (reg)); |
| 88365 | 2499 else if (charset->iso_chars_96) |
| 2500 { | |
| 2501 if (reg96 < 4) | |
| 89483 | 2502 SSET (safe_charsets, XINT (id), reg96); |
| 88365 | 2503 } |
| 2504 else | |
| 2505 { | |
| 2506 if (reg94 < 4) | |
| 89483 | 2507 SSET (safe_charsets, XINT (id), reg94); |
| 88365 | 2508 } |
| 2509 } | |
| 2510 ASET (attrs, coding_attr_safe_charsets, safe_charsets); | |
| 2511 } | |
| 2512 | |
|
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
2513 |
| 17052 | 2514 /* 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
|
2515 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
|
2516 If it is, return 1, else return 0. */ |
| 17052 | 2517 |
|
34531
37f85e931855
(ONE_MORE_BYTE_CHECK_MULTIBYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34197
diff
changeset
|
2518 static int |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2519 detect_coding_iso_2022 (coding, detect_info) |
| 88365 | 2520 struct coding_system *coding; |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2521 struct coding_detection_info *detect_info; |
| 17052 | 2522 { |
| 89483 | 2523 const unsigned char *src = coding->source, *src_base = src; |
| 2524 const unsigned char *src_end = coding->source + coding->src_bytes; | |
| 88365 | 2525 int multibytep = coding->src_multibyte; |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2526 int single_shifting = 0; |
| 88365 | 2527 int id; |
| 2528 int c, c1; | |
| 2529 int consumed_chars = 0; | |
| 2530 int i; | |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2531 int rejected = 0; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2532 int found = 0; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2533 |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2534 detect_info->checked |= CATEGORY_MASK_ISO; |
| 88365 | 2535 |
| 2536 for (i = coding_category_iso_7; i <= coding_category_iso_8_else; i++) | |
| 2537 { | |
| 2538 struct coding_system *this = &(coding_categories[i]); | |
| 2539 Lisp_Object attrs, val; | |
| 2540 | |
| 2541 attrs = CODING_ID_ATTRS (this->id); | |
| 2542 if (CODING_ISO_FLAGS (this) & CODING_ISO_FLAG_FULL_SUPPORT | |
| 2543 && ! EQ (CODING_ATTR_SAFE_CHARSETS (attrs), Viso_2022_charset_list)) | |
| 2544 setup_iso_safe_charsets (attrs); | |
| 2545 val = CODING_ATTR_SAFE_CHARSETS (attrs); | |
| 89483 | 2546 this->max_charset_id = SCHARS (val) - 1; |
| 2547 this->safe_charsets = (char *) SDATA (val); | |
| 88365 | 2548 } |
| 2549 | |
| 2550 /* A coding system of this category is always ASCII compatible. */ | |
| 2551 src += coding->head_ascii; | |
| 2552 | |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2553 while (rejected != CATEGORY_MASK_ISO) |
| 88365 | 2554 { |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
2555 src_base = src; |
| 88365 | 2556 ONE_MORE_BYTE (c); |
| 17052 | 2557 switch (c) |
| 2558 { | |
| 2559 case ISO_CODE_ESC: | |
|
30204
35aec8514228
(inhibit_iso_escape_detection): New variable.
Kenichi Handa <handa@m17n.org>
parents:
29985
diff
changeset
|
2560 if (inhibit_iso_escape_detection) |
|
35aec8514228
(inhibit_iso_escape_detection): New variable.
Kenichi Handa <handa@m17n.org>
parents:
29985
diff
changeset
|
2561 break; |
|
23088
45c36d636f66
(detect_coding_iso2022): Don't check the byte length of
Kenichi Handa <handa@m17n.org>
parents:
23082
diff
changeset
|
2562 single_shifting = 0; |
| 88365 | 2563 ONE_MORE_BYTE (c); |
|
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
2564 if (c >= '(' && c <= '/') |
|
19134
8fa6e23f8d22
(detect_coding_iso2022): Do not exclude posibility of
Kenichi Handa <handa@m17n.org>
parents:
19118
diff
changeset
|
2565 { |
|
8fa6e23f8d22
(detect_coding_iso2022): Do not exclude posibility of
Kenichi Handa <handa@m17n.org>
parents:
19118
diff
changeset
|
2566 /* Designation sequence for a charset of dimension 1. */ |
| 88365 | 2567 ONE_MORE_BYTE (c1); |
|
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
2568 if (c1 < ' ' || c1 >= 0x80 |
| 88365 | 2569 || (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
|
2570 /* Invalid designation sequence. Just ignore. */ |
|
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
2571 break; |
|
19134
8fa6e23f8d22
(detect_coding_iso2022): Do not exclude posibility of
Kenichi Handa <handa@m17n.org>
parents:
19118
diff
changeset
|
2572 } |
|
8fa6e23f8d22
(detect_coding_iso2022): Do not exclude posibility of
Kenichi Handa <handa@m17n.org>
parents:
19118
diff
changeset
|
2573 else if (c == '$') |
| 17052 | 2574 { |
|
19134
8fa6e23f8d22
(detect_coding_iso2022): Do not exclude posibility of
Kenichi Handa <handa@m17n.org>
parents:
19118
diff
changeset
|
2575 /* Designation sequence for a charset of dimension 2. */ |
| 88365 | 2576 ONE_MORE_BYTE (c); |
|
19134
8fa6e23f8d22
(detect_coding_iso2022): Do not exclude posibility of
Kenichi Handa <handa@m17n.org>
parents:
19118
diff
changeset
|
2577 if (c >= '@' && c <= 'B') |
|
8fa6e23f8d22
(detect_coding_iso2022): Do not exclude posibility of
Kenichi Handa <handa@m17n.org>
parents:
19118
diff
changeset
|
2578 /* Designation for JISX0208.1978, GB2312, or JISX0208. */ |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2579 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
|
2580 else if (c >= '(' && c <= '/') |
|
17320
9d15bec5f47e
(detect_coding_iso2022, detect_coding_mask): Ignore
Kenichi Handa <handa@m17n.org>
parents:
17304
diff
changeset
|
2581 { |
| 88365 | 2582 ONE_MORE_BYTE (c1); |
|
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
2583 if (c1 < ' ' || c1 >= 0x80 |
| 88365 | 2584 || (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
|
2585 /* Invalid designation sequence. Just ignore. */ |
|
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
2586 break; |
|
17320
9d15bec5f47e
(detect_coding_iso2022, detect_coding_mask): Ignore
Kenichi Handa <handa@m17n.org>
parents:
17304
diff
changeset
|
2587 } |
|
19134
8fa6e23f8d22
(detect_coding_iso2022): Do not exclude posibility of
Kenichi Handa <handa@m17n.org>
parents:
19118
diff
changeset
|
2588 else |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2589 /* Invalid designation sequence. Just ignore it. */ |
|
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
2590 break; |
|
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
2591 } |
|
23116
6736da064f4a
(detect_coding_iso2022): Handle ESC N and ESC O
Kenichi Handa <handa@m17n.org>
parents:
23089
diff
changeset
|
2592 else if (c == 'N' || c == 'O') |
|
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
2593 { |
|
23116
6736da064f4a
(detect_coding_iso2022): Handle ESC N and ESC O
Kenichi Handa <handa@m17n.org>
parents:
23089
diff
changeset
|
2594 /* ESC <Fe> for SS2 or SS3. */ |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2595 single_shifting = 1; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2596 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
|
2597 break; |
|
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
2598 } |
| 26847 | 2599 else if (c >= '0' && c <= '4') |
| 2600 { | |
| 2601 /* ESC <Fp> for start/end composition. */ | |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2602 found |= CATEGORY_MASK_ISO; |
| 26847 | 2603 break; |
| 2604 } | |
|
19134
8fa6e23f8d22
(detect_coding_iso2022): Do not exclude posibility of
Kenichi Handa <handa@m17n.org>
parents:
19118
diff
changeset
|
2605 else |
| 88365 | 2606 { |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2607 /* Invalid escape sequence. Just ignore it. */ |
| 88365 | 2608 break; |
| 2609 } | |
|
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
2610 |
|
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
2611 /* 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
|
2612 rejected |= CATEGORY_MASK_ISO_8BIT; |
| 88365 | 2613 if (SAFE_CHARSET_P (&coding_categories[coding_category_iso_7], |
| 2614 id)) | |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2615 found |= CATEGORY_MASK_ISO_7; |
|
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
2616 else |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2617 rejected |= CATEGORY_MASK_ISO_7; |
| 88365 | 2618 if (SAFE_CHARSET_P (&coding_categories[coding_category_iso_7_tight], |
| 2619 id)) | |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2620 found |= CATEGORY_MASK_ISO_7_TIGHT; |
|
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
2621 else |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2622 rejected |= CATEGORY_MASK_ISO_7_TIGHT; |
| 88365 | 2623 if (SAFE_CHARSET_P (&coding_categories[coding_category_iso_7_else], |
| 2624 id)) | |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2625 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
|
2626 else |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2627 rejected |= CATEGORY_MASK_ISO_7_ELSE; |
| 88365 | 2628 if (SAFE_CHARSET_P (&coding_categories[coding_category_iso_8_else], |
| 2629 id)) | |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2630 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
|
2631 else |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2632 rejected |= CATEGORY_MASK_ISO_8_ELSE; |
| 17052 | 2633 break; |
| 2634 | |
| 2635 case ISO_CODE_SO: | |
|
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
2636 case ISO_CODE_SI: |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2637 /* Locking shift out/in. */ |
|
30204
35aec8514228
(inhibit_iso_escape_detection): New variable.
Kenichi Handa <handa@m17n.org>
parents:
29985
diff
changeset
|
2638 if (inhibit_iso_escape_detection) |
|
35aec8514228
(inhibit_iso_escape_detection): New variable.
Kenichi Handa <handa@m17n.org>
parents:
29985
diff
changeset
|
2639 break; |
|
23088
45c36d636f66
(detect_coding_iso2022): Don't check the byte length of
Kenichi Handa <handa@m17n.org>
parents:
23082
diff
changeset
|
2640 single_shifting = 0; |
|
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_8BIT; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2642 found |= CATEGORY_MASK_ISO_ELSE; |
|
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
2643 break; |
|
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
2644 |
| 17052 | 2645 case ISO_CODE_CSI: |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2646 /* Control sequence introducer. */ |
|
23088
45c36d636f66
(detect_coding_iso2022): Don't check the byte length of
Kenichi Handa <handa@m17n.org>
parents:
23082
diff
changeset
|
2647 single_shifting = 0; |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2648 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
|
2649 found |= CATEGORY_MASK_ISO_8_ELSE; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2650 goto check_extra_latin; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2651 |
| 17052 | 2652 case ISO_CODE_SS2: |
| 2653 case ISO_CODE_SS3: | |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2654 /* Single shift. */ |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2655 if (inhibit_iso_escape_detection) |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2656 break; |
|
89780
a53cb5864a40
(detect_coding_iso_2022): Fix handling of SS2 and SS3.
Kenichi Handa <handa@m17n.org>
parents:
89779
diff
changeset
|
2657 single_shifting = 0; |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2658 rejected |= CATEGORY_MASK_ISO_7BIT; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2659 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
|
2660 & 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
|
2661 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
|
2662 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
|
2663 & 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
|
2664 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
|
2665 if (single_shifting) |
|
a53cb5864a40
(detect_coding_iso_2022): Fix handling of SS2 and SS3.
Kenichi Handa <handa@m17n.org>
parents:
89779
diff
changeset
|
2666 break; |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2667 goto check_extra_latin; |
| 17052 | 2668 |
| 2669 default: | |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
2670 if (c < 0) |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
2671 continue; |
| 17052 | 2672 if (c < 0x80) |
|
23088
45c36d636f66
(detect_coding_iso2022): Don't check the byte length of
Kenichi Handa <handa@m17n.org>
parents:
23082
diff
changeset
|
2673 { |
|
45c36d636f66
(detect_coding_iso2022): Don't check the byte length of
Kenichi Handa <handa@m17n.org>
parents:
23082
diff
changeset
|
2674 single_shifting = 0; |
|
45c36d636f66
(detect_coding_iso2022): Don't check the byte length of
Kenichi Handa <handa@m17n.org>
parents:
23082
diff
changeset
|
2675 break; |
|
45c36d636f66
(detect_coding_iso2022): Don't check the byte length of
Kenichi Handa <handa@m17n.org>
parents:
23082
diff
changeset
|
2676 } |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2677 if (c >= 0xA0) |
|
19280
e755044718ee
(ENCODE_ISO_CHARACTER_DIMENSION1): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
19193
diff
changeset
|
2678 { |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2679 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
|
2680 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
|
2681 /* 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
|
2682 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
|
2683 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
|
2684 only when we are not single shifting. */ |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2685 if (! single_shifting |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2686 && ! (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
|
2687 { |
|
29299
b33b38d81020
(detect_coding_iso2022): Fix code for checking
Kenichi Handa <handa@m17n.org>
parents:
29275
diff
changeset
|
2688 int i = 1; |
|
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2689 while (src < src_end) |
|
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2690 { |
| 88365 | 2691 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
|
2692 if (c < 0xA0) |
|
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2693 break; |
|
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2694 i++; |
|
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2695 } |
|
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2696 |
|
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2697 if (i & 1 && src < src_end) |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2698 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
|
2699 else |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2700 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
|
2701 } |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2702 break; |
| 17052 | 2703 } |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2704 check_extra_latin: |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2705 single_shifting = 0; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2706 if (! VECTORP (Vlatin_extra_code_table) |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2707 || NILP (XVECTOR (Vlatin_extra_code_table)->contents[c])) |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2708 { |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2709 rejected = CATEGORY_MASK_ISO; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2710 break; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2711 } |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2712 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
|
2713 & CODING_ISO_FLAG_LATIN_EXTRA) |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2714 found |= CATEGORY_MASK_ISO_8_1; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2715 else |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2716 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
|
2717 rejected |= CATEGORY_MASK_ISO_8_2; |
| 17052 | 2718 } |
| 2719 } | |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2720 detect_info->rejected |= CATEGORY_MASK_ISO; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2721 return 0; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2722 |
| 88365 | 2723 no_more_source: |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2724 detect_info->rejected |= rejected; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2725 detect_info->found |= (found & ~rejected); |
| 88365 | 2726 return 1; |
| 17052 | 2727 } |
| 2728 | |
| 2729 | |
|
89873
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
2730 /* Set designation state into CODING. Set CHARS_96 to -1 if the |
|
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
2731 escape sequence should be kept. */ |
| 88365 | 2732 #define DECODE_DESIGNATION(reg, dim, chars_96, final) \ |
| 2733 do { \ | |
| 2734 int id, prev; \ | |
| 2735 \ | |
| 2736 if (final < '0' || final >= 128 \ | |
| 2737 || ((id = ISO_CHARSET_TABLE (dim, chars_96, final)) < 0) \ | |
| 2738 || !SAFE_CHARSET_P (coding, id)) \ | |
| 2739 { \ | |
| 2740 CODING_ISO_DESIGNATION (coding, reg) = -2; \ | |
|
89873
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
2741 chars_96 = -1; \ |
|
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
2742 break; \ |
| 88365 | 2743 } \ |
| 2744 prev = CODING_ISO_DESIGNATION (coding, reg); \ | |
|
88681
2cdfbffa8a0d
(CODING_ISO_FLAG_USE_ROMAN): New macro
Kenichi Handa <handa@m17n.org>
parents:
88669
diff
changeset
|
2745 if (id == charset_jisx0201_roman) \ |
|
2cdfbffa8a0d
(CODING_ISO_FLAG_USE_ROMAN): New macro
Kenichi Handa <handa@m17n.org>
parents:
88669
diff
changeset
|
2746 { \ |
|
2cdfbffa8a0d
(CODING_ISO_FLAG_USE_ROMAN): New macro
Kenichi Handa <handa@m17n.org>
parents:
88669
diff
changeset
|
2747 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
|
2748 id = charset_ascii; \ |
|
2cdfbffa8a0d
(CODING_ISO_FLAG_USE_ROMAN): New macro
Kenichi Handa <handa@m17n.org>
parents:
88669
diff
changeset
|
2749 } \ |
|
2cdfbffa8a0d
(CODING_ISO_FLAG_USE_ROMAN): New macro
Kenichi Handa <handa@m17n.org>
parents:
88669
diff
changeset
|
2750 else if (id == charset_jisx0208_1978) \ |
|
2cdfbffa8a0d
(CODING_ISO_FLAG_USE_ROMAN): New macro
Kenichi Handa <handa@m17n.org>
parents:
88669
diff
changeset
|
2751 { \ |
|
2cdfbffa8a0d
(CODING_ISO_FLAG_USE_ROMAN): New macro
Kenichi Handa <handa@m17n.org>
parents:
88669
diff
changeset
|
2752 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
|
2753 id = charset_jisx0208; \ |
|
2cdfbffa8a0d
(CODING_ISO_FLAG_USE_ROMAN): New macro
Kenichi Handa <handa@m17n.org>
parents:
88669
diff
changeset
|
2754 } \ |
| 88365 | 2755 CODING_ISO_DESIGNATION (coding, reg) = id; \ |
| 2756 /* If there was an invalid designation to REG previously, and this \ | |
| 2757 designation is ASCII to REG, we should keep this designation \ | |
| 2758 sequence. */ \ | |
| 2759 if (prev == -2 && id == charset_ascii) \ | |
|
89873
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
2760 chars_96 = -1; \ |
| 17052 | 2761 } while (0) |
| 2762 | |
| 88365 | 2763 |
| 2764 #define MAYBE_FINISH_COMPOSITION() \ | |
| 2765 do { \ | |
| 2766 int i; \ | |
| 2767 if (composition_state == COMPOSING_NO) \ | |
| 2768 break; \ | |
| 2769 /* It is assured that we have enough room for producing \ | |
| 2770 characters stored in the table `components'. */ \ | |
| 2771 if (charbuf + component_idx > charbuf_end) \ | |
| 2772 goto no_more_source; \ | |
| 2773 composition_state = COMPOSING_NO; \ | |
| 2774 if (method == COMPOSITION_RELATIVE \ | |
| 2775 || method == COMPOSITION_WITH_ALTCHARS) \ | |
| 2776 { \ | |
| 2777 for (i = 0; i < component_idx; i++) \ | |
| 2778 *charbuf++ = components[i]; \ | |
| 2779 char_offset += component_idx; \ | |
| 2780 } \ | |
| 2781 else \ | |
| 2782 { \ | |
| 2783 for (i = 0; i < component_idx; i += 2) \ | |
| 2784 *charbuf++ = components[i]; \ | |
| 2785 char_offset += (component_idx / 2) + 1; \ | |
| 2786 } \ | |
| 2787 } while (0) | |
| 2788 | |
|
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
2789 |
|
34888
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
2790 /* 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
|
2791 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
|
2792 ESC 2 : rulebase composition : ESC 2 CHAR RULE CHAR RULE ... CHAR ESC 1 |
| 88365 | 2793 ESC 3 : altchar composition : ESC 3 CHAR ... ESC 0 CHAR ... ESC 1 |
| 2794 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
|
2795 */ |
| 26847 | 2796 |
| 88365 | 2797 #define DECODE_COMPOSITION_START(c1) \ |
| 26847 | 2798 do { \ |
| 88365 | 2799 if (c1 == '0' \ |
|
88585
c7772f702227
(ONE_MORE_BYTE_NO_CHECK): Increment consumed_chars.
Kenichi Handa <handa@m17n.org>
parents:
88573
diff
changeset
|
2800 && composition_state == COMPOSING_COMPONENT_RULE) \ |
| 26847 | 2801 { \ |
| 88365 | 2802 component_len = component_idx; \ |
| 2803 composition_state = COMPOSING_CHAR; \ | |
| 26847 | 2804 } \ |
| 2805 else \ | |
| 2806 { \ | |
| 89483 | 2807 const unsigned char *p; \ |
| 88365 | 2808 \ |
| 2809 MAYBE_FINISH_COMPOSITION (); \ | |
| 2810 if (charbuf + MAX_COMPOSITION_COMPONENTS > charbuf_end) \ | |
| 2811 goto no_more_source; \ | |
| 2812 for (p = src; p < src_end - 1; p++) \ | |
| 2813 if (*p == ISO_CODE_ESC && p[1] == '1') \ | |
| 2814 break; \ | |
| 2815 if (p == src_end - 1) \ | |
| 2816 { \ | |
| 2817 if (coding->mode & CODING_MODE_LAST_BLOCK) \ | |
| 2818 goto invalid_code; \ | |
| 2819 goto no_more_source; \ | |
| 2820 } \ | |
| 2821 \ | |
| 2822 /* This is surely the start of a composition. */ \ | |
| 2823 method = (c1 == '0' ? COMPOSITION_RELATIVE \ | |
| 2824 : c1 == '2' ? COMPOSITION_WITH_RULE \ | |
| 2825 : c1 == '3' ? COMPOSITION_WITH_ALTCHARS \ | |
| 2826 : COMPOSITION_WITH_RULE_ALTCHARS); \ | |
| 2827 composition_state = (c1 <= '2' ? COMPOSING_CHAR \ | |
| 2828 : COMPOSING_COMPONENT_CHAR); \ | |
| 2829 component_idx = component_len = 0; \ | |
| 26847 | 2830 } \ |
| 2831 } while (0) | |
| 2832 | |
| 88365 | 2833 |
| 2834 /* Handle compositoin end sequence ESC 1. */ | |
| 2835 | |
| 2836 #define DECODE_COMPOSITION_END() \ | |
| 2837 do { \ | |
| 2838 int nchars = (component_len > 0 ? component_idx - component_len \ | |
| 2839 : method == COMPOSITION_RELATIVE ? component_idx \ | |
| 2840 : (component_idx + 1) / 2); \ | |
| 2841 int i; \ | |
| 2842 int *saved_charbuf = charbuf; \ | |
| 2843 \ | |
|
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
2844 ADD_COMPOSITION_DATA (charbuf, nchars, method); \ |
| 88365 | 2845 if (method != COMPOSITION_RELATIVE) \ |
| 2846 { \ | |
| 2847 if (component_len == 0) \ | |
| 2848 for (i = 0; i < component_idx; i++) \ | |
| 2849 *charbuf++ = components[i]; \ | |
| 2850 else \ | |
| 2851 for (i = 0; i < component_len; i++) \ | |
| 2852 *charbuf++ = components[i]; \ | |
| 2853 *saved_charbuf = saved_charbuf - charbuf; \ | |
| 2854 } \ | |
| 2855 if (method == COMPOSITION_WITH_RULE) \ | |
| 2856 for (i = 0; i < component_idx; i += 2, char_offset++) \ | |
| 2857 *charbuf++ = components[i]; \ | |
| 2858 else \ | |
| 2859 for (i = component_len; i < component_idx; i++, char_offset++) \ | |
| 2860 *charbuf++ = components[i]; \ | |
| 2861 coding->annotated = 1; \ | |
| 2862 composition_state = COMPOSING_NO; \ | |
| 2863 } while (0) | |
| 2864 | |
| 2865 | |
| 26847 | 2866 /* Decode a composition rule from the byte C1 (and maybe one more byte |
| 2867 from SRC) and store one encoded composition rule in | |
| 2868 coding->cmp_data. */ | |
| 2869 | |
| 2870 #define DECODE_COMPOSITION_RULE(c1) \ | |
| 2871 do { \ | |
| 2872 (c1) -= 32; \ | |
| 2873 if (c1 < 81) /* old format (before ver.21) */ \ | |
| 2874 { \ | |
| 2875 int gref = (c1) / 9; \ | |
| 2876 int nref = (c1) % 9; \ | |
| 2877 if (gref == 4) gref = 10; \ | |
| 2878 if (nref == 4) nref = 10; \ | |
| 88365 | 2879 c1 = COMPOSITION_ENCODE_RULE (gref, nref); \ |
| 26847 | 2880 } \ |
|
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2881 else if (c1 < 93) /* new format (after ver.21) */ \ |
| 26847 | 2882 { \ |
| 2883 ONE_MORE_BYTE (c2); \ | |
| 88365 | 2884 c1 = COMPOSITION_ENCODE_RULE (c1 - 81, c2 - 32); \ |
| 26847 | 2885 } \ |
| 88365 | 2886 else \ |
| 2887 c1 = 0; \ | |
| 26847 | 2888 } while (0) |
| 2889 | |
| 2890 | |
| 17052 | 2891 /* See the above "GENERAL NOTES on `decode_coding_XXX ()' functions". */ |
| 2892 | |
|
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2893 static void |
| 88365 | 2894 decode_coding_iso_2022 (coding) |
| 17052 | 2895 struct coding_system *coding; |
| 2896 { | |
| 89483 | 2897 const unsigned char *src = coding->source + coding->consumed; |
| 2898 const unsigned char *src_end = coding->source + coding->src_bytes; | |
| 2899 const unsigned char *src_base; | |
|
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
2900 int *charbuf = coding->charbuf + coding->charbuf_used; |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2901 int *charbuf_end |
|
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
2902 = coding->charbuf + coding->charbuf_size - 4 - MAX_ANNOTATION_LENGTH; |
| 88365 | 2903 int consumed_chars = 0, consumed_chars_base; |
| 2904 int multibytep = coding->src_multibyte; | |
| 17052 | 2905 /* Charsets invoked to graphic plane 0 and 1 respectively. */ |
| 88365 | 2906 int charset_id_0 = CODING_ISO_INVOKED_CHARSET (coding, 0); |
| 2907 int charset_id_1 = CODING_ISO_INVOKED_CHARSET (coding, 1); | |
|
89873
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
2908 int charset_id_2, charset_id_3; |
| 88365 | 2909 struct charset *charset; |
| 2910 int c; | |
| 2911 /* For handling composition sequence. */ | |
| 2912 #define COMPOSING_NO 0 | |
| 2913 #define COMPOSING_CHAR 1 | |
| 2914 #define COMPOSING_RULE 2 | |
| 2915 #define COMPOSING_COMPONENT_CHAR 3 | |
| 2916 #define COMPOSING_COMPONENT_RULE 4 | |
| 2917 | |
| 2918 int composition_state = COMPOSING_NO; | |
| 2919 enum composition_method method; | |
| 2920 int components[MAX_COMPOSITION_COMPONENTS * 2 + 1]; | |
| 2921 int component_idx; | |
| 2922 int component_len; | |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
2923 Lisp_Object attrs, charset_list; |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2924 int char_offset = coding->produced_char; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2925 int last_offset = char_offset; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
2926 int last_id = charset_ascii; |
| 88365 | 2927 |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
2928 CODING_GET_INFO (coding, attrs, charset_list); |
| 88365 | 2929 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
|
2930 |
|
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2931 while (1) |
|
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2932 { |
|
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2933 int c1, c2; |
|
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2934 |
|
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2935 src_base = src; |
| 88365 | 2936 consumed_chars_base = consumed_chars; |
| 2937 | |
| 2938 if (charbuf >= charbuf_end) | |
| 2939 break; | |
| 2940 | |
|
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2941 ONE_MORE_BYTE (c1); |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
2942 if (c1 < 0) |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
2943 goto invalid_code; |
| 17052 | 2944 |
|
89279
1fd77c471ee6
(decode_coding_utf_8): When eol_type is Qdos, handle
Kenichi Handa <handa@m17n.org>
parents:
89227
diff
changeset
|
2945 /* We produce at most one character. */ |
| 17052 | 2946 switch (iso_code_class [c1]) |
| 2947 { | |
| 2948 case ISO_0x20_or_0x7F: | |
| 88365 | 2949 if (composition_state != COMPOSING_NO) |
| 26847 | 2950 { |
| 88365 | 2951 if (composition_state == COMPOSING_RULE |
| 2952 || composition_state == COMPOSING_COMPONENT_RULE) | |
| 2953 { | |
| 2954 DECODE_COMPOSITION_RULE (c1); | |
| 2955 components[component_idx++] = c1; | |
| 2956 composition_state--; | |
| 2957 continue; | |
| 2958 } | |
| 26847 | 2959 } |
| 88365 | 2960 if (charset_id_0 < 0 |
| 2961 || ! 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
|
2962 /* This is SPACE or DEL. */ |
|
c7772f702227
(ONE_MORE_BYTE_NO_CHECK): Increment consumed_chars.
Kenichi Handa <handa@m17n.org>
parents:
88573
diff
changeset
|
2963 charset = CHARSET_FROM_ID (charset_ascii); |
|
c7772f702227
(ONE_MORE_BYTE_NO_CHECK): Increment consumed_chars.
Kenichi Handa <handa@m17n.org>
parents:
88573
diff
changeset
|
2964 else |
|
c7772f702227
(ONE_MORE_BYTE_NO_CHECK): Increment consumed_chars.
Kenichi Handa <handa@m17n.org>
parents:
88573
diff
changeset
|
2965 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
|
2966 break; |
| 17052 | 2967 |
| 2968 case ISO_graphic_plane_0: | |
|
88585
c7772f702227
(ONE_MORE_BYTE_NO_CHECK): Increment consumed_chars.
Kenichi Handa <handa@m17n.org>
parents:
88573
diff
changeset
|
2969 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
|
2970 { |
|
88585
c7772f702227
(ONE_MORE_BYTE_NO_CHECK): Increment consumed_chars.
Kenichi Handa <handa@m17n.org>
parents:
88573
diff
changeset
|
2971 if (composition_state == COMPOSING_RULE |
|
c7772f702227
(ONE_MORE_BYTE_NO_CHECK): Increment consumed_chars.
Kenichi Handa <handa@m17n.org>
parents:
88573
diff
changeset
|
2972 || composition_state == COMPOSING_COMPONENT_RULE) |
|
c7772f702227
(ONE_MORE_BYTE_NO_CHECK): Increment consumed_chars.
Kenichi Handa <handa@m17n.org>
parents:
88573
diff
changeset
|
2973 { |
|
c7772f702227
(ONE_MORE_BYTE_NO_CHECK): Increment consumed_chars.
Kenichi Handa <handa@m17n.org>
parents:
88573
diff
changeset
|
2974 DECODE_COMPOSITION_RULE (c1); |
|
c7772f702227
(ONE_MORE_BYTE_NO_CHECK): Increment consumed_chars.
Kenichi Handa <handa@m17n.org>
parents:
88573
diff
changeset
|
2975 components[component_idx++] = c1; |
|
c7772f702227
(ONE_MORE_BYTE_NO_CHECK): Increment consumed_chars.
Kenichi Handa <handa@m17n.org>
parents:
88573
diff
changeset
|
2976 composition_state--; |
|
c7772f702227
(ONE_MORE_BYTE_NO_CHECK): Increment consumed_chars.
Kenichi Handa <handa@m17n.org>
parents:
88573
diff
changeset
|
2977 continue; |
|
c7772f702227
(ONE_MORE_BYTE_NO_CHECK): Increment consumed_chars.
Kenichi Handa <handa@m17n.org>
parents:
88573
diff
changeset
|
2978 } |
|
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2979 } |
|
89873
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
2980 if (charset_id_0 < 0) |
|
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
2981 charset = CHARSET_FROM_ID (charset_ascii); |
|
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
2982 else |
|
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
2983 charset = CHARSET_FROM_ID (charset_id_0); |
| 17052 | 2984 break; |
| 2985 | |
| 2986 case ISO_0xA0_or_0xFF: | |
| 88365 | 2987 if (charset_id_1 < 0 |
| 2988 || ! CHARSET_ISO_CHARS_96 (CHARSET_FROM_ID (charset_id_1)) | |
| 2989 || CODING_ISO_FLAGS (coding) & CODING_ISO_FLAG_SEVEN_BITS) | |
| 2990 goto invalid_code; | |
| 17052 | 2991 /* This is a graphic character, we fall down ... */ |
| 2992 | |
| 2993 case ISO_graphic_plane_1: | |
| 88365 | 2994 if (charset_id_1 < 0) |
| 2995 goto invalid_code; | |
| 2996 charset = CHARSET_FROM_ID (charset_id_1); | |
| 17052 | 2997 break; |
| 2998 | |
|
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
2999 case ISO_control_0: |
| 88365 | 3000 MAYBE_FINISH_COMPOSITION (); |
| 3001 charset = CHARSET_FROM_ID (charset_ascii); | |
| 17052 | 3002 break; |
| 3003 | |
|
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3004 case ISO_control_1: |
| 88365 | 3005 MAYBE_FINISH_COMPOSITION (); |
| 3006 goto invalid_code; | |
| 17052 | 3007 |
| 3008 case ISO_shift_out: | |
| 88365 | 3009 if (! (CODING_ISO_FLAGS (coding) & CODING_ISO_FLAG_LOCKING_SHIFT) |
| 3010 || CODING_ISO_DESIGNATION (coding, 1) < 0) | |
| 3011 goto invalid_code; | |
| 3012 CODING_ISO_INVOCATION (coding, 0) = 1; | |
| 3013 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
|
3014 continue; |
| 17052 | 3015 |
| 3016 case ISO_shift_in: | |
| 88365 | 3017 if (! (CODING_ISO_FLAGS (coding) & CODING_ISO_FLAG_LOCKING_SHIFT)) |
| 3018 goto invalid_code; | |
| 3019 CODING_ISO_INVOCATION (coding, 0) = 0; | |
| 3020 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
|
3021 continue; |
| 17052 | 3022 |
| 3023 case ISO_single_shift_2_7: | |
| 3024 case ISO_single_shift_2: | |
| 88365 | 3025 if (! (CODING_ISO_FLAGS (coding) & CODING_ISO_FLAG_SINGLE_SHIFT)) |
| 3026 goto invalid_code; | |
| 17052 | 3027 /* SS2 is handled as an escape sequence of ESC 'N' */ |
| 3028 c1 = 'N'; | |
| 3029 goto label_escape_sequence; | |
| 3030 | |
| 3031 case ISO_single_shift_3: | |
| 88365 | 3032 if (! (CODING_ISO_FLAGS (coding) & CODING_ISO_FLAG_SINGLE_SHIFT)) |
| 3033 goto invalid_code; | |
| 17052 | 3034 /* SS2 is handled as an escape sequence of ESC 'O' */ |
| 3035 c1 = 'O'; | |
| 3036 goto label_escape_sequence; | |
| 3037 | |
| 3038 case ISO_control_sequence_introducer: | |
| 3039 /* CSI is handled as an escape sequence of ESC '[' ... */ | |
| 3040 c1 = '['; | |
| 3041 goto label_escape_sequence; | |
| 3042 | |
| 3043 case ISO_escape: | |
| 3044 ONE_MORE_BYTE (c1); | |
| 3045 label_escape_sequence: | |
| 88365 | 3046 /* Escape sequences handled here are invocation, |
| 17052 | 3047 designation, direction specification, and character |
| 3048 composition specification. */ | |
| 3049 switch (c1) | |
| 3050 { | |
| 3051 case '&': /* revision of following character set */ | |
| 3052 ONE_MORE_BYTE (c1); | |
| 3053 if (!(c1 >= '@' && c1 <= '~')) | |
| 88365 | 3054 goto invalid_code; |
| 17052 | 3055 ONE_MORE_BYTE (c1); |
| 3056 if (c1 != ISO_CODE_ESC) | |
| 88365 | 3057 goto invalid_code; |
| 17052 | 3058 ONE_MORE_BYTE (c1); |
| 3059 goto label_escape_sequence; | |
| 3060 | |
| 3061 case '$': /* designation of 2-byte character set */ | |
| 88365 | 3062 if (! (CODING_ISO_FLAGS (coding) & CODING_ISO_FLAG_DESIGNATION)) |
| 3063 goto invalid_code; | |
|
89873
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
3064 { |
|
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
3065 int reg, chars96; |
|
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
3066 |
|
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
3067 ONE_MORE_BYTE (c1); |
|
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
3068 if (c1 >= '@' && c1 <= 'B') |
|
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
3069 { /* 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
|
3070 or JISX0208.1980 */ |
|
89873
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
3071 reg = 0, chars96 = 0; |
|
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
3072 } |
|
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
3073 else if (c1 >= 0x28 && c1 <= 0x2B) |
|
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
3074 { /* designation of DIMENSION2_CHARS94 character set */ |
|
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
3075 reg = c1 - 0x28, chars96 = 0; |
|
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
3076 ONE_MORE_BYTE (c1); |
|
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
3077 } |
|
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
3078 else if (c1 >= 0x2C && c1 <= 0x2F) |
|
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
3079 { /* designation of DIMENSION2_CHARS96 character set */ |
|
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
3080 reg = c1 - 0x2C, chars96 = 1; |
|
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
3081 ONE_MORE_BYTE (c1); |
|
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
3082 } |
|
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
3083 else |
|
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
3084 goto invalid_code; |
|
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
3085 DECODE_DESIGNATION (reg, 2, chars96, c1); |
|
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
3086 /* We must update these variables now. */ |
|
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
3087 if (reg == 0) |
|
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
3088 charset_id_0 = CODING_ISO_INVOKED_CHARSET (coding, 0); |
|
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
3089 else if (reg == 1) |
|
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
3090 charset_id_1 = CODING_ISO_INVOKED_CHARSET (coding, 1); |
|
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
3091 if (chars96 < 0) |
|
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
3092 goto invalid_code; |
|
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
3093 } |
|
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3094 continue; |
| 17052 | 3095 |
| 3096 case 'n': /* invocation of locking-shift-2 */ | |
| 88365 | 3097 if (! (CODING_ISO_FLAGS (coding) & CODING_ISO_FLAG_LOCKING_SHIFT) |
| 3098 || CODING_ISO_DESIGNATION (coding, 2) < 0) | |
| 3099 goto invalid_code; | |
| 3100 CODING_ISO_INVOCATION (coding, 0) = 2; | |
| 3101 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
|
3102 continue; |
| 17052 | 3103 |
| 3104 case 'o': /* invocation of locking-shift-3 */ | |
| 88365 | 3105 if (! (CODING_ISO_FLAGS (coding) & CODING_ISO_FLAG_LOCKING_SHIFT) |
| 3106 || CODING_ISO_DESIGNATION (coding, 3) < 0) | |
| 3107 goto invalid_code; | |
| 3108 CODING_ISO_INVOCATION (coding, 0) = 3; | |
| 3109 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
|
3110 continue; |
| 17052 | 3111 |
| 3112 case 'N': /* invocation of single-shift-2 */ | |
| 88365 | 3113 if (! (CODING_ISO_FLAGS (coding) & CODING_ISO_FLAG_SINGLE_SHIFT) |
| 3114 || CODING_ISO_DESIGNATION (coding, 2) < 0) | |
| 3115 goto invalid_code; | |
|
89873
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
3116 charset_id_2 = CODING_ISO_DESIGNATION (coding, 2); |
|
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
3117 if (charset_id_2 < 0) |
|
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
3118 charset = CHARSET_FROM_ID (charset_ascii); |
|
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
3119 else |
|
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
3120 charset = CHARSET_FROM_ID (charset_id_2); |
| 17052 | 3121 ONE_MORE_BYTE (c1); |
|
30578
705b94e152b1
(decode_coding_iso2022): More strict check for handling single
Kenichi Handa <handa@m17n.org>
parents:
30487
diff
changeset
|
3122 if (c1 < 0x20 || (c1 >= 0x80 && c1 < 0xA0)) |
| 88365 | 3123 goto invalid_code; |
| 17052 | 3124 break; |
| 3125 | |
| 3126 case 'O': /* invocation of single-shift-3 */ | |
| 88365 | 3127 if (! (CODING_ISO_FLAGS (coding) & CODING_ISO_FLAG_SINGLE_SHIFT) |
| 3128 || CODING_ISO_DESIGNATION (coding, 3) < 0) | |
| 3129 goto invalid_code; | |
|
89873
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
3130 charset_id_3 = CODING_ISO_DESIGNATION (coding, 3); |
|
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
3131 if (charset_id_3 < 0) |
|
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
3132 charset = CHARSET_FROM_ID (charset_ascii); |
|
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
3133 else |
|
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
3134 charset = CHARSET_FROM_ID (charset_id_3); |
| 17052 | 3135 ONE_MORE_BYTE (c1); |
|
30578
705b94e152b1
(decode_coding_iso2022): More strict check for handling single
Kenichi Handa <handa@m17n.org>
parents:
30487
diff
changeset
|
3136 if (c1 < 0x20 || (c1 >= 0x80 && c1 < 0xA0)) |
| 88365 | 3137 goto invalid_code; |
| 17052 | 3138 break; |
| 3139 | |
| 26847 | 3140 case '0': case '2': case '3': case '4': /* start composition */ |
| 88365 | 3141 if (! (coding->common_flags & CODING_ANNOTATE_COMPOSITION_MASK)) |
| 3142 goto invalid_code; | |
| 26847 | 3143 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
|
3144 continue; |
| 17052 | 3145 |
| 26847 | 3146 case '1': /* end composition */ |
| 88365 | 3147 if (composition_state == COMPOSING_NO) |
| 3148 goto invalid_code; | |
| 3149 DECODE_COMPOSITION_END (); | |
|
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3150 continue; |
| 17052 | 3151 |
| 3152 case '[': /* specification of direction */ | |
| 88365 | 3153 if (! CODING_ISO_FLAGS (coding) & CODING_ISO_FLAG_DIRECTION) |
| 3154 goto invalid_code; | |
| 17052 | 3155 /* 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
|
3156 So, `coding->mode & CODING_MODE_DIRECTION' zero means |
| 88365 | 3157 left-to-right, and nozero means right-to-left. */ |
| 17052 | 3158 ONE_MORE_BYTE (c1); |
| 3159 switch (c1) | |
| 3160 { | |
| 3161 case ']': /* end of the current direction */ | |
|
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3162 coding->mode &= ~CODING_MODE_DIRECTION; |
| 17052 | 3163 |
| 3164 case '0': /* end of the current direction */ | |
| 3165 case '1': /* start of left-to-right direction */ | |
| 3166 ONE_MORE_BYTE (c1); | |
| 3167 if (c1 == ']') | |
|
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3168 coding->mode &= ~CODING_MODE_DIRECTION; |
| 17052 | 3169 else |
| 88365 | 3170 goto invalid_code; |
| 17052 | 3171 break; |
| 3172 | |
| 3173 case '2': /* start of right-to-left direction */ | |
| 3174 ONE_MORE_BYTE (c1); | |
| 3175 if (c1 == ']') | |
|
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3176 coding->mode |= CODING_MODE_DIRECTION; |
| 17052 | 3177 else |
| 88365 | 3178 goto invalid_code; |
| 17052 | 3179 break; |
| 3180 | |
| 3181 default: | |
| 88365 | 3182 goto invalid_code; |
| 17052 | 3183 } |
|
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3184 continue; |
| 17052 | 3185 |
|
89442
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
3186 case '%': |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
3187 ONE_MORE_BYTE (c1); |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
3188 if (c1 == '/') |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
3189 { |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
3190 /* CTEXT extended segment: |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
3191 ESC % / [0-4] M L --ENCODING-NAME-- \002 --BYTES-- |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
3192 We keep these bytes as is for the moment. |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
3193 They may be decoded by post-read-conversion. */ |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
3194 int dim, M, L; |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
3195 int size; |
| 89483 | 3196 |
|
89442
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
3197 ONE_MORE_BYTE (dim); |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
3198 ONE_MORE_BYTE (M); |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
3199 ONE_MORE_BYTE (L); |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
3200 size = ((M - 128) * 128) + (L - 128); |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
3201 if (charbuf + 8 + size > charbuf_end) |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
3202 goto break_loop; |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
3203 *charbuf++ = ISO_CODE_ESC; |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
3204 *charbuf++ = '%'; |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
3205 *charbuf++ = '/'; |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
3206 *charbuf++ = dim; |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
3207 *charbuf++ = BYTE8_TO_CHAR (M); |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
3208 *charbuf++ = BYTE8_TO_CHAR (L); |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
3209 while (size-- > 0) |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
3210 { |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
3211 ONE_MORE_BYTE (c1); |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
3212 *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
|
3213 } |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
3214 } |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
3215 else if (c1 == 'G') |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
3216 { |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
3217 /* XFree86 extension for embedding UTF-8 in CTEXT: |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
3218 ESC % G --UTF-8-BYTES-- ESC % @ |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
3219 We keep these bytes as is for the moment. |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
3220 They may be decoded by post-read-conversion. */ |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
3221 int *p = charbuf; |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
3222 |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
3223 if (p + 6 > charbuf_end) |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
3224 goto break_loop; |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
3225 *p++ = ISO_CODE_ESC; |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
3226 *p++ = '%'; |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
3227 *p++ = 'G'; |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
3228 while (p < charbuf_end) |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
3229 { |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
3230 ONE_MORE_BYTE (c1); |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
3231 if (c1 == ISO_CODE_ESC |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
3232 && src + 1 < src_end |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
3233 && src[0] == '%' |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
3234 && src[1] == '@') |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
3235 break; |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
3236 *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
|
3237 } |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
3238 if (p + 3 > charbuf_end) |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
3239 goto break_loop; |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
3240 *p++ = ISO_CODE_ESC; |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
3241 *p++ = '%'; |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
3242 *p++ = '@'; |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
3243 charbuf = p; |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
3244 } |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
3245 else |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
3246 goto invalid_code; |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
3247 continue; |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
3248 break; |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
3249 |
| 17052 | 3250 default: |
| 88365 | 3251 if (! (CODING_ISO_FLAGS (coding) & CODING_ISO_FLAG_DESIGNATION)) |
| 3252 goto invalid_code; | |
|
89873
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
3253 { |
|
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
3254 int reg, chars96; |
|
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
3255 |
|
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
3256 if (c1 >= 0x28 && c1 <= 0x2B) |
|
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
3257 { /* designation of DIMENSION1_CHARS94 character set */ |
|
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
3258 reg = c1 - 0x28, chars96 = 0; |
|
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
3259 ONE_MORE_BYTE (c1); |
|
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
3260 } |
|
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
3261 else if (c1 >= 0x2C && c1 <= 0x2F) |
|
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
3262 { /* designation of DIMENSION1_CHARS96 character set */ |
|
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
3263 reg = c1 - 0x2C, chars96 = 1; |
|
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
3264 ONE_MORE_BYTE (c1); |
|
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
3265 } |
|
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
3266 else |
|
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
3267 goto invalid_code; |
|
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
3268 DECODE_DESIGNATION (reg, 1, chars96, c1); |
|
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
3269 /* We must update these variables now. */ |
|
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
3270 if (reg == 0) |
|
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
3271 charset_id_0 = CODING_ISO_INVOKED_CHARSET (coding, 0); |
|
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
3272 else if (reg == 1) |
|
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
3273 charset_id_1 = CODING_ISO_INVOKED_CHARSET (coding, 1); |
|
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
3274 if (chars96 < 0) |
|
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
3275 goto invalid_code; |
|
9a279ff9d245
(DECODE_DESIGNATION): Set chars_96 to -1 instead of
Kenichi Handa <handa@m17n.org>
parents:
89863
diff
changeset
|
3276 } |
|
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3277 continue; |
| 17052 | 3278 } |
|
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3279 } |
|
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3280 |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3281 if (charset->id != charset_ascii |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3282 && last_id != charset->id) |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3283 { |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3284 if (last_id != charset_ascii) |
|
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
3285 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
|
3286 last_id = charset->id; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3287 last_offset = char_offset; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3288 } |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3289 |
|
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3290 /* Now we know CHARSET and 1st position code C1 of a character. |
| 88365 | 3291 Produce a decoded character while getting 2nd position code |
| 3292 C2 if necessary. */ | |
| 3293 c1 &= 0x7F; | |
| 3294 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
|
3295 { |
|
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3296 ONE_MORE_BYTE (c2); |
| 88365 | 3297 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
|
3298 /* C2 is not in a valid range. */ |
| 88365 | 3299 goto invalid_code; |
| 3300 c1 = (c1 << 8) | (c2 & 0x7F); | |
| 3301 if (CHARSET_DIMENSION (charset) > 2) | |
| 3302 { | |
| 3303 ONE_MORE_BYTE (c2); | |
| 3304 if (c2 < 0x20 || (c2 >= 0x80 && c2 < 0xA0)) | |
| 3305 /* C2 is not in a valid range. */ | |
| 3306 goto invalid_code; | |
| 3307 c1 = (c1 << 8) | (c2 & 0x7F); | |
| 3308 } | |
| 17052 | 3309 } |
| 88365 | 3310 |
| 3311 CODING_DECODE_CHAR (coding, src, src_base, src_end, charset, c1, c); | |
| 3312 if (c < 0) | |
| 3313 { | |
| 3314 MAYBE_FINISH_COMPOSITION (); | |
| 3315 for (; src_base < src; src_base++, char_offset++) | |
| 3316 { | |
| 3317 if (ASCII_BYTE_P (*src_base)) | |
| 3318 *charbuf++ = *src_base; | |
| 3319 else | |
| 3320 *charbuf++ = BYTE8_TO_CHAR (*src_base); | |
| 3321 } | |
| 3322 } | |
| 3323 else if (composition_state == COMPOSING_NO) | |
| 3324 { | |
| 3325 *charbuf++ = c; | |
| 3326 char_offset++; | |
| 3327 } | |
| 3328 else | |
|
88585
c7772f702227
(ONE_MORE_BYTE_NO_CHECK): Increment consumed_chars.
Kenichi Handa <handa@m17n.org>
parents:
88573
diff
changeset
|
3329 { |
|
c7772f702227
(ONE_MORE_BYTE_NO_CHECK): Increment consumed_chars.
Kenichi Handa <handa@m17n.org>
parents:
88573
diff
changeset
|
3330 components[component_idx++] = c; |
|
c7772f702227
(ONE_MORE_BYTE_NO_CHECK): Increment consumed_chars.
Kenichi Handa <handa@m17n.org>
parents:
88573
diff
changeset
|
3331 if (method == COMPOSITION_WITH_RULE |
|
c7772f702227
(ONE_MORE_BYTE_NO_CHECK): Increment consumed_chars.
Kenichi Handa <handa@m17n.org>
parents:
88573
diff
changeset
|
3332 || (method == COMPOSITION_WITH_RULE_ALTCHARS |
|
c7772f702227
(ONE_MORE_BYTE_NO_CHECK): Increment consumed_chars.
Kenichi Handa <handa@m17n.org>
parents:
88573
diff
changeset
|
3333 && composition_state == COMPOSING_COMPONENT_CHAR)) |
|
c7772f702227
(ONE_MORE_BYTE_NO_CHECK): Increment consumed_chars.
Kenichi Handa <handa@m17n.org>
parents:
88573
diff
changeset
|
3334 composition_state++; |
|
c7772f702227
(ONE_MORE_BYTE_NO_CHECK): Increment consumed_chars.
Kenichi Handa <handa@m17n.org>
parents:
88573
diff
changeset
|
3335 } |
| 17052 | 3336 continue; |
| 3337 | |
| 88365 | 3338 invalid_code: |
| 3339 MAYBE_FINISH_COMPOSITION (); | |
| 3340 src = src_base; | |
| 3341 consumed_chars = consumed_chars_base; | |
| 3342 ONE_MORE_BYTE (c); | |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
3343 *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
|
3344 char_offset++; |
|
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3345 coding->errors++; |
|
89442
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
3346 continue; |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
3347 |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
3348 break_loop: |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
3349 break; |
| 88365 | 3350 } |
| 3351 | |
| 3352 no_more_source: | |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3353 if (last_id != charset_ascii) |
|
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
3354 ADD_CHARSET_DATA (charbuf, char_offset - last_offset, last_id); |
| 88365 | 3355 coding->consumed_char += consumed_chars_base; |
| 3356 coding->consumed = src_base - coding->source; | |
| 3357 coding->charbuf_used = charbuf - coding->charbuf; | |
| 17052 | 3358 } |
| 3359 | |
|
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3360 |
| 18766 | 3361 /* ISO2022 encoding stuff. */ |
| 17052 | 3362 |
| 3363 /* | |
| 18766 | 3364 It is not enough to say just "ISO2022" on encoding, we have to |
| 88365 | 3365 specify more details. In Emacs, each coding system of ISO2022 |
| 17052 | 3366 variant has the following specifications: |
| 88365 | 3367 1. Initial designation to G0 thru G3. |
| 17052 | 3368 2. Allows short-form designation? |
| 3369 3. ASCII should be designated to G0 before control characters? | |
| 3370 4. ASCII should be designated to G0 at end of line? | |
| 3371 5. 7-bit environment or 8-bit environment? | |
| 3372 6. Use locking-shift? | |
| 3373 7. Use Single-shift? | |
| 3374 And the following two are only for Japanese: | |
| 3375 8. Use ASCII in place of JIS0201-1976-Roman? | |
| 3376 9. Use JISX0208-1983 in place of JISX0208-1978? | |
| 88365 | 3377 These specifications are encoded in CODING_ISO_FLAGS (coding) as flag bits |
| 3378 defined by macros CODING_ISO_FLAG_XXX. See `coding.h' for more | |
| 18766 | 3379 details. |
| 17052 | 3380 */ |
| 3381 | |
| 3382 /* 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
|
3383 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
|
3384 '@', '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
|
3385 designation sequence of short-form. */ |
| 17052 | 3386 |
| 3387 #define ENCODE_DESIGNATION(charset, reg, coding) \ | |
| 3388 do { \ | |
| 88365 | 3389 unsigned char final_char = CHARSET_ISO_FINAL (charset); \ |
| 17052 | 3390 char *intermediate_char_94 = "()*+"; \ |
| 3391 char *intermediate_char_96 = ",-./"; \ | |
| 88365 | 3392 int revision = -1; \ |
| 3393 int c; \ | |
| 3394 \ | |
| 3395 if (CODING_ISO_FLAGS (coding) & CODING_ISO_FLAG_REVISION) \ | |
| 88856 | 3396 revision = CHARSET_ISO_REVISION (charset); \ |
| 88365 | 3397 \ |
| 3398 if (revision >= 0) \ | |
|
20150
402b6e5f4b58
(encode_designation_at_bol): Fix bug of finding graphic
Kenichi Handa <handa@m17n.org>
parents:
20105
diff
changeset
|
3399 { \ |
| 88365 | 3400 EMIT_TWO_ASCII_BYTES (ISO_CODE_ESC, '&'); \ |
| 3401 EMIT_ONE_BYTE ('@' + revision); \ | |
| 17052 | 3402 } \ |
| 88365 | 3403 EMIT_ONE_ASCII_BYTE (ISO_CODE_ESC); \ |
| 17052 | 3404 if (CHARSET_DIMENSION (charset) == 1) \ |
| 3405 { \ | |
| 88365 | 3406 if (! CHARSET_ISO_CHARS_96 (charset)) \ |
| 3407 c = intermediate_char_94[reg]; \ | |
| 17052 | 3408 else \ |
| 88365 | 3409 c = intermediate_char_96[reg]; \ |
| 3410 EMIT_ONE_ASCII_BYTE (c); \ | |
| 17052 | 3411 } \ |
| 3412 else \ | |
| 3413 { \ | |
| 88365 | 3414 EMIT_ONE_ASCII_BYTE ('$'); \ |
| 3415 if (! CHARSET_ISO_CHARS_96 (charset)) \ | |
| 17052 | 3416 { \ |
| 88365 | 3417 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
|
3418 || reg != 0 \ |
|
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3419 || final_char < '@' || final_char > 'B') \ |
| 88365 | 3420 EMIT_ONE_ASCII_BYTE (intermediate_char_94[reg]); \ |
| 17052 | 3421 } \ |
| 3422 else \ | |
| 88365 | 3423 EMIT_ONE_ASCII_BYTE (intermediate_char_96[reg]); \ |
| 17052 | 3424 } \ |
| 88365 | 3425 EMIT_ONE_ASCII_BYTE (final_char); \ |
| 3426 \ | |
| 3427 CODING_ISO_DESIGNATION (coding, reg) = CHARSET_ID (charset); \ | |
| 17052 | 3428 } while (0) |
| 3429 | |
| 88365 | 3430 |
| 17052 | 3431 /* The following two macros produce codes (control character or escape |
| 3432 sequence) for ISO2022 single-shift functions (single-shift-2 and | |
| 3433 single-shift-3). */ | |
| 3434 | |
| 88365 | 3435 #define ENCODE_SINGLE_SHIFT_2 \ |
| 3436 do { \ | |
| 3437 if (CODING_ISO_FLAGS (coding) & CODING_ISO_FLAG_SEVEN_BITS) \ | |
| 3438 EMIT_TWO_ASCII_BYTES (ISO_CODE_ESC, 'N'); \ | |
| 3439 else \ | |
| 3440 EMIT_ONE_BYTE (ISO_CODE_SS2); \ | |
| 3441 CODING_ISO_SINGLE_SHIFTING (coding) = 1; \ | |
| 17052 | 3442 } while (0) |
| 3443 | |
| 88365 | 3444 |
| 3445 #define ENCODE_SINGLE_SHIFT_3 \ | |
| 3446 do { \ | |
| 3447 if (CODING_ISO_FLAGS (coding) & CODING_ISO_FLAG_SEVEN_BITS) \ | |
| 3448 EMIT_TWO_ASCII_BYTES (ISO_CODE_ESC, 'O'); \ | |
| 3449 else \ | |
| 3450 EMIT_ONE_BYTE (ISO_CODE_SS3); \ | |
| 3451 CODING_ISO_SINGLE_SHIFTING (coding) = 1; \ | |
| 17052 | 3452 } while (0) |
| 3453 | |
| 88365 | 3454 |
| 17052 | 3455 /* The following four macros produce codes (control character or |
| 3456 escape sequence) for ISO2022 locking-shift functions (shift-in, | |
| 3457 shift-out, locking-shift-2, and locking-shift-3). */ | |
| 3458 | |
| 88365 | 3459 #define ENCODE_SHIFT_IN \ |
| 3460 do { \ | |
| 3461 EMIT_ONE_ASCII_BYTE (ISO_CODE_SI); \ | |
| 3462 CODING_ISO_INVOCATION (coding, 0) = 0; \ | |
| 17052 | 3463 } while (0) |
| 3464 | |
| 88365 | 3465 |
| 3466 #define ENCODE_SHIFT_OUT \ | |
| 3467 do { \ | |
| 3468 EMIT_ONE_ASCII_BYTE (ISO_CODE_SO); \ | |
| 3469 CODING_ISO_INVOCATION (coding, 0) = 1; \ | |
| 17052 | 3470 } while (0) |
| 3471 | |
| 88365 | 3472 |
| 3473 #define ENCODE_LOCKING_SHIFT_2 \ | |
| 3474 do { \ | |
| 3475 EMIT_TWO_ASCII_BYTES (ISO_CODE_ESC, 'n'); \ | |
| 3476 CODING_ISO_INVOCATION (coding, 0) = 2; \ | |
| 17052 | 3477 } while (0) |
| 3478 | |
| 88365 | 3479 |
| 3480 #define ENCODE_LOCKING_SHIFT_3 \ | |
| 3481 do { \ | |
| 3482 EMIT_TWO_ASCII_BYTES (ISO_CODE_ESC, 'n'); \ | |
| 3483 CODING_ISO_INVOCATION (coding, 0) = 3; \ | |
| 17052 | 3484 } while (0) |
| 3485 | |
| 88365 | 3486 |
| 18766 | 3487 /* Produce codes for a DIMENSION1 character whose character set is |
| 3488 CHARSET and whose position-code is C1. Designation and invocation | |
| 17052 | 3489 sequences are also produced in advance if necessary. */ |
| 3490 | |
|
19285
af3d00fde172
(Fset_terminal_coding_system_internal): Set
Kenichi Handa <handa@m17n.org>
parents:
19280
diff
changeset
|
3491 #define ENCODE_ISO_CHARACTER_DIMENSION1(charset, c1) \ |
|
af3d00fde172
(Fset_terminal_coding_system_internal): Set
Kenichi Handa <handa@m17n.org>
parents:
19280
diff
changeset
|
3492 do { \ |
| 88365 | 3493 int id = CHARSET_ID (charset); \ |
|
88681
2cdfbffa8a0d
(CODING_ISO_FLAG_USE_ROMAN): New macro
Kenichi Handa <handa@m17n.org>
parents:
88669
diff
changeset
|
3494 \ |
|
2cdfbffa8a0d
(CODING_ISO_FLAG_USE_ROMAN): New macro
Kenichi Handa <handa@m17n.org>
parents:
88669
diff
changeset
|
3495 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
|
3496 && id == charset_ascii) \ |
|
2cdfbffa8a0d
(CODING_ISO_FLAG_USE_ROMAN): New macro
Kenichi Handa <handa@m17n.org>
parents:
88669
diff
changeset
|
3497 { \ |
|
2cdfbffa8a0d
(CODING_ISO_FLAG_USE_ROMAN): New macro
Kenichi Handa <handa@m17n.org>
parents:
88669
diff
changeset
|
3498 id = charset_jisx0201_roman; \ |
|
2cdfbffa8a0d
(CODING_ISO_FLAG_USE_ROMAN): New macro
Kenichi Handa <handa@m17n.org>
parents:
88669
diff
changeset
|
3499 charset = CHARSET_FROM_ID (id); \ |
|
2cdfbffa8a0d
(CODING_ISO_FLAG_USE_ROMAN): New macro
Kenichi Handa <handa@m17n.org>
parents:
88669
diff
changeset
|
3500 } \ |
|
2cdfbffa8a0d
(CODING_ISO_FLAG_USE_ROMAN): New macro
Kenichi Handa <handa@m17n.org>
parents:
88669
diff
changeset
|
3501 \ |
| 88365 | 3502 if (CODING_ISO_SINGLE_SHIFTING (coding)) \ |
|
19285
af3d00fde172
(Fset_terminal_coding_system_internal): Set
Kenichi Handa <handa@m17n.org>
parents:
19280
diff
changeset
|
3503 { \ |
| 88365 | 3504 if (CODING_ISO_FLAGS (coding) & CODING_ISO_FLAG_SEVEN_BITS) \ |
| 3505 EMIT_ONE_ASCII_BYTE (c1 & 0x7F); \ | |
|
19285
af3d00fde172
(Fset_terminal_coding_system_internal): Set
Kenichi Handa <handa@m17n.org>
parents:
19280
diff
changeset
|
3506 else \ |
| 88365 | 3507 EMIT_ONE_BYTE (c1 | 0x80); \ |
| 3508 CODING_ISO_SINGLE_SHIFTING (coding) = 0; \ | |
|
19285
af3d00fde172
(Fset_terminal_coding_system_internal): Set
Kenichi Handa <handa@m17n.org>
parents:
19280
diff
changeset
|
3509 break; \ |
|
af3d00fde172
(Fset_terminal_coding_system_internal): Set
Kenichi Handa <handa@m17n.org>
parents:
19280
diff
changeset
|
3510 } \ |
| 88365 | 3511 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
|
3512 { \ |
| 88365 | 3513 EMIT_ONE_ASCII_BYTE (c1 & 0x7F); \ |
|
19285
af3d00fde172
(Fset_terminal_coding_system_internal): Set
Kenichi Handa <handa@m17n.org>
parents:
19280
diff
changeset
|
3514 break; \ |
|
af3d00fde172
(Fset_terminal_coding_system_internal): Set
Kenichi Handa <handa@m17n.org>
parents:
19280
diff
changeset
|
3515 } \ |
| 88365 | 3516 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
|
3517 { \ |
| 88365 | 3518 EMIT_ONE_BYTE (c1 | 0x80); \ |
|
19285
af3d00fde172
(Fset_terminal_coding_system_internal): Set
Kenichi Handa <handa@m17n.org>
parents:
19280
diff
changeset
|
3519 break; \ |
|
af3d00fde172
(Fset_terminal_coding_system_internal): Set
Kenichi Handa <handa@m17n.org>
parents:
19280
diff
changeset
|
3520 } \ |
|
af3d00fde172
(Fset_terminal_coding_system_internal): Set
Kenichi Handa <handa@m17n.org>
parents:
19280
diff
changeset
|
3521 else \ |
|
af3d00fde172
(Fset_terminal_coding_system_internal): Set
Kenichi Handa <handa@m17n.org>
parents:
19280
diff
changeset
|
3522 /* 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
|
3523 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
|
3524 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
|
3525 character. */ \ |
| 88365 | 3526 dst = encode_invocation_designation (charset, coding, dst, \ |
| 3527 &produced_chars); \ | |
| 17052 | 3528 } while (1) |
| 3529 | |
| 88365 | 3530 |
| 3531 /* Produce codes for a DIMENSION2 character whose character set is | |
| 3532 CHARSET and whose position-codes are C1 and C2. Designation and | |
| 3533 invocation codes are also produced in advance if necessary. */ | |
| 3534 | |
| 3535 #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
|
3536 do { \ |
| 88365 | 3537 int id = CHARSET_ID (charset); \ |
|
88681
2cdfbffa8a0d
(CODING_ISO_FLAG_USE_ROMAN): New macro
Kenichi Handa <handa@m17n.org>
parents:
88669
diff
changeset
|
3538 \ |
|
2cdfbffa8a0d
(CODING_ISO_FLAG_USE_ROMAN): New macro
Kenichi Handa <handa@m17n.org>
parents:
88669
diff
changeset
|
3539 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
|
3540 && id == charset_jisx0208) \ |
|
2cdfbffa8a0d
(CODING_ISO_FLAG_USE_ROMAN): New macro
Kenichi Handa <handa@m17n.org>
parents:
88669
diff
changeset
|
3541 { \ |
|
2cdfbffa8a0d
(CODING_ISO_FLAG_USE_ROMAN): New macro
Kenichi Handa <handa@m17n.org>
parents:
88669
diff
changeset
|
3542 id = charset_jisx0208_1978; \ |
|
2cdfbffa8a0d
(CODING_ISO_FLAG_USE_ROMAN): New macro
Kenichi Handa <handa@m17n.org>
parents:
88669
diff
changeset
|
3543 charset = CHARSET_FROM_ID (id); \ |
|
2cdfbffa8a0d
(CODING_ISO_FLAG_USE_ROMAN): New macro
Kenichi Handa <handa@m17n.org>
parents:
88669
diff
changeset
|
3544 } \ |
|
2cdfbffa8a0d
(CODING_ISO_FLAG_USE_ROMAN): New macro
Kenichi Handa <handa@m17n.org>
parents:
88669
diff
changeset
|
3545 \ |
| 88365 | 3546 if (CODING_ISO_SINGLE_SHIFTING (coding)) \ |
| 3547 { \ | |
| 3548 if (CODING_ISO_FLAGS (coding) & CODING_ISO_FLAG_SEVEN_BITS) \ | |
| 3549 EMIT_TWO_ASCII_BYTES ((c1) & 0x7F, (c2) & 0x7F); \ | |
| 3550 else \ | |
| 3551 EMIT_TWO_BYTES ((c1) | 0x80, (c2) | 0x80); \ | |
| 3552 CODING_ISO_SINGLE_SHIFTING (coding) = 0; \ | |
| 3553 break; \ | |
| 3554 } \ | |
| 3555 else if (id == CODING_ISO_INVOKED_CHARSET (coding, 0)) \ | |
| 3556 { \ | |
| 3557 EMIT_TWO_ASCII_BYTES ((c1) & 0x7F, (c2) & 0x7F); \ | |
| 3558 break; \ | |
| 3559 } \ | |
| 3560 else if (id == CODING_ISO_INVOKED_CHARSET (coding, 1)) \ | |
| 3561 { \ | |
| 3562 EMIT_TWO_BYTES ((c1) | 0x80, (c2) | 0x80); \ | |
| 3563 break; \ | |
| 3564 } \ | |
| 3565 else \ | |
| 3566 /* Since CHARSET is not yet invoked to any graphic planes, we \ | |
| 3567 must invoke it, or, at first, designate it to some graphic \ | |
| 3568 register. Then repeat the loop to actually produce the \ | |
| 3569 character. */ \ | |
| 3570 dst = encode_invocation_designation (charset, coding, dst, \ | |
| 3571 &produced_chars); \ | |
| 3572 } while (1) | |
| 3573 | |
| 3574 | |
| 3575 #define ENCODE_ISO_CHARACTER(charset, c) \ | |
| 3576 do { \ | |
| 3577 int code = ENCODE_CHAR ((charset),(c)); \ | |
| 3578 \ | |
| 3579 if (CHARSET_DIMENSION (charset) == 1) \ | |
| 3580 ENCODE_ISO_CHARACTER_DIMENSION1 ((charset), code); \ | |
| 3581 else \ | |
| 3582 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
|
3583 } while (0) |
|
17725
92f042f73be2
(Valternate_charset_table): The valiable deleted.
Kenichi Handa <handa@m17n.org>
parents:
17717
diff
changeset
|
3584 |
|
30487
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
3585 |
| 17052 | 3586 /* Produce designation and invocation codes at a place pointed by DST |
| 88365 | 3587 to use CHARSET. The element `spec.iso_2022' of *CODING is updated. |
| 17052 | 3588 Return new DST. */ |
| 3589 | |
| 3590 unsigned char * | |
| 88365 | 3591 encode_invocation_designation (charset, coding, dst, p_nchars) |
| 3592 struct charset *charset; | |
| 17052 | 3593 struct coding_system *coding; |
| 3594 unsigned char *dst; | |
| 88365 | 3595 int *p_nchars; |
| 17052 | 3596 { |
| 88365 | 3597 int multibytep = coding->dst_multibyte; |
| 3598 int produced_chars = *p_nchars; | |
| 17052 | 3599 int reg; /* graphic register number */ |
| 88365 | 3600 int id = CHARSET_ID (charset); |
| 17052 | 3601 |
| 3602 /* At first, check designations. */ | |
| 3603 for (reg = 0; reg < 4; reg++) | |
| 88365 | 3604 if (id == CODING_ISO_DESIGNATION (coding, reg)) |
| 17052 | 3605 break; |
| 3606 | |
| 3607 if (reg >= 4) | |
| 3608 { | |
| 3609 /* CHARSET is not yet designated to any graphic registers. */ | |
| 3610 /* At first check the requested designation. */ | |
| 88365 | 3611 reg = CODING_ISO_REQUEST (coding, id); |
| 3612 if (reg < 0) | |
|
18002
a14261786239
(encode_invocation_designation): Use macro
Kenichi Handa <handa@m17n.org>
parents:
17835
diff
changeset
|
3613 /* Since CHARSET requests no special designation, designate it |
|
a14261786239
(encode_invocation_designation): Use macro
Kenichi Handa <handa@m17n.org>
parents:
17835
diff
changeset
|
3614 to graphic register 0. */ |
| 17052 | 3615 reg = 0; |
| 3616 | |
| 3617 ENCODE_DESIGNATION (charset, reg, coding); | |
| 3618 } | |
| 3619 | |
| 88365 | 3620 if (CODING_ISO_INVOCATION (coding, 0) != reg |
| 3621 && CODING_ISO_INVOCATION (coding, 1) != reg) | |
| 17052 | 3622 { |
| 3623 /* Since the graphic register REG is not invoked to any graphic | |
| 3624 planes, invoke it to graphic plane 0. */ | |
| 3625 switch (reg) | |
| 3626 { | |
| 3627 case 0: /* graphic register 0 */ | |
| 3628 ENCODE_SHIFT_IN; | |
| 3629 break; | |
| 3630 | |
| 3631 case 1: /* graphic register 1 */ | |
| 3632 ENCODE_SHIFT_OUT; | |
| 3633 break; | |
| 3634 | |
| 3635 case 2: /* graphic register 2 */ | |
| 88365 | 3636 if (CODING_ISO_FLAGS (coding) & CODING_ISO_FLAG_SINGLE_SHIFT) |
| 17052 | 3637 ENCODE_SINGLE_SHIFT_2; |
| 3638 else | |
| 3639 ENCODE_LOCKING_SHIFT_2; | |
| 3640 break; | |
| 3641 | |
| 3642 case 3: /* graphic register 3 */ | |
| 88365 | 3643 if (CODING_ISO_FLAGS (coding) & CODING_ISO_FLAG_SINGLE_SHIFT) |
| 17052 | 3644 ENCODE_SINGLE_SHIFT_3; |
| 3645 else | |
| 3646 ENCODE_LOCKING_SHIFT_3; | |
| 3647 break; | |
| 3648 } | |
| 3649 } | |
|
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3650 |
| 88365 | 3651 *p_nchars = produced_chars; |
| 17052 | 3652 return dst; |
| 3653 } | |
| 3654 | |
| 3655 /* The following three macros produce codes for indicating direction | |
| 3656 of text. */ | |
| 88365 | 3657 #define ENCODE_CONTROL_SEQUENCE_INTRODUCER \ |
| 3658 do { \ | |
| 3659 if (CODING_ISO_FLAGS (coding) == CODING_ISO_FLAG_SEVEN_BITS) \ | |
| 3660 EMIT_TWO_ASCII_BYTES (ISO_CODE_ESC, '['); \ | |
| 3661 else \ | |
| 3662 EMIT_ONE_BYTE (ISO_CODE_CSI); \ | |
| 17052 | 3663 } while (0) |
| 3664 | |
| 88365 | 3665 |
| 3666 #define ENCODE_DIRECTION_R2L() \ | |
| 3667 do { \ | |
| 3668 ENCODE_CONTROL_SEQUENCE_INTRODUCER (dst); \ | |
| 3669 EMIT_TWO_ASCII_BYTES ('2', ']'); \ | |
| 3670 } while (0) | |
| 3671 | |
| 3672 | |
| 3673 #define ENCODE_DIRECTION_L2R() \ | |
| 3674 do { \ | |
| 3675 ENCODE_CONTROL_SEQUENCE_INTRODUCER (dst); \ | |
| 3676 EMIT_TWO_ASCII_BYTES ('0', ']'); \ | |
| 3677 } while (0) | |
| 3678 | |
| 17052 | 3679 |
| 3680 /* Produce codes for designation and invocation to reset the graphic | |
| 3681 planes and registers to initial state. */ | |
| 88365 | 3682 #define ENCODE_RESET_PLANE_AND_REGISTER() \ |
| 3683 do { \ | |
| 3684 int reg; \ | |
| 3685 struct charset *charset; \ | |
| 3686 \ | |
| 3687 if (CODING_ISO_INVOCATION (coding, 0) != 0) \ | |
| 3688 ENCODE_SHIFT_IN; \ | |
| 3689 for (reg = 0; reg < 4; reg++) \ | |
| 3690 if (CODING_ISO_INITIAL (coding, reg) >= 0 \ | |
| 3691 && (CODING_ISO_DESIGNATION (coding, reg) \ | |
| 3692 != CODING_ISO_INITIAL (coding, reg))) \ | |
| 3693 { \ | |
| 3694 charset = CHARSET_FROM_ID (CODING_ISO_INITIAL (coding, reg)); \ | |
| 3695 ENCODE_DESIGNATION (charset, reg, coding); \ | |
| 3696 } \ | |
| 17052 | 3697 } while (0) |
| 3698 | |
| 88365 | 3699 |
|
17725
92f042f73be2
(Valternate_charset_table): The valiable deleted.
Kenichi Handa <handa@m17n.org>
parents:
17717
diff
changeset
|
3700 /* 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
|
3701 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
|
3702 |
|
92f042f73be2
(Valternate_charset_table): The valiable deleted.
Kenichi Handa <handa@m17n.org>
parents:
17717
diff
changeset
|
3703 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
|
3704 find all the necessary designations. */ |
|
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3705 |
|
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3706 static unsigned char * |
| 88365 | 3707 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
|
3708 struct coding_system *coding; |
| 88365 | 3709 int *charbuf, *charbuf_end; |
| 3710 unsigned char *dst; | |
|
17119
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
3711 { |
| 88365 | 3712 struct charset *charset; |
|
17725
92f042f73be2
(Valternate_charset_table): The valiable deleted.
Kenichi Handa <handa@m17n.org>
parents:
17717
diff
changeset
|
3713 /* 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
|
3714 int r[4]; |
| 88365 | 3715 int c, found = 0, reg; |
| 3716 int produced_chars = 0; | |
| 3717 int multibytep = coding->dst_multibyte; | |
| 3718 Lisp_Object attrs; | |
| 3719 Lisp_Object charset_list; | |
| 3720 | |
| 3721 attrs = CODING_ID_ATTRS (coding->id); | |
| 3722 charset_list = CODING_ATTR_CHARSET_LIST (attrs); | |
| 3723 if (EQ (charset_list, Qiso_2022)) | |
| 3724 charset_list = Viso_2022_charset_list; | |
|
17725
92f042f73be2
(Valternate_charset_table): The valiable deleted.
Kenichi Handa <handa@m17n.org>
parents:
17717
diff
changeset
|
3725 |
|
92f042f73be2
(Valternate_charset_table): The valiable deleted.
Kenichi Handa <handa@m17n.org>
parents:
17717
diff
changeset
|
3726 for (reg = 0; reg < 4; reg++) |
|
92f042f73be2
(Valternate_charset_table): The valiable deleted.
Kenichi Handa <handa@m17n.org>
parents:
17717
diff
changeset
|
3727 r[reg] = -1; |
|
92f042f73be2
(Valternate_charset_table): The valiable deleted.
Kenichi Handa <handa@m17n.org>
parents:
17717
diff
changeset
|
3728 |
|
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3729 while (found < 4) |
|
17119
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
3730 { |
| 88365 | 3731 int id; |
| 3732 | |
| 3733 c = *charbuf++; | |
|
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3734 if (c == '\n') |
|
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3735 break; |
| 88365 | 3736 charset = char_charset (c, charset_list, NULL); |
| 3737 id = CHARSET_ID (charset); | |
| 3738 reg = CODING_ISO_REQUEST (coding, id); | |
| 3739 if (reg >= 0 && r[reg] < 0) | |
|
17725
92f042f73be2
(Valternate_charset_table): The valiable deleted.
Kenichi Handa <handa@m17n.org>
parents:
17717
diff
changeset
|
3740 { |
|
92f042f73be2
(Valternate_charset_table): The valiable deleted.
Kenichi Handa <handa@m17n.org>
parents:
17717
diff
changeset
|
3741 found++; |
| 88365 | 3742 r[reg] = id; |
|
17119
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
3743 } |
|
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
3744 } |
|
17725
92f042f73be2
(Valternate_charset_table): The valiable deleted.
Kenichi Handa <handa@m17n.org>
parents:
17717
diff
changeset
|
3745 |
|
92f042f73be2
(Valternate_charset_table): The valiable deleted.
Kenichi Handa <handa@m17n.org>
parents:
17717
diff
changeset
|
3746 if (found) |
|
92f042f73be2
(Valternate_charset_table): The valiable deleted.
Kenichi Handa <handa@m17n.org>
parents:
17717
diff
changeset
|
3747 { |
|
92f042f73be2
(Valternate_charset_table): The valiable deleted.
Kenichi Handa <handa@m17n.org>
parents:
17717
diff
changeset
|
3748 for (reg = 0; reg < 4; reg++) |
|
92f042f73be2
(Valternate_charset_table): The valiable deleted.
Kenichi Handa <handa@m17n.org>
parents:
17717
diff
changeset
|
3749 if (r[reg] >= 0 |
| 88365 | 3750 && CODING_ISO_DESIGNATION (coding, reg) != r[reg]) |
| 3751 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
|
3752 } |
|
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3753 |
|
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3754 return dst; |
|
17119
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
3755 } |
|
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
3756 |
| 17052 | 3757 /* See the above "GENERAL NOTES on `encode_coding_XXX ()' functions". */ |
| 3758 | |
| 88365 | 3759 static int |
| 3760 encode_coding_iso_2022 (coding) | |
| 17052 | 3761 struct coding_system *coding; |
| 3762 { | |
| 88365 | 3763 int multibytep = coding->dst_multibyte; |
| 3764 int *charbuf = coding->charbuf; | |
| 3765 int *charbuf_end = charbuf + coding->charbuf_used; | |
| 3766 unsigned char *dst = coding->destination + coding->produced; | |
| 3767 unsigned char *dst_end = coding->destination + coding->dst_bytes; | |
| 3768 int safe_room = 16; | |
| 3769 int bol_designation | |
| 3770 = (CODING_ISO_FLAGS (coding) & CODING_ISO_FLAG_DESIGNATE_AT_BOL | |
| 3771 && CODING_ISO_BOL (coding)); | |
| 3772 int produced_chars = 0; | |
| 3773 Lisp_Object attrs, eol_type, charset_list; | |
| 3774 int ascii_compatible; | |
|
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3775 int c; |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3776 int preferred_charset_id = -1; |
| 88365 | 3777 |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
3778 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
|
3779 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
|
3780 if (VECTORP (eol_type)) |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
3781 eol_type = Qunix; |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
3782 |
|
88497
d2b9e0d4c2f6
(Fdecode_sjis_char): Fix typo (0x7F->0xFF). Fix the
Kenichi Handa <handa@m17n.org>
parents:
88485
diff
changeset
|
3783 setup_iso_safe_charsets (attrs); |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3784 /* Charset list may have been changed. */ |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3785 charset_list = CODING_ATTR_CHARSET_LIST (attrs); \ |
| 89483 | 3786 coding->safe_charsets = (char *) SDATA (CODING_ATTR_SAFE_CHARSETS(attrs)); |
| 88365 | 3787 |
| 3788 ascii_compatible = ! NILP (CODING_ATTR_ASCII_COMPAT (attrs)); | |
| 3789 | |
| 3790 while (charbuf < charbuf_end) | |
| 3791 { | |
| 3792 ASSURE_DESTINATION (safe_room); | |
| 3793 | |
| 3794 if (bol_designation) | |
|
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3795 { |
| 88365 | 3796 unsigned char *dst_prev = dst; |
| 3797 | |
|
17725
92f042f73be2
(Valternate_charset_table): The valiable deleted.
Kenichi Handa <handa@m17n.org>
parents:
17717
diff
changeset
|
3798 /* We have to produce designation sequences if any now. */ |
| 88365 | 3799 dst = encode_designation_at_bol (coding, charbuf, charbuf_end, dst); |
| 3800 bol_designation = 0; | |
| 3801 /* We are sure that designation sequences are all ASCII bytes. */ | |
| 3802 produced_chars += dst - dst_prev; | |
|
17119
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
3803 } |
|
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
3804 |
| 88365 | 3805 c = *charbuf++; |
|
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3806 |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3807 if (c < 0) |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3808 { |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3809 /* Handle an annotation. */ |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3810 switch (*charbuf) |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3811 { |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3812 case CODING_ANNOTATE_COMPOSITION_MASK: |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3813 /* Not yet implemented. */ |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3814 break; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3815 case CODING_ANNOTATE_CHARSET_MASK: |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3816 preferred_charset_id = charbuf[3]; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3817 if (preferred_charset_id >= 0 |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3818 && NILP (Fmemq (make_number (preferred_charset_id), |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3819 charset_list))) |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3820 preferred_charset_id = -1; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3821 break; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3822 default: |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3823 abort (); |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3824 } |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3825 charbuf += -c - 1; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3826 continue; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3827 } |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3828 |
|
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3829 /* 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
|
3830 if (c < 0x20 || c == 0x7F) |
| 17052 | 3831 { |
| 88365 | 3832 if (c == '\n' |
| 3833 || (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
|
3834 { |
| 88365 | 3835 if (CODING_ISO_FLAGS (coding) & CODING_ISO_FLAG_RESET_AT_EOL) |
| 3836 ENCODE_RESET_PLANE_AND_REGISTER (); | |
| 3837 if (CODING_ISO_FLAGS (coding) & CODING_ISO_FLAG_INIT_AT_BOL) | |
| 3838 { | |
| 3839 int i; | |
| 3840 | |
| 3841 for (i = 0; i < 4; i++) | |
| 3842 CODING_ISO_DESIGNATION (coding, i) | |
| 3843 = CODING_ISO_INITIAL (coding, i); | |
| 3844 } | |
| 3845 bol_designation | |
| 3846 = 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
|
3847 } |
| 88365 | 3848 else if (CODING_ISO_FLAGS (coding) & CODING_ISO_FLAG_RESET_AT_CNTL) |
| 3849 ENCODE_RESET_PLANE_AND_REGISTER (); | |
| 3850 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
|
3851 } |
| 88365 | 3852 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
|
3853 { |
| 88365 | 3854 if (ascii_compatible) |
| 3855 EMIT_ONE_ASCII_BYTE (c); | |
| 3856 else | |
|
88681
2cdfbffa8a0d
(CODING_ISO_FLAG_USE_ROMAN): New macro
Kenichi Handa <handa@m17n.org>
parents:
88669
diff
changeset
|
3857 { |
|
2cdfbffa8a0d
(CODING_ISO_FLAG_USE_ROMAN): New macro
Kenichi Handa <handa@m17n.org>
parents:
88669
diff
changeset
|
3858 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
|
3859 ENCODE_ISO_CHARACTER (charset, c); |
|
2cdfbffa8a0d
(CODING_ISO_FLAG_USE_ROMAN): New macro
Kenichi Handa <handa@m17n.org>
parents:
88669
diff
changeset
|
3860 } |
| 17052 | 3861 } |
|
88690
7f284ac55b07
(encode_coding_emacs_mule): Pay attention to raw-8-bit chars.
Kenichi Handa <handa@m17n.org>
parents:
88681
diff
changeset
|
3862 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
|
3863 { |
|
7f284ac55b07
(encode_coding_emacs_mule): Pay attention to raw-8-bit chars.
Kenichi Handa <handa@m17n.org>
parents:
88681
diff
changeset
|
3864 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
|
3865 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
|
3866 } |
|
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3867 else |
| 88365 | 3868 { |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3869 struct charset *charset; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3870 |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3871 if (preferred_charset_id >= 0) |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3872 { |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3873 charset = CHARSET_FROM_ID (preferred_charset_id); |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3874 if (! CHAR_CHARSET_P (c, charset)) |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3875 charset = char_charset (c, charset_list, NULL); |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3876 } |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3877 else |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3878 charset = char_charset (c, charset_list, NULL); |
| 88365 | 3879 if (!charset) |
| 3880 { | |
|
88573
133bf7ab1bad
(encode_coding_iso_2022): If coding requires safe
Kenichi Handa <handa@m17n.org>
parents:
88544
diff
changeset
|
3881 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
|
3882 { |
|
133bf7ab1bad
(encode_coding_iso_2022): If coding requires safe
Kenichi Handa <handa@m17n.org>
parents:
88544
diff
changeset
|
3883 c = CODING_INHIBIT_CHARACTER_SUBSTITUTION; |
|
133bf7ab1bad
(encode_coding_iso_2022): If coding requires safe
Kenichi Handa <handa@m17n.org>
parents:
88544
diff
changeset
|
3884 charset = CHARSET_FROM_ID (charset_ascii); |
|
133bf7ab1bad
(encode_coding_iso_2022): If coding requires safe
Kenichi Handa <handa@m17n.org>
parents:
88544
diff
changeset
|
3885 } |
|
133bf7ab1bad
(encode_coding_iso_2022): If coding requires safe
Kenichi Handa <handa@m17n.org>
parents:
88544
diff
changeset
|
3886 else |
|
133bf7ab1bad
(encode_coding_iso_2022): If coding requires safe
Kenichi Handa <handa@m17n.org>
parents:
88544
diff
changeset
|
3887 { |
|
133bf7ab1bad
(encode_coding_iso_2022): If coding requires safe
Kenichi Handa <handa@m17n.org>
parents:
88544
diff
changeset
|
3888 c = coding->default_char; |
|
133bf7ab1bad
(encode_coding_iso_2022): If coding requires safe
Kenichi Handa <handa@m17n.org>
parents:
88544
diff
changeset
|
3889 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
|
3890 } |
| 88365 | 3891 } |
| 3892 ENCODE_ISO_CHARACTER (charset, c); | |
| 3893 } | |
| 3894 } | |
| 3895 | |
| 3896 if (coding->mode & CODING_MODE_LAST_BLOCK | |
| 3897 && CODING_ISO_FLAGS (coding) & CODING_ISO_FLAG_RESET_AT_EOL) | |
| 3898 { | |
| 3899 ASSURE_DESTINATION (safe_room); | |
| 3900 ENCODE_RESET_PLANE_AND_REGISTER (); | |
| 3901 } | |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
3902 record_conversion_result (coding, CODING_RESULT_SUCCESS); |
| 88365 | 3903 CODING_ISO_BOL (coding) = bol_designation; |
| 3904 coding->produced_char += produced_chars; | |
| 3905 coding->produced = dst - coding->destination; | |
| 3906 return 0; | |
| 17052 | 3907 } |
| 3908 | |
| 3909 | |
| 88365 | 3910 /*** 8,9. SJIS and BIG5 handlers ***/ |
| 3911 | |
| 3912 /* Although SJIS and BIG5 are not ISO's coding system, they are used | |
| 17052 | 3913 quite widely. So, for the moment, Emacs supports them in the bare |
| 3914 C code. But, in the future, they may be supported only by CCL. */ | |
| 3915 | |
| 3916 /* SJIS is a coding system encoding three character sets: ASCII, right | |
| 3917 half of JISX0201-Kana, and JISX0208. An ASCII character is encoded | |
| 3918 as is. A character of charset katakana-jisx0201 is encoded by | |
| 3919 "position-code + 0x80". A character of charset japanese-jisx0208 | |
| 3920 is encoded in 2-byte but two position-codes are divided and shifted | |
| 88365 | 3921 so that it fit in the range below. |
| 17052 | 3922 |
| 3923 --- CODE RANGE of SJIS --- | |
| 3924 (character set) (range) | |
| 3925 ASCII 0x00 .. 0x7F | |
| 88365 | 3926 KATAKANA-JISX0201 0xA0 .. 0xDF |
|
24324
2eec590faf26
(Fdecode_sjis_char, Fencode_sjis_char): Hanlde
Kenichi Handa <handa@m17n.org>
parents:
24316
diff
changeset
|
3927 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
|
3928 (2nd byte) 0x40 .. 0x7E and 0x80 .. 0xFC |
| 17052 | 3929 ------------------------------- |
| 3930 | |
| 3931 */ | |
| 3932 | |
| 3933 /* BIG5 is a coding system encoding two character sets: ASCII and | |
| 3934 Big5. An ASCII character is encoded as is. Big5 is a two-byte | |
| 88365 | 3935 character set and is encoded in two-byte. |
| 17052 | 3936 |
| 3937 --- CODE RANGE of BIG5 --- | |
| 3938 (character set) (range) | |
| 3939 ASCII 0x00 .. 0x7F | |
| 3940 Big5 (1st byte) 0xA1 .. 0xFE | |
| 3941 (2nd byte) 0x40 .. 0x7E and 0xA1 .. 0xFE | |
| 3942 -------------------------- | |
| 3943 | |
| 88365 | 3944 */ |
| 17052 | 3945 |
| 3946 /* See the above "GENERAL NOTES on `detect_coding_XXX ()' functions". | |
| 3947 Check if a text is encoded in SJIS. If it is, return | |
| 88365 | 3948 CATEGORY_MASK_SJIS, else return 0. */ |
| 17052 | 3949 |
|
34531
37f85e931855
(ONE_MORE_BYTE_CHECK_MULTIBYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34197
diff
changeset
|
3950 static int |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3951 detect_coding_sjis (coding, detect_info) |
| 88365 | 3952 struct coding_system *coding; |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3953 struct coding_detection_info *detect_info; |
| 17052 | 3954 { |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
3955 const unsigned char *src = coding->source, *src_base; |
| 89483 | 3956 const unsigned char *src_end = coding->source + coding->src_bytes; |
| 88365 | 3957 int multibytep = coding->src_multibyte; |
| 3958 int consumed_chars = 0; | |
| 3959 int found = 0; | |
|
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3960 int c; |
| 88365 | 3961 |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3962 detect_info->checked |= CATEGORY_MASK_SJIS; |
| 88365 | 3963 /* A coding system of this category is always ASCII compatible. */ |
| 3964 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
|
3965 |
|
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
3966 while (1) |
| 17052 | 3967 { |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
3968 src_base = src; |
| 88365 | 3969 ONE_MORE_BYTE (c); |
|
36647
0a75ccbe42b2
(detect_coding_sjis): Do more rigid check.
Kenichi Handa <handa@m17n.org>
parents:
36520
diff
changeset
|
3970 if (c < 0x80) |
|
0a75ccbe42b2
(detect_coding_sjis): Do more rigid check.
Kenichi Handa <handa@m17n.org>
parents:
36520
diff
changeset
|
3971 continue; |
| 88365 | 3972 if ((c >= 0x81 && c <= 0x9F) || (c >= 0xE0 && c <= 0xEF)) |
| 17052 | 3973 { |
| 88365 | 3974 ONE_MORE_BYTE (c); |
|
36647
0a75ccbe42b2
(detect_coding_sjis): Do more rigid check.
Kenichi Handa <handa@m17n.org>
parents:
36520
diff
changeset
|
3975 if (c < 0x40 || c == 0x7F || c > 0xFC) |
| 88365 | 3976 break; |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3977 found = CATEGORY_MASK_SJIS; |
| 17052 | 3978 } |
| 88365 | 3979 else if (c >= 0xA0 && c < 0xE0) |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3980 found = CATEGORY_MASK_SJIS; |
| 88365 | 3981 else |
| 3982 break; | |
| 3983 } | |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3984 detect_info->rejected |= CATEGORY_MASK_SJIS; |
| 88365 | 3985 return 0; |
| 3986 | |
| 3987 no_more_source: | |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
3988 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
|
3989 { |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3990 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
|
3991 return 0; |
|
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
3992 } |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3993 detect_info->found |= found; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
3994 return 1; |
| 17052 | 3995 } |
| 3996 | |
| 3997 /* See the above "GENERAL NOTES on `detect_coding_XXX ()' functions". | |
| 3998 Check if a text is encoded in BIG5. If it is, return | |
| 88365 | 3999 CATEGORY_MASK_BIG5, else return 0. */ |
| 17052 | 4000 |
|
34531
37f85e931855
(ONE_MORE_BYTE_CHECK_MULTIBYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34197
diff
changeset
|
4001 static int |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
4002 detect_coding_big5 (coding, detect_info) |
| 88365 | 4003 struct coding_system *coding; |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
4004 struct coding_detection_info *detect_info; |
| 17052 | 4005 { |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
4006 const unsigned char *src = coding->source, *src_base; |
| 89483 | 4007 const unsigned char *src_end = coding->source + coding->src_bytes; |
| 88365 | 4008 int multibytep = coding->src_multibyte; |
| 4009 int consumed_chars = 0; | |
| 4010 int found = 0; | |
|
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4011 int c; |
| 88365 | 4012 |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
4013 detect_info->checked |= CATEGORY_MASK_BIG5; |
| 88365 | 4014 /* A coding system of this category is always ASCII compatible. */ |
| 4015 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
|
4016 |
|
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4017 while (1) |
|
28022
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
4018 { |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
4019 src_base = src; |
| 88365 | 4020 ONE_MORE_BYTE (c); |
| 4021 if (c < 0x80) | |
|
28022
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
4022 continue; |
| 88365 | 4023 if (c >= 0xA1) |
|
28022
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
4024 { |
| 88365 | 4025 ONE_MORE_BYTE (c); |
| 4026 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
|
4027 return 0; |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
4028 found = CATEGORY_MASK_BIG5; |
|
28022
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
4029 } |
| 88365 | 4030 else |
| 4031 break; | |
| 4032 } | |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
4033 detect_info->rejected |= CATEGORY_MASK_BIG5; |
|
28022
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
4034 return 0; |
| 88365 | 4035 |
| 4036 no_more_source: | |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
4037 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
|
4038 { |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
4039 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
|
4040 return 0; |
|
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
4041 } |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
4042 detect_info->found |= found; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
4043 return 1; |
|
28022
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
4044 } |
|
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
4045 |
| 17052 | 4046 /* See the above "GENERAL NOTES on `decode_coding_XXX ()' functions". |
| 4047 If SJIS_P is 1, decode SJIS text, else decode BIG5 test. */ | |
| 4048 | |
|
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4049 static void |
| 88365 | 4050 decode_coding_sjis (coding) |
| 17052 | 4051 struct coding_system *coding; |
| 4052 { | |
| 89483 | 4053 const unsigned char *src = coding->source + coding->consumed; |
| 4054 const unsigned char *src_end = coding->source + coding->src_bytes; | |
| 4055 const unsigned char *src_base; | |
|
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
4056 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
|
4057 int *charbuf_end |
|
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
4058 = coding->charbuf + coding->charbuf_size - MAX_ANNOTATION_LENGTH; |
| 88365 | 4059 int consumed_chars = 0, consumed_chars_base; |
| 4060 int multibytep = coding->src_multibyte; | |
| 4061 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
|
4062 struct charset *charset_kanji2; |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4063 Lisp_Object attrs, charset_list, val; |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
4064 int char_offset = coding->produced_char; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
4065 int last_offset = char_offset; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
4066 int last_id = charset_ascii; |
| 88365 | 4067 |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4068 CODING_GET_INFO (coding, attrs, charset_list); |
| 88365 | 4069 |
| 4070 val = charset_list; | |
| 4071 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
|
4072 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
|
4073 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
|
4074 charset_kanji2 = NILP (val) ? NULL : CHARSET_FROM_ID (XINT (XCAR (val))); |
| 88365 | 4075 |
|
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4076 while (1) |
| 17052 | 4077 { |
| 88365 | 4078 int c, c1; |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4079 struct charset *charset; |
|
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4080 |
|
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4081 src_base = src; |
| 88365 | 4082 consumed_chars_base = consumed_chars; |
| 4083 | |
| 4084 if (charbuf >= charbuf_end) | |
| 4085 break; | |
| 4086 | |
| 4087 ONE_MORE_BYTE (c); | |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
4088 if (c < 0) |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
4089 goto invalid_code; |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4090 if (c < 0x80) |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4091 charset = charset_roman; |
|
89764
e3d26232ab78
(decode_coding_sjis): Handle 4th charset (typically JISX0212).
Kenichi Handa <handa@m17n.org>
parents:
89759
diff
changeset
|
4092 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
|
4093 goto invalid_code; |
|
89764
e3d26232ab78
(decode_coding_sjis): Handle 4th charset (typically JISX0212).
Kenichi Handa <handa@m17n.org>
parents:
89759
diff
changeset
|
4094 else if (c >= 0xA1 && c <= 0xDF) |
|
e3d26232ab78
(decode_coding_sjis): Handle 4th charset (typically JISX0212).
Kenichi Handa <handa@m17n.org>
parents:
89759
diff
changeset
|
4095 { |
|
e3d26232ab78
(decode_coding_sjis): Handle 4th charset (typically JISX0212).
Kenichi Handa <handa@m17n.org>
parents:
89759
diff
changeset
|
4096 /* SJIS -> JISX0201-Kana */ |
|
e3d26232ab78
(decode_coding_sjis): Handle 4th charset (typically JISX0212).
Kenichi Handa <handa@m17n.org>
parents:
89759
diff
changeset
|
4097 c &= 0x7F; |
|
e3d26232ab78
(decode_coding_sjis): Handle 4th charset (typically JISX0212).
Kenichi Handa <handa@m17n.org>
parents:
89759
diff
changeset
|
4098 charset = charset_kana; |
|
e3d26232ab78
(decode_coding_sjis): Handle 4th charset (typically JISX0212).
Kenichi Handa <handa@m17n.org>
parents:
89759
diff
changeset
|
4099 } |
|
e3d26232ab78
(decode_coding_sjis): Handle 4th charset (typically JISX0212).
Kenichi Handa <handa@m17n.org>
parents:
89759
diff
changeset
|
4100 else if (c <= 0xEF) |
|
e3d26232ab78
(decode_coding_sjis): Handle 4th charset (typically JISX0212).
Kenichi Handa <handa@m17n.org>
parents:
89759
diff
changeset
|
4101 { |
|
e3d26232ab78
(decode_coding_sjis): Handle 4th charset (typically JISX0212).
Kenichi Handa <handa@m17n.org>
parents:
89759
diff
changeset
|
4102 /* SJIS -> JISX0208 */ |
|
e3d26232ab78
(decode_coding_sjis): Handle 4th charset (typically JISX0212).
Kenichi Handa <handa@m17n.org>
parents:
89759
diff
changeset
|
4103 ONE_MORE_BYTE (c1); |
|
e3d26232ab78
(decode_coding_sjis): Handle 4th charset (typically JISX0212).
Kenichi Handa <handa@m17n.org>
parents:
89759
diff
changeset
|
4104 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
|
4105 goto invalid_code; |
|
89764
e3d26232ab78
(decode_coding_sjis): Handle 4th charset (typically JISX0212).
Kenichi Handa <handa@m17n.org>
parents:
89759
diff
changeset
|
4106 c = (c << 8) | c1; |
|
e3d26232ab78
(decode_coding_sjis): Handle 4th charset (typically JISX0212).
Kenichi Handa <handa@m17n.org>
parents:
89759
diff
changeset
|
4107 SJIS_TO_JIS (c); |
|
e3d26232ab78
(decode_coding_sjis): Handle 4th charset (typically JISX0212).
Kenichi Handa <handa@m17n.org>
parents:
89759
diff
changeset
|
4108 charset = charset_kanji; |
|
e3d26232ab78
(decode_coding_sjis): Handle 4th charset (typically JISX0212).
Kenichi Handa <handa@m17n.org>
parents:
89759
diff
changeset
|
4109 } |
|
e3d26232ab78
(decode_coding_sjis): Handle 4th charset (typically JISX0212).
Kenichi Handa <handa@m17n.org>
parents:
89759
diff
changeset
|
4110 else if (c <= 0xFC && charset_kanji2) |
|
e3d26232ab78
(decode_coding_sjis): Handle 4th charset (typically JISX0212).
Kenichi Handa <handa@m17n.org>
parents:
89759
diff
changeset
|
4111 { |
|
89779
74c503490829
(decode_coding_sjis): Fix comment.
Kenichi Handa <handa@m17n.org>
parents:
89764
diff
changeset
|
4112 /* SJIS -> JISX0213-2 */ |
|
89764
e3d26232ab78
(decode_coding_sjis): Handle 4th charset (typically JISX0212).
Kenichi Handa <handa@m17n.org>
parents:
89759
diff
changeset
|
4113 ONE_MORE_BYTE (c1); |
|
e3d26232ab78
(decode_coding_sjis): Handle 4th charset (typically JISX0212).
Kenichi Handa <handa@m17n.org>
parents:
89759
diff
changeset
|
4114 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
|
4115 goto invalid_code; |
|
89764
e3d26232ab78
(decode_coding_sjis): Handle 4th charset (typically JISX0212).
Kenichi Handa <handa@m17n.org>
parents:
89759
diff
changeset
|
4116 c = (c << 8) | c1; |
|
e3d26232ab78
(decode_coding_sjis): Handle 4th charset (typically JISX0212).
Kenichi Handa <handa@m17n.org>
parents:
89759
diff
changeset
|
4117 SJIS_TO_JIS2 (c); |
|
e3d26232ab78
(decode_coding_sjis): Handle 4th charset (typically JISX0212).
Kenichi Handa <handa@m17n.org>
parents:
89759
diff
changeset
|
4118 charset = charset_kanji2; |
|
e3d26232ab78
(decode_coding_sjis): Handle 4th charset (typically JISX0212).
Kenichi Handa <handa@m17n.org>
parents:
89759
diff
changeset
|
4119 } |
|
e3d26232ab78
(decode_coding_sjis): Handle 4th charset (typically JISX0212).
Kenichi Handa <handa@m17n.org>
parents:
89759
diff
changeset
|
4120 else |
|
e3d26232ab78
(decode_coding_sjis): Handle 4th charset (typically JISX0212).
Kenichi Handa <handa@m17n.org>
parents:
89759
diff
changeset
|
4121 goto invalid_code; |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4122 if (charset->id != charset_ascii |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4123 && last_id != charset->id) |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4124 { |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4125 if (last_id != charset_ascii) |
|
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
4126 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
|
4127 last_id = charset->id; |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4128 last_offset = char_offset; |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4129 } |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4130 CODING_DECODE_CHAR (coding, src, src_base, src_end, charset, c, c); |
| 88365 | 4131 *charbuf++ = c; |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
4132 char_offset++; |
| 88365 | 4133 continue; |
| 4134 | |
| 4135 invalid_code: | |
| 4136 src = src_base; | |
| 4137 consumed_chars = consumed_chars_base; | |
| 4138 ONE_MORE_BYTE (c); | |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
4139 *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
|
4140 char_offset++; |
| 88365 | 4141 coding->errors++; |
| 4142 } | |
| 4143 | |
| 4144 no_more_source: | |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
4145 if (last_id != charset_ascii) |
|
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
4146 ADD_CHARSET_DATA (charbuf, char_offset - last_offset, last_id); |
| 88365 | 4147 coding->consumed_char += consumed_chars_base; |
| 4148 coding->consumed = src_base - coding->source; | |
| 4149 coding->charbuf_used = charbuf - coding->charbuf; | |
| 4150 } | |
| 4151 | |
| 4152 static void | |
| 4153 decode_coding_big5 (coding) | |
| 4154 struct coding_system *coding; | |
| 4155 { | |
| 89483 | 4156 const unsigned char *src = coding->source + coding->consumed; |
| 4157 const unsigned char *src_end = coding->source + coding->src_bytes; | |
| 4158 const unsigned char *src_base; | |
|
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
4159 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
|
4160 int *charbuf_end |
|
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
4161 = coding->charbuf + coding->charbuf_size - MAX_ANNOTATION_LENGTH; |
| 88365 | 4162 int consumed_chars = 0, consumed_chars_base; |
| 4163 int multibytep = coding->src_multibyte; | |
| 4164 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
|
4165 Lisp_Object attrs, charset_list, val; |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
4166 int char_offset = coding->produced_char; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
4167 int last_offset = char_offset; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
4168 int last_id = charset_ascii; |
| 88365 | 4169 |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4170 CODING_GET_INFO (coding, attrs, charset_list); |
| 88365 | 4171 val = charset_list; |
| 4172 charset_roman = CHARSET_FROM_ID (XINT (XCAR (val))), val = XCDR (val); | |
| 4173 charset_big5 = CHARSET_FROM_ID (XINT (XCAR (val))); | |
| 4174 | |
| 4175 while (1) | |
| 4176 { | |
| 4177 int c, c1; | |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4178 struct charset *charset; |
| 88365 | 4179 |
| 4180 src_base = src; | |
| 4181 consumed_chars_base = consumed_chars; | |
| 4182 | |
| 4183 if (charbuf >= charbuf_end) | |
| 4184 break; | |
| 4185 | |
| 4186 ONE_MORE_BYTE (c); | |
| 4187 | |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
4188 if (c < 0) |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
4189 goto invalid_code; |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4190 if (c < 0x80) |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4191 charset = charset_roman; |
| 88365 | 4192 else |
| 4193 { | |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4194 /* BIG5 -> Big5 */ |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4195 if (c < 0xA1 || c > 0xFE) |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4196 goto invalid_code; |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4197 ONE_MORE_BYTE (c1); |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4198 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
|
4199 goto invalid_code; |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4200 c = c << 8 | c1; |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4201 charset = charset_big5; |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4202 } |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4203 if (charset->id != charset_ascii |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4204 && last_id != charset->id) |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4205 { |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4206 if (last_id != charset_ascii) |
|
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
4207 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
|
4208 last_id = charset->id; |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4209 last_offset = char_offset; |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4210 } |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4211 CODING_DECODE_CHAR (coding, src, src_base, src_end, charset, c, c); |
| 88365 | 4212 *charbuf++ = c; |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
4213 char_offset++; |
|
20931
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
4214 continue; |
|
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
4215 |
| 88365 | 4216 invalid_code: |
| 17052 | 4217 src = src_base; |
| 88365 | 4218 consumed_chars = consumed_chars_base; |
| 4219 ONE_MORE_BYTE (c); | |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
4220 *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
|
4221 char_offset++; |
| 88365 | 4222 coding->errors++; |
| 4223 } | |
| 4224 | |
| 4225 no_more_source: | |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
4226 if (last_id != charset_ascii) |
|
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
4227 ADD_CHARSET_DATA (charbuf, char_offset - last_offset, last_id); |
| 88365 | 4228 coding->consumed_char += consumed_chars_base; |
| 4229 coding->consumed = src_base - coding->source; | |
| 4230 coding->charbuf_used = charbuf - coding->charbuf; | |
| 17052 | 4231 } |
| 4232 | |
| 4233 /* 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
|
4234 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
|
4235 `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
|
4236 are sure that all these charsets are registered as official charset |
| 17052 | 4237 (i.e. do not have extended leading-codes). Characters of other |
| 4238 charsets are produced without any encoding. If SJIS_P is 1, encode | |
| 4239 SJIS text, else encode BIG5 text. */ | |
| 4240 | |
| 88365 | 4241 static int |
| 4242 encode_coding_sjis (coding) | |
| 17052 | 4243 struct coding_system *coding; |
| 4244 { | |
| 88365 | 4245 int multibytep = coding->dst_multibyte; |
| 4246 int *charbuf = coding->charbuf; | |
| 4247 int *charbuf_end = charbuf + coding->charbuf_used; | |
| 4248 unsigned char *dst = coding->destination + coding->produced; | |
| 4249 unsigned char *dst_end = coding->destination + coding->dst_bytes; | |
| 4250 int safe_room = 4; | |
| 4251 int produced_chars = 0; | |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4252 Lisp_Object attrs, charset_list, val; |
| 88365 | 4253 int ascii_compatible; |
| 4254 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
|
4255 struct charset *charset_kanji2; |
| 88365 | 4256 int c; |
| 4257 | |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4258 CODING_GET_INFO (coding, attrs, charset_list); |
| 88365 | 4259 val = charset_list; |
| 4260 charset_roman = CHARSET_FROM_ID (XINT (XCAR (val))), val = XCDR (val); | |
| 4261 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
|
4262 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
|
4263 charset_kanji2 = NILP (val) ? NULL : CHARSET_FROM_ID (XINT (XCAR (val))); |
| 88365 | 4264 |
| 4265 ascii_compatible = ! NILP (CODING_ATTR_ASCII_COMPAT (attrs)); | |
| 4266 | |
| 4267 while (charbuf < charbuf_end) | |
| 4268 { | |
| 4269 ASSURE_DESTINATION (safe_room); | |
| 4270 c = *charbuf++; | |
|
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4271 /* Now encode the character C. */ |
| 88365 | 4272 if (ASCII_CHAR_P (c) && ascii_compatible) |
| 4273 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
|
4274 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
|
4275 { |
|
7f284ac55b07
(encode_coding_emacs_mule): Pay attention to raw-8-bit chars.
Kenichi Handa <handa@m17n.org>
parents:
88681
diff
changeset
|
4276 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
|
4277 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
|
4278 } |
|
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4279 else |
|
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4280 { |
| 88365 | 4281 unsigned code; |
| 4282 struct charset *charset = char_charset (c, charset_list, &code); | |
| 4283 | |
| 4284 if (!charset) | |
| 4285 { | |
|
88573
133bf7ab1bad
(encode_coding_iso_2022): If coding requires safe
Kenichi Handa <handa@m17n.org>
parents:
88544
diff
changeset
|
4286 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
|
4287 { |
|
133bf7ab1bad
(encode_coding_iso_2022): If coding requires safe
Kenichi Handa <handa@m17n.org>
parents:
88544
diff
changeset
|
4288 code = CODING_INHIBIT_CHARACTER_SUBSTITUTION; |
|
133bf7ab1bad
(encode_coding_iso_2022): If coding requires safe
Kenichi Handa <handa@m17n.org>
parents:
88544
diff
changeset
|
4289 charset = CHARSET_FROM_ID (charset_ascii); |
|
133bf7ab1bad
(encode_coding_iso_2022): If coding requires safe
Kenichi Handa <handa@m17n.org>
parents:
88544
diff
changeset
|
4290 } |
|
133bf7ab1bad
(encode_coding_iso_2022): If coding requires safe
Kenichi Handa <handa@m17n.org>
parents:
88544
diff
changeset
|
4291 else |
|
133bf7ab1bad
(encode_coding_iso_2022): If coding requires safe
Kenichi Handa <handa@m17n.org>
parents:
88544
diff
changeset
|
4292 { |
|
133bf7ab1bad
(encode_coding_iso_2022): If coding requires safe
Kenichi Handa <handa@m17n.org>
parents:
88544
diff
changeset
|
4293 c = coding->default_char; |
|
133bf7ab1bad
(encode_coding_iso_2022): If coding requires safe
Kenichi Handa <handa@m17n.org>
parents:
88544
diff
changeset
|
4294 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
|
4295 } |
| 88365 | 4296 } |
| 4297 if (code == CHARSET_INVALID_CODE (charset)) | |
| 4298 abort (); | |
| 4299 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
|
4300 { |
| 88365 | 4301 int c1, c2; |
| 4302 JIS_TO_SJIS (code); | |
| 4303 c1 = code >> 8, c2 = code & 0xFF; | |
| 4304 EMIT_TWO_BYTES (c1, c2); | |
| 4305 } | |
| 4306 else if (charset == charset_kana) | |
| 4307 EMIT_ONE_BYTE (code | 0x80); | |
|
89764
e3d26232ab78
(decode_coding_sjis): Handle 4th charset (typically JISX0212).
Kenichi Handa <handa@m17n.org>
parents:
89759
diff
changeset
|
4308 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
|
4309 { |
|
e3d26232ab78
(decode_coding_sjis): Handle 4th charset (typically JISX0212).
Kenichi Handa <handa@m17n.org>
parents:
89759
diff
changeset
|
4310 int c1, c2; |
|
e3d26232ab78
(decode_coding_sjis): Handle 4th charset (typically JISX0212).
Kenichi Handa <handa@m17n.org>
parents:
89759
diff
changeset
|
4311 |
|
e3d26232ab78
(decode_coding_sjis): Handle 4th charset (typically JISX0212).
Kenichi Handa <handa@m17n.org>
parents:
89759
diff
changeset
|
4312 c1 = code >> 8; |
|
e3d26232ab78
(decode_coding_sjis): Handle 4th charset (typically JISX0212).
Kenichi Handa <handa@m17n.org>
parents:
89759
diff
changeset
|
4313 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
|
4314 || (c1 >= 0x2C && c1 <= 0x2F) || c1 >= 0x6E) |
|
e3d26232ab78
(decode_coding_sjis): Handle 4th charset (typically JISX0212).
Kenichi Handa <handa@m17n.org>
parents:
89759
diff
changeset
|
4315 { |
|
e3d26232ab78
(decode_coding_sjis): Handle 4th charset (typically JISX0212).
Kenichi Handa <handa@m17n.org>
parents:
89759
diff
changeset
|
4316 JIS_TO_SJIS2 (code); |
|
e3d26232ab78
(decode_coding_sjis): Handle 4th charset (typically JISX0212).
Kenichi Handa <handa@m17n.org>
parents:
89759
diff
changeset
|
4317 c1 = code >> 8, c2 = code & 0xFF; |
|
e3d26232ab78
(decode_coding_sjis): Handle 4th charset (typically JISX0212).
Kenichi Handa <handa@m17n.org>
parents:
89759
diff
changeset
|
4318 EMIT_TWO_BYTES (c1, c2); |
|
e3d26232ab78
(decode_coding_sjis): Handle 4th charset (typically JISX0212).
Kenichi Handa <handa@m17n.org>
parents:
89759
diff
changeset
|
4319 } |
|
e3d26232ab78
(decode_coding_sjis): Handle 4th charset (typically JISX0212).
Kenichi Handa <handa@m17n.org>
parents:
89759
diff
changeset
|
4320 else |
|
e3d26232ab78
(decode_coding_sjis): Handle 4th charset (typically JISX0212).
Kenichi Handa <handa@m17n.org>
parents:
89759
diff
changeset
|
4321 EMIT_ONE_ASCII_BYTE (code & 0x7F); |
|
e3d26232ab78
(decode_coding_sjis): Handle 4th charset (typically JISX0212).
Kenichi Handa <handa@m17n.org>
parents:
89759
diff
changeset
|
4322 } |
| 88365 | 4323 else |
| 4324 EMIT_ONE_ASCII_BYTE (code & 0x7F); | |
| 4325 } | |
| 4326 } | |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
4327 record_conversion_result (coding, CODING_RESULT_SUCCESS); |
| 88365 | 4328 coding->produced_char += produced_chars; |
| 4329 coding->produced = dst - coding->destination; | |
| 4330 return 0; | |
| 4331 } | |
| 4332 | |
| 4333 static int | |
| 4334 encode_coding_big5 (coding) | |
| 4335 struct coding_system *coding; | |
| 4336 { | |
| 4337 int multibytep = coding->dst_multibyte; | |
| 4338 int *charbuf = coding->charbuf; | |
| 4339 int *charbuf_end = charbuf + coding->charbuf_used; | |
| 4340 unsigned char *dst = coding->destination + coding->produced; | |
| 4341 unsigned char *dst_end = coding->destination + coding->dst_bytes; | |
| 4342 int safe_room = 4; | |
| 4343 int produced_chars = 0; | |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4344 Lisp_Object attrs, charset_list, val; |
| 88365 | 4345 int ascii_compatible; |
| 4346 struct charset *charset_roman, *charset_big5; | |
| 4347 int c; | |
| 4348 | |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4349 CODING_GET_INFO (coding, attrs, charset_list); |
| 88365 | 4350 val = charset_list; |
| 4351 charset_roman = CHARSET_FROM_ID (XINT (XCAR (val))), val = XCDR (val); | |
| 4352 charset_big5 = CHARSET_FROM_ID (XINT (XCAR (val))); | |
| 4353 ascii_compatible = ! NILP (CODING_ATTR_ASCII_COMPAT (attrs)); | |
| 4354 | |
| 4355 while (charbuf < charbuf_end) | |
| 4356 { | |
| 4357 ASSURE_DESTINATION (safe_room); | |
| 4358 c = *charbuf++; | |
| 4359 /* Now encode the character C. */ | |
| 4360 if (ASCII_CHAR_P (c) && ascii_compatible) | |
| 4361 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
|
4362 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
|
4363 { |
|
7f284ac55b07
(encode_coding_emacs_mule): Pay attention to raw-8-bit chars.
Kenichi Handa <handa@m17n.org>
parents:
88681
diff
changeset
|
4364 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
|
4365 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
|
4366 } |
| 88365 | 4367 else |
| 4368 { | |
| 4369 unsigned code; | |
| 4370 struct charset *charset = char_charset (c, charset_list, &code); | |
| 4371 | |
| 4372 if (! charset) | |
| 4373 { | |
|
88573
133bf7ab1bad
(encode_coding_iso_2022): If coding requires safe
Kenichi Handa <handa@m17n.org>
parents:
88544
diff
changeset
|
4374 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
|
4375 { |
|
133bf7ab1bad
(encode_coding_iso_2022): If coding requires safe
Kenichi Handa <handa@m17n.org>
parents:
88544
diff
changeset
|
4376 code = CODING_INHIBIT_CHARACTER_SUBSTITUTION; |
|
133bf7ab1bad
(encode_coding_iso_2022): If coding requires safe
Kenichi Handa <handa@m17n.org>
parents:
88544
diff
changeset
|
4377 charset = CHARSET_FROM_ID (charset_ascii); |
|
133bf7ab1bad
(encode_coding_iso_2022): If coding requires safe
Kenichi Handa <handa@m17n.org>
parents:
88544
diff
changeset
|
4378 } |
|
133bf7ab1bad
(encode_coding_iso_2022): If coding requires safe
Kenichi Handa <handa@m17n.org>
parents:
88544
diff
changeset
|
4379 else |
|
133bf7ab1bad
(encode_coding_iso_2022): If coding requires safe
Kenichi Handa <handa@m17n.org>
parents:
88544
diff
changeset
|
4380 { |
|
133bf7ab1bad
(encode_coding_iso_2022): If coding requires safe
Kenichi Handa <handa@m17n.org>
parents:
88544
diff
changeset
|
4381 c = coding->default_char; |
|
133bf7ab1bad
(encode_coding_iso_2022): If coding requires safe
Kenichi Handa <handa@m17n.org>
parents:
88544
diff
changeset
|
4382 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
|
4383 } |
| 88365 | 4384 } |
| 4385 if (code == CHARSET_INVALID_CODE (charset)) | |
| 4386 abort (); | |
| 4387 if (charset == charset_big5) | |
| 4388 { | |
| 4389 int c1, c2; | |
| 4390 | |
| 4391 c1 = code >> 8, c2 = code & 0xFF; | |
| 4392 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
|
4393 } |
| 17052 | 4394 else |
| 88365 | 4395 EMIT_ONE_ASCII_BYTE (code & 0x7F); |
| 17052 | 4396 } |
| 88365 | 4397 } |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
4398 record_conversion_result (coding, CODING_RESULT_SUCCESS); |
| 88365 | 4399 coding->produced_char += produced_chars; |
| 4400 coding->produced = dst - coding->destination; | |
| 4401 return 0; | |
| 17052 | 4402 } |
| 4403 | |
| 4404 | |
| 88365 | 4405 /*** 10. CCL handlers ***/ |
|
22874
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
4406 |
|
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
4407 /* See the above "GENERAL NOTES on `detect_coding_XXX ()' functions". |
|
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
4408 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
|
4409 encoder/decoder are written in CCL program. If it is, return |
| 88365 | 4410 CATEGORY_MASK_CCL, else return 0. */ |
|
22874
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
4411 |
|
34531
37f85e931855
(ONE_MORE_BYTE_CHECK_MULTIBYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34197
diff
changeset
|
4412 static int |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
4413 detect_coding_ccl (coding, detect_info) |
| 88365 | 4414 struct coding_system *coding; |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
4415 struct coding_detection_info *detect_info; |
| 88365 | 4416 { |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
4417 const unsigned char *src = coding->source, *src_base; |
| 89483 | 4418 const unsigned char *src_end = coding->source + coding->src_bytes; |
| 88365 | 4419 int multibytep = coding->src_multibyte; |
| 4420 int consumed_chars = 0; | |
| 4421 int found = 0; | |
|
89848
3edfa038a435
(detect_coding_emacs_mule): Fix counting of encoded
Kenichi Handa <handa@m17n.org>
parents:
89842
diff
changeset
|
4422 unsigned char *valids; |
| 88365 | 4423 int head_ascii = coding->head_ascii; |
| 4424 Lisp_Object attrs; | |
| 4425 | |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
4426 detect_info->checked |= CATEGORY_MASK_CCL; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
4427 |
| 88365 | 4428 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
|
4429 valids = CODING_CCL_VALIDS (coding); |
| 88365 | 4430 attrs = CODING_ID_ATTRS (coding->id); |
| 4431 if (! NILP (CODING_ATTR_ASCII_COMPAT (attrs))) | |
| 4432 src += head_ascii; | |
| 4433 | |
| 4434 while (1) | |
| 4435 { | |
| 4436 int c; | |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
4437 |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
4438 src_base = src; |
| 88365 | 4439 ONE_MORE_BYTE (c); |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
4440 if (c < 0 || ! valids[c]) |
| 88365 | 4441 break; |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
4442 if ((valids[c] > 1)) |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
4443 found = CATEGORY_MASK_CCL; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
4444 } |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
4445 detect_info->rejected |= CATEGORY_MASK_CCL; |
| 88365 | 4446 return 0; |
| 4447 | |
| 4448 no_more_source: | |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
4449 detect_info->found |= found; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
4450 return 1; |
| 88365 | 4451 } |
| 4452 | |
| 4453 static void | |
| 4454 decode_coding_ccl (coding) | |
| 4455 struct coding_system *coding; | |
|
22874
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
4456 { |
|
88876
af9012fdad56
(LEADING_CODE_PRIVATE_11, LEADING_CODE_PRIVATE_12,
Kenichi Handa <handa@m17n.org>
parents:
88862
diff
changeset
|
4457 const unsigned char *src = coding->source + coding->consumed; |
| 89483 | 4458 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
|
4459 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
|
4460 int *charbuf_end = coding->charbuf + coding->charbuf_size; |
| 88365 | 4461 int consumed_chars = 0; |
| 4462 int multibytep = coding->src_multibyte; | |
| 4463 struct ccl_program ccl; | |
| 4464 int source_charbuf[1024]; | |
| 4465 int source_byteidx[1024]; | |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4466 Lisp_Object attrs, charset_list; |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4467 |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4468 CODING_GET_INFO (coding, attrs, charset_list); |
| 88365 | 4469 setup_ccl_program (&ccl, CODING_CCL_DECODER (coding)); |
| 4470 | |
| 4471 while (src < src_end) | |
| 4472 { | |
|
88876
af9012fdad56
(LEADING_CODE_PRIVATE_11, LEADING_CODE_PRIVATE_12,
Kenichi Handa <handa@m17n.org>
parents:
88862
diff
changeset
|
4473 const unsigned char *p = src; |
| 88365 | 4474 int *source, *source_end; |
| 4475 int i = 0; | |
| 4476 | |
| 4477 if (multibytep) | |
| 4478 while (i < 1024 && p < src_end) | |
| 4479 { | |
| 4480 source_byteidx[i] = p - src; | |
| 4481 source_charbuf[i++] = STRING_CHAR_ADVANCE (p); | |
| 4482 } | |
| 4483 else | |
| 4484 while (i < 1024 && p < src_end) | |
| 4485 source_charbuf[i++] = *p++; | |
| 89483 | 4486 |
| 88365 | 4487 if (p == src_end && coding->mode & CODING_MODE_LAST_BLOCK) |
| 4488 ccl.last_block = 1; | |
| 4489 | |
| 4490 source = source_charbuf; | |
| 4491 source_end = source + i; | |
| 4492 while (source < source_end) | |
| 4493 { | |
| 4494 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
|
4495 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
|
4496 charset_list); |
| 88365 | 4497 source += ccl.consumed; |
| 4498 charbuf += ccl.produced; | |
| 4499 if (ccl.status != CCL_STAT_SUSPEND_BY_DST) | |
| 4500 break; | |
| 4501 } | |
| 4502 if (source < source_end) | |
| 4503 src += source_byteidx[source - source_charbuf]; | |
| 4504 else | |
| 4505 src = p; | |
| 4506 consumed_chars += source - source_charbuf; | |
| 4507 | |
| 4508 if (ccl.status != CCL_STAT_SUSPEND_BY_SRC | |
| 4509 && ccl.status != CODING_RESULT_INSUFFICIENT_SRC) | |
| 4510 break; | |
| 4511 } | |
| 4512 | |
| 4513 switch (ccl.status) | |
| 4514 { | |
| 4515 case CCL_STAT_SUSPEND_BY_SRC: | |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
4516 record_conversion_result (coding, CODING_RESULT_INSUFFICIENT_SRC); |
| 88365 | 4517 break; |
| 4518 case CCL_STAT_SUSPEND_BY_DST: | |
| 4519 break; | |
| 4520 case CCL_STAT_QUIT: | |
| 4521 case CCL_STAT_INVALID_CMD: | |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
4522 record_conversion_result (coding, CODING_RESULT_INTERRUPT); |
| 88365 | 4523 break; |
| 4524 default: | |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
4525 record_conversion_result (coding, CODING_RESULT_SUCCESS); |
| 88365 | 4526 break; |
| 4527 } | |
| 4528 coding->consumed_char += consumed_chars; | |
| 4529 coding->consumed = src - coding->source; | |
| 4530 coding->charbuf_used = charbuf - coding->charbuf; | |
|
22874
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
4531 } |
|
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
4532 |
| 88365 | 4533 static int |
| 4534 encode_coding_ccl (coding) | |
| 4535 struct coding_system *coding; | |
| 4536 { | |
| 4537 struct ccl_program ccl; | |
| 4538 int multibytep = coding->dst_multibyte; | |
| 4539 int *charbuf = coding->charbuf; | |
| 4540 int *charbuf_end = charbuf + coding->charbuf_used; | |
| 4541 unsigned char *dst = coding->destination + coding->produced; | |
| 4542 unsigned char *dst_end = coding->destination + coding->dst_bytes; | |
| 4543 unsigned char *adjusted_dst_end = dst_end - 1; | |
| 4544 int destination_charbuf[1024]; | |
| 4545 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
|
4546 Lisp_Object attrs, charset_list; |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4547 |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4548 CODING_GET_INFO (coding, attrs, charset_list); |
| 88365 | 4549 setup_ccl_program (&ccl, CODING_CCL_ENCODER (coding)); |
| 4550 | |
| 4551 ccl.last_block = coding->mode & CODING_MODE_LAST_BLOCK; | |
| 4552 ccl.dst_multibyte = coding->dst_multibyte; | |
| 4553 | |
| 4554 while (charbuf < charbuf_end && dst < adjusted_dst_end) | |
| 4555 { | |
| 4556 int dst_bytes = dst_end - dst; | |
| 4557 if (dst_bytes > 1024) | |
| 4558 dst_bytes = 1024; | |
| 4559 | |
| 4560 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
|
4561 charbuf_end - charbuf, dst_bytes, charset_list); |
| 88365 | 4562 charbuf += ccl.consumed; |
| 4563 if (multibytep) | |
| 4564 for (i = 0; i < ccl.produced; i++) | |
| 4565 EMIT_ONE_BYTE (destination_charbuf[i] & 0xFF); | |
| 4566 else | |
| 4567 { | |
| 4568 for (i = 0; i < ccl.produced; i++) | |
| 4569 *dst++ = destination_charbuf[i] & 0xFF; | |
| 4570 produced_chars += ccl.produced; | |
| 4571 } | |
| 4572 } | |
| 4573 | |
| 4574 switch (ccl.status) | |
| 4575 { | |
| 4576 case CCL_STAT_SUSPEND_BY_SRC: | |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
4577 record_conversion_result (coding, CODING_RESULT_INSUFFICIENT_SRC); |
| 88365 | 4578 break; |
| 4579 case CCL_STAT_SUSPEND_BY_DST: | |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
4580 record_conversion_result (coding, CODING_RESULT_INSUFFICIENT_DST); |
| 88365 | 4581 break; |
| 4582 case CCL_STAT_QUIT: | |
| 4583 case CCL_STAT_INVALID_CMD: | |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
4584 record_conversion_result (coding, CODING_RESULT_INTERRUPT); |
| 88365 | 4585 break; |
| 4586 default: | |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
4587 record_conversion_result (coding, CODING_RESULT_SUCCESS); |
| 88365 | 4588 break; |
| 4589 } | |
| 4590 | |
| 4591 coding->produced_char += produced_chars; | |
| 4592 coding->produced = dst - coding->destination; | |
| 4593 return 0; | |
| 4594 } | |
| 4595 | |
| 4596 | |
|
22874
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
4597 |
| 88365 | 4598 /*** 10, 11. no-conversion handlers ***/ |
| 17052 | 4599 |
|
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4600 /* 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
|
4601 |
|
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4602 static void |
| 88365 | 4603 decode_coding_raw_text (coding) |
| 17052 | 4604 struct coding_system *coding; |
| 4605 { | |
| 88365 | 4606 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
|
4607 coding->consumed_char = 0; |
|
a7b309f72920
(coding_alloc_by_making_gap): Check the case that the
Kenichi Handa <handa@m17n.org>
parents:
88443
diff
changeset
|
4608 coding->consumed = 0; |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
4609 record_conversion_result (coding, CODING_RESULT_SUCCESS); |
| 88365 | 4610 } |
| 4611 | |
| 4612 static int | |
| 4613 encode_coding_raw_text (coding) | |
| 4614 struct coding_system *coding; | |
| 4615 { | |
| 4616 int multibytep = coding->dst_multibyte; | |
| 4617 int *charbuf = coding->charbuf; | |
| 4618 int *charbuf_end = coding->charbuf + coding->charbuf_used; | |
| 4619 unsigned char *dst = coding->destination + coding->produced; | |
| 4620 unsigned char *dst_end = coding->destination + coding->dst_bytes; | |
| 4621 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
|
4622 int c; |
|
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4623 |
| 88365 | 4624 if (multibytep) |
| 4625 { | |
| 4626 int safe_room = MAX_MULTIBYTE_LENGTH * 2; | |
| 4627 | |
| 4628 if (coding->src_multibyte) | |
| 4629 while (charbuf < charbuf_end) | |
| 4630 { | |
| 4631 ASSURE_DESTINATION (safe_room); | |
| 4632 c = *charbuf++; | |
| 4633 if (ASCII_CHAR_P (c)) | |
| 4634 EMIT_ONE_ASCII_BYTE (c); | |
| 4635 else if (CHAR_BYTE8_P (c)) | |
| 4636 { | |
| 4637 c = CHAR_TO_BYTE8 (c); | |
| 4638 EMIT_ONE_BYTE (c); | |
| 4639 } | |
| 4640 else | |
| 4641 { | |
| 4642 unsigned char str[MAX_MULTIBYTE_LENGTH], *p0 = str, *p1 = str; | |
| 4643 | |
| 4644 CHAR_STRING_ADVANCE (c, p1); | |
| 4645 while (p0 < p1) | |
|
88950
ad258ee59fbb
* coding.c (make_conversion_work_buffer): Adjusted for the change
Kenichi Handa <handa@m17n.org>
parents:
88936
diff
changeset
|
4646 { |
|
ad258ee59fbb
* coding.c (make_conversion_work_buffer): Adjusted for the change
Kenichi Handa <handa@m17n.org>
parents:
88936
diff
changeset
|
4647 EMIT_ONE_BYTE (*p0); |
|
ad258ee59fbb
* coding.c (make_conversion_work_buffer): Adjusted for the change
Kenichi Handa <handa@m17n.org>
parents:
88936
diff
changeset
|
4648 p0++; |
|
ad258ee59fbb
* coding.c (make_conversion_work_buffer): Adjusted for the change
Kenichi Handa <handa@m17n.org>
parents:
88936
diff
changeset
|
4649 } |
| 88365 | 4650 } |
| 4651 } | |
| 4652 else | |
| 4653 while (charbuf < charbuf_end) | |
| 4654 { | |
| 4655 ASSURE_DESTINATION (safe_room); | |
| 4656 c = *charbuf++; | |
|
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4657 EMIT_ONE_BYTE (c); |
| 88365 | 4658 } |
|
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4659 } |
|
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4660 else |
|
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4661 { |
| 88365 | 4662 if (coding->src_multibyte) |
|
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4663 { |
| 88365 | 4664 int safe_room = MAX_MULTIBYTE_LENGTH; |
| 4665 | |
| 4666 while (charbuf < charbuf_end) | |
| 4667 { | |
| 4668 ASSURE_DESTINATION (safe_room); | |
| 4669 c = *charbuf++; | |
| 4670 if (ASCII_CHAR_P (c)) | |
| 4671 *dst++ = c; | |
| 4672 else if (CHAR_BYTE8_P (c)) | |
| 4673 *dst++ = CHAR_TO_BYTE8 (c); | |
| 4674 else | |
| 4675 CHAR_STRING_ADVANCE (c, dst); | |
| 4676 produced_chars++; | |
| 4677 } | |
|
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4678 } |
|
20931
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
4679 else |
|
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4680 { |
| 88365 | 4681 ASSURE_DESTINATION (charbuf_end - charbuf); |
| 4682 while (charbuf < charbuf_end && dst < dst_end) | |
| 4683 *dst++ = *charbuf++; | |
| 4684 produced_chars = dst - (coding->destination + coding->dst_bytes); | |
| 89483 | 4685 } |
| 88365 | 4686 } |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
4687 record_conversion_result (coding, CODING_RESULT_SUCCESS); |
| 88365 | 4688 coding->produced_char += produced_chars; |
| 4689 coding->produced = dst - coding->destination; | |
| 4690 return 0; | |
| 4691 } | |
| 4692 | |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
4693 /* 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
|
4694 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
|
4695 is, return 1, else return 0. */ |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
4696 |
| 88365 | 4697 static int |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
4698 detect_coding_charset (coding, detect_info) |
| 88365 | 4699 struct coding_system *coding; |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
4700 struct coding_detection_info *detect_info; |
| 88365 | 4701 { |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
4702 const unsigned char *src = coding->source, *src_base; |
| 89483 | 4703 const unsigned char *src_end = coding->source + coding->src_bytes; |
| 88365 | 4704 int multibytep = coding->src_multibyte; |
| 4705 int consumed_chars = 0; | |
| 4706 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
|
4707 int found = 0; |
| 88365 | 4708 |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
4709 detect_info->checked |= CATEGORY_MASK_CHARSET; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
4710 |
| 88365 | 4711 coding = &coding_categories[coding_category_charset]; |
| 4712 attrs = CODING_ID_ATTRS (coding->id); | |
| 4713 valids = AREF (attrs, coding_attr_charset_valids); | |
| 4714 | |
| 4715 if (! NILP (CODING_ATTR_ASCII_COMPAT (attrs))) | |
| 4716 src += coding->head_ascii; | |
| 4717 | |
| 4718 while (1) | |
| 4719 { | |
| 4720 int c; | |
| 4721 | |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
4722 src_base = src; |
| 88365 | 4723 ONE_MORE_BYTE (c); |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
4724 if (c < 0) |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
4725 continue; |
| 88365 | 4726 if (NILP (AREF (valids, c))) |
| 4727 break; | |
|
89225
32058afc72e2
(detect_coding_charset): If only ASCII bytes are found, return 0.
Kenichi Handa <handa@m17n.org>
parents:
89221
diff
changeset
|
4728 if (c >= 0x80) |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
4729 found = CATEGORY_MASK_CHARSET; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
4730 } |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
4731 detect_info->rejected |= CATEGORY_MASK_CHARSET; |
| 88365 | 4732 return 0; |
| 4733 | |
| 4734 no_more_source: | |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
4735 detect_info->found |= found; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
4736 return 1; |
| 88365 | 4737 } |
| 4738 | |
| 4739 static void | |
| 4740 decode_coding_charset (coding) | |
| 4741 struct coding_system *coding; | |
| 4742 { | |
| 89483 | 4743 const unsigned char *src = coding->source + coding->consumed; |
| 4744 const unsigned char *src_end = coding->source + coding->src_bytes; | |
| 4745 const unsigned char *src_base; | |
|
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
4746 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
|
4747 int *charbuf_end |
|
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
4748 = coding->charbuf + coding->charbuf_size - MAX_ANNOTATION_LENGTH; |
| 88365 | 4749 int consumed_chars = 0, consumed_chars_base; |
| 4750 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
|
4751 Lisp_Object attrs, charset_list, valids; |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
4752 int char_offset = coding->produced_char; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
4753 int last_offset = char_offset; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
4754 int last_id = charset_ascii; |
| 88365 | 4755 |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4756 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
|
4757 valids = AREF (attrs, coding_attr_charset_valids); |
| 88365 | 4758 |
| 4759 while (1) | |
| 4760 { | |
|
88465
ae455bb40718
(decode_coding_charset, encode_coding_charset): Handle
Kenichi Handa <handa@m17n.org>
parents:
88456
diff
changeset
|
4761 int c; |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4762 Lisp_Object val; |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4763 struct charset *charset; |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4764 int dim; |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4765 int len = 1; |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4766 unsigned code; |
| 88365 | 4767 |
| 4768 src_base = src; | |
| 4769 consumed_chars_base = consumed_chars; | |
| 4770 | |
| 4771 if (charbuf >= charbuf_end) | |
| 4772 break; | |
| 4773 | |
|
88465
ae455bb40718
(decode_coding_charset, encode_coding_charset): Handle
Kenichi Handa <handa@m17n.org>
parents:
88456
diff
changeset
|
4774 ONE_MORE_BYTE (c); |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
4775 if (c < 0) |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
4776 goto invalid_code; |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4777 code = c; |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4778 |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4779 val = AREF (valids, c); |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4780 if (NILP (val)) |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4781 goto invalid_code; |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4782 if (INTEGERP (val)) |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4783 { |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4784 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
|
4785 dim = CHARSET_DIMENSION (charset); |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4786 while (len < dim) |
| 88365 | 4787 { |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4788 ONE_MORE_BYTE (c); |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4789 code = (code << 8) | c; |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4790 len++; |
| 88365 | 4791 } |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4792 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
|
4793 charset, code, c); |
|
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4794 } |
| 88365 | 4795 else |
|
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
4796 { |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4797 /* 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
|
4798 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
|
4799 comes first). */ |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4800 while (CONSP (val)) |
|
88465
ae455bb40718
(decode_coding_charset, encode_coding_charset): Handle
Kenichi Handa <handa@m17n.org>
parents:
88456
diff
changeset
|
4801 { |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4802 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
|
4803 dim = CHARSET_DIMENSION (charset); |
|
88607
18436bf3d6dd
(Fdefine_coding_system_internal): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
88598
diff
changeset
|
4804 while (len < dim) |
|
88465
ae455bb40718
(decode_coding_charset, encode_coding_charset): Handle
Kenichi Handa <handa@m17n.org>
parents:
88456
diff
changeset
|
4805 { |
|
88598
b88195f69856
(decode_coding_charset): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
88597
diff
changeset
|
4806 ONE_MORE_BYTE (c); |
|
b88195f69856
(decode_coding_charset): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
88597
diff
changeset
|
4807 code = (code << 8) | c; |
|
88607
18436bf3d6dd
(Fdefine_coding_system_internal): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
88598
diff
changeset
|
4808 len++; |
|
88465
ae455bb40718
(decode_coding_charset, encode_coding_charset): Handle
Kenichi Handa <handa@m17n.org>
parents:
88456
diff
changeset
|
4809 } |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4810 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
|
4811 src_end, charset, code, c); |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4812 if (c >= 0) |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4813 break; |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4814 val = XCDR (val); |
|
88465
ae455bb40718
(decode_coding_charset, encode_coding_charset): Handle
Kenichi Handa <handa@m17n.org>
parents:
88456
diff
changeset
|
4815 } |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4816 } |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4817 if (c < 0) |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4818 goto invalid_code; |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4819 if (charset->id != charset_ascii |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4820 && last_id != charset->id) |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4821 { |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4822 if (last_id != charset_ascii) |
|
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
4823 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
|
4824 last_id = charset->id; |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4825 last_offset = char_offset; |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4826 } |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4827 |
| 88365 | 4828 *charbuf++ = c; |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
4829 char_offset++; |
| 88365 | 4830 continue; |
| 4831 | |
| 4832 invalid_code: | |
| 4833 src = src_base; | |
| 4834 consumed_chars = consumed_chars_base; | |
| 4835 ONE_MORE_BYTE (c); | |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
4836 *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
|
4837 char_offset++; |
| 88365 | 4838 coding->errors++; |
| 4839 } | |
| 4840 | |
| 4841 no_more_source: | |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
4842 if (last_id != charset_ascii) |
|
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
4843 ADD_CHARSET_DATA (charbuf, char_offset - last_offset, last_id); |
| 88365 | 4844 coding->consumed_char += consumed_chars_base; |
| 4845 coding->consumed = src_base - coding->source; | |
| 4846 coding->charbuf_used = charbuf - coding->charbuf; | |
| 4847 } | |
| 4848 | |
| 4849 static int | |
| 4850 encode_coding_charset (coding) | |
| 4851 struct coding_system *coding; | |
| 4852 { | |
| 4853 int multibytep = coding->dst_multibyte; | |
| 4854 int *charbuf = coding->charbuf; | |
| 4855 int *charbuf_end = charbuf + coding->charbuf_used; | |
| 4856 unsigned char *dst = coding->destination + coding->produced; | |
| 4857 unsigned char *dst_end = coding->destination + coding->dst_bytes; | |
| 4858 int safe_room = MAX_MULTIBYTE_LENGTH; | |
| 4859 int produced_chars = 0; | |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4860 Lisp_Object attrs, charset_list; |
| 88365 | 4861 int ascii_compatible; |
| 4862 int c; | |
| 4863 | |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
4864 CODING_GET_INFO (coding, attrs, charset_list); |
| 88365 | 4865 ascii_compatible = ! NILP (CODING_ATTR_ASCII_COMPAT (attrs)); |
| 4866 | |
| 4867 while (charbuf < charbuf_end) | |
| 4868 { | |
|
88465
ae455bb40718
(decode_coding_charset, encode_coding_charset): Handle
Kenichi Handa <handa@m17n.org>
parents:
88456
diff
changeset
|
4869 struct charset *charset; |
| 88365 | 4870 unsigned code; |
| 89483 | 4871 |
| 88365 | 4872 ASSURE_DESTINATION (safe_room); |
| 4873 c = *charbuf++; | |
| 4874 if (ascii_compatible && ASCII_CHAR_P (c)) | |
| 4875 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
|
4876 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
|
4877 { |
|
7f284ac55b07
(encode_coding_emacs_mule): Pay attention to raw-8-bit chars.
Kenichi Handa <handa@m17n.org>
parents:
88681
diff
changeset
|
4878 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
|
4879 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
|
4880 } |
| 88365 | 4881 else |
|
88465
ae455bb40718
(decode_coding_charset, encode_coding_charset): Handle
Kenichi Handa <handa@m17n.org>
parents:
88456
diff
changeset
|
4882 { |
|
ae455bb40718
(decode_coding_charset, encode_coding_charset): Handle
Kenichi Handa <handa@m17n.org>
parents:
88456
diff
changeset
|
4883 charset = char_charset (c, charset_list, &code); |
|
ae455bb40718
(decode_coding_charset, encode_coding_charset): Handle
Kenichi Handa <handa@m17n.org>
parents:
88456
diff
changeset
|
4884 if (charset) |
|
ae455bb40718
(decode_coding_charset, encode_coding_charset): Handle
Kenichi Handa <handa@m17n.org>
parents:
88456
diff
changeset
|
4885 { |
|
ae455bb40718
(decode_coding_charset, encode_coding_charset): Handle
Kenichi Handa <handa@m17n.org>
parents:
88456
diff
changeset
|
4886 if (CHARSET_DIMENSION (charset) == 1) |
|
ae455bb40718
(decode_coding_charset, encode_coding_charset): Handle
Kenichi Handa <handa@m17n.org>
parents:
88456
diff
changeset
|
4887 EMIT_ONE_BYTE (code); |
|
ae455bb40718
(decode_coding_charset, encode_coding_charset): Handle
Kenichi Handa <handa@m17n.org>
parents:
88456
diff
changeset
|
4888 else if (CHARSET_DIMENSION (charset) == 2) |
|
ae455bb40718
(decode_coding_charset, encode_coding_charset): Handle
Kenichi Handa <handa@m17n.org>
parents:
88456
diff
changeset
|
4889 EMIT_TWO_BYTES (code >> 8, code & 0xFF); |
|
ae455bb40718
(decode_coding_charset, encode_coding_charset): Handle
Kenichi Handa <handa@m17n.org>
parents:
88456
diff
changeset
|
4890 else if (CHARSET_DIMENSION (charset) == 3) |
|
ae455bb40718
(decode_coding_charset, encode_coding_charset): Handle
Kenichi Handa <handa@m17n.org>
parents:
88456
diff
changeset
|
4891 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
|
4892 else |
|
ae455bb40718
(decode_coding_charset, encode_coding_charset): Handle
Kenichi Handa <handa@m17n.org>
parents:
88456
diff
changeset
|
4893 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
|
4894 (code >> 8) & 0xFF, code & 0xFF); |
|
ae455bb40718
(decode_coding_charset, encode_coding_charset): Handle
Kenichi Handa <handa@m17n.org>
parents:
88456
diff
changeset
|
4895 } |
|
ae455bb40718
(decode_coding_charset, encode_coding_charset): Handle
Kenichi Handa <handa@m17n.org>
parents:
88456
diff
changeset
|
4896 else |
|
88573
133bf7ab1bad
(encode_coding_iso_2022): If coding requires safe
Kenichi Handa <handa@m17n.org>
parents:
88544
diff
changeset
|
4897 { |
|
133bf7ab1bad
(encode_coding_iso_2022): If coding requires safe
Kenichi Handa <handa@m17n.org>
parents:
88544
diff
changeset
|
4898 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
|
4899 c = CODING_INHIBIT_CHARACTER_SUBSTITUTION; |
|
133bf7ab1bad
(encode_coding_iso_2022): If coding requires safe
Kenichi Handa <handa@m17n.org>
parents:
88544
diff
changeset
|
4900 else |
|
133bf7ab1bad
(encode_coding_iso_2022): If coding requires safe
Kenichi Handa <handa@m17n.org>
parents:
88544
diff
changeset
|
4901 c = coding->default_char; |
|
133bf7ab1bad
(encode_coding_iso_2022): If coding requires safe
Kenichi Handa <handa@m17n.org>
parents:
88544
diff
changeset
|
4902 EMIT_ONE_BYTE (c); |
|
133bf7ab1bad
(encode_coding_iso_2022): If coding requires safe
Kenichi Handa <handa@m17n.org>
parents:
88544
diff
changeset
|
4903 } |
|
88465
ae455bb40718
(decode_coding_charset, encode_coding_charset): Handle
Kenichi Handa <handa@m17n.org>
parents:
88456
diff
changeset
|
4904 } |
| 88365 | 4905 } |
| 4906 | |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
4907 record_conversion_result (coding, CODING_RESULT_SUCCESS); |
| 88365 | 4908 coding->produced_char += produced_chars; |
| 4909 coding->produced = dst - coding->destination; | |
| 4910 return 0; | |
| 17052 | 4911 } |
| 4912 | |
| 4913 | |
|
22874
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
4914 /*** 7. C library functions ***/ |
| 17052 | 4915 |
| 88365 | 4916 /* Setup coding context CODING from information about CODING_SYSTEM. |
| 4917 If CODING_SYSTEM is nil, `no-conversion' is assumed. If | |
| 4918 CODING_SYSTEM is invalid, signal an error. */ | |
| 4919 | |
| 4920 void | |
|
17119
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
4921 setup_coding_system (coding_system, coding) |
|
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
4922 Lisp_Object coding_system; |
| 17052 | 4923 struct coding_system *coding; |
| 4924 { | |
| 88365 | 4925 Lisp_Object attrs; |
| 4926 Lisp_Object eol_type; | |
| 4927 Lisp_Object coding_type; | |
|
20105
c017642863c2
(Qcoding_system_spec): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
19824
diff
changeset
|
4928 Lisp_Object val; |
| 17052 | 4929 |
|
24460
be35d27a4bfb
(setup_coding_system): Check for CODING_SYSTEM = nil.
Kenichi Handa <handa@m17n.org>
parents:
24425
diff
changeset
|
4930 if (NILP (coding_system)) |
| 88365 | 4931 coding_system = Qno_conversion; |
| 4932 | |
| 4933 CHECK_CODING_SYSTEM_GET_ID (coding_system, coding->id); | |
| 4934 | |
| 4935 attrs = CODING_ID_ATTRS (coding->id); | |
| 4936 eol_type = CODING_ID_EOL_TYPE (coding->id); | |
| 4937 | |
| 4938 coding->mode = 0; | |
| 4939 coding->head_ascii = -1; | |
| 4940 coding->common_flags | |
| 4941 = (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
|
4942 if (! NILP (CODING_ATTR_POST_READ (attrs))) |
|
de8b460070cc
(setup_coding_system): If coding has
Kenichi Handa <handa@m17n.org>
parents:
89446
diff
changeset
|
4943 coding->common_flags |= CODING_REQUIRE_DECODING_MASK; |
|
de8b460070cc
(setup_coding_system): If coding has
Kenichi Handa <handa@m17n.org>
parents:
89446
diff
changeset
|
4944 if (! NILP (CODING_ATTR_PRE_WRITE (attrs))) |
|
de8b460070cc
(setup_coding_system): If coding has
Kenichi Handa <handa@m17n.org>
parents:
89446
diff
changeset
|
4945 coding->common_flags |= CODING_REQUIRE_ENCODING_MASK; |
| 89483 | 4946 if (! NILP (CODING_ATTR_FOR_UNIBYTE (attrs))) |
| 4947 coding->common_flags |= CODING_FOR_UNIBYTE_MASK; | |
| 88365 | 4948 |
| 4949 val = CODING_ATTR_SAFE_CHARSETS (attrs); | |
| 89483 | 4950 coding->max_charset_id = SCHARS (val) - 1; |
| 4951 coding->safe_charsets = (char *) SDATA (val); | |
| 88365 | 4952 coding->default_char = XINT (CODING_ATTR_DEFAULT_CHAR (attrs)); |
| 4953 | |
| 4954 coding_type = CODING_ATTR_TYPE (attrs); | |
| 4955 if (EQ (coding_type, Qundecided)) | |
| 4956 { | |
| 4957 coding->detector = NULL; | |
| 4958 coding->decoder = decode_coding_raw_text; | |
| 4959 coding->encoder = encode_coding_raw_text; | |
| 4960 coding->common_flags |= CODING_REQUIRE_DETECTION_MASK; | |
| 4961 } | |
| 4962 else if (EQ (coding_type, Qiso_2022)) | |
| 4963 { | |
| 4964 int i; | |
| 4965 int flags = XINT (AREF (attrs, coding_attr_iso_flags)); | |
| 4966 | |
| 4967 /* Invoke graphic register 0 to plane 0. */ | |
| 4968 CODING_ISO_INVOCATION (coding, 0) = 0; | |
| 4969 /* Invoke graphic register 1 to plane 1 if we can use 8-bit. */ | |
| 4970 CODING_ISO_INVOCATION (coding, 1) | |
| 4971 = (flags & CODING_ISO_FLAG_SEVEN_BITS ? -1 : 1); | |
| 4972 /* Setup the initial status of designation. */ | |
| 4973 for (i = 0; i < 4; i++) | |
| 4974 CODING_ISO_DESIGNATION (coding, i) = CODING_ISO_INITIAL (coding, i); | |
| 4975 /* Not single shifting initially. */ | |
| 4976 CODING_ISO_SINGLE_SHIFTING (coding) = 0; | |
| 4977 /* Beginning of buffer should also be regarded as bol. */ | |
| 4978 CODING_ISO_BOL (coding) = 1; | |
| 4979 coding->detector = detect_coding_iso_2022; | |
| 4980 coding->decoder = decode_coding_iso_2022; | |
| 4981 coding->encoder = encode_coding_iso_2022; | |
| 4982 if (flags & CODING_ISO_FLAG_SAFE) | |
| 4983 coding->mode |= CODING_MODE_SAFE_ENCODING; | |
|
20227
71008f909642
(setup_coding_system): Initialize common_flags member
Kenichi Handa <handa@m17n.org>
parents:
20150
diff
changeset
|
4984 coding->common_flags |
| 88365 | 4985 |= (CODING_REQUIRE_DECODING_MASK | CODING_REQUIRE_ENCODING_MASK |
| 4986 | CODING_REQUIRE_FLUSHING_MASK); | |
| 4987 if (flags & CODING_ISO_FLAG_COMPOSITION) | |
| 4988 coding->common_flags |= CODING_ANNOTATE_COMPOSITION_MASK; | |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
4989 if (flags & CODING_ISO_FLAG_DESIGNATION) |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
4990 coding->common_flags |= CODING_ANNOTATE_CHARSET_MASK; |
| 88365 | 4991 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
|
4992 { |
| 88365 | 4993 setup_iso_safe_charsets (attrs); |
| 4994 val = CODING_ATTR_SAFE_CHARSETS (attrs); | |
| 89483 | 4995 coding->max_charset_id = SCHARS (val) - 1; |
| 4996 coding->safe_charsets = (char *) SDATA (val); | |
|
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
4997 } |
| 88365 | 4998 CODING_ISO_FLAGS (coding) = flags; |
| 4999 } | |
| 5000 else if (EQ (coding_type, Qcharset)) | |
| 5001 { | |
| 5002 coding->detector = detect_coding_charset; | |
| 5003 coding->decoder = decode_coding_charset; | |
| 5004 coding->encoder = encode_coding_charset; | |
| 5005 coding->common_flags | |
| 5006 |= (CODING_REQUIRE_DECODING_MASK | CODING_REQUIRE_ENCODING_MASK); | |
| 5007 } | |
| 5008 else if (EQ (coding_type, Qutf_8)) | |
| 5009 { | |
| 5010 coding->detector = detect_coding_utf_8; | |
| 5011 coding->decoder = decode_coding_utf_8; | |
| 5012 coding->encoder = encode_coding_utf_8; | |
|
34888
b469d29c0815
(SAFE_ONE_MORE_BYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34813
diff
changeset
|
5013 coding->common_flags |
| 88365 | 5014 |= (CODING_REQUIRE_DECODING_MASK | CODING_REQUIRE_ENCODING_MASK); |
| 5015 } | |
| 5016 else if (EQ (coding_type, Qutf_16)) | |
| 5017 { | |
| 5018 val = AREF (attrs, coding_attr_utf_16_bom); | |
| 5019 CODING_UTF_16_BOM (coding) = (CONSP (val) ? utf_16_detect_bom | |
| 5020 : EQ (val, Qt) ? utf_16_with_bom | |
| 5021 : utf_16_without_bom); | |
| 5022 val = AREF (attrs, coding_attr_utf_16_endian); | |
|
89420
c3e67ce6ee0f
(Qsignature, Qendian): Delete these variables.
Kenichi Handa <handa@m17n.org>
parents:
89418
diff
changeset
|
5023 CODING_UTF_16_ENDIAN (coding) = (EQ (val, Qbig) ? utf_16_big_endian |
| 88365 | 5024 : utf_16_little_endian); |
|
88438
3a34b722dd71
(encode_coding_utf_8): Initialize produced_chars to 0.
Kenichi Handa <handa@m17n.org>
parents:
88430
diff
changeset
|
5025 CODING_UTF_16_SURROGATE (coding) = 0; |
| 88365 | 5026 coding->detector = detect_coding_utf_16; |
| 5027 coding->decoder = decode_coding_utf_16; | |
| 5028 coding->encoder = encode_coding_utf_16; | |
|
20227
71008f909642
(setup_coding_system): Initialize common_flags member
Kenichi Handa <handa@m17n.org>
parents:
20150
diff
changeset
|
5029 coding->common_flags |
| 88365 | 5030 |= (CODING_REQUIRE_DECODING_MASK | CODING_REQUIRE_ENCODING_MASK); |
|
89420
c3e67ce6ee0f
(Qsignature, Qendian): Delete these variables.
Kenichi Handa <handa@m17n.org>
parents:
89418
diff
changeset
|
5031 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
|
5032 coding->common_flags |= CODING_REQUIRE_DETECTION_MASK; |
| 88365 | 5033 } |
| 5034 else if (EQ (coding_type, Qccl)) | |
| 5035 { | |
| 5036 coding->detector = detect_coding_ccl; | |
| 5037 coding->decoder = decode_coding_ccl; | |
| 5038 coding->encoder = encode_coding_ccl; | |
|
20227
71008f909642
(setup_coding_system): Initialize common_flags member
Kenichi Handa <handa@m17n.org>
parents:
20150
diff
changeset
|
5039 coding->common_flags |
| 88365 | 5040 |= (CODING_REQUIRE_DECODING_MASK | CODING_REQUIRE_ENCODING_MASK |
| 5041 | CODING_REQUIRE_FLUSHING_MASK); | |
| 5042 } | |
| 5043 else if (EQ (coding_type, Qemacs_mule)) | |
| 5044 { | |
| 5045 coding->detector = detect_coding_emacs_mule; | |
| 5046 coding->decoder = decode_coding_emacs_mule; | |
| 5047 coding->encoder = encode_coding_emacs_mule; | |
| 5048 coding->common_flags | |
| 5049 |= (CODING_REQUIRE_DECODING_MASK | CODING_REQUIRE_ENCODING_MASK); | |
| 5050 if (! NILP (AREF (attrs, coding_attr_emacs_mule_full)) | |
| 5051 && ! EQ (CODING_ATTR_CHARSET_LIST (attrs), Vemacs_mule_charset_list)) | |
| 5052 { | |
| 5053 Lisp_Object tail, safe_charsets; | |
| 5054 int max_charset_id = 0; | |
| 5055 | |
| 5056 for (tail = Vemacs_mule_charset_list; CONSP (tail); | |
| 5057 tail = XCDR (tail)) | |
| 5058 if (max_charset_id < XFASTINT (XCAR (tail))) | |
| 5059 max_charset_id = XFASTINT (XCAR (tail)); | |
| 5060 safe_charsets = Fmake_string (make_number (max_charset_id + 1), | |
| 5061 make_number (255)); | |
| 5062 for (tail = Vemacs_mule_charset_list; CONSP (tail); | |
| 5063 tail = XCDR (tail)) | |
| 89483 | 5064 SSET (safe_charsets, XFASTINT (XCAR (tail)), 0); |
| 88365 | 5065 coding->max_charset_id = max_charset_id; |
| 89483 | 5066 coding->safe_charsets = (char *) SDATA (safe_charsets); |
| 88365 | 5067 } |
| 5068 } | |
| 5069 else if (EQ (coding_type, Qshift_jis)) | |
| 5070 { | |
| 5071 coding->detector = detect_coding_sjis; | |
| 5072 coding->decoder = decode_coding_sjis; | |
| 5073 coding->encoder = encode_coding_sjis; | |
| 5074 coding->common_flags | |
| 5075 |= (CODING_REQUIRE_DECODING_MASK | CODING_REQUIRE_ENCODING_MASK); | |
| 5076 } | |
| 5077 else if (EQ (coding_type, Qbig5)) | |
| 5078 { | |
| 5079 coding->detector = detect_coding_big5; | |
| 5080 coding->decoder = decode_coding_big5; | |
| 5081 coding->encoder = encode_coding_big5; | |
|
20227
71008f909642
(setup_coding_system): Initialize common_flags member
Kenichi Handa <handa@m17n.org>
parents:
20150
diff
changeset
|
5082 coding->common_flags |
| 88365 | 5083 |= (CODING_REQUIRE_DECODING_MASK | CODING_REQUIRE_ENCODING_MASK); |
| 5084 } | |
| 5085 else /* EQ (coding_type, Qraw_text) */ | |
| 5086 { | |
| 5087 coding->detector = NULL; | |
| 5088 coding->decoder = decode_coding_raw_text; | |
| 5089 coding->encoder = encode_coding_raw_text; | |
| 5090 } | |
| 5091 | |
| 5092 return; | |
| 17052 | 5093 } |
| 5094 | |
| 88365 | 5095 /* Return raw-text or one of its subsidiaries that has the same |
| 5096 eol_type as CODING-SYSTEM. */ | |
| 5097 | |
| 5098 Lisp_Object | |
| 5099 raw_text_coding_system (coding_system) | |
| 5100 Lisp_Object coding_system; | |
| 26847 | 5101 { |
|
88430
6418a272b97e
* coding.c: Delete unused variables.
Kenichi Handa <handa@m17n.org>
parents:
88365
diff
changeset
|
5102 Lisp_Object spec, attrs; |
| 88365 | 5103 Lisp_Object eol_type, raw_text_eol_type; |
| 5104 | |
|
89462
4e359ebf3984
(decode_coding_iso_2022): Fix handling of invalid
Kenichi Handa <handa@m17n.org>
parents:
89448
diff
changeset
|
5105 if (NILP (coding_system)) |
|
4e359ebf3984
(decode_coding_iso_2022): Fix handling of invalid
Kenichi Handa <handa@m17n.org>
parents:
89448
diff
changeset
|
5106 return Qraw_text; |
| 88365 | 5107 spec = CODING_SYSTEM_SPEC (coding_system); |
| 5108 attrs = AREF (spec, 0); | |
| 89483 | 5109 |
| 88365 | 5110 if (EQ (CODING_ATTR_TYPE (attrs), Qraw_text)) |
| 5111 return coding_system; | |
| 5112 | |
| 5113 eol_type = AREF (spec, 2); | |
| 5114 if (VECTORP (eol_type)) | |
| 5115 return Qraw_text; | |
| 5116 spec = CODING_SYSTEM_SPEC (Qraw_text); | |
| 5117 raw_text_eol_type = AREF (spec, 2); | |
| 5118 return (EQ (eol_type, Qunix) ? AREF (raw_text_eol_type, 0) | |
| 5119 : EQ (eol_type, Qdos) ? AREF (raw_text_eol_type, 1) | |
| 5120 : AREF (raw_text_eol_type, 2)); | |
| 26847 | 5121 } |
| 5122 | |
| 88365 | 5123 |
| 5124 /* If CODING_SYSTEM doesn't specify end-of-line format but PARENT | |
| 5125 does, return one of the subsidiary that has the same eol-spec as | |
| 5126 PARENT. Otherwise, return CODING_SYSTEM. */ | |
| 5127 | |
| 5128 Lisp_Object | |
| 5129 coding_inherit_eol_type (coding_system, parent) | |
| 88473 | 5130 Lisp_Object coding_system, parent; |
|
22616
c493ce6a31e4
(setup_raw_text_coding_system): New function.
Kenichi Handa <handa@m17n.org>
parents:
22529
diff
changeset
|
5131 { |
|
89545
4f394eed6ff2
(inhibit_pre_post_conversion): Removed (unused).
Dave Love <fx@gnu.org>
parents:
89519
diff
changeset
|
5132 Lisp_Object spec, eol_type; |
| 88365 | 5133 |
|
89462
4e359ebf3984
(decode_coding_iso_2022): Fix handling of invalid
Kenichi Handa <handa@m17n.org>
parents:
89448
diff
changeset
|
5134 if (NILP (coding_system)) |
|
4e359ebf3984
(decode_coding_iso_2022): Fix handling of invalid
Kenichi Handa <handa@m17n.org>
parents:
89448
diff
changeset
|
5135 coding_system = Qraw_text; |
| 88365 | 5136 spec = CODING_SYSTEM_SPEC (coding_system); |
| 5137 eol_type = AREF (spec, 2); | |
|
89462
4e359ebf3984
(decode_coding_iso_2022): Fix handling of invalid
Kenichi Handa <handa@m17n.org>
parents:
89448
diff
changeset
|
5138 if (VECTORP (eol_type) |
|
4e359ebf3984
(decode_coding_iso_2022): Fix handling of invalid
Kenichi Handa <handa@m17n.org>
parents:
89448
diff
changeset
|
5139 && ! NILP (parent)) |
| 88365 | 5140 { |
| 5141 Lisp_Object parent_spec; | |
| 5142 Lisp_Object parent_eol_type; | |
| 5143 | |
| 5144 parent_spec | |
| 5145 = CODING_SYSTEM_SPEC (buffer_defaults.buffer_file_coding_system); | |
| 5146 parent_eol_type = AREF (parent_spec, 2); | |
| 5147 if (EQ (parent_eol_type, Qunix)) | |
| 5148 coding_system = AREF (eol_type, 0); | |
| 5149 else if (EQ (parent_eol_type, Qdos)) | |
| 5150 coding_system = AREF (eol_type, 1); | |
| 5151 else if (EQ (parent_eol_type, Qmac)) | |
| 5152 coding_system = AREF (eol_type, 2); | |
| 5153 } | |
| 5154 return coding_system; | |
|
22616
c493ce6a31e4
(setup_raw_text_coding_system): New function.
Kenichi Handa <handa@m17n.org>
parents:
22529
diff
changeset
|
5155 } |
|
c493ce6a31e4
(setup_raw_text_coding_system): New function.
Kenichi Handa <handa@m17n.org>
parents:
22529
diff
changeset
|
5156 |
| 17052 | 5157 /* Emacs has a mechanism to automatically detect a coding system if it |
| 5158 is one of Emacs' internal format, ISO2022, SJIS, and BIG5. But, | |
| 5159 it's impossible to distinguish some coding systems accurately | |
| 5160 because they use the same range of codes. So, at first, coding | |
| 5161 systems are categorized into 7, those are: | |
| 5162 | |
|
17835
f36ffb6f1208
Name change through the code:
Kenichi Handa <handa@m17n.org>
parents:
17725
diff
changeset
|
5163 o coding-category-emacs-mule |
| 17052 | 5164 |
| 5165 The category for a coding system which has the same code range | |
| 5166 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
|
5167 symbol) `emacs-mule' by default. |
| 17052 | 5168 |
| 5169 o coding-category-sjis | |
| 5170 | |
| 5171 The category for a coding system which has the same code range | |
| 5172 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
|
5173 symbol) `japanese-shift-jis' by default. |
| 17052 | 5174 |
| 5175 o coding-category-iso-7 | |
| 5176 | |
| 5177 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
|
5178 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
|
5179 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
|
5180 charsets. Assigned the coding-system (Lisp symbol) |
|
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5181 `iso-2022-7bit' by default. |
|
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5182 |
|
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5183 o coding-category-iso-7-tight |
|
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5184 |
|
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5185 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
|
5186 encode/decode only the specified charsets. |
| 17052 | 5187 |
| 5188 o coding-category-iso-8-1 | |
| 5189 | |
| 5190 The category for a coding system which has the same code range | |
| 5191 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
|
5192 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
|
5193 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
|
5194 symbol) `iso-latin-1' by default. |
| 17052 | 5195 |
| 5196 o coding-category-iso-8-2 | |
| 5197 | |
| 5198 The category for a coding system which has the same code range | |
| 5199 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
|
5200 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
|
5201 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
|
5202 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
|
5203 |
|
954e6be0a757
(detect_coding_iso2022): Distinguish coding-category-iso-7-else and
Kenichi Handa <handa@m17n.org>
parents:
18766
diff
changeset
|
5204 o coding-category-iso-7-else |
| 17052 | 5205 |
| 5206 The category for a coding system which has the same code range | |
| 88365 | 5207 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
|
5208 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
|
5209 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
|
5210 |
|
954e6be0a757
(detect_coding_iso2022): Distinguish coding-category-iso-7-else and
Kenichi Handa <handa@m17n.org>
parents:
18766
diff
changeset
|
5211 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
|
5212 |
|
954e6be0a757
(detect_coding_iso2022): Distinguish coding-category-iso-7-else and
Kenichi Handa <handa@m17n.org>
parents:
18766
diff
changeset
|
5213 The category for a coding system which has the same code range |
| 88365 | 5214 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
|
5215 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
|
5216 symbol) `iso-2022-8bit-ss2' by default. |
| 17052 | 5217 |
| 5218 o coding-category-big5 | |
| 5219 | |
| 5220 The category for a coding system which has the same code range | |
| 5221 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
|
5222 `cn-big5' by default. |
| 17052 | 5223 |
|
28022
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
5224 o coding-category-utf-8 |
|
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
5225 |
|
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
5226 The category for a coding system which has the same code range |
| 89851 | 5227 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
|
5228 symbol) `utf-8' by default. |
|
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
5229 |
|
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
5230 o coding-category-utf-16-be |
|
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
5231 |
|
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
5232 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
|
5233 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
|
5234 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
|
5235 `utf-16-be' by default. |
|
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
5236 |
|
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
5237 o coding-category-utf-16-le |
|
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
5238 |
|
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
5239 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
|
5240 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
|
5241 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
|
5242 symbol) `utf-16-le' by default. |
|
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
5243 |
|
22874
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
5244 o coding-category-ccl |
|
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
5245 |
|
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
5246 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
|
5247 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
|
5248 coding system is assigned. |
|
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
5249 |
| 17052 | 5250 o coding-category-binary |
| 5251 | |
| 5252 The category for a coding system not categorized in any of the | |
| 5253 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
|
5254 `no-conversion' by default. |
| 17052 | 5255 |
| 5256 Each of them is a Lisp symbol and the value is an actual | |
| 88365 | 5257 `coding-system's (this is also a Lisp symbol) assigned by a user. |
| 17052 | 5258 What Emacs does actually is to detect a category of coding system. |
| 5259 Then, it uses a `coding-system' assigned to it. If Emacs can't | |
| 88365 | 5260 decide only one possible category, it selects a category of the |
| 17052 | 5261 highest priority. Priorities of categories are also specified by a |
| 5262 user in a Lisp variable `coding-category-list'. | |
| 5263 | |
| 5264 */ | |
| 5265 | |
| 88365 | 5266 #define EOL_SEEN_NONE 0 |
| 5267 #define EOL_SEEN_LF 1 | |
| 5268 #define EOL_SEEN_CR 2 | |
| 5269 #define EOL_SEEN_CRLF 4 | |
| 5270 | |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
5271 /* 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
|
5272 SOURCE is encoded. If CATEGORY is one of |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
5273 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
|
5274 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
|
5275 |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
5276 Return one of EOL_SEEN_XXX. */ |
| 17052 | 5277 |
|
19173
04ed7c3f5cee
(detect_eol_type): If EOL representation does not
Richard M. Stallman <rms@gnu.org>
parents:
19134
diff
changeset
|
5278 #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
|
5279 |
|
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5280 static int |
|
89193
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
5281 detect_eol (source, src_bytes, category) |
|
89863
428fc37b2ae6
Add many prototypes for static functions.
Kenichi Handa <handa@m17n.org>
parents:
89861
diff
changeset
|
5282 const unsigned char *source; |
| 88365 | 5283 EMACS_INT src_bytes; |
|
89193
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
5284 enum coding_category category; |
| 17052 | 5285 { |
|
89863
428fc37b2ae6
Add many prototypes for static functions.
Kenichi Handa <handa@m17n.org>
parents:
89861
diff
changeset
|
5286 const unsigned char *src = source, *src_end = src + src_bytes; |
| 17052 | 5287 unsigned char c; |
| 88365 | 5288 int total = 0; |
| 5289 int eol_seen = EOL_SEEN_NONE; | |
| 5290 | |
|
89193
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
5291 if ((1 << category) & CATEGORY_MASK_UTF_16) |
| 88365 | 5292 { |
| 5293 int msb, lsb; | |
| 5294 | |
|
89193
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
5295 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
|
5296 | coding_category_utf_16_le_nosig); |
| 88365 | 5297 lsb = 1 - msb; |
| 5298 | |
| 5299 while (src + 1 < src_end) | |
| 17052 | 5300 { |
| 88365 | 5301 c = src[lsb]; |
| 5302 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
|
5303 { |
| 88365 | 5304 int this_eol; |
| 5305 | |
| 5306 if (c == '\n') | |
| 5307 this_eol = EOL_SEEN_LF; | |
| 5308 else if (src + 3 >= src_end | |
| 5309 || src[msb + 2] != 0 | |
| 5310 || src[lsb + 2] != '\n') | |
| 5311 this_eol = EOL_SEEN_CR; | |
| 5312 else | |
| 89483 | 5313 this_eol = EOL_SEEN_CRLF; |
| 88365 | 5314 |
| 5315 if (eol_seen == EOL_SEEN_NONE) | |
| 5316 /* This is the first end-of-line. */ | |
| 5317 eol_seen = this_eol; | |
| 5318 else if (eol_seen != this_eol) | |
| 5319 { | |
| 5320 /* The found type is different from what found before. */ | |
| 5321 eol_seen = EOL_SEEN_LF; | |
| 5322 break; | |
| 5323 } | |
| 5324 if (++total == MAX_EOL_CHECK_COUNT) | |
| 5325 break; | |
| 5326 } | |
| 5327 src += 2; | |
| 5328 } | |
|
30833
2db6e42a6ba3
(MINIMUM_CONVERSION_BUFFER_SIZE): Macro deleted.
Kenichi Handa <handa@m17n.org>
parents:
30756
diff
changeset
|
5329 } |
| 88365 | 5330 else |
| 5331 { | |
| 5332 while (src < src_end) | |
| 5333 { | |
| 5334 c = *src++; | |
| 5335 if (c == '\n' || c == '\r') | |
| 5336 { | |
| 5337 int this_eol; | |
| 5338 | |
| 5339 if (c == '\n') | |
| 5340 this_eol = EOL_SEEN_LF; | |
| 5341 else if (src >= src_end || *src != '\n') | |
| 5342 this_eol = EOL_SEEN_CR; | |
| 5343 else | |
| 5344 this_eol = EOL_SEEN_CRLF, src++; | |
| 5345 | |
| 5346 if (eol_seen == EOL_SEEN_NONE) | |
| 5347 /* This is the first end-of-line. */ | |
| 5348 eol_seen = this_eol; | |
| 5349 else if (eol_seen != this_eol) | |
| 5350 { | |
| 5351 /* The found type is different from what found before. */ | |
| 5352 eol_seen = EOL_SEEN_LF; | |
| 5353 break; | |
| 5354 } | |
| 5355 if (++total == MAX_EOL_CHECK_COUNT) | |
| 5356 break; | |
|
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5357 } |
| 17052 | 5358 } |
| 5359 } | |
| 88365 | 5360 return eol_seen; |
| 17052 | 5361 } |
| 5362 | |
| 88365 | 5363 |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5364 static Lisp_Object |
| 88365 | 5365 adjust_coding_eol_type (coding, eol_seen) |
| 5366 struct coding_system *coding; | |
| 5367 int eol_seen; | |
| 5368 { | |
|
88430
6418a272b97e
* coding.c: Delete unused variables.
Kenichi Handa <handa@m17n.org>
parents:
88365
diff
changeset
|
5369 Lisp_Object eol_type; |
| 89483 | 5370 |
| 88365 | 5371 eol_type = CODING_ID_EOL_TYPE (coding->id); |
| 5372 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
|
5373 { |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5374 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
|
5375 eol_type = Qunix; |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5376 } |
|
88862
108e2535280d
(adjust_coding_eol_type): Fix eol_type/eol_seen mixup.
Dave Love <fx@gnu.org>
parents:
88856
diff
changeset
|
5377 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
|
5378 { |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5379 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
|
5380 eol_type = Qdos; |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5381 } |
|
88862
108e2535280d
(adjust_coding_eol_type): Fix eol_type/eol_seen mixup.
Dave Love <fx@gnu.org>
parents:
88856
diff
changeset
|
5382 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
|
5383 { |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5384 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
|
5385 eol_type = Qmac; |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5386 } |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5387 return eol_type; |
| 88365 | 5388 } |
| 5389 | |
| 5390 /* Detect how a text specified in CODING is encoded. If a coding | |
| 5391 system is detected, update fields of CODING by the detected coding | |
| 5392 system. */ | |
| 5393 | |
| 5394 void | |
| 5395 detect_coding (coding) | |
| 5396 struct coding_system *coding; | |
|
28022
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
5397 { |
| 89483 | 5398 const unsigned char *src, *src_end; |
| 88365 | 5399 Lisp_Object attrs, coding_type; |
| 5400 | |
| 5401 coding->consumed = coding->consumed_char = 0; | |
| 5402 coding->produced = coding->produced_char = 0; | |
| 5403 coding_set_source (coding); | |
| 5404 | |
| 5405 src_end = coding->source + coding->src_bytes; | |
| 5406 | |
| 5407 /* If we have not yet decided the text encoding type, detect it | |
| 5408 now. */ | |
| 5409 if (EQ (CODING_ATTR_TYPE (CODING_ID_ATTRS (coding->id)), Qundecided)) | |
| 5410 { | |
| 5411 int c, i; | |
| 5412 | |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5413 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
|
5414 { |
| 88365 | 5415 c = *src; |
|
89780
a53cb5864a40
(detect_coding_iso_2022): Fix handling of SS2 and SS3.
Kenichi Handa <handa@m17n.org>
parents:
89779
diff
changeset
|
5416 if (c & 0x80 || (c < 0x20 && (c == ISO_CODE_ESC |
| 88365 | 5417 || c == ISO_CODE_SI |
| 5418 || c == ISO_CODE_SO))) | |
| 5419 break; | |
| 5420 } | |
| 5421 coding->head_ascii = src - (coding->source + coding->consumed); | |
| 5422 | |
| 5423 if (coding->head_ascii < coding->src_bytes) | |
| 5424 { | |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
5425 struct coding_detection_info detect_info; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
5426 enum coding_category category; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
5427 struct coding_system *this; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
5428 |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
5429 detect_info.checked = detect_info.found = detect_info.rejected = 0; |
| 88365 | 5430 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
|
5431 { |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
5432 category = coding_priorities[i]; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
5433 this = coding_categories + category; |
| 88365 | 5434 if (this->id < 0) |
|
28022
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
5435 { |
| 88365 | 5436 /* 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
|
5437 detect_info.rejected |= (1 << category); |
|
28022
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
5438 } |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
5439 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
|
5440 continue; |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
5441 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
|
5442 { |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
5443 if (detect_info.found & (1 << category)) |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
5444 break; |
|
28022
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
5445 } |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
5446 else if ((*(this->detector)) (coding, &detect_info) |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
5447 && 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
|
5448 { |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5449 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
|
5450 { |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5451 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
|
5452 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
|
5453 else |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5454 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
|
5455 } |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5456 break; |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5457 } |
|
28022
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
5458 } |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
5459 if (i < coding_category_raw_text) |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
5460 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
|
5461 else if (detect_info.rejected == CATEGORY_MASK_ANY) |
| 88365 | 5462 setup_coding_system (Qraw_text, coding); |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
5463 else if (detect_info.rejected) |
| 88365 | 5464 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
|
5465 if (! (detect_info.rejected & (1 << coding_priorities[i]))) |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
5466 { |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
5467 this = coding_categories + coding_priorities[i]; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
5468 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
|
5469 break; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
5470 } |
| 88365 | 5471 } |
| 5472 } | |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5473 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
|
5474 == coding_category_utf_16_auto) |
|
89420
c3e67ce6ee0f
(Qsignature, Qendian): Delete these variables.
Kenichi Handa <handa@m17n.org>
parents:
89418
diff
changeset
|
5475 { |
|
c3e67ce6ee0f
(Qsignature, Qendian): Delete these variables.
Kenichi Handa <handa@m17n.org>
parents:
89418
diff
changeset
|
5476 Lisp_Object coding_systems; |
|
c3e67ce6ee0f
(Qsignature, Qendian): Delete these variables.
Kenichi Handa <handa@m17n.org>
parents:
89418
diff
changeset
|
5477 struct coding_detection_info detect_info; |
|
c3e67ce6ee0f
(Qsignature, Qendian): Delete these variables.
Kenichi Handa <handa@m17n.org>
parents:
89418
diff
changeset
|
5478 |
|
c3e67ce6ee0f
(Qsignature, Qendian): Delete these variables.
Kenichi Handa <handa@m17n.org>
parents:
89418
diff
changeset
|
5479 coding_systems |
|
c3e67ce6ee0f
(Qsignature, Qendian): Delete these variables.
Kenichi Handa <handa@m17n.org>
parents:
89418
diff
changeset
|
5480 = 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
|
5481 detect_info.found = detect_info.rejected = 0; |
|
c3e67ce6ee0f
(Qsignature, Qendian): Delete these variables.
Kenichi Handa <handa@m17n.org>
parents:
89418
diff
changeset
|
5482 if (CONSP (coding_systems) |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5483 && detect_coding_utf_16 (coding, &detect_info)) |
|
89420
c3e67ce6ee0f
(Qsignature, Qendian): Delete these variables.
Kenichi Handa <handa@m17n.org>
parents:
89418
diff
changeset
|
5484 { |
|
c3e67ce6ee0f
(Qsignature, Qendian): Delete these variables.
Kenichi Handa <handa@m17n.org>
parents:
89418
diff
changeset
|
5485 if (detect_info.found & CATEGORY_MASK_UTF_16_LE) |
|
c3e67ce6ee0f
(Qsignature, Qendian): Delete these variables.
Kenichi Handa <handa@m17n.org>
parents:
89418
diff
changeset
|
5486 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
|
5487 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
|
5488 setup_coding_system (XCDR (coding_systems), coding); |
|
c3e67ce6ee0f
(Qsignature, Qendian): Delete these variables.
Kenichi Handa <handa@m17n.org>
parents:
89418
diff
changeset
|
5489 } |
|
c3e67ce6ee0f
(Qsignature, Qendian): Delete these variables.
Kenichi Handa <handa@m17n.org>
parents:
89418
diff
changeset
|
5490 } |
| 88365 | 5491 } |
| 5492 | |
| 5493 | |
| 5494 static void | |
| 5495 decode_eol (coding) | |
| 5496 struct coding_system *coding; | |
| 5497 { | |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5498 Lisp_Object eol_type; |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5499 unsigned char *p, *pbeg, *pend; |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5500 |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5501 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
|
5502 if (EQ (eol_type, Qunix)) |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5503 return; |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5504 |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5505 if (NILP (coding->dst_object)) |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5506 pbeg = coding->destination; |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5507 else |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5508 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
|
5509 pend = pbeg + coding->produced; |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5510 |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5511 if (VECTORP (eol_type)) |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5512 { |
| 88365 | 5513 int eol_seen = EOL_SEEN_NONE; |
| 5514 | |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5515 for (p = pbeg; p < pend; p++) |
| 88365 | 5516 { |
| 5517 if (*p == '\n') | |
| 5518 eol_seen |= EOL_SEEN_LF; | |
| 5519 else if (*p == '\r') | |
|
28022
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
5520 { |
| 88365 | 5521 if (p + 1 < pend && *(p + 1) == '\n') |
| 5522 { | |
| 5523 eol_seen |= EOL_SEEN_CRLF; | |
| 5524 p++; | |
| 5525 } | |
| 5526 else | |
| 5527 eol_seen |= EOL_SEEN_CR; | |
|
28022
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
5528 } |
|
6c41f3276340
Add comments on coding-category-utf-8,
Kenichi Handa <handa@m17n.org>
parents:
27943
diff
changeset
|
5529 } |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5530 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
|
5531 && eol_seen != EOL_SEEN_LF |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5532 && eol_seen != EOL_SEEN_CRLF |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5533 && eol_seen != EOL_SEEN_CR) |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5534 eol_seen = EOL_SEEN_LF; |
| 88365 | 5535 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
|
5536 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
|
5537 } |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5538 |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5539 if (EQ (eol_type, Qmac)) |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5540 { |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5541 for (p = pbeg; p < pend; p++) |
| 88365 | 5542 if (*p == '\r') |
| 5543 *p = '\n'; | |
| 5544 } | |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5545 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
|
5546 { |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5547 int n = 0; |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5548 |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5549 if (NILP (coding->dst_object)) |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5550 { |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5551 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
|
5552 if (*p == '\r') |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5553 { |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5554 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
|
5555 n++; |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5556 } |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5557 } |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5558 else |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5559 { |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5560 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
|
5561 if (*p == '\r') |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5562 { |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5563 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
|
5564 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
|
5565 |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5566 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
|
5567 n++; |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5568 } |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5569 } |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5570 coding->produced -= n; |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
5571 coding->produced_char -= n; |
| 17052 | 5572 } |
| 5573 } | |
| 5574 | |
|
89732
8acde12aba89
(get_translation_table): New function.
Kenichi Handa <handa@m17n.org>
parents:
89730
diff
changeset
|
5575 |
|
89759
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
5576 /* Return a translation table (or list of them) from coding system |
|
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
5577 attribute vector ATTRS for encoding (ENCODEP is nonzero) or |
|
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
5578 decoding (ENCODEP is zero). */ |
|
89732
8acde12aba89
(get_translation_table): New function.
Kenichi Handa <handa@m17n.org>
parents:
89730
diff
changeset
|
5579 |
|
89858
23cb9ed79225
(get_translation_table): Declare it as Lisp_Object.
Kenichi Handa <handa@m17n.org>
parents:
89856
diff
changeset
|
5580 static Lisp_Object |
|
89859
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
5581 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
|
5582 Lisp_Object attrs; |
|
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
5583 int encodep, *max_lookup; |
|
89732
8acde12aba89
(get_translation_table): New function.
Kenichi Handa <handa@m17n.org>
parents:
89730
diff
changeset
|
5584 { |
|
8acde12aba89
(get_translation_table): New function.
Kenichi Handa <handa@m17n.org>
parents:
89730
diff
changeset
|
5585 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
|
5586 Lisp_Object val; |
|
89732
8acde12aba89
(get_translation_table): New function.
Kenichi Handa <handa@m17n.org>
parents:
89730
diff
changeset
|
5587 |
|
8acde12aba89
(get_translation_table): New function.
Kenichi Handa <handa@m17n.org>
parents:
89730
diff
changeset
|
5588 if (encodep) |
|
8acde12aba89
(get_translation_table): New function.
Kenichi Handa <handa@m17n.org>
parents:
89730
diff
changeset
|
5589 translation_table = CODING_ATTR_ENCODE_TBL (attrs), |
|
8acde12aba89
(get_translation_table): New function.
Kenichi Handa <handa@m17n.org>
parents:
89730
diff
changeset
|
5590 standard = Vstandard_translation_table_for_encode; |
|
8acde12aba89
(get_translation_table): New function.
Kenichi Handa <handa@m17n.org>
parents:
89730
diff
changeset
|
5591 else |
|
8acde12aba89
(get_translation_table): New function.
Kenichi Handa <handa@m17n.org>
parents:
89730
diff
changeset
|
5592 translation_table = CODING_ATTR_DECODE_TBL (attrs), |
|
8acde12aba89
(get_translation_table): New function.
Kenichi Handa <handa@m17n.org>
parents:
89730
diff
changeset
|
5593 standard = Vstandard_translation_table_for_decode; |
|
89759
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
5594 if (NILP (translation_table)) |
|
89859
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
5595 translation_table = standard; |
|
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
5596 else |
|
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
5597 { |
|
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
5598 if (SYMBOLP (translation_table)) |
|
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
5599 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
|
5600 else if (CONSP (translation_table)) |
|
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
5601 { |
|
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
5602 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
|
5603 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
|
5604 if (SYMBOLP (XCAR (val))) |
|
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
5605 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
|
5606 } |
|
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
5607 if (CHAR_TABLE_P (standard)) |
|
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
5608 { |
|
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
5609 if (CONSP (translation_table)) |
|
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
5610 translation_table = nconc2 (translation_table, |
|
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
5611 Fcons (standard, Qnil)); |
|
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
5612 else |
|
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
5613 translation_table = Fcons (translation_table, |
|
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
5614 Fcons (standard, Qnil)); |
|
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
5615 } |
|
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
5616 } |
|
89861
7160ded23e55
(get_translation_table): Allow max_lookup to be NULL.
Kenichi Handa <handa@m17n.org>
parents:
89859
diff
changeset
|
5617 |
|
7160ded23e55
(get_translation_table): Allow max_lookup to be NULL.
Kenichi Handa <handa@m17n.org>
parents:
89859
diff
changeset
|
5618 if (max_lookup) |
|
7160ded23e55
(get_translation_table): Allow max_lookup to be NULL.
Kenichi Handa <handa@m17n.org>
parents:
89859
diff
changeset
|
5619 { |
|
7160ded23e55
(get_translation_table): Allow max_lookup to be NULL.
Kenichi Handa <handa@m17n.org>
parents:
89859
diff
changeset
|
5620 *max_lookup = 1; |
|
7160ded23e55
(get_translation_table): Allow max_lookup to be NULL.
Kenichi Handa <handa@m17n.org>
parents:
89859
diff
changeset
|
5621 if (CHAR_TABLE_P (translation_table) |
|
7160ded23e55
(get_translation_table): Allow max_lookup to be NULL.
Kenichi Handa <handa@m17n.org>
parents:
89859
diff
changeset
|
5622 && CHAR_TABLE_EXTRA_SLOTS (XCHAR_TABLE (translation_table)) > 1) |
|
7160ded23e55
(get_translation_table): Allow max_lookup to be NULL.
Kenichi Handa <handa@m17n.org>
parents:
89859
diff
changeset
|
5623 { |
|
7160ded23e55
(get_translation_table): Allow max_lookup to be NULL.
Kenichi Handa <handa@m17n.org>
parents:
89859
diff
changeset
|
5624 val = XCHAR_TABLE (translation_table)->extras[1]; |
|
7160ded23e55
(get_translation_table): Allow max_lookup to be NULL.
Kenichi Handa <handa@m17n.org>
parents:
89859
diff
changeset
|
5625 if (NATNUMP (val) && *max_lookup < XFASTINT (val)) |
|
7160ded23e55
(get_translation_table): Allow max_lookup to be NULL.
Kenichi Handa <handa@m17n.org>
parents:
89859
diff
changeset
|
5626 *max_lookup = XFASTINT (val); |
|
7160ded23e55
(get_translation_table): Allow max_lookup to be NULL.
Kenichi Handa <handa@m17n.org>
parents:
89859
diff
changeset
|
5627 } |
|
7160ded23e55
(get_translation_table): Allow max_lookup to be NULL.
Kenichi Handa <handa@m17n.org>
parents:
89859
diff
changeset
|
5628 else if (CONSP (translation_table)) |
|
7160ded23e55
(get_translation_table): Allow max_lookup to be NULL.
Kenichi Handa <handa@m17n.org>
parents:
89859
diff
changeset
|
5629 { |
|
7160ded23e55
(get_translation_table): Allow max_lookup to be NULL.
Kenichi Handa <handa@m17n.org>
parents:
89859
diff
changeset
|
5630 Lisp_Object tail, val; |
|
7160ded23e55
(get_translation_table): Allow max_lookup to be NULL.
Kenichi Handa <handa@m17n.org>
parents:
89859
diff
changeset
|
5631 |
|
7160ded23e55
(get_translation_table): Allow max_lookup to be NULL.
Kenichi Handa <handa@m17n.org>
parents:
89859
diff
changeset
|
5632 for (tail = translation_table; CONSP (tail); tail = XCDR (tail)) |
|
7160ded23e55
(get_translation_table): Allow max_lookup to be NULL.
Kenichi Handa <handa@m17n.org>
parents:
89859
diff
changeset
|
5633 if (CHAR_TABLE_P (XCAR (tail)) |
|
7160ded23e55
(get_translation_table): Allow max_lookup to be NULL.
Kenichi Handa <handa@m17n.org>
parents:
89859
diff
changeset
|
5634 && CHAR_TABLE_EXTRA_SLOTS (XCHAR_TABLE (XCAR (tail))) > 1) |
|
7160ded23e55
(get_translation_table): Allow max_lookup to be NULL.
Kenichi Handa <handa@m17n.org>
parents:
89859
diff
changeset
|
5635 { |
|
7160ded23e55
(get_translation_table): Allow max_lookup to be NULL.
Kenichi Handa <handa@m17n.org>
parents:
89859
diff
changeset
|
5636 val = XCHAR_TABLE (XCAR (tail))->extras[1]; |
|
7160ded23e55
(get_translation_table): Allow max_lookup to be NULL.
Kenichi Handa <handa@m17n.org>
parents:
89859
diff
changeset
|
5637 if (NATNUMP (val) && *max_lookup < XFASTINT (val)) |
|
7160ded23e55
(get_translation_table): Allow max_lookup to be NULL.
Kenichi Handa <handa@m17n.org>
parents:
89859
diff
changeset
|
5638 *max_lookup = XFASTINT (val); |
|
7160ded23e55
(get_translation_table): Allow max_lookup to be NULL.
Kenichi Handa <handa@m17n.org>
parents:
89859
diff
changeset
|
5639 } |
|
7160ded23e55
(get_translation_table): Allow max_lookup to be NULL.
Kenichi Handa <handa@m17n.org>
parents:
89859
diff
changeset
|
5640 } |
|
89759
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
5641 } |
|
89732
8acde12aba89
(get_translation_table): New function.
Kenichi Handa <handa@m17n.org>
parents:
89730
diff
changeset
|
5642 return translation_table; |
|
8acde12aba89
(get_translation_table): New function.
Kenichi Handa <handa@m17n.org>
parents:
89730
diff
changeset
|
5643 } |
|
8acde12aba89
(get_translation_table): New function.
Kenichi Handa <handa@m17n.org>
parents:
89730
diff
changeset
|
5644 |
|
89859
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
5645 #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
|
5646 do { \ |
|
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
5647 trans = Qnil; \ |
|
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
5648 if (CHAR_TABLE_P (table)) \ |
|
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
5649 { \ |
|
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
5650 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
|
5651 if (CHARACTERP (trans)) \ |
|
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
5652 c = XFASTINT (trans), trans = Qnil; \ |
|
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
5653 } \ |
|
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
5654 else if (CONSP (table)) \ |
|
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
5655 { \ |
|
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
5656 Lisp_Object tail; \ |
|
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
5657 \ |
|
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
5658 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
|
5659 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
|
5660 { \ |
|
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
5661 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
|
5662 if (CHARACTERP (trans)) \ |
|
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
5663 c = XFASTINT (trans), trans = Qnil; \ |
|
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
5664 else if (! NILP (trans)) \ |
|
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
5665 break; \ |
|
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
5666 } \ |
|
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
5667 } \ |
|
89858
23cb9ed79225
(get_translation_table): Declare it as Lisp_Object.
Kenichi Handa <handa@m17n.org>
parents:
89856
diff
changeset
|
5668 } while (0) |
|
23cb9ed79225
(get_translation_table): Declare it as Lisp_Object.
Kenichi Handa <handa@m17n.org>
parents:
89856
diff
changeset
|
5669 |
|
89732
8acde12aba89
(get_translation_table): New function.
Kenichi Handa <handa@m17n.org>
parents:
89730
diff
changeset
|
5670 |
|
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
5671 static Lisp_Object |
|
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
5672 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
|
5673 Lisp_Object val; |
|
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
5674 int *buf, *buf_end; |
|
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
5675 int last_block; |
|
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
5676 int *from_nchars, *to_nchars; |
|
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
5677 { |
|
89856
18b52da60a76
(get_translation): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89852
diff
changeset
|
5678 /* 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
|
5679 [TO-CHAR ...]. */ |
|
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
5680 if (CONSP (val)) |
|
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
5681 { |
|
89856
18b52da60a76
(get_translation): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89852
diff
changeset
|
5682 Lisp_Object from, tail; |
|
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
5683 int i, len; |
|
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
5684 |
|
89856
18b52da60a76
(get_translation): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89852
diff
changeset
|
5685 for (tail = val; CONSP (tail); tail = XCDR (tail)) |
|
18b52da60a76
(get_translation): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89852
diff
changeset
|
5686 { |
|
18b52da60a76
(get_translation): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89852
diff
changeset
|
5687 val = XCAR (tail); |
|
18b52da60a76
(get_translation): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89852
diff
changeset
|
5688 from = XCAR (val); |
|
18b52da60a76
(get_translation): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89852
diff
changeset
|
5689 len = ASIZE (from); |
|
18b52da60a76
(get_translation): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89852
diff
changeset
|
5690 for (i = 0; i < len; i++) |
|
18b52da60a76
(get_translation): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89852
diff
changeset
|
5691 { |
|
18b52da60a76
(get_translation): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89852
diff
changeset
|
5692 if (buf + i == buf_end) |
|
18b52da60a76
(get_translation): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89852
diff
changeset
|
5693 { |
|
18b52da60a76
(get_translation): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89852
diff
changeset
|
5694 if (! last_block) |
|
18b52da60a76
(get_translation): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89852
diff
changeset
|
5695 return Qt; |
|
18b52da60a76
(get_translation): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89852
diff
changeset
|
5696 break; |
|
18b52da60a76
(get_translation): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89852
diff
changeset
|
5697 } |
|
18b52da60a76
(get_translation): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89852
diff
changeset
|
5698 if (XINT (AREF (from, i)) != buf[i]) |
|
18b52da60a76
(get_translation): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89852
diff
changeset
|
5699 break; |
|
18b52da60a76
(get_translation): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89852
diff
changeset
|
5700 } |
|
18b52da60a76
(get_translation): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89852
diff
changeset
|
5701 if (i == len) |
|
18b52da60a76
(get_translation): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89852
diff
changeset
|
5702 { |
|
18b52da60a76
(get_translation): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89852
diff
changeset
|
5703 val = XCDR (val); |
|
18b52da60a76
(get_translation): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89852
diff
changeset
|
5704 *from_nchars = len; |
|
18b52da60a76
(get_translation): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89852
diff
changeset
|
5705 break; |
|
18b52da60a76
(get_translation): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89852
diff
changeset
|
5706 } |
|
18b52da60a76
(get_translation): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89852
diff
changeset
|
5707 } |
|
18b52da60a76
(get_translation): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89852
diff
changeset
|
5708 if (! CONSP (tail)) |
|
18b52da60a76
(get_translation): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89852
diff
changeset
|
5709 return Qnil; |
|
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
5710 } |
|
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
5711 if (VECTORP (val)) |
|
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
5712 *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
|
5713 else |
|
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
5714 *buf = XINT (val); |
|
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
5715 return val; |
|
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
5716 } |
|
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
5717 |
|
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
5718 |
| 88365 | 5719 static int |
|
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
5720 produce_chars (coding, translation_table, last_block) |
| 88365 | 5721 struct coding_system *coding; |
|
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
5722 Lisp_Object translation_table; |
|
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
5723 int last_block; |
| 17052 | 5724 { |
| 88365 | 5725 unsigned char *dst = coding->destination + coding->produced; |
| 5726 unsigned char *dst_end = coding->destination + coding->dst_bytes; | |
| 5727 int produced; | |
| 5728 int produced_chars = 0; | |
|
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
5729 int carryover = 0; |
| 88365 | 5730 |
| 5731 if (! coding->chars_at_source) | |
| 5732 { | |
| 5733 /* Characters are in coding->charbuf. */ | |
|
89575
59d10ebd2a0b
(produce_chars): Revert last change.
Andreas Schwab <schwab@suse.de>
parents:
89571
diff
changeset
|
5734 int *buf = coding->charbuf; |
|
59d10ebd2a0b
(produce_chars): Revert last change.
Andreas Schwab <schwab@suse.de>
parents:
89571
diff
changeset
|
5735 int *buf_end = buf + coding->charbuf_used; |
| 88365 | 5736 |
| 5737 if (BUFFERP (coding->src_object) | |
| 5738 && EQ (coding->src_object, coding->dst_object)) | |
| 89483 | 5739 dst_end = ((unsigned char *) coding->source) + coding->consumed; |
| 88365 | 5740 |
| 5741 while (buf < buf_end) | |
| 5742 { | |
|
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
5743 int c = *buf, i; |
|
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
5744 |
| 88365 | 5745 if (c >= 0) |
| 5746 { | |
|
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
5747 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
|
5748 Lisp_Object trans = Qnil; |
|
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
5749 |
|
89859
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
5750 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
|
5751 if (! NILP (trans)) |
|
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
5752 { |
|
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
5753 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
|
5754 &from_nchars, &to_nchars); |
|
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
5755 if (EQ (trans, Qt)) |
|
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
5756 break; |
|
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
5757 c = *buf; |
|
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
5758 } |
|
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
5759 |
|
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
5760 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
|
5761 { |
|
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
5762 dst = alloc_destination (coding, |
|
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
5763 buf_end - buf |
|
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
5764 + MAX_MULTIBYTE_LENGTH * to_nchars, |
|
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
5765 dst); |
|
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
5766 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
|
5767 } |
|
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
5768 |
|
89856
18b52da60a76
(get_translation): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89852
diff
changeset
|
5769 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
|
5770 { |
|
89856
18b52da60a76
(get_translation): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89852
diff
changeset
|
5771 if (i > 0) |
|
18b52da60a76
(get_translation): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89852
diff
changeset
|
5772 c = XINT (AREF (trans, i)); |
|
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
5773 if (coding->dst_multibyte |
|
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
5774 || ! CHAR_BYTE8_P (c)) |
|
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
5775 CHAR_STRING_ADVANCE (c, dst); |
|
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
5776 else |
|
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
5777 *dst++ = CHAR_TO_BYTE8 (c); |
|
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
5778 } |
|
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
5779 produced_chars += to_nchars; |
|
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
5780 *buf++ = to_nchars; |
|
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
5781 while (--from_nchars > 0) |
|
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
5782 *buf++ = 0; |
| 88365 | 5783 } |
| 5784 else | |
|
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
5785 /* 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
|
5786 buf += -c; |
|
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
5787 } |
|
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
5788 carryover = buf_end - buf; |
|
30833
2db6e42a6ba3
(MINIMUM_CONVERSION_BUFFER_SIZE): Macro deleted.
Kenichi Handa <handa@m17n.org>
parents:
30756
diff
changeset
|
5789 } |
|
2db6e42a6ba3
(MINIMUM_CONVERSION_BUFFER_SIZE): Macro deleted.
Kenichi Handa <handa@m17n.org>
parents:
30756
diff
changeset
|
5790 else |
|
2db6e42a6ba3
(MINIMUM_CONVERSION_BUFFER_SIZE): Macro deleted.
Kenichi Handa <handa@m17n.org>
parents:
30756
diff
changeset
|
5791 { |
| 89483 | 5792 const unsigned char *src = coding->source; |
| 5793 const unsigned char *src_end = src + coding->src_bytes; | |
| 88365 | 5794 Lisp_Object eol_type; |
| 5795 | |
| 5796 eol_type = CODING_ID_EOL_TYPE (coding->id); | |
| 5797 | |
| 5798 if (coding->src_multibyte != coding->dst_multibyte) | |
|
34892
3868f2e7355a
(setup_coding_system): Initialize
Kenichi Handa <handa@m17n.org>
parents:
34888
diff
changeset
|
5799 { |
| 88365 | 5800 if (coding->src_multibyte) |
|
34892
3868f2e7355a
(setup_coding_system): Initialize
Kenichi Handa <handa@m17n.org>
parents:
34888
diff
changeset
|
5801 { |
|
88443
6b86cf30a0b9
(produce_chars): Set the variable `multibytep' correctly.
Kenichi Handa <handa@m17n.org>
parents:
88438
diff
changeset
|
5802 int multibytep = 1; |
| 88365 | 5803 int consumed_chars; |
| 5804 | |
| 5805 while (1) | |
|
34892
3868f2e7355a
(setup_coding_system): Initialize
Kenichi Handa <handa@m17n.org>
parents:
34888
diff
changeset
|
5806 { |
| 89483 | 5807 const unsigned char *src_base = src; |
| 88365 | 5808 int c; |
| 5809 | |
| 5810 ONE_MORE_BYTE (c); | |
| 5811 if (c == '\r') | |
| 5812 { | |
| 5813 if (EQ (eol_type, Qdos)) | |
| 5814 { | |
|
89279
1fd77c471ee6
(decode_coding_utf_8): When eol_type is Qdos, handle
Kenichi Handa <handa@m17n.org>
parents:
89227
diff
changeset
|
5815 if (src == src_end) |
|
1fd77c471ee6
(decode_coding_utf_8): When eol_type is Qdos, handle
Kenichi Handa <handa@m17n.org>
parents:
89227
diff
changeset
|
5816 { |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
5817 record_conversion_result |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
5818 (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
|
5819 goto no_more_source; |
|
1fd77c471ee6
(decode_coding_utf_8): When eol_type is Qdos, handle
Kenichi Handa <handa@m17n.org>
parents:
89227
diff
changeset
|
5820 } |
|
1fd77c471ee6
(decode_coding_utf_8): When eol_type is Qdos, handle
Kenichi Handa <handa@m17n.org>
parents:
89227
diff
changeset
|
5821 if (*src == '\n') |
| 88365 | 5822 c = *src++; |
| 5823 } | |
| 5824 else if (EQ (eol_type, Qmac)) | |
| 5825 c = '\n'; | |
| 5826 } | |
| 5827 if (dst == dst_end) | |
| 5828 { | |
|
88456
a7b309f72920
(coding_alloc_by_making_gap): Check the case that the
Kenichi Handa <handa@m17n.org>
parents:
88443
diff
changeset
|
5829 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
|
5830 |
|
a7b309f72920
(coding_alloc_by_making_gap): Check the case that the
Kenichi Handa <handa@m17n.org>
parents:
88443
diff
changeset
|
5831 if (EQ (coding->src_object, coding->dst_object)) |
| 89483 | 5832 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
|
5833 if (dst == dst_end) |
|
a7b309f72920
(coding_alloc_by_making_gap): Check the case that the
Kenichi Handa <handa@m17n.org>
parents:
88443
diff
changeset
|
5834 { |
|
a7b309f72920
(coding_alloc_by_making_gap): Check the case that the
Kenichi Handa <handa@m17n.org>
parents:
88443
diff
changeset
|
5835 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
|
5836 dst); |
|
a7b309f72920
(coding_alloc_by_making_gap): Check the case that the
Kenichi Handa <handa@m17n.org>
parents:
88443
diff
changeset
|
5837 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
|
5838 coding_set_source (coding); |
|
a7b309f72920
(coding_alloc_by_making_gap): Check the case that the
Kenichi Handa <handa@m17n.org>
parents:
88443
diff
changeset
|
5839 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
|
5840 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
|
5841 } |
| 88365 | 5842 } |
| 5843 *dst++ = c; | |
| 5844 produced_chars++; | |
| 5845 } | |
| 5846 no_more_source: | |
| 5847 ; | |
| 5848 } | |
| 5849 else | |
| 5850 while (src < src_end) | |
| 5851 { | |
|
88443
6b86cf30a0b9
(produce_chars): Set the variable `multibytep' correctly.
Kenichi Handa <handa@m17n.org>
parents:
88438
diff
changeset
|
5852 int multibytep = 1; |
| 88365 | 5853 int c = *src++; |
| 5854 | |
| 5855 if (c == '\r') | |
| 5856 { | |
| 5857 if (EQ (eol_type, Qdos)) | |
| 5858 { | |
| 5859 if (src < src_end | |
| 5860 && *src == '\n') | |
| 5861 c = *src++; | |
| 5862 } | |
| 5863 else if (EQ (eol_type, Qmac)) | |
| 5864 c = '\n'; | |
| 5865 } | |
| 5866 if (dst >= dst_end - 1) | |
| 5867 { | |
|
88456
a7b309f72920
(coding_alloc_by_making_gap): Check the case that the
Kenichi Handa <handa@m17n.org>
parents:
88443
diff
changeset
|
5868 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
|
5869 |
|
a7b309f72920
(coding_alloc_by_making_gap): Check the case that the
Kenichi Handa <handa@m17n.org>
parents:
88443
diff
changeset
|
5870 if (EQ (coding->src_object, coding->dst_object)) |
| 89483 | 5871 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
|
5872 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
|
5873 { |
|
a7b309f72920
(coding_alloc_by_making_gap): Check the case that the
Kenichi Handa <handa@m17n.org>
parents:
88443
diff
changeset
|
5874 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
|
5875 dst); |
|
a7b309f72920
(coding_alloc_by_making_gap): Check the case that the
Kenichi Handa <handa@m17n.org>
parents:
88443
diff
changeset
|
5876 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
|
5877 coding_set_source (coding); |
|
a7b309f72920
(coding_alloc_by_making_gap): Check the case that the
Kenichi Handa <handa@m17n.org>
parents:
88443
diff
changeset
|
5878 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
|
5879 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
|
5880 } |
| 88365 | 5881 } |
| 5882 EMIT_ONE_BYTE (c); | |
| 5883 } | |
| 5884 } | |
| 5885 else | |
| 5886 { | |
| 5887 if (!EQ (coding->src_object, coding->dst_object)) | |
| 5888 { | |
| 5889 int require = coding->src_bytes - coding->dst_bytes; | |
| 5890 | |
| 5891 if (require > 0) | |
| 5892 { | |
| 5893 EMACS_INT offset = src - coding->source; | |
| 5894 | |
| 5895 dst = alloc_destination (coding, require, dst); | |
| 5896 coding_set_source (coding); | |
| 5897 src = coding->source + offset; | |
| 5898 src_end = coding->source + coding->src_bytes; | |
|
34892
3868f2e7355a
(setup_coding_system): Initialize
Kenichi Handa <handa@m17n.org>
parents:
34888
diff
changeset
|
5899 } |
|
3868f2e7355a
(setup_coding_system): Initialize
Kenichi Handa <handa@m17n.org>
parents:
34888
diff
changeset
|
5900 } |
| 88365 | 5901 produced_chars = coding->src_chars; |
| 5902 while (src < src_end) | |
|
34892
3868f2e7355a
(setup_coding_system): Initialize
Kenichi Handa <handa@m17n.org>
parents:
34888
diff
changeset
|
5903 { |
| 88365 | 5904 int c = *src++; |
| 5905 | |
| 5906 if (c == '\r') | |
| 5907 { | |
| 5908 if (EQ (eol_type, Qdos)) | |
| 5909 { | |
| 5910 if (src < src_end | |
| 5911 && *src == '\n') | |
| 5912 c = *src++; | |
| 5913 produced_chars--; | |
| 5914 } | |
| 5915 else if (EQ (eol_type, Qmac)) | |
| 5916 c = '\n'; | |
| 5917 } | |
| 5918 *dst++ = c; | |
|
34892
3868f2e7355a
(setup_coding_system): Initialize
Kenichi Handa <handa@m17n.org>
parents:
34888
diff
changeset
|
5919 } |
|
3868f2e7355a
(setup_coding_system): Initialize
Kenichi Handa <handa@m17n.org>
parents:
34888
diff
changeset
|
5920 } |
|
88456
a7b309f72920
(coding_alloc_by_making_gap): Check the case that the
Kenichi Handa <handa@m17n.org>
parents:
88443
diff
changeset
|
5921 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
|
5922 coding->consumed_char = coding->src_chars; |
| 88365 | 5923 } |
| 5924 | |
| 5925 produced = dst - (coding->destination + coding->produced); | |
| 5926 if (BUFFERP (coding->dst_object)) | |
| 5927 insert_from_gap (produced_chars, produced); | |
| 5928 coding->produced += produced; | |
| 5929 coding->produced_char += produced_chars; | |
|
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
5930 return carryover; |
| 88365 | 5931 } |
| 5932 | |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
5933 /* 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
|
5934 CHARBUF. CHARBUF is an array: |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
5935 [ -LENGTH ANNOTATION_MASK FROM TO METHOD COMP_LEN [ COMPONENTS... ] ] |
| 88365 | 5936 */ |
| 5937 | |
| 5938 static INLINE void | |
|
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
5939 produce_composition (coding, charbuf, pos) |
| 88365 | 5940 struct coding_system *coding; |
| 5941 int *charbuf; | |
|
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
5942 EMACS_INT pos; |
| 88365 | 5943 { |
| 5944 int len; | |
|
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
5945 EMACS_INT to; |
| 88365 | 5946 enum composition_method method; |
| 5947 Lisp_Object components; | |
| 5948 | |
| 5949 len = -charbuf[0]; | |
|
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
5950 to = pos + charbuf[2]; |
|
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
5951 method = (enum composition_method) (charbuf[3]); |
| 88365 | 5952 |
| 5953 if (method == COMPOSITION_RELATIVE) | |
| 5954 components = Qnil; | |
| 5955 else | |
| 5956 { | |
| 5957 Lisp_Object args[MAX_COMPOSITION_COMPONENTS * 2 - 1]; | |
| 5958 int i; | |
| 5959 | |
|
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
5960 len -= 4; |
|
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
5961 charbuf += 4; |
| 88365 | 5962 for (i = 0; i < len; i++) |
| 5963 args[i] = make_number (charbuf[i]); | |
| 5964 components = (method == COMPOSITION_WITH_ALTCHARS | |
| 5965 ? Fstring (len, args) : Fvector (len, args)); | |
| 5966 } | |
|
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
5967 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
|
5968 } |
|
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
5969 |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
5970 |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
5971 /* 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
|
5972 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
|
5973 [ -LENGTH ANNOTATION_MASK NCHARS CHARSET-ID ] |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
5974 */ |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
5975 |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
5976 static INLINE void |
|
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
5977 produce_charset (coding, charbuf, pos) |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
5978 struct coding_system *coding; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
5979 int *charbuf; |
|
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
5980 EMACS_INT pos; |
|
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
5981 { |
|
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
5982 EMACS_INT from = pos - charbuf[2]; |
|
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
5983 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
|
5984 |
|
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
5985 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
|
5986 Qcharset, CHARSET_NAME (charset), |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
5987 coding->dst_object); |
| 88365 | 5988 } |
| 5989 | |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
5990 |
| 88365 | 5991 #define CHARBUF_SIZE 0x4000 |
| 5992 | |
| 5993 #define ALLOC_CONVERSION_WORK_AREA(coding) \ | |
| 5994 do { \ | |
| 5995 int size = CHARBUF_SIZE;; \ | |
| 5996 \ | |
| 5997 coding->charbuf = NULL; \ | |
| 5998 while (size > 1024) \ | |
| 5999 { \ | |
| 6000 coding->charbuf = (int *) alloca (sizeof (int) * size); \ | |
| 6001 if (coding->charbuf) \ | |
| 6002 break; \ | |
| 6003 size >>= 1; \ | |
| 6004 } \ | |
| 6005 if (! coding->charbuf) \ | |
| 6006 { \ | |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
6007 record_conversion_result (coding, CODING_RESULT_INSUFFICIENT_MEM); \ |
| 88365 | 6008 return coding->result; \ |
| 6009 } \ | |
| 6010 coding->charbuf_size = size; \ | |
| 6011 } while (0) | |
| 6012 | |
|
29725
2bc397e9b09a
(setup_coding_system) <4>: Reset member `cr_carryover'.
Kenichi Handa <handa@m17n.org>
parents:
29663
diff
changeset
|
6013 |
|
2bc397e9b09a
(setup_coding_system) <4>: Reset member `cr_carryover'.
Kenichi Handa <handa@m17n.org>
parents:
29663
diff
changeset
|
6014 static void |
|
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
6015 produce_annotation (coding, pos) |
|
29725
2bc397e9b09a
(setup_coding_system) <4>: Reset member `cr_carryover'.
Kenichi Handa <handa@m17n.org>
parents:
29663
diff
changeset
|
6016 struct coding_system *coding; |
|
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
6017 EMACS_INT pos; |
|
29725
2bc397e9b09a
(setup_coding_system) <4>: Reset member `cr_carryover'.
Kenichi Handa <handa@m17n.org>
parents:
29663
diff
changeset
|
6018 { |
| 88365 | 6019 int *charbuf = coding->charbuf; |
| 6020 int *charbuf_end = charbuf + coding->charbuf_used; | |
| 6021 | |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6022 if (NILP (coding->dst_object)) |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6023 return; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6024 |
| 88365 | 6025 while (charbuf < charbuf_end) |
| 6026 { | |
| 6027 if (*charbuf >= 0) | |
|
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
6028 pos += *charbuf++; |
| 88365 | 6029 else |
|
29877
7b43e1fb478a
(decode_eol_post_ccl): Special handling for undecided
Eli Zaretskii <eliz@gnu.org>
parents:
29725
diff
changeset
|
6030 { |
| 88365 | 6031 int len = -*charbuf; |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6032 switch (charbuf[1]) |
|
29725
2bc397e9b09a
(setup_coding_system) <4>: Reset member `cr_carryover'.
Kenichi Handa <handa@m17n.org>
parents:
29663
diff
changeset
|
6033 { |
| 88365 | 6034 case CODING_ANNOTATE_COMPOSITION_MASK: |
|
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
6035 produce_composition (coding, charbuf, pos); |
| 88365 | 6036 break; |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6037 case CODING_ANNOTATE_CHARSET_MASK: |
|
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
6038 produce_charset (coding, charbuf, pos); |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6039 break; |
| 88365 | 6040 default: |
| 6041 abort (); | |
|
29725
2bc397e9b09a
(setup_coding_system) <4>: Reset member `cr_carryover'.
Kenichi Handa <handa@m17n.org>
parents:
29663
diff
changeset
|
6042 } |
| 88365 | 6043 charbuf += len; |
|
29725
2bc397e9b09a
(setup_coding_system) <4>: Reset member `cr_carryover'.
Kenichi Handa <handa@m17n.org>
parents:
29663
diff
changeset
|
6044 } |
|
2bc397e9b09a
(setup_coding_system) <4>: Reset member `cr_carryover'.
Kenichi Handa <handa@m17n.org>
parents:
29663
diff
changeset
|
6045 } |
|
2bc397e9b09a
(setup_coding_system) <4>: Reset member `cr_carryover'.
Kenichi Handa <handa@m17n.org>
parents:
29663
diff
changeset
|
6046 } |
|
2bc397e9b09a
(setup_coding_system) <4>: Reset member `cr_carryover'.
Kenichi Handa <handa@m17n.org>
parents:
29663
diff
changeset
|
6047 |
| 88365 | 6048 /* Decode the data at CODING->src_object into CODING->dst_object. |
| 6049 CODING->src_object is a buffer, a string, or nil. | |
| 6050 CODING->dst_object is a buffer. | |
| 6051 | |
| 6052 If CODING->src_object is a buffer, it must be the current buffer. | |
| 6053 In this case, if CODING->src_pos is positive, it is a position of | |
| 6054 the source text in the buffer, otherwise, the source text is in the | |
| 6055 gap area of the buffer, and CODING->src_pos specifies the offset of | |
| 6056 the text from GPT (which must be the same as PT). If this is the | |
| 6057 same buffer as CODING->dst_object, CODING->src_pos must be | |
| 6058 negative. | |
| 6059 | |
| 6060 If CODING->src_object is a string, CODING->src_pos in an index to | |
| 6061 that string. | |
| 6062 | |
| 6063 If CODING->src_object is nil, CODING->source must already point to | |
| 6064 the non-relocatable memory area. In this case, CODING->src_pos is | |
| 6065 an offset from CODING->source. | |
| 6066 | |
| 6067 The decoded data is inserted at the current point of the buffer | |
| 6068 CODING->dst_object. | |
| 6069 */ | |
| 6070 | |
| 6071 static int | |
| 6072 decode_coding (coding) | |
|
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
6073 struct coding_system *coding; |
|
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
6074 { |
| 88365 | 6075 Lisp_Object attrs; |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6076 Lisp_Object undo_list; |
|
89732
8acde12aba89
(get_translation_table): New function.
Kenichi Handa <handa@m17n.org>
parents:
89730
diff
changeset
|
6077 Lisp_Object translation_table; |
|
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
6078 int carryover; |
|
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
6079 int i; |
| 88365 | 6080 |
| 6081 if (BUFFERP (coding->src_object) | |
| 6082 && coding->src_pos > 0 | |
| 6083 && coding->src_pos < GPT | |
| 6084 && coding->src_pos + coding->src_chars > GPT) | |
| 6085 move_gap_both (coding->src_pos, coding->src_pos_byte); | |
| 6086 | |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6087 undo_list = Qt; |
| 88365 | 6088 if (BUFFERP (coding->dst_object)) |
| 6089 { | |
| 6090 if (current_buffer != XBUFFER (coding->dst_object)) | |
| 6091 set_buffer_internal (XBUFFER (coding->dst_object)); | |
| 6092 if (GPT != PT) | |
| 6093 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
|
6094 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
|
6095 current_buffer->undo_list = Qt; |
| 88365 | 6096 } |
| 6097 | |
| 6098 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
|
6099 coding->produced = coding->produced_char = 0; |
| 88365 | 6100 coding->chars_at_source = 0; |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
6101 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
|
6102 coding->errors = 0; |
| 88365 | 6103 |
| 6104 ALLOC_CONVERSION_WORK_AREA (coding); | |
| 6105 | |
| 6106 attrs = CODING_ID_ATTRS (coding->id); | |
|
89861
7160ded23e55
(get_translation_table): Allow max_lookup to be NULL.
Kenichi Handa <handa@m17n.org>
parents:
89859
diff
changeset
|
6107 translation_table = get_translation_table (attrs, 0, NULL); |
| 88365 | 6108 |
|
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
6109 carryover = 0; |
| 88365 | 6110 do |
| 6111 { | |
|
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
6112 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
|
6113 |
| 88365 | 6114 coding_set_source (coding); |
| 6115 coding->annotated = 0; | |
|
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
6116 coding->charbuf_used = carryover; |
| 88365 | 6117 (*(coding->decoder)) (coding); |
| 6118 coding_set_destination (coding); | |
|
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
6119 carryover = produce_chars (coding, translation_table, 0); |
| 88365 | 6120 if (coding->annotated) |
|
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
6121 produce_annotation (coding, pos); |
|
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
6122 for (i = 0; i < carryover; i++) |
|
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
6123 coding->charbuf[i] |
|
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
6124 = coding->charbuf[coding->charbuf_used - carryover + i]; |
| 88365 | 6125 } |
| 6126 while (coding->consumed < coding->src_bytes | |
| 6127 && ! coding->result); | |
| 6128 | |
|
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
6129 if (carryover > 0) |
|
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
6130 { |
|
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
6131 coding_set_destination (coding); |
|
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
6132 coding->charbuf_used = carryover; |
|
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
6133 produce_chars (coding, translation_table, 1); |
|
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
6134 } |
|
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
6135 |
| 88365 | 6136 coding->carryover_bytes = 0; |
| 6137 if (coding->consumed < coding->src_bytes) | |
| 6138 { | |
| 6139 int nbytes = coding->src_bytes - coding->consumed; | |
| 89483 | 6140 const unsigned char *src; |
| 88365 | 6141 |
| 6142 coding_set_source (coding); | |
| 6143 coding_set_destination (coding); | |
| 6144 src = coding->source + coding->consumed; | |
| 6145 | |
| 6146 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
|
6147 { |
| 88365 | 6148 /* Flush out unprocessed data as binary chars. We are sure |
| 6149 that the number of data is less than the size of | |
| 6150 coding->charbuf. */ | |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
6151 coding->charbuf_used = 0; |
| 88365 | 6152 while (nbytes-- > 0) |
| 6153 { | |
| 6154 int c = *src++; | |
|
89279
1fd77c471ee6
(decode_coding_utf_8): When eol_type is Qdos, handle
Kenichi Handa <handa@m17n.org>
parents:
89227
diff
changeset
|
6155 |
|
1fd77c471ee6
(decode_coding_utf_8): When eol_type is Qdos, handle
Kenichi Handa <handa@m17n.org>
parents:
89227
diff
changeset
|
6156 coding->charbuf[coding->charbuf_used++] = (c & 0x80 ? - c : c); |
| 88365 | 6157 } |
|
89863
428fc37b2ae6
Add many prototypes for static functions.
Kenichi Handa <handa@m17n.org>
parents:
89861
diff
changeset
|
6158 produce_chars (coding, Qnil, 1); |
|
29725
2bc397e9b09a
(setup_coding_system) <4>: Reset member `cr_carryover'.
Kenichi Handa <handa@m17n.org>
parents:
29663
diff
changeset
|
6159 } |
| 88365 | 6160 else |
|
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
6161 { |
| 88365 | 6162 /* Record unprocessed bytes in coding->carryover. We are |
| 6163 sure that the number of data is less than the size of | |
| 6164 coding->carryover. */ | |
| 6165 unsigned char *p = coding->carryover; | |
| 6166 | |
| 6167 coding->carryover_bytes = nbytes; | |
| 6168 while (nbytes-- > 0) | |
| 6169 *p++ = *src++; | |
|
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
6170 } |
| 88365 | 6171 coding->consumed = coding->src_bytes; |
| 6172 } | |
| 6173 | |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6174 if (BUFFERP (coding->dst_object)) |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6175 { |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6176 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
|
6177 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
|
6178 } |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6179 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
|
6180 decode_eol (coding); |
|
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
6181 return coding->result; |
|
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
6182 } |
|
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
6183 |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6184 |
|
89394
6ffca50f25b9
(Fcheck_coding_systems_region): Fix type errors.
Dave Love <fx@gnu.org>
parents:
89373
diff
changeset
|
6185 /* 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
|
6186 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
|
6187 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
|
6188 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
|
6189 next element of BUF. |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6190 |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6191 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
|
6192 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
|
6193 return BUF. */ |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6194 |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6195 static INLINE int * |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6196 handle_composition_annotation (pos, limit, coding, buf, stop) |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6197 EMACS_INT pos, limit; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6198 struct coding_system *coding; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6199 int *buf; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6200 EMACS_INT *stop; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6201 { |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6202 EMACS_INT start, end; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6203 Lisp_Object prop; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6204 |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6205 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
|
6206 || end > limit) |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6207 *stop = limit; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6208 else if (start > pos) |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6209 *stop = start; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6210 else |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6211 { |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6212 if (start == pos) |
|
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 /* We found a composition. Store the corresponding |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6215 annotation data in BUF. */ |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6216 int *head = buf; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6217 enum composition_method method = COMPOSITION_METHOD (prop); |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6218 int nchars = COMPOSITION_LENGTH (prop); |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6219 |
|
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
6220 ADD_COMPOSITION_DATA (buf, nchars, method); |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6221 if (method != COMPOSITION_RELATIVE) |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6222 { |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6223 Lisp_Object components; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6224 int len, i, i_byte; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6225 |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6226 components = COMPOSITION_COMPONENTS (prop); |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6227 if (VECTORP (components)) |
|
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 len = XVECTOR (components)->size; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6230 for (i = 0; i < len; i++) |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6231 *buf++ = XINT (AREF (components, i)); |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6232 } |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6233 else if (STRINGP (components)) |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6234 { |
| 89483 | 6235 len = SCHARS (components); |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6236 i = i_byte = 0; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6237 while (i < len) |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6238 { |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6239 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
|
6240 buf++; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6241 } |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6242 } |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6243 else if (INTEGERP (components)) |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6244 { |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6245 len = 1; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6246 *buf++ = XINT (components); |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6247 } |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6248 else if (CONSP (components)) |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6249 { |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6250 for (len = 0; CONSP (components); |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6251 len++, components = XCDR (components)) |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6252 *buf++ = XINT (XCAR (components)); |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6253 } |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6254 else |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6255 abort (); |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6256 *head -= len; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6257 } |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6258 } |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6259 |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6260 if (find_composition (end, limit, &start, &end, &prop, |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6261 coding->src_object) |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6262 && end <= limit) |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6263 *stop = start; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6264 else |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6265 *stop = limit; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6266 } |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6267 return buf; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6268 } |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6269 |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6270 |
|
89394
6ffca50f25b9
(Fcheck_coding_systems_region): Fix type errors.
Dave Love <fx@gnu.org>
parents:
89373
diff
changeset
|
6271 /* 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
|
6272 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
|
6273 *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
|
6274 (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
|
6275 BUF. |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6276 |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6277 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
|
6278 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
|
6279 |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6280 static INLINE int * |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6281 handle_charset_annotation (pos, limit, coding, buf, stop) |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6282 EMACS_INT pos, limit; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6283 struct coding_system *coding; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6284 int *buf; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6285 EMACS_INT *stop; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6286 { |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6287 Lisp_Object val, next; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6288 int id; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6289 |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6290 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
|
6291 if (! NILP (val) && CHARSETP (val)) |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6292 id = XINT (CHARSET_SYMBOL_ID (val)); |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6293 else |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6294 id = -1; |
|
89852
b636ae1109c6
(MAX_ANNOTATION_LENGTH): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
89851
diff
changeset
|
6295 ADD_CHARSET_DATA (buf, 0, id); |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6296 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
|
6297 coding->src_object, |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6298 make_number (limit)); |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6299 *stop = XINT (next); |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6300 return buf; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6301 } |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6302 |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6303 |
| 88365 | 6304 static void |
|
89859
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
6305 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
|
6306 struct coding_system *coding; |
|
89856
18b52da60a76
(get_translation): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89852
diff
changeset
|
6307 Lisp_Object translation_table; |
|
89859
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
6308 int max_lookup; |
|
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
6309 { |
| 88365 | 6310 int *buf = coding->charbuf; |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6311 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
|
6312 const unsigned char *src = coding->source + coding->consumed; |
|
89442
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
6313 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
|
6314 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
|
6315 EMACS_INT end_pos = coding->src_pos + coding->src_chars; |
| 88365 | 6316 int multibytep = coding->src_multibyte; |
| 6317 Lisp_Object eol_type; | |
| 6318 int c; | |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6319 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
|
6320 int *lookup_buf = NULL; |
|
89856
18b52da60a76
(get_translation): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89852
diff
changeset
|
6321 |
|
18b52da60a76
(get_translation): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89852
diff
changeset
|
6322 if (! NILP (translation_table)) |
|
89859
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
6323 lookup_buf = alloca (sizeof (int) * max_lookup); |
| 88365 | 6324 |
| 6325 eol_type = CODING_ID_EOL_TYPE (coding->id); | |
| 6326 if (VECTORP (eol_type)) | |
| 6327 eol_type = Qunix; | |
| 6328 | |
| 6329 /* Note: composition handling is not yet implemented. */ | |
| 6330 coding->common_flags &= ~CODING_ANNOTATE_COMPOSITION_MASK; | |
| 6331 | |
|
89562
12fbcfebb9ad
(consume_chars): If coding->src_object is nil, don't check annotation.
Kenichi Handa <handa@m17n.org>
parents:
89545
diff
changeset
|
6332 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
|
6333 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
|
6334 else |
|
89562
12fbcfebb9ad
(consume_chars): If coding->src_object is nil, don't check annotation.
Kenichi Handa <handa@m17n.org>
parents:
89545
diff
changeset
|
6335 { |
|
12fbcfebb9ad
(consume_chars): If coding->src_object is nil, don't check annotation.
Kenichi Handa <handa@m17n.org>
parents:
89545
diff
changeset
|
6336 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
|
6337 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
|
6338 else |
|
12fbcfebb9ad
(consume_chars): If coding->src_object is nil, don't check annotation.
Kenichi Handa <handa@m17n.org>
parents:
89545
diff
changeset
|
6339 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
|
6340 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
|
6341 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
|
6342 else |
|
12fbcfebb9ad
(consume_chars): If coding->src_object is nil, don't check annotation.
Kenichi Handa <handa@m17n.org>
parents:
89545
diff
changeset
|
6343 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
|
6344 } |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6345 |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6346 /* Compensate for CRLF and conversion. */ |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6347 buf_end -= 1 + MAX_ANNOTATION_LENGTH; |
| 88365 | 6348 while (buf < buf_end) |
| 6349 { | |
|
89856
18b52da60a76
(get_translation): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89852
diff
changeset
|
6350 Lisp_Object trans; |
|
18b52da60a76
(get_translation): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89852
diff
changeset
|
6351 |
| 88365 | 6352 if (pos == stop) |
|
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
6353 { |
| 88365 | 6354 if (pos == end_pos) |
| 6355 break; | |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6356 if (pos == stop_composition) |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6357 buf = handle_composition_annotation (pos, end_pos, coding, |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6358 buf, &stop_composition); |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6359 if (pos == stop_charset) |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6360 buf = handle_charset_annotation (pos, end_pos, coding, |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6361 buf, &stop_charset); |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6362 stop = (stop_composition < stop_charset |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6363 ? stop_composition : stop_charset); |
| 88365 | 6364 } |
| 6365 | |
| 6366 if (! multibytep) | |
|
89442
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
6367 { |
|
89462
4e359ebf3984
(decode_coding_iso_2022): Fix handling of invalid
Kenichi Handa <handa@m17n.org>
parents:
89448
diff
changeset
|
6368 EMACS_INT bytes; |
|
4e359ebf3984
(decode_coding_iso_2022): Fix handling of invalid
Kenichi Handa <handa@m17n.org>
parents:
89448
diff
changeset
|
6369 |
|
4e359ebf3984
(decode_coding_iso_2022): Fix handling of invalid
Kenichi Handa <handa@m17n.org>
parents:
89448
diff
changeset
|
6370 if (! CODING_FOR_UNIBYTE (coding) |
|
4e359ebf3984
(decode_coding_iso_2022): Fix handling of invalid
Kenichi Handa <handa@m17n.org>
parents:
89448
diff
changeset
|
6371 && (bytes = MULTIBYTE_LENGTH (src, src_end)) > 0) |
|
89442
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
6372 c = STRING_CHAR_ADVANCE (src), pos += bytes; |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
6373 else |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
6374 c = *src++, pos++; |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
6375 } |
| 88365 | 6376 else |
|
89442
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
6377 c = STRING_CHAR_ADVANCE (src), pos++; |
| 88365 | 6378 if ((c == '\r') && (coding->mode & CODING_MODE_SELECTIVE_DISPLAY)) |
| 6379 c = '\n'; | |
| 6380 if (! EQ (eol_type, Qunix)) | |
| 6381 { | |
| 6382 if (c == '\n') | |
| 6383 { | |
| 6384 if (EQ (eol_type, Qdos)) | |
| 6385 *buf++ = '\r'; | |
| 6386 else | |
| 6387 c = '\r'; | |
| 6388 } | |
|
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
6389 } |
|
89856
18b52da60a76
(get_translation): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89852
diff
changeset
|
6390 |
|
89858
23cb9ed79225
(get_translation_table): Declare it as Lisp_Object.
Kenichi Handa <handa@m17n.org>
parents:
89856
diff
changeset
|
6391 trans = Qnil; |
|
89859
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
6392 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
|
6393 if (NILP (trans)) |
|
89856
18b52da60a76
(get_translation): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89852
diff
changeset
|
6394 *buf++ = c; |
|
18b52da60a76
(get_translation): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89852
diff
changeset
|
6395 else |
|
18b52da60a76
(get_translation): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89852
diff
changeset
|
6396 { |
|
18b52da60a76
(get_translation): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89852
diff
changeset
|
6397 int from_nchars = 1, to_nchars = 1; |
|
18b52da60a76
(get_translation): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89852
diff
changeset
|
6398 int *lookup_buf_end; |
|
18b52da60a76
(get_translation): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89852
diff
changeset
|
6399 const unsigned char *p = src; |
|
18b52da60a76
(get_translation): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89852
diff
changeset
|
6400 int i; |
|
18b52da60a76
(get_translation): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89852
diff
changeset
|
6401 |
|
18b52da60a76
(get_translation): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89852
diff
changeset
|
6402 lookup_buf[0] = c; |
|
18b52da60a76
(get_translation): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89852
diff
changeset
|
6403 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
|
6404 lookup_buf[i] = STRING_CHAR_ADVANCE (p); |
|
18b52da60a76
(get_translation): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89852
diff
changeset
|
6405 lookup_buf_end = lookup_buf + i; |
|
18b52da60a76
(get_translation): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89852
diff
changeset
|
6406 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
|
6407 &from_nchars, &to_nchars); |
|
18b52da60a76
(get_translation): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89852
diff
changeset
|
6408 if (EQ (trans, Qt) |
|
18b52da60a76
(get_translation): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89852
diff
changeset
|
6409 || buf + to_nchars > buf_end) |
|
18b52da60a76
(get_translation): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89852
diff
changeset
|
6410 break; |
|
18b52da60a76
(get_translation): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89852
diff
changeset
|
6411 *buf++ = *lookup_buf; |
|
18b52da60a76
(get_translation): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89852
diff
changeset
|
6412 for (i = 1; i < to_nchars; i++) |
|
18b52da60a76
(get_translation): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89852
diff
changeset
|
6413 *buf++ = XINT (AREF (trans, i)); |
|
18b52da60a76
(get_translation): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89852
diff
changeset
|
6414 for (i = 1; i < from_nchars; i++, pos++) |
|
18b52da60a76
(get_translation): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89852
diff
changeset
|
6415 src += MULTIBYTE_LENGTH_NO_CHECK (src); |
|
18b52da60a76
(get_translation): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89852
diff
changeset
|
6416 } |
| 88365 | 6417 } |
| 6418 | |
| 6419 coding->consumed = src - coding->source; | |
| 6420 coding->consumed_char = pos - coding->src_pos; | |
| 6421 coding->charbuf_used = buf - coding->charbuf; | |
| 6422 coding->chars_at_source = 0; | |
|
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
6423 } |
|
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
6424 |
| 88365 | 6425 |
| 6426 /* Encode the text at CODING->src_object into CODING->dst_object. | |
| 6427 CODING->src_object is a buffer or a string. | |
| 6428 CODING->dst_object is a buffer or nil. | |
| 6429 | |
| 6430 If CODING->src_object is a buffer, it must be the current buffer. | |
| 6431 In this case, if CODING->src_pos is positive, it is a position of | |
| 6432 the source text in the buffer, otherwise. the source text is in the | |
| 6433 gap area of the buffer, and coding->src_pos specifies the offset of | |
| 6434 the text from GPT (which must be the same as PT). If this is the | |
| 6435 same buffer as CODING->dst_object, CODING->src_pos must be | |
| 6436 negative and CODING should not have `pre-write-conversion'. | |
| 6437 | |
| 6438 If CODING->src_object is a string, CODING should not have | |
| 6439 `pre-write-conversion'. | |
| 6440 | |
| 6441 If CODING->dst_object is a buffer, the encoded data is inserted at | |
| 6442 the current point of that buffer. | |
| 6443 | |
| 6444 If CODING->dst_object is nil, the encoded data is placed at the | |
| 6445 memory area specified by CODING->destination. */ | |
| 6446 | |
| 6447 static int | |
| 6448 encode_coding (coding) | |
|
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
6449 struct coding_system *coding; |
|
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
6450 { |
| 88365 | 6451 Lisp_Object attrs; |
|
89732
8acde12aba89
(get_translation_table): New function.
Kenichi Handa <handa@m17n.org>
parents:
89730
diff
changeset
|
6452 Lisp_Object translation_table; |
|
89859
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
6453 int max_lookup; |
| 88365 | 6454 |
| 6455 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
|
6456 translation_table = get_translation_table (attrs, 1, &max_lookup); |
| 88365 | 6457 |
| 6458 if (BUFFERP (coding->dst_object)) | |
| 6459 { | |
| 6460 set_buffer_internal (XBUFFER (coding->dst_object)); | |
| 6461 coding->dst_multibyte | |
| 6462 = ! NILP (current_buffer->enable_multibyte_characters); | |
| 6463 } | |
| 6464 | |
| 6465 coding->consumed = coding->consumed_char = 0; | |
| 6466 coding->produced = coding->produced_char = 0; | |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
6467 record_conversion_result (coding, CODING_RESULT_SUCCESS); |
| 88365 | 6468 coding->errors = 0; |
| 6469 | |
| 6470 ALLOC_CONVERSION_WORK_AREA (coding); | |
| 6471 | |
| 6472 do { | |
| 6473 coding_set_source (coding); | |
|
89859
b706c5ee6492
(get_translation_table): New arg max_lookup. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
89858
diff
changeset
|
6474 consume_chars (coding, translation_table, max_lookup); |
| 88365 | 6475 coding_set_destination (coding); |
| 6476 (*(coding->encoder)) (coding); | |
| 6477 } while (coding->consumed_char < coding->src_chars); | |
| 6478 | |
| 6479 if (BUFFERP (coding->dst_object)) | |
| 6480 insert_from_gap (coding->produced_char, coding->produced); | |
| 6481 | |
| 6482 return (coding->result); | |
| 6483 } | |
| 6484 | |
|
89442
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
6485 |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6486 /* 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
|
6487 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
|
6488 |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6489 /* 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
|
6490 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
|
6491 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
|
6492 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
|
6493 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
|
6494 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
|
6495 |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6496 /* 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
|
6497 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
|
6498 |
|
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 /* 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
|
6501 multibyteness of returning buffer. */ |
| 88365 | 6502 |
|
89863
428fc37b2ae6
Add many prototypes for static functions.
Kenichi Handa <handa@m17n.org>
parents:
89861
diff
changeset
|
6503 static Lisp_Object |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6504 make_conversion_work_buffer (multibyte) |
|
89863
428fc37b2ae6
Add many prototypes for static functions.
Kenichi Handa <handa@m17n.org>
parents:
89861
diff
changeset
|
6505 int multibyte; |
| 88365 | 6506 { |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6507 Lisp_Object name, workbuf; |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6508 struct buffer *current; |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6509 |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6510 if (reused_workbuf_in_use++) |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
6511 { |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
6512 name = Fgenerate_new_buffer_name (Vcode_conversion_workbuf_name, Qnil); |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
6513 workbuf = Fget_buffer_create (name); |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
6514 } |
|
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
6515 else |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
6516 { |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
6517 name = Vcode_conversion_workbuf_name; |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
6518 workbuf = Fget_buffer_create (name); |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
6519 if (NILP (Vcode_conversion_reused_workbuf)) |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
6520 Vcode_conversion_reused_workbuf = workbuf; |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
6521 } |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6522 current = current_buffer; |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6523 set_buffer_internal (XBUFFER (workbuf)); |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6524 Ferase_buffer (); |
| 88365 | 6525 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
|
6526 current_buffer->enable_multibyte_characters = multibyte ? Qt : Qnil; |
| 88365 | 6527 set_buffer_internal (current); |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6528 return workbuf; |
|
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
6529 } |
|
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
6530 |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6531 |
|
89442
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
6532 static Lisp_Object |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6533 code_conversion_restore (arg) |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6534 Lisp_Object arg; |
|
26067
f54ca66e2571
(code_convert_string): Add record_unwind_protect to
Kenichi Handa <handa@m17n.org>
parents:
25860
diff
changeset
|
6535 { |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6536 Lisp_Object current, workbuf; |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6537 |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6538 current = XCAR (arg); |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6539 workbuf = XCDR (arg); |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6540 if (! NILP (workbuf)) |
|
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 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
|
6543 reused_workbuf_in_use = 0; |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6544 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
|
6545 Fkill_buffer (workbuf); |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6546 } |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6547 set_buffer_internal (XBUFFER (current)); |
|
89442
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
6548 return Qnil; |
|
26067
f54ca66e2571
(code_convert_string): Add record_unwind_protect to
Kenichi Handa <handa@m17n.org>
parents:
25860
diff
changeset
|
6549 } |
|
f54ca66e2571
(code_convert_string): Add record_unwind_protect to
Kenichi Handa <handa@m17n.org>
parents:
25860
diff
changeset
|
6550 |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6551 Lisp_Object |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6552 code_conversion_save (with_work_buf, multibyte) |
|
89442
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
6553 int with_work_buf, multibyte; |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
6554 { |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6555 Lisp_Object workbuf = Qnil; |
|
89442
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
6556 |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
6557 if (with_work_buf) |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6558 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
|
6559 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
|
6560 Fcons (Fcurrent_buffer (), workbuf)); |
|
89442
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
6561 return workbuf; |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
6562 } |
| 88365 | 6563 |
| 6564 int | |
| 6565 decode_coding_gap (coding, chars, bytes) | |
| 26847 | 6566 struct coding_system *coding; |
| 88365 | 6567 EMACS_INT chars, bytes; |
| 6568 { | |
| 6569 int count = specpdl_ptr - specpdl; | |
|
89448
de8b460070cc
(setup_coding_system): If coding has
Kenichi Handa <handa@m17n.org>
parents:
89446
diff
changeset
|
6570 Lisp_Object attrs; |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6571 |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6572 code_conversion_save (0, 0); |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6573 |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6574 coding->src_object = Fcurrent_buffer (); |
| 88365 | 6575 coding->src_chars = chars; |
| 6576 coding->src_bytes = bytes; | |
| 6577 coding->src_pos = -chars; | |
| 6578 coding->src_pos_byte = -bytes; | |
| 6579 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
|
6580 coding->dst_object = coding->src_object; |
| 88365 | 6581 coding->dst_pos = PT; |
| 6582 coding->dst_pos_byte = PT_BYTE; | |
|
88443
6b86cf30a0b9
(produce_chars): Set the variable `multibytep' correctly.
Kenichi Handa <handa@m17n.org>
parents:
88438
diff
changeset
|
6583 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
|
6584 coding->mode |= CODING_MODE_LAST_BLOCK; |
| 88365 | 6585 |
| 6586 if (CODING_REQUIRE_DETECTION (coding)) | |
| 6587 detect_coding (coding); | |
| 89483 | 6588 |
| 88365 | 6589 decode_coding (coding); |
| 6590 | |
|
89448
de8b460070cc
(setup_coding_system): If coding has
Kenichi Handa <handa@m17n.org>
parents:
89446
diff
changeset
|
6591 attrs = CODING_ID_ATTRS (coding->id); |
|
de8b460070cc
(setup_coding_system): If coding has
Kenichi Handa <handa@m17n.org>
parents:
89446
diff
changeset
|
6592 if (! NILP (CODING_ATTR_POST_READ (attrs))) |
|
de8b460070cc
(setup_coding_system): If coding has
Kenichi Handa <handa@m17n.org>
parents:
89446
diff
changeset
|
6593 { |
|
de8b460070cc
(setup_coding_system): If coding has
Kenichi Handa <handa@m17n.org>
parents:
89446
diff
changeset
|
6594 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
|
6595 Lisp_Object val; |
|
de8b460070cc
(setup_coding_system): If coding has
Kenichi Handa <handa@m17n.org>
parents:
89446
diff
changeset
|
6596 |
|
de8b460070cc
(setup_coding_system): If coding has
Kenichi Handa <handa@m17n.org>
parents:
89446
diff
changeset
|
6597 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
|
6598 val = call1 (CODING_ATTR_POST_READ (attrs), |
|
de8b460070cc
(setup_coding_system): If coding has
Kenichi Handa <handa@m17n.org>
parents:
89446
diff
changeset
|
6599 make_number (coding->produced_char)); |
|
de8b460070cc
(setup_coding_system): If coding has
Kenichi Handa <handa@m17n.org>
parents:
89446
diff
changeset
|
6600 CHECK_NATNUM (val); |
|
de8b460070cc
(setup_coding_system): If coding has
Kenichi Handa <handa@m17n.org>
parents:
89446
diff
changeset
|
6601 coding->produced_char += Z - prev_Z; |
|
de8b460070cc
(setup_coding_system): If coding has
Kenichi Handa <handa@m17n.org>
parents:
89446
diff
changeset
|
6602 coding->produced += Z_BYTE - prev_Z_BYTE; |
|
de8b460070cc
(setup_coding_system): If coding has
Kenichi Handa <handa@m17n.org>
parents:
89446
diff
changeset
|
6603 } |
|
de8b460070cc
(setup_coding_system): If coding has
Kenichi Handa <handa@m17n.org>
parents:
89446
diff
changeset
|
6604 |
| 88365 | 6605 unbind_to (count, Qnil); |
| 6606 return coding->result; | |
| 6607 } | |
| 6608 | |
| 6609 int | |
| 6610 encode_coding_gap (coding, chars, bytes) | |
| 6611 struct coding_system *coding; | |
| 6612 EMACS_INT chars, bytes; | |
| 26847 | 6613 { |
| 88365 | 6614 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
|
6615 |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6616 code_conversion_save (0, 0); |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6617 |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6618 coding->src_object = Fcurrent_buffer (); |
| 88365 | 6619 coding->src_chars = chars; |
| 6620 coding->src_bytes = bytes; | |
| 6621 coding->src_pos = -chars; | |
| 6622 coding->src_pos_byte = -bytes; | |
| 6623 coding->src_multibyte = chars < bytes; | |
| 6624 coding->dst_object = coding->src_object; | |
| 6625 coding->dst_pos = PT; | |
| 6626 coding->dst_pos_byte = PT_BYTE; | |
| 6627 | |
| 6628 encode_coding (coding); | |
| 6629 | |
| 6630 unbind_to (count, Qnil); | |
| 6631 return coding->result; | |
| 26847 | 6632 } |
| 6633 | |
| 88365 | 6634 |
| 6635 /* Decode the text in the range FROM/FROM_BYTE and TO/TO_BYTE in | |
| 6636 SRC_OBJECT into DST_OBJECT by coding context CODING. | |
| 6637 | |
| 6638 SRC_OBJECT is a buffer, a string, or Qnil. | |
| 6639 | |
| 6640 If it is a buffer, the text is at point of the buffer. FROM and TO | |
| 6641 are positions in the buffer. | |
| 6642 | |
| 6643 If it is a string, the text is at the beginning of the string. | |
| 6644 FROM and TO are indices to the string. | |
| 6645 | |
| 6646 If it is nil, the text is at coding->source. FROM and TO are | |
| 6647 indices to coding->source. | |
| 6648 | |
| 6649 DST_OBJECT is a buffer, Qt, or Qnil. | |
| 6650 | |
| 6651 If it is a buffer, the decoded text is inserted at point of the | |
| 6652 buffer. If the buffer is the same as SRC_OBJECT, the source text | |
| 6653 is deleted. | |
| 6654 | |
| 6655 If it is Qt, a string is made from the decoded text, and | |
| 6656 set in CODING->dst_object. | |
| 6657 | |
| 6658 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
|
6659 The caller must allocate CODING->dst_bytes bytes at |
| 88365 | 6660 CODING->destination by xmalloc. If the decoded text is longer than |
| 6661 CODING->dst_bytes, CODING->destination is relocated by xrealloc. | |
| 6662 */ | |
| 26847 | 6663 |
|
29275
b4ea9178e480
(DECODE_COMPOSITION_START): If coding->cmp_data is not
Kenichi Handa <handa@m17n.org>
parents:
29247
diff
changeset
|
6664 void |
| 88365 | 6665 decode_coding_object (coding, src_object, from, from_byte, to, to_byte, |
| 6666 dst_object) | |
| 26847 | 6667 struct coding_system *coding; |
| 88365 | 6668 Lisp_Object src_object; |
| 6669 EMACS_INT from, from_byte, to, to_byte; | |
| 6670 Lisp_Object dst_object; | |
| 26847 | 6671 { |
| 88365 | 6672 int count = specpdl_ptr - specpdl; |
| 6673 unsigned char *destination; | |
| 6674 EMACS_INT dst_bytes; | |
| 6675 EMACS_INT chars = to - from; | |
| 6676 EMACS_INT bytes = to_byte - from_byte; | |
| 6677 Lisp_Object attrs; | |
|
89442
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
6678 Lisp_Object buffer; |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
6679 int saved_pt = -1, saved_pt_byte; |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
6680 |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
6681 buffer = Fcurrent_buffer (); |
| 88365 | 6682 |
| 6683 if (NILP (dst_object)) | |
| 6684 { | |
| 6685 destination = coding->destination; | |
| 6686 dst_bytes = coding->dst_bytes; | |
| 6687 } | |
| 6688 | |
| 6689 coding->src_object = src_object; | |
| 6690 coding->src_chars = chars; | |
| 6691 coding->src_bytes = bytes; | |
| 6692 coding->src_multibyte = chars < bytes; | |
| 6693 | |
| 6694 if (STRINGP (src_object)) | |
| 6695 { | |
| 6696 coding->src_pos = from; | |
| 6697 coding->src_pos_byte = from_byte; | |
| 6698 } | |
| 6699 else if (BUFFERP (src_object)) | |
| 6700 { | |
| 6701 set_buffer_internal (XBUFFER (src_object)); | |
| 6702 if (from != GPT) | |
| 6703 move_gap_both (from, from_byte); | |
| 6704 if (EQ (src_object, dst_object)) | |
| 26847 | 6705 { |
|
89442
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
6706 saved_pt = PT, saved_pt_byte = PT_BYTE; |
| 88365 | 6707 TEMP_SET_PT_BOTH (from, from_byte); |
| 6708 del_range_both (from, from_byte, to, to_byte, 1); | |
| 6709 coding->src_pos = -chars; | |
| 6710 coding->src_pos_byte = -bytes; | |
|
20931
068eb408c911
(decode_coding_iso2022): Update coding->fake_multibyte.
Kenichi Handa <handa@m17n.org>
parents:
20803
diff
changeset
|
6711 } |
|
42661
e85e4d9494b1
(code_convert_region): Don't copy old text if undo disabled.
Richard M. Stallman <rms@gnu.org>
parents:
42105
diff
changeset
|
6712 else |
|
e85e4d9494b1
(code_convert_region): Don't copy old text if undo disabled.
Richard M. Stallman <rms@gnu.org>
parents:
42105
diff
changeset
|
6713 { |
| 88365 | 6714 coding->src_pos = from; |
| 6715 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
|
6716 } |
| 88365 | 6717 } |
| 6718 | |
| 6719 if (CODING_REQUIRE_DETECTION (coding)) | |
| 6720 detect_coding (coding); | |
| 6721 attrs = CODING_ID_ATTRS (coding->id); | |
| 6722 | |
|
89418
a9c2b3712863
(coding_set_source): Fix for the case that the current
Kenichi Handa <handa@m17n.org>
parents:
89404
diff
changeset
|
6723 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
|
6724 || (! 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
|
6725 && NILP (dst_object))) |
| 88365 | 6726 { |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6727 coding->dst_object = code_conversion_save (1, 1); |
| 88365 | 6728 coding->dst_pos = BEG; |
| 6729 coding->dst_pos_byte = BEG_BYTE; | |
| 6730 coding->dst_multibyte = 1; | |
| 6731 } | |
| 6732 else if (BUFFERP (dst_object)) | |
| 6733 { | |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6734 code_conversion_save (0, 0); |
| 88365 | 6735 coding->dst_object = dst_object; |
| 6736 coding->dst_pos = BUF_PT (XBUFFER (dst_object)); | |
| 6737 coding->dst_pos_byte = BUF_PT_BYTE (XBUFFER (dst_object)); | |
| 6738 coding->dst_multibyte | |
| 6739 = ! NILP (XBUFFER (dst_object)->enable_multibyte_characters); | |
| 6740 } | |
| 6741 else | |
| 6742 { | |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6743 code_conversion_save (0, 0); |
| 88365 | 6744 coding->dst_object = Qnil; |
| 6745 coding->dst_multibyte = 1; | |
| 6746 } | |
| 6747 | |
| 6748 decode_coding (coding); | |
| 6749 | |
| 6750 if (BUFFERP (coding->dst_object)) | |
| 6751 set_buffer_internal (XBUFFER (coding->dst_object)); | |
| 6752 | |
| 6753 if (! NILP (CODING_ATTR_POST_READ (attrs))) | |
| 6754 { | |
| 6755 struct gcpro gcpro1, gcpro2; | |
| 6756 EMACS_INT prev_Z = Z, prev_Z_BYTE = Z_BYTE; | |
| 6757 Lisp_Object val; | |
| 6758 | |
|
88506
a7f0d13affa5
(decode_coding_object): Move point to coding->dst_pos before
Kenichi Handa <handa@m17n.org>
parents:
88497
diff
changeset
|
6759 TEMP_SET_PT_BOTH (coding->dst_pos, coding->dst_pos_byte); |
| 88365 | 6760 GCPRO2 (coding->src_object, coding->dst_object); |
| 6761 val = call1 (CODING_ATTR_POST_READ (attrs), | |
| 6762 make_number (coding->produced_char)); | |
| 6763 UNGCPRO; | |
| 6764 CHECK_NATNUM (val); | |
| 6765 coding->produced_char += Z - prev_Z; | |
| 6766 coding->produced += Z_BYTE - prev_Z_BYTE; | |
| 6767 } | |
| 6768 | |
| 6769 if (EQ (dst_object, Qt)) | |
| 6770 { | |
| 6771 coding->dst_object = Fbuffer_string (); | |
| 6772 } | |
| 6773 else if (NILP (dst_object) && BUFFERP (coding->dst_object)) | |
| 6774 { | |
| 6775 set_buffer_internal (XBUFFER (coding->dst_object)); | |
| 6776 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
|
6777 { |
| 88365 | 6778 destination |
| 6779 = (unsigned char *) xrealloc (destination, coding->produced); | |
| 6780 if (! destination) | |
|
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
6781 { |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
6782 record_conversion_result (coding, |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
6783 CODING_RESULT_INSUFFICIENT_DST); |
| 88365 | 6784 unbind_to (count, Qnil); |
| 6785 return; | |
|
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
6786 } |
| 88365 | 6787 if (BEGV < GPT && GPT < BEGV + coding->produced_char) |
| 6788 move_gap_both (BEGV, BEGV_BYTE); | |
| 6789 bcopy (BEGV_ADDR, destination, coding->produced); | |
| 6790 coding->destination = destination; | |
|
23279
ca159e828a68
(ccl_coding_driver): If ccl_driver is interrupted by a
Kenichi Handa <handa@m17n.org>
parents:
23258
diff
changeset
|
6791 } |
| 88365 | 6792 } |
| 6793 | |
|
89442
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
6794 if (saved_pt >= 0) |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
6795 { |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
6796 /* This is the case of: |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
6797 (BUFFERP (src_object) && EQ (src_object, dst_object)) |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
6798 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
|
6799 contents, we must recover it now. */ |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
6800 set_buffer_internal (XBUFFER (src_object)); |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
6801 if (saved_pt < from) |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
6802 TEMP_SET_PT_BOTH (saved_pt, saved_pt_byte); |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
6803 else if (saved_pt < from + chars) |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
6804 TEMP_SET_PT_BOTH (from, from_byte); |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
6805 else if (! NILP (current_buffer->enable_multibyte_characters)) |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
6806 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
|
6807 saved_pt_byte + (coding->produced - bytes)); |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
6808 else |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
6809 TEMP_SET_PT_BOTH (saved_pt + (coding->produced - bytes), |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
6810 saved_pt_byte + (coding->produced - bytes)); |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
6811 } |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
6812 |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
6813 unbind_to (count, coding->dst_object); |
| 88365 | 6814 } |
| 6815 | |
| 6816 | |
| 6817 void | |
| 6818 encode_coding_object (coding, src_object, from, from_byte, to, to_byte, | |
| 6819 dst_object) | |
| 6820 struct coding_system *coding; | |
| 6821 Lisp_Object src_object; | |
| 6822 EMACS_INT from, from_byte, to, to_byte; | |
| 6823 Lisp_Object dst_object; | |
| 6824 { | |
| 6825 int count = specpdl_ptr - specpdl; | |
| 6826 EMACS_INT chars = to - from; | |
| 6827 EMACS_INT bytes = to_byte - from_byte; | |
| 6828 Lisp_Object attrs; | |
|
89442
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
6829 Lisp_Object buffer; |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
6830 int saved_pt = -1, saved_pt_byte; |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
6831 |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
6832 buffer = Fcurrent_buffer (); |
| 88365 | 6833 |
| 6834 coding->src_object = src_object; | |
| 6835 coding->src_chars = chars; | |
| 6836 coding->src_bytes = bytes; | |
| 6837 coding->src_multibyte = chars < bytes; | |
| 6838 | |
| 6839 attrs = CODING_ID_ATTRS (coding->id); | |
| 6840 | |
| 6841 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
|
6842 { |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6843 coding->src_object = code_conversion_save (1, coding->src_multibyte); |
| 88365 | 6844 set_buffer_internal (XBUFFER (coding->src_object)); |
| 6845 if (STRINGP (src_object)) | |
| 6846 insert_from_string (src_object, from, from_byte, chars, bytes, 0); | |
| 6847 else if (BUFFERP (src_object)) | |
| 6848 insert_from_buffer (XBUFFER (src_object), from, chars, 0); | |
| 6849 else | |
| 6850 insert_1_both (coding->source + from, chars, bytes, 0, 0, 0); | |
| 6851 | |
| 6852 if (EQ (src_object, dst_object)) | |
| 6853 { | |
| 6854 set_buffer_internal (XBUFFER (src_object)); | |
|
89442
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
6855 saved_pt = PT, saved_pt_byte = PT_BYTE; |
| 88365 | 6856 del_range_both (from, from_byte, to, to_byte, 1); |
| 6857 set_buffer_internal (XBUFFER (coding->src_object)); | |
| 6858 } | |
| 6859 | |
|
88510
d266b8fb8761
(encode_coding_object): Give correct arguments ot
Kenichi Handa <handa@m17n.org>
parents:
88506
diff
changeset
|
6860 call2 (CODING_ATTR_PRE_WRITE (attrs), |
|
d266b8fb8761
(encode_coding_object): Give correct arguments ot
Kenichi Handa <handa@m17n.org>
parents:
88506
diff
changeset
|
6861 make_number (BEG), make_number (Z)); |
|
d266b8fb8761
(encode_coding_object): Give correct arguments ot
Kenichi Handa <handa@m17n.org>
parents:
88506
diff
changeset
|
6862 coding->src_object = Fcurrent_buffer (); |
| 88365 | 6863 if (BEG != GPT) |
| 6864 move_gap_both (BEG, BEG_BYTE); | |
| 6865 coding->src_chars = Z - BEG; | |
| 6866 coding->src_bytes = Z_BYTE - BEG_BYTE; | |
| 6867 coding->src_pos = BEG; | |
| 6868 coding->src_pos_byte = BEG_BYTE; | |
| 6869 coding->src_multibyte = Z < Z_BYTE; | |
| 6870 } | |
| 6871 else if (STRINGP (src_object)) | |
| 6872 { | |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6873 code_conversion_save (0, 0); |
| 88365 | 6874 coding->src_pos = from; |
| 6875 coding->src_pos_byte = from_byte; | |
| 6876 } | |
| 6877 else if (BUFFERP (src_object)) | |
| 6878 { | |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6879 code_conversion_save (0, 0); |
| 88365 | 6880 set_buffer_internal (XBUFFER (src_object)); |
| 6881 if (EQ (src_object, dst_object)) | |
| 6882 { | |
|
89442
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
6883 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
|
6884 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
|
6885 coding->src_pos = 0; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6886 coding->src_pos_byte = 0; |
| 88365 | 6887 } |
|
23514
7bad909cd6f1
(setup_coding_system): Fix setting up
Kenichi Handa <handa@m17n.org>
parents:
23475
diff
changeset
|
6888 else |
| 88365 | 6889 { |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6890 if (from < GPT && to >= GPT) |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
6891 move_gap_both (from, from_byte); |
| 88365 | 6892 coding->src_pos = from; |
| 6893 coding->src_pos_byte = from_byte; | |
| 6894 } | |
| 6895 } | |
|
89442
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
6896 else |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
6897 code_conversion_save (0, 0); |
| 88365 | 6898 |
| 6899 if (BUFFERP (dst_object)) | |
| 6900 { | |
| 6901 coding->dst_object = dst_object; | |
|
89042
2b9f8973f240
(coding_set_destination): Fix coding->destination for
Kenichi Handa <handa@m17n.org>
parents:
88977
diff
changeset
|
6902 if (EQ (src_object, dst_object)) |
|
2b9f8973f240
(coding_set_destination): Fix coding->destination for
Kenichi Handa <handa@m17n.org>
parents:
88977
diff
changeset
|
6903 { |
|
2b9f8973f240
(coding_set_destination): Fix coding->destination for
Kenichi Handa <handa@m17n.org>
parents:
88977
diff
changeset
|
6904 coding->dst_pos = from; |
|
2b9f8973f240
(coding_set_destination): Fix coding->destination for
Kenichi Handa <handa@m17n.org>
parents:
88977
diff
changeset
|
6905 coding->dst_pos_byte = from_byte; |
|
2b9f8973f240
(coding_set_destination): Fix coding->destination for
Kenichi Handa <handa@m17n.org>
parents:
88977
diff
changeset
|
6906 } |
|
2b9f8973f240
(coding_set_destination): Fix coding->destination for
Kenichi Handa <handa@m17n.org>
parents:
88977
diff
changeset
|
6907 else |
|
2b9f8973f240
(coding_set_destination): Fix coding->destination for
Kenichi Handa <handa@m17n.org>
parents:
88977
diff
changeset
|
6908 { |
|
2b9f8973f240
(coding_set_destination): Fix coding->destination for
Kenichi Handa <handa@m17n.org>
parents:
88977
diff
changeset
|
6909 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
|
6910 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
|
6911 } |
| 88365 | 6912 coding->dst_multibyte |
| 6913 = ! NILP (XBUFFER (dst_object)->enable_multibyte_characters); | |
| 6914 } | |
| 6915 else if (EQ (dst_object, Qt)) | |
| 6916 { | |
| 6917 coding->dst_object = Qnil; | |
| 6918 coding->dst_bytes = coding->src_chars; | |
|
88510
d266b8fb8761
(encode_coding_object): Give correct arguments ot
Kenichi Handa <handa@m17n.org>
parents:
88506
diff
changeset
|
6919 if (coding->dst_bytes == 0) |
|
d266b8fb8761
(encode_coding_object): Give correct arguments ot
Kenichi Handa <handa@m17n.org>
parents:
88506
diff
changeset
|
6920 coding->dst_bytes = 1; |
|
d266b8fb8761
(encode_coding_object): Give correct arguments ot
Kenichi Handa <handa@m17n.org>
parents:
88506
diff
changeset
|
6921 coding->destination = (unsigned char *) xmalloc (coding->dst_bytes); |
| 88365 | 6922 coding->dst_multibyte = 0; |
| 6923 } | |
| 6924 else | |
| 6925 { | |
| 6926 coding->dst_object = Qnil; | |
| 6927 coding->dst_multibyte = 0; | |
| 6928 } | |
| 6929 | |
| 6930 encode_coding (coding); | |
| 6931 | |
| 6932 if (EQ (dst_object, Qt)) | |
| 6933 { | |
| 6934 if (BUFFERP (coding->dst_object)) | |
| 6935 coding->dst_object = Fbuffer_string (); | |
| 6936 else | |
| 6937 { | |
| 6938 coding->dst_object | |
| 6939 = make_unibyte_string ((char *) coding->destination, | |
| 6940 coding->produced); | |
| 6941 xfree (coding->destination); | |
| 6942 } | |
| 6943 } | |
| 6944 | |
|
89442
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
6945 if (saved_pt >= 0) |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
6946 { |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
6947 /* This is the case of: |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
6948 (BUFFERP (src_object) && EQ (src_object, dst_object)) |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
6949 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
|
6950 contents, we must recover it now. */ |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
6951 set_buffer_internal (XBUFFER (src_object)); |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
6952 if (saved_pt < from) |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
6953 TEMP_SET_PT_BOTH (saved_pt, saved_pt_byte); |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
6954 else if (saved_pt < from + chars) |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
6955 TEMP_SET_PT_BOTH (from, from_byte); |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
6956 else if (! NILP (current_buffer->enable_multibyte_characters)) |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
6957 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
|
6958 saved_pt_byte + (coding->produced - bytes)); |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
6959 else |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
6960 TEMP_SET_PT_BOTH (saved_pt + (coding->produced - bytes), |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
6961 saved_pt_byte + (coding->produced - bytes)); |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
6962 } |
|
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
6963 |
| 88365 | 6964 unbind_to (count, Qnil); |
|
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
6965 } |
|
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
6966 |
|
29005
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
6967 |
|
b396df3a5181
(ONE_MORE_BYTE, TWO_MORE_BYTES): Set coding->resutl to
Kenichi Handa <handa@m17n.org>
parents:
28512
diff
changeset
|
6968 Lisp_Object |
| 88365 | 6969 preferred_coding_system () |
|
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
6970 { |
| 88365 | 6971 int id = coding_categories[coding_priorities[0]].id; |
| 6972 | |
| 6973 return CODING_ID_NAME (id); | |
|
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
6974 } |
|
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
6975 |
| 17052 | 6976 |
| 6977 #ifdef emacs | |
|
22874
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
6978 /*** 8. Emacs Lisp library functions ***/ |
| 17052 | 6979 |
| 6980 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
|
6981 doc: /* Return t if OBJECT is nil or a coding-system. |
| 88365 | 6982 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
|
6983 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
|
6984 (obj) |
| 17052 | 6985 Lisp_Object obj; |
| 6986 { | |
| 88365 | 6987 return ((NILP (obj) || CODING_SYSTEM_P (obj)) ? Qt : Qnil); |
| 17052 | 6988 } |
| 6989 | |
|
17717
4891aaecc5cc
(Fread_coding_system, Fread_non_nil_coding_system):
Richard M. Stallman <rms@gnu.org>
parents:
17485
diff
changeset
|
6990 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
|
6991 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
|
6992 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
|
6993 (prompt) |
| 17052 | 6994 Lisp_Object prompt; |
| 6995 { | |
|
17119
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
6996 Lisp_Object val; |
|
17717
4891aaecc5cc
(Fread_coding_system, Fread_non_nil_coding_system):
Richard M. Stallman <rms@gnu.org>
parents:
17485
diff
changeset
|
6997 do |
|
4891aaecc5cc
(Fread_coding_system, Fread_non_nil_coding_system):
Richard M. Stallman <rms@gnu.org>
parents:
17485
diff
changeset
|
6998 { |
|
20105
c017642863c2
(Qcoding_system_spec): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
19824
diff
changeset
|
6999 val = Fcompleting_read (prompt, Vcoding_system_alist, Qnil, |
|
c017642863c2
(Qcoding_system_spec): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
19824
diff
changeset
|
7000 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
|
7001 } |
|
46370
40db0673e6f0
Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents:
46293
diff
changeset
|
7002 while (SCHARS (val) == 0); |
|
17119
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
7003 return (Fintern (val, Qnil)); |
| 17052 | 7004 } |
| 7005 | |
|
19758
49a1662b68dd
(Fread_coding_system): New optional arg DEFAULT_CODING_SYSTEM.
Richard M. Stallman <rms@gnu.org>
parents:
19750
diff
changeset
|
7006 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
|
7007 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
|
7008 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
|
7009 (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
|
7010 Lisp_Object prompt, default_coding_system; |
| 17052 | 7011 { |
|
19747
bed06df9cbc5
(setup_coding_system, Ffind_operation_coding_system)
Richard M. Stallman <rms@gnu.org>
parents:
19743
diff
changeset
|
7012 Lisp_Object val; |
|
19758
49a1662b68dd
(Fread_coding_system): New optional arg DEFAULT_CODING_SYSTEM.
Richard M. Stallman <rms@gnu.org>
parents:
19750
diff
changeset
|
7013 if (SYMBOLP (default_coding_system)) |
|
89519
040a08a2a879
(Fread_coding_system): Fix arg of XSETSTRING.
Dave Love <fx@gnu.org>
parents:
89483
diff
changeset
|
7014 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
|
7015 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
|
7016 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
|
7017 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
|
7018 return (SCHARS (val) == 0 ? Qnil : Fintern (val, Qnil)); |
| 17052 | 7019 } |
| 7020 | |
| 7021 DEFUN ("check-coding-system", Fcheck_coding_system, Scheck_coding_system, | |
| 7022 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
|
7023 doc: /* Check validity of CODING-SYSTEM. |
| 89218 | 7024 If valid, return CODING-SYSTEM, else signal a `coding-system-error' error. */) |
| 88365 | 7025 (coding_system) |
| 17052 | 7026 Lisp_Object coding_system; |
| 7027 { | |
|
40656
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Jan?k <Pavel@Janik.cz>
parents:
40461
diff
changeset
|
7028 CHECK_SYMBOL (coding_system); |
| 17052 | 7029 if (!NILP (Fcoding_system_p (coding_system))) |
| 7030 return coding_system; | |
| 7031 while (1) | |
|
18180
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
7032 Fsignal (Qcoding_system_error, Fcons (coding_system, Qnil)); |
| 17052 | 7033 } |
| 88365 | 7034 |
|
20680
dd46027e8412
(code_convert_region): Always count chars inserted
Richard M. Stallman <rms@gnu.org>
parents:
20668
diff
changeset
|
7035 |
|
89193
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
7036 /* 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
|
7037 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
|
7038 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
|
7039 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
|
7040 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
|
7041 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
|
7042 Otherwise, the bytes are raw bytes. |
|
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
7043 |
|
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
7044 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
|
7045 |
|
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
7046 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
|
7047 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
|
7048 (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
|
7049 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
|
7050 detect only text-format. */ |
|
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
7051 |
|
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
7052 Lisp_Object |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
7053 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
|
7054 coding_system) |
|
46548
cb1914307488
(encode_eol, detect_coding, detect_eol):
Ken Raeburn <raeburn@raeburn.org>
parents:
46462
diff
changeset
|
7055 const unsigned char *src; |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
7056 int src_chars, src_bytes, highest; |
|
34531
37f85e931855
(ONE_MORE_BYTE_CHECK_MULTIBYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34197
diff
changeset
|
7057 int multibytep; |
| 88365 | 7058 Lisp_Object coding_system; |
| 17052 | 7059 { |
| 89483 | 7060 const unsigned char *src_end = src + src_bytes; |
| 88365 | 7061 Lisp_Object attrs, eol_type; |
| 7062 Lisp_Object val; | |
| 7063 struct coding_system coding; | |
|
89193
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
7064 int id; |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7065 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
|
7066 enum coding_category base_category; |
| 88365 | 7067 |
| 7068 if (NILP (coding_system)) | |
| 7069 coding_system = Qundecided; | |
| 7070 setup_coding_system (coding_system, &coding); | |
| 7071 attrs = CODING_ID_ATTRS (coding.id); | |
| 7072 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
|
7073 coding_system = CODING_ATTR_BASE_NAME (attrs); |
| 88365 | 7074 |
| 7075 coding.source = src; | |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
7076 coding.src_chars = src_chars; |
| 88365 | 7077 coding.src_bytes = src_bytes; |
| 7078 coding.src_multibyte = multibytep; | |
| 7079 coding.consumed = 0; | |
|
89193
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
7080 coding.mode |= CODING_MODE_LAST_BLOCK; |
|
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
7081 |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7082 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
|
7083 |
|
89193
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
7084 /* 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
|
7085 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
|
7086 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
|
7087 { |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7088 enum coding_category category; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7089 struct coding_system *this; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7090 int c, i; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7091 |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
7092 /* 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
|
7093 for (i = 0; src < src_end; i++, src++) |
| 17052 | 7094 { |
| 88365 | 7095 c = *src; |
|
89780
a53cb5864a40
(detect_coding_iso_2022): Fix handling of SS2 and SS3.
Kenichi Handa <handa@m17n.org>
parents:
89779
diff
changeset
|
7096 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
|
7097 || c == ISO_CODE_SI |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
7098 || c == ISO_CODE_SO))) |
|
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
7099 break; |
| 17052 | 7100 } |
| 88365 | 7101 coding.head_ascii = src - coding.source; |
| 7102 | |
| 7103 if (src < src_end) | |
| 7104 for (i = 0; i < coding_category_raw_text; i++) | |
| 7105 { | |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7106 category = coding_priorities[i]; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7107 this = coding_categories + category; |
| 88365 | 7108 |
| 7109 if (this->id < 0) | |
| 7110 { | |
| 7111 /* 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
|
7112 detect_info.rejected |= (1 << category); |
| 88365 | 7113 } |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7114 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
|
7115 continue; |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7116 else if (detect_info.checked & (1 << category)) |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7117 { |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7118 if (highest |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7119 && (detect_info.found & (1 << category))) |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7120 break; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7121 } |
| 88365 | 7122 else |
| 7123 { | |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7124 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
|
7125 && highest |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7126 && (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
|
7127 { |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
7128 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
|
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 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
|
7132 else |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
7133 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
|
7134 } |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
7135 break; |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
7136 } |
| 88365 | 7137 } |
| 7138 } | |
|
89193
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
7139 |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7140 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
|
7141 { |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7142 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
|
7143 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
|
7144 val = Fcons (make_number (id), Qnil); |
|
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
7145 } |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7146 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
|
7147 { |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7148 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
|
7149 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
|
7150 val = Fcons (make_number (id), Qnil); |
|
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
7151 } |
|
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
7152 else if (highest) |
|
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) |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7155 { |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7156 detect_info.found = 1 << category; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7157 val = Fcons (make_number (this->id), Qnil); |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7158 } |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7159 else |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7160 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
|
7161 if (! (detect_info.rejected & (1 << coding_priorities[i]))) |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7162 { |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7163 detect_info.found = 1 << coding_priorities[i]; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7164 id = coding_categories[coding_priorities[i]].id; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7165 val = Fcons (make_number (id), Qnil); |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7166 break; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7167 } |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7168 } |
|
89193
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
7169 else |
|
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
7170 { |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7171 int mask = detect_info.rejected | detect_info.found; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7172 int found = 0; |
|
89193
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
7173 val = Qnil; |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7174 |
|
89193
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
7175 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
|
7176 { |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7177 category = coding_priorities[i]; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7178 if (! (mask & (1 << category))) |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7179 { |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7180 found |= 1 << category; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7181 id = coding_categories[category].id; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7182 val = Fcons (make_number (id), val); |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7183 } |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7184 } |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7185 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
|
7186 { |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7187 category = coding_priorities[i]; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7188 if (detect_info.found & (1 << category)) |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7189 { |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7190 id = coding_categories[category].id; |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7191 val = Fcons (make_number (id), val); |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7192 } |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7193 } |
|
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7194 detect_info.found |= found; |
|
89193
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
7195 } |
|
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
7196 } |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
7197 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
|
7198 { |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
7199 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
|
7200 { |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
7201 enum coding_category category; |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
7202 struct coding_system *this; |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
7203 |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
7204 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
|
7205 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
|
7206 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
|
7207 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
|
7208 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
|
7209 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
|
7210 else |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
7211 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
|
7212 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
|
7213 } |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
7214 } |
| 88365 | 7215 else |
| 7216 { | |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7217 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
|
7218 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
|
7219 } |
|
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
7220 |
|
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
7221 /* Then, detect eol-format if necessary. */ |
| 88365 | 7222 { |
|
89193
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
7223 int normal_eol = -1, utf_16_be_eol = -1, utf_16_le_eol; |
| 88365 | 7224 Lisp_Object tail; |
| 7225 | |
|
89193
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
7226 if (VECTORP (eol_type)) |
|
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
7227 { |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7228 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
|
7229 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
|
7230 coding_category_raw_text); |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7231 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
|
7232 | 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
|
7233 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
|
7234 coding_category_utf_16_be); |
|
89331
1892a75ffcac
(CATEGORY_MASK_RAW_TEXT): New macro.
Kenichi Handa <handa@m17n.org>
parents:
89279
diff
changeset
|
7235 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
|
7236 | 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
|
7237 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
|
7238 coding_category_utf_16_le); |
|
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
7239 } |
|
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
7240 else |
|
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
7241 { |
|
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
7242 if (EQ (eol_type, Qunix)) |
|
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
7243 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
|
7244 else if (EQ (eol_type, Qdos)) |
|
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
7245 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
|
7246 else |
|
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
7247 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
|
7248 } |
|
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
7249 |
| 88365 | 7250 for (tail = val; CONSP (tail); tail = XCDR (tail)) |
| 7251 { | |
|
89193
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
7252 enum coding_category category; |
| 88365 | 7253 int this_eol; |
|
89193
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
7254 |
|
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
7255 id = XINT (XCAR (tail)); |
|
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
7256 attrs = CODING_ID_ATTRS (id); |
|
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
7257 category = XINT (CODING_ATTR_CATEGORY (attrs)); |
|
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
7258 eol_type = CODING_ID_EOL_TYPE (id); |
| 88365 | 7259 if (VECTORP (eol_type)) |
| 7260 { | |
|
89193
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
7261 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
|
7262 || 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
|
7263 this_eol = utf_16_be_eol; |
|
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
7264 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
|
7265 || 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
|
7266 this_eol = utf_16_le_eol; |
| 88365 | 7267 else |
|
89193
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
7268 this_eol = normal_eol; |
|
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
7269 |
| 88365 | 7270 if (this_eol == EOL_SEEN_LF) |
| 7271 XSETCAR (tail, AREF (eol_type, 0)); | |
| 7272 else if (this_eol == EOL_SEEN_CRLF) | |
| 7273 XSETCAR (tail, AREF (eol_type, 1)); | |
| 7274 else if (this_eol == EOL_SEEN_CR) | |
| 7275 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
|
7276 else |
|
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
7277 XSETCAR (tail, CODING_ID_NAME (id)); |
| 88365 | 7278 } |
|
89193
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
7279 else |
|
311d061195ef
(detect_coding_utf_8): Check incomplete byte sequence.
Kenichi Handa <handa@m17n.org>
parents:
89184
diff
changeset
|
7280 XSETCAR (tail, CODING_ID_NAME (id)); |
| 88365 | 7281 } |
| 7282 } | |
| 7283 | |
|
25662
0a7261c1d487
Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25370
diff
changeset
|
7284 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
|
7285 } |
|
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
7286 |
| 88365 | 7287 |
|
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
7288 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
|
7289 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
|
7290 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
|
7291 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
|
7292 |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
7293 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
|
7294 `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
|
7295 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
|
7296 |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
7297 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
|
7298 highest priority. */) |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
7299 (start, end, highest) |
|
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
7300 Lisp_Object start, end, highest; |
| 17052 | 7301 { |
|
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
7302 int from, to; |
|
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
7303 int from_byte, to_byte; |
|
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
7304 |
|
40656
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Jan?k <Pavel@Janik.cz>
parents:
40461
diff
changeset
|
7305 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
|
7306 CHECK_NUMBER_COERCE_MARKER (end); |
|
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
7307 |
|
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
7308 validate_region (&start, &end); |
|
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
7309 from = XINT (start), to = XINT (end); |
|
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
7310 from_byte = CHAR_TO_BYTE (from); |
|
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
7311 to_byte = CHAR_TO_BYTE (to); |
|
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
7312 |
|
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
7313 if (from < GPT && to >= GPT) |
|
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
7314 move_gap_both (to, to_byte); |
| 88365 | 7315 |
|
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
7316 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
|
7317 to - from, to_byte - from_byte, |
|
34531
37f85e931855
(ONE_MORE_BYTE_CHECK_MULTIBYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34197
diff
changeset
|
7318 !NILP (highest), |
|
37f85e931855
(ONE_MORE_BYTE_CHECK_MULTIBYTE): New macro.
Kenichi Handa <handa@m17n.org>
parents:
34197
diff
changeset
|
7319 !NILP (current_buffer |
| 88365 | 7320 ->enable_multibyte_characters), |
| 7321 Qnil); | |
|
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
7322 } |
|
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
7323 |
|
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
7324 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
|
7325 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
|
7326 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
|
7327 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
|
7328 |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
7329 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
|
7330 `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
|
7331 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
|
7332 |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
7333 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
|
7334 highest priority. */) |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
7335 (string, highest) |
|
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
7336 Lisp_Object string, highest; |
|
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
7337 { |
|
40656
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Jan?k <Pavel@Janik.cz>
parents:
40461
diff
changeset
|
7338 CHECK_STRING (string); |
|
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
7339 |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
7340 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
|
7341 SCHARS (string), SBYTES (string), |
| 89483 | 7342 !NILP (highest), STRING_MULTIBYTE (string), |
| 88365 | 7343 Qnil); |
|
30487
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
7344 } |
|
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
7345 |
|
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
7346 |
| 88365 | 7347 static INLINE int |
| 7348 char_encodable_p (c, attrs) | |
| 7349 int c; | |
| 7350 Lisp_Object attrs; | |
|
30487
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
7351 { |
| 88365 | 7352 Lisp_Object tail; |
| 7353 struct charset *charset; | |
|
89732
8acde12aba89
(get_translation_table): New function.
Kenichi Handa <handa@m17n.org>
parents:
89730
diff
changeset
|
7354 Lisp_Object translation_table; |
|
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 translation_table = CODING_ATTR_TRANS_TBL (attrs); |
|
89759
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
7357 if (! NILP (translation_table)) |
|
89732
8acde12aba89
(get_translation_table): New function.
Kenichi Handa <handa@m17n.org>
parents:
89730
diff
changeset
|
7358 c = translate_char (translation_table, c); |
| 88365 | 7359 for (tail = CODING_ATTR_CHARSET_LIST (attrs); |
| 7360 CONSP (tail); tail = XCDR (tail)) | |
| 7361 { | |
| 7362 charset = CHARSET_FROM_ID (XINT (XCAR (tail))); | |
| 7363 if (CHAR_CHARSET_P (c, charset)) | |
| 7364 break; | |
| 7365 } | |
| 7366 return (! NILP (tail)); | |
|
30487
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
7367 } |
|
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
7368 |
|
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
7369 |
|
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
7370 /* Return a list of coding systems that safely encode the text between |
| 88365 | 7371 START and END. If EXCLUDE is non-nil, it is a list of coding |
| 7372 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
|
7373 coding systems. In any case, if the text contains only ASCII or is |
| 88365 | 7374 unibyte, return t. */ |
|
30487
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
7375 |
|
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
7376 DEFUN ("find-coding-systems-region-internal", |
|
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
7377 Ffind_coding_systems_region_internal, |
| 88365 | 7378 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
|
7379 doc: /* Internal use only. */) |
| 88365 | 7380 (start, end, exclude) |
| 7381 Lisp_Object start, end, exclude; | |
|
30487
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
7382 { |
| 88365 | 7383 Lisp_Object coding_attrs_list, safe_codings; |
| 7384 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
|
7385 const unsigned char *p, *pbeg, *pend; |
| 88365 | 7386 int c; |
| 7387 Lisp_Object tail, elt; | |
|
30487
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
7388 |
|
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
7389 if (STRINGP (start)) |
|
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
7390 { |
| 88365 | 7391 if (!STRING_MULTIBYTE (start) |
| 89483 | 7392 || SCHARS (start) == SBYTES (start)) |
|
30487
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
7393 return Qt; |
| 88365 | 7394 start_byte = 0; |
| 89483 | 7395 end_byte = SBYTES (start); |
|
30487
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
7396 } |
|
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
7397 else |
|
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
7398 { |
|
40656
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Jan?k <Pavel@Janik.cz>
parents:
40461
diff
changeset
|
7399 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
|
7400 CHECK_NUMBER_COERCE_MARKER (end); |
|
30487
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
7401 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
|
7402 args_out_of_range (start, end); |
|
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
7403 if (NILP (current_buffer->enable_multibyte_characters)) |
|
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
7404 return Qt; |
| 88365 | 7405 start_byte = CHAR_TO_BYTE (XINT (start)); |
| 7406 end_byte = CHAR_TO_BYTE (XINT (end)); | |
| 7407 if (XINT (end) - XINT (start) == end_byte - start_byte) | |
| 7408 return Qt; | |
| 7409 | |
|
89394
6ffca50f25b9
(Fcheck_coding_systems_region): Fix type errors.
Dave Love <fx@gnu.org>
parents:
89373
diff
changeset
|
7410 if (XINT (start) < GPT && XINT (end) > GPT) |
| 88365 | 7411 { |
|
89394
6ffca50f25b9
(Fcheck_coding_systems_region): Fix type errors.
Dave Love <fx@gnu.org>
parents:
89373
diff
changeset
|
7412 if ((GPT - XINT (start)) < (XINT (end) - GPT)) |
|
6ffca50f25b9
(Fcheck_coding_systems_region): Fix type errors.
Dave Love <fx@gnu.org>
parents:
89373
diff
changeset
|
7413 move_gap_both (XINT (start), start_byte); |
| 88365 | 7414 else |
|
89394
6ffca50f25b9
(Fcheck_coding_systems_region): Fix type errors.
Dave Love <fx@gnu.org>
parents:
89373
diff
changeset
|
7415 move_gap_both (XINT (end), end_byte); |
| 88365 | 7416 } |
| 7417 } | |
| 7418 | |
| 7419 coding_attrs_list = Qnil; | |
| 7420 for (tail = Vcoding_system_list; CONSP (tail); tail = XCDR (tail)) | |
| 7421 if (NILP (exclude) | |
| 7422 || NILP (Fmemq (XCAR (tail), exclude))) | |
| 7423 { | |
| 7424 Lisp_Object attrs; | |
| 7425 | |
| 7426 attrs = AREF (CODING_SYSTEM_SPEC (XCAR (tail)), 0); | |
| 7427 if (EQ (XCAR (tail), CODING_ATTR_BASE_NAME (attrs)) | |
| 7428 && ! EQ (CODING_ATTR_TYPE (attrs), Qundecided)) | |
|
89732
8acde12aba89
(get_translation_table): New function.
Kenichi Handa <handa@m17n.org>
parents:
89730
diff
changeset
|
7429 { |
|
8acde12aba89
(get_translation_table): New function.
Kenichi Handa <handa@m17n.org>
parents:
89730
diff
changeset
|
7430 ASET (attrs, coding_attr_trans_tbl, |
|
89861
7160ded23e55
(get_translation_table): Allow max_lookup to be NULL.
Kenichi Handa <handa@m17n.org>
parents:
89859
diff
changeset
|
7431 get_translation_table (attrs, 1, NULL)); |
|
89732
8acde12aba89
(get_translation_table): New function.
Kenichi Handa <handa@m17n.org>
parents:
89730
diff
changeset
|
7432 coding_attrs_list = Fcons (attrs, coding_attrs_list); |
|
8acde12aba89
(get_translation_table): New function.
Kenichi Handa <handa@m17n.org>
parents:
89730
diff
changeset
|
7433 } |
| 88365 | 7434 } |
| 7435 | |
| 7436 if (STRINGP (start)) | |
| 89483 | 7437 p = pbeg = SDATA (start); |
| 88365 | 7438 else |
| 7439 p = pbeg = BYTE_POS_ADDR (start_byte); | |
| 7440 pend = p + (end_byte - start_byte); | |
| 7441 | |
| 7442 while (p < pend && ASCII_BYTE_P (*p)) p++; | |
| 7443 while (p < pend && ASCII_BYTE_P (*(pend - 1))) pend--; | |
| 7444 | |
| 7445 while (p < pend) | |
| 7446 { | |
| 7447 if (ASCII_BYTE_P (*p)) | |
| 7448 p++; | |
|
30487
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
7449 else |
|
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
7450 { |
| 88365 | 7451 c = STRING_CHAR_ADVANCE (p); |
| 7452 | |
| 7453 charset_map_loaded = 0; | |
| 7454 for (tail = coding_attrs_list; CONSP (tail);) | |
| 7455 { | |
| 7456 elt = XCAR (tail); | |
| 7457 if (NILP (elt)) | |
| 7458 tail = XCDR (tail); | |
| 7459 else if (char_encodable_p (c, elt)) | |
| 7460 tail = XCDR (tail); | |
| 7461 else if (CONSP (XCDR (tail))) | |
| 7462 { | |
| 7463 XSETCAR (tail, XCAR (XCDR (tail))); | |
| 7464 XSETCDR (tail, XCDR (XCDR (tail))); | |
| 7465 } | |
| 7466 else | |
| 7467 { | |
| 7468 XSETCAR (tail, Qnil); | |
| 7469 tail = XCDR (tail); | |
| 7470 } | |
| 7471 } | |
| 7472 if (charset_map_loaded) | |
| 7473 { | |
| 7474 EMACS_INT p_offset = p - pbeg, pend_offset = pend - pbeg; | |
| 7475 | |
| 7476 if (STRINGP (start)) | |
| 89483 | 7477 pbeg = SDATA (start); |
| 88365 | 7478 else |
| 7479 pbeg = BYTE_POS_ADDR (start_byte); | |
| 7480 p = pbeg + p_offset; | |
| 7481 pend = pbeg + pend_offset; | |
| 7482 } | |
|
30487
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
7483 } |
|
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
7484 } |
|
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
7485 |
| 88365 | 7486 safe_codings = Qnil; |
| 7487 for (tail = coding_attrs_list; CONSP (tail); tail = XCDR (tail)) | |
| 7488 if (! NILP (XCAR (tail))) | |
| 7489 safe_codings = Fcons (CODING_ATTR_BASE_NAME (XCAR (tail)), safe_codings); | |
| 7490 | |
| 7491 return safe_codings; | |
| 7492 } | |
| 7493 | |
| 7494 | |
|
46859
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
7495 DEFUN ("unencodable-char-position", Funencodable_char_position, |
|
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
7496 Sunencodable_char_position, 3, 5, 0, |
|
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
7497 doc: /* |
|
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
7498 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
|
7499 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
|
7500 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
|
7501 |
|
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
7502 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
|
7503 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
|
7504 list of positions. |
|
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
7505 |
|
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
7506 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
|
7507 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
|
7508 to the string. */) |
|
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
7509 (start, end, coding_system, count, string) |
|
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
7510 Lisp_Object start, end, coding_system, count, string; |
|
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
7511 { |
|
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
7512 int n; |
|
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
7513 struct coding_system coding; |
|
89732
8acde12aba89
(get_translation_table): New function.
Kenichi Handa <handa@m17n.org>
parents:
89730
diff
changeset
|
7514 Lisp_Object attrs, charset_list, translation_table; |
|
46859
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
7515 Lisp_Object positions; |
|
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
7516 int from, to; |
| 89483 | 7517 const unsigned char *p, *stop, *pend; |
| 7518 int ascii_compatible; | |
| 7519 | |
| 7520 setup_coding_system (Fcheck_coding_system (coding_system), &coding); | |
| 7521 attrs = CODING_ID_ATTRS (coding.id); | |
| 7522 if (EQ (CODING_ATTR_TYPE (attrs), Qraw_text)) | |
| 7523 return Qnil; | |
| 7524 ascii_compatible = ! NILP (CODING_ATTR_ASCII_COMPAT (attrs)); | |
| 7525 charset_list = CODING_ATTR_CHARSET_LIST (attrs); | |
|
89861
7160ded23e55
(get_translation_table): Allow max_lookup to be NULL.
Kenichi Handa <handa@m17n.org>
parents:
89859
diff
changeset
|
7526 translation_table = get_translation_table (attrs, 1, NULL); |
|
46859
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
7527 |
|
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
7528 if (NILP (string)) |
|
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
7529 { |
|
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
7530 validate_region (&start, &end); |
|
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
7531 from = XINT (start); |
|
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
7532 to = XINT (end); |
| 89483 | 7533 if (NILP (current_buffer->enable_multibyte_characters) |
| 7534 || (ascii_compatible | |
| 7535 && (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
|
7536 return Qnil; |
|
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
7537 p = CHAR_POS_ADDR (from); |
| 89483 | 7538 pend = CHAR_POS_ADDR (to); |
| 7539 if (from < GPT && to >= GPT) | |
| 7540 stop = GPT_ADDR; | |
|
48829
f6c59ca557c7
(Funencodable_char_position): Set pend correctly.
Kenichi Handa <handa@m17n.org>
parents:
48230
diff
changeset
|
7541 else |
| 89483 | 7542 stop = pend; |
|
46859
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
7543 } |
|
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
7544 else |
|
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
7545 { |
|
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
7546 CHECK_STRING (string); |
|
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
7547 CHECK_NATNUM (start); |
|
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
7548 CHECK_NATNUM (end); |
|
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
7549 from = XINT (start); |
|
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
7550 to = XINT (end); |
|
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
7551 if (from > to |
|
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
7552 || to > SCHARS (string)) |
|
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
7553 args_out_of_range_3 (string, start, end); |
|
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
7554 if (! STRING_MULTIBYTE (string)) |
|
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
7555 return Qnil; |
|
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
7556 p = SDATA (string) + string_char_to_byte (string, from); |
| 89483 | 7557 stop = pend = SDATA (string) + string_char_to_byte (string, to); |
| 7558 if (ascii_compatible && (to - from) == (pend - p)) | |
| 7559 return Qnil; | |
| 7560 } | |
|
46859
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
7561 |
|
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
7562 if (NILP (count)) |
|
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
7563 n = 1; |
|
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
7564 else |
|
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
7565 { |
|
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
7566 CHECK_NATNUM (count); |
|
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
7567 n = XINT (count); |
|
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
7568 } |
|
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
7569 |
| 89483 | 7570 positions = Qnil; |
| 7571 while (1) | |
| 7572 { | |
| 7573 int c; | |
| 7574 | |
| 7575 if (ascii_compatible) | |
| 7576 while (p < stop && ASCII_BYTE_P (*p)) | |
| 7577 p++, from++; | |
| 7578 if (p >= stop) | |
| 7579 { | |
| 7580 if (p >= pend) | |
| 7581 break; | |
| 7582 stop = pend; | |
| 7583 p = GAP_END_ADDR; | |
| 7584 } | |
| 7585 | |
| 7586 c = STRING_CHAR_ADVANCE (p); | |
| 7587 if (! (ASCII_CHAR_P (c) && ascii_compatible) | |
|
89732
8acde12aba89
(get_translation_table): New function.
Kenichi Handa <handa@m17n.org>
parents:
89730
diff
changeset
|
7588 && ! char_charset (translate_char (translation_table, c), |
|
8acde12aba89
(get_translation_table): New function.
Kenichi Handa <handa@m17n.org>
parents:
89730
diff
changeset
|
7589 charset_list, NULL)) |
| 89483 | 7590 { |
| 7591 positions = Fcons (make_number (from), positions); | |
| 7592 n--; | |
| 7593 if (n == 0) | |
| 7594 break; | |
| 7595 } | |
| 7596 | |
| 7597 from++; | |
| 7598 } | |
| 7599 | |
| 7600 return (NILP (count) ? Fcar (positions) : Fnreverse (positions)); | |
| 7601 } | |
| 7602 | |
| 7603 | |
| 88365 | 7604 DEFUN ("check-coding-systems-region", Fcheck_coding_systems_region, |
| 7605 Scheck_coding_systems_region, 3, 3, 0, | |
| 7606 doc: /* Check if the region is encodable by coding systems. | |
| 7607 | |
| 7608 START and END are buffer positions specifying the region. | |
| 7609 CODING-SYSTEM-LIST is a list of coding systems to check. | |
| 7610 | |
| 7611 The value is an alist ((CODING-SYSTEM POS0 POS1 ...) ...), where | |
| 7612 CODING-SYSTEM is a member of CODING-SYSTEM-LIst and can't encode the | |
| 7613 whole region, POS0, POS1, ... are buffer positions where non-encodable | |
| 7614 characters are found. | |
| 7615 | |
| 7616 If all coding systems in CODING-SYSTEM-LIST can encode the region, the | |
| 7617 value is nil. | |
| 7618 | |
| 7619 START may be a string. In that case, check if the string is | |
| 7620 encodable, and the value contains indices to the string instead of | |
| 7621 buffer positions. END is ignored. */) | |
| 7622 (start, end, coding_system_list) | |
| 7623 Lisp_Object start, end, coding_system_list; | |
| 7624 { | |
| 7625 Lisp_Object list; | |
| 7626 EMACS_INT start_byte, end_byte; | |
| 7627 int pos; | |
|
88876
af9012fdad56
(LEADING_CODE_PRIVATE_11, LEADING_CODE_PRIVATE_12,
Kenichi Handa <handa@m17n.org>
parents:
88862
diff
changeset
|
7628 const unsigned char *p, *pbeg, *pend; |
| 88365 | 7629 int c; |
|
89732
8acde12aba89
(get_translation_table): New function.
Kenichi Handa <handa@m17n.org>
parents:
89730
diff
changeset
|
7630 Lisp_Object tail, elt, attrs; |
| 88365 | 7631 |
| 7632 if (STRINGP (start)) | |
| 7633 { | |
| 7634 if (!STRING_MULTIBYTE (start) | |
| 89483 | 7635 && SCHARS (start) != SBYTES (start)) |
| 88365 | 7636 return Qnil; |
| 7637 start_byte = 0; | |
| 89483 | 7638 end_byte = SBYTES (start); |
| 88365 | 7639 pos = 0; |
|
30487
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
7640 } |
|
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
7641 else |
| 88365 | 7642 { |
| 7643 CHECK_NUMBER_COERCE_MARKER (start); | |
| 7644 CHECK_NUMBER_COERCE_MARKER (end); | |
| 7645 if (XINT (start) < BEG || XINT (end) > Z || XINT (start) > XINT (end)) | |
| 7646 args_out_of_range (start, end); | |
| 7647 if (NILP (current_buffer->enable_multibyte_characters)) | |
| 7648 return Qnil; | |
| 7649 start_byte = CHAR_TO_BYTE (XINT (start)); | |
| 7650 end_byte = CHAR_TO_BYTE (XINT (end)); | |
| 7651 if (XINT (end) - XINT (start) == end_byte - start_byte) | |
| 7652 return Qt; | |
| 7653 | |
|
89394
6ffca50f25b9
(Fcheck_coding_systems_region): Fix type errors.
Dave Love <fx@gnu.org>
parents:
89373
diff
changeset
|
7654 if (XINT (start) < GPT && XINT (end) > GPT) |
| 88365 | 7655 { |
|
89394
6ffca50f25b9
(Fcheck_coding_systems_region): Fix type errors.
Dave Love <fx@gnu.org>
parents:
89373
diff
changeset
|
7656 if ((GPT - XINT (start)) < (XINT (end) - GPT)) |
|
6ffca50f25b9
(Fcheck_coding_systems_region): Fix type errors.
Dave Love <fx@gnu.org>
parents:
89373
diff
changeset
|
7657 move_gap_both (XINT (start), start_byte); |
| 88365 | 7658 else |
|
89394
6ffca50f25b9
(Fcheck_coding_systems_region): Fix type errors.
Dave Love <fx@gnu.org>
parents:
89373
diff
changeset
|
7659 move_gap_both (XINT (end), end_byte); |
| 88365 | 7660 } |
|
89394
6ffca50f25b9
(Fcheck_coding_systems_region): Fix type errors.
Dave Love <fx@gnu.org>
parents:
89373
diff
changeset
|
7661 pos = XINT (start); |
| 88365 | 7662 } |
| 7663 | |
| 7664 list = Qnil; | |
| 7665 for (tail = coding_system_list; CONSP (tail); tail = XCDR (tail)) | |
| 7666 { | |
| 7667 elt = XCAR (tail); | |
|
89732
8acde12aba89
(get_translation_table): New function.
Kenichi Handa <handa@m17n.org>
parents:
89730
diff
changeset
|
7668 attrs = AREF (CODING_SYSTEM_SPEC (elt), 0); |
|
89861
7160ded23e55
(get_translation_table): Allow max_lookup to be NULL.
Kenichi Handa <handa@m17n.org>
parents:
89859
diff
changeset
|
7669 ASET (attrs, coding_attr_trans_tbl, |
|
7160ded23e55
(get_translation_table): Allow max_lookup to be NULL.
Kenichi Handa <handa@m17n.org>
parents:
89859
diff
changeset
|
7670 get_translation_table (attrs, 1, NULL)); |
|
89732
8acde12aba89
(get_translation_table): New function.
Kenichi Handa <handa@m17n.org>
parents:
89730
diff
changeset
|
7671 list = Fcons (Fcons (elt, Fcons (attrs, Qnil)), list); |
| 88365 | 7672 } |
| 7673 | |
| 7674 if (STRINGP (start)) | |
| 89483 | 7675 p = pbeg = SDATA (start); |
| 88365 | 7676 else |
| 7677 p = pbeg = BYTE_POS_ADDR (start_byte); | |
| 7678 pend = p + (end_byte - start_byte); | |
| 7679 | |
| 7680 while (p < pend && ASCII_BYTE_P (*p)) p++, pos++; | |
| 7681 while (p < pend && ASCII_BYTE_P (*(pend - 1))) pend--; | |
| 7682 | |
| 7683 while (p < pend) | |
| 7684 { | |
| 7685 if (ASCII_BYTE_P (*p)) | |
| 7686 p++; | |
| 7687 else | |
| 7688 { | |
| 7689 c = STRING_CHAR_ADVANCE (p); | |
| 7690 | |
| 7691 charset_map_loaded = 0; | |
| 7692 for (tail = list; CONSP (tail); tail = XCDR (tail)) | |
| 7693 { | |
| 7694 elt = XCDR (XCAR (tail)); | |
| 7695 if (! char_encodable_p (c, XCAR (elt))) | |
| 7696 XSETCDR (elt, Fcons (make_number (pos), XCDR (elt))); | |
| 7697 } | |
| 7698 if (charset_map_loaded) | |
| 7699 { | |
| 7700 EMACS_INT p_offset = p - pbeg, pend_offset = pend - pbeg; | |
| 7701 | |
| 7702 if (STRINGP (start)) | |
| 89483 | 7703 pbeg = SDATA (start); |
| 88365 | 7704 else |
| 7705 pbeg = BYTE_POS_ADDR (start_byte); | |
| 7706 p = pbeg + p_offset; | |
| 7707 pend = pbeg + pend_offset; | |
| 7708 } | |
| 7709 } | |
| 7710 pos++; | |
| 7711 } | |
| 7712 | |
| 7713 tail = list; | |
| 7714 list = Qnil; | |
| 7715 for (; CONSP (tail); tail = XCDR (tail)) | |
| 7716 { | |
| 7717 elt = XCAR (tail); | |
| 7718 if (CONSP (XCDR (XCDR (elt)))) | |
| 7719 list = Fcons (Fcons (XCAR (elt), Fnreverse (XCDR (XCDR (elt)))), | |
| 7720 list); | |
| 7721 } | |
| 7722 | |
| 7723 return list; | |
|
30487
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
7724 } |
|
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
7725 |
|
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
7726 |
|
20803
0fa2183c587d
(ENCODE_ISO_CHARACTER): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
20794
diff
changeset
|
7727 Lisp_Object |
| 88365 | 7728 code_convert_region (start, end, coding_system, dst_object, encodep, norecord) |
| 7729 Lisp_Object start, end, coding_system, dst_object; | |
| 7730 int encodep, norecord; | |
|
20680
dd46027e8412
(code_convert_region): Always count chars inserted
Richard M. Stallman <rms@gnu.org>
parents:
20668
diff
changeset
|
7731 { |
|
dd46027e8412
(code_convert_region): Always count chars inserted
Richard M. Stallman <rms@gnu.org>
parents:
20668
diff
changeset
|
7732 struct coding_system coding; |
| 88365 | 7733 EMACS_INT from, from_byte, to, to_byte; |
| 7734 Lisp_Object src_object; | |
|
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
7735 |
|
40656
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Jan?k <Pavel@Janik.cz>
parents:
40461
diff
changeset
|
7736 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
|
7737 CHECK_NUMBER_COERCE_MARKER (end); |
| 88365 | 7738 if (NILP (coding_system)) |
| 7739 coding_system = Qno_conversion; | |
| 7740 else | |
| 7741 CHECK_CODING_SYSTEM (coding_system); | |
| 7742 src_object = Fcurrent_buffer (); | |
| 7743 if (NILP (dst_object)) | |
| 7744 dst_object = src_object; | |
| 7745 else if (! EQ (dst_object, Qt)) | |
| 7746 CHECK_BUFFER (dst_object); | |
|
20680
dd46027e8412
(code_convert_region): Always count chars inserted
Richard M. Stallman <rms@gnu.org>
parents:
20668
diff
changeset
|
7747 |
|
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
7748 validate_region (&start, &end); |
|
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
7749 from = XFASTINT (start); |
| 88365 | 7750 from_byte = CHAR_TO_BYTE (from); |
|
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
7751 to = XFASTINT (end); |
| 88365 | 7752 to_byte = CHAR_TO_BYTE (to); |
| 7753 | |
| 7754 setup_coding_system (coding_system, &coding); | |
|
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
7755 coding.mode |= CODING_MODE_LAST_BLOCK; |
| 88365 | 7756 |
| 7757 if (encodep) | |
| 7758 encode_coding_object (&coding, src_object, from, from_byte, to, to_byte, | |
| 7759 dst_object); | |
| 7760 else | |
| 7761 decode_coding_object (&coding, src_object, from, from_byte, to, to_byte, | |
| 7762 dst_object); | |
| 7763 if (! norecord) | |
| 7764 Vlast_coding_system_used = CODING_ID_NAME (coding.id); | |
| 7765 | |
| 7766 return (BUFFERP (dst_object) | |
| 7767 ? make_number (coding.produced_char) | |
| 7768 : coding.dst_object); | |
|
20803
0fa2183c587d
(ENCODE_ISO_CHARACTER): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
20794
diff
changeset
|
7769 } |
|
0fa2183c587d
(ENCODE_ISO_CHARACTER): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
20794
diff
changeset
|
7770 |
| 88365 | 7771 |
|
20803
0fa2183c587d
(ENCODE_ISO_CHARACTER): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
20794
diff
changeset
|
7772 DEFUN ("decode-coding-region", Fdecode_coding_region, Sdecode_coding_region, |
| 88365 | 7773 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
|
7774 doc: /* Decode the current region from the specified coding system. |
| 88365 | 7775 When called from a program, takes four arguments: |
| 7776 START, END, CODING-SYSTEM, and DESTINATION. | |
| 7777 START and END are buffer positions. | |
| 7778 | |
| 7779 Optional 4th arguments DESTINATION specifies where the decoded text goes. | |
| 7780 If nil, the region between START and END is replace by the decoded text. | |
| 7781 If buffer, the decoded text is inserted in the buffer. | |
| 7782 If t, the decoded text is returned. | |
| 7783 | |
|
40713
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
7784 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
|
7785 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
|
7786 not fully specified.) |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
7787 It returns the length of the decoded text. */) |
| 88365 | 7788 (start, end, coding_system, destination) |
| 7789 Lisp_Object start, end, coding_system, destination; | |
|
20803
0fa2183c587d
(ENCODE_ISO_CHARACTER): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
20794
diff
changeset
|
7790 { |
| 88365 | 7791 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
|
7792 } |
|
dd46027e8412
(code_convert_region): Always count chars inserted
Richard M. Stallman <rms@gnu.org>
parents:
20668
diff
changeset
|
7793 |
|
dd46027e8412
(code_convert_region): Always count chars inserted
Richard M. Stallman <rms@gnu.org>
parents:
20668
diff
changeset
|
7794 DEFUN ("encode-coding-region", Fencode_coding_region, Sencode_coding_region, |
| 88365 | 7795 3, 4, "r\nzCoding system: ", |
| 7796 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
|
7797 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
|
7798 START, END, and CODING-SYSTEM. START and END are buffer positions. |
| 88365 | 7799 |
| 7800 Optional 4th arguments DESTINATION specifies where the encoded text goes. | |
| 7801 If nil, the region between START and END is replace by the encoded text. | |
| 7802 If buffer, the encoded text is inserted in the buffer. | |
| 7803 If t, the encoded text is returned. | |
| 7804 | |
|
40713
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
7805 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
|
7806 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
|
7807 not fully specified.) |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
7808 It returns the length of the encoded text. */) |
| 88365 | 7809 (start, end, coding_system, destination) |
| 7810 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
|
7811 { |
| 88365 | 7812 return code_convert_region (start, end, coding_system, destination, 1, 0); |
| 17052 | 7813 } |
| 7814 | |
|
20803
0fa2183c587d
(ENCODE_ISO_CHARACTER): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
20794
diff
changeset
|
7815 Lisp_Object |
| 88365 | 7816 code_convert_string (string, coding_system, dst_object, |
| 7817 encodep, nocopy, norecord) | |
| 7818 Lisp_Object string, coding_system, dst_object; | |
| 7819 int encodep, nocopy, norecord; | |
| 17052 | 7820 { |
| 7821 struct coding_system coding; | |
| 88365 | 7822 EMACS_INT chars, bytes; |
| 17052 | 7823 |
|
40656
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Jan?k <Pavel@Janik.cz>
parents:
40461
diff
changeset
|
7824 CHECK_STRING (string); |
| 88365 | 7825 if (NILP (coding_system)) |
| 7826 { | |
| 7827 if (! norecord) | |
| 7828 Vlast_coding_system_used = Qno_conversion; | |
| 7829 if (NILP (dst_object)) | |
| 7830 return (nocopy ? Fcopy_sequence (string) : string); | |
| 7831 } | |
| 17052 | 7832 |
|
17119
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
7833 if (NILP (coding_system)) |
| 88365 | 7834 coding_system = Qno_conversion; |
| 7835 else | |
| 7836 CHECK_CODING_SYSTEM (coding_system); | |
| 7837 if (NILP (dst_object)) | |
| 7838 dst_object = Qt; | |
| 7839 else if (! EQ (dst_object, Qt)) | |
| 7840 CHECK_BUFFER (dst_object); | |
| 7841 | |
| 7842 setup_coding_system (coding_system, &coding); | |
|
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
7843 coding.mode |= CODING_MODE_LAST_BLOCK; |
| 89483 | 7844 chars = SCHARS (string); |
| 7845 bytes = SBYTES (string); | |
| 88365 | 7846 if (encodep) |
| 7847 encode_coding_object (&coding, string, 0, 0, chars, bytes, dst_object); | |
| 7848 else | |
| 7849 decode_coding_object (&coding, string, 0, 0, chars, bytes, dst_object); | |
| 7850 if (! norecord) | |
| 7851 Vlast_coding_system_used = CODING_ID_NAME (coding.id); | |
| 7852 | |
| 7853 return (BUFFERP (dst_object) | |
| 7854 ? make_number (coding.produced_char) | |
| 7855 : coding.dst_object); | |
|
20803
0fa2183c587d
(ENCODE_ISO_CHARACTER): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
20794
diff
changeset
|
7856 } |
|
0fa2183c587d
(ENCODE_ISO_CHARACTER): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
20794
diff
changeset
|
7857 |
|
0fa2183c587d
(ENCODE_ISO_CHARACTER): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
20794
diff
changeset
|
7858 |
|
22341
572ba933a4bf
(code_convert_string_norecord): New function.
Karl Heuer <kwzh@gnu.org>
parents:
22329
diff
changeset
|
7859 /* Encode or decode STRING according to CODING_SYSTEM. |
| 26847 | 7860 Do not set Vlast_coding_system_used. |
| 7861 | |
| 7862 This function is called only from macros DECODE_FILE and | |
| 7863 ENCODE_FILE, thus we ignore character composition. */ | |
|
22341
572ba933a4bf
(code_convert_string_norecord): New function.
Karl Heuer <kwzh@gnu.org>
parents:
22329
diff
changeset
|
7864 |
|
572ba933a4bf
(code_convert_string_norecord): New function.
Karl Heuer <kwzh@gnu.org>
parents:
22329
diff
changeset
|
7865 Lisp_Object |
|
572ba933a4bf
(code_convert_string_norecord): New function.
Karl Heuer <kwzh@gnu.org>
parents:
22329
diff
changeset
|
7866 code_convert_string_norecord (string, coding_system, encodep) |
|
572ba933a4bf
(code_convert_string_norecord): New function.
Karl Heuer <kwzh@gnu.org>
parents:
22329
diff
changeset
|
7867 Lisp_Object string, coding_system; |
|
572ba933a4bf
(code_convert_string_norecord): New function.
Karl Heuer <kwzh@gnu.org>
parents:
22329
diff
changeset
|
7868 int encodep; |
|
572ba933a4bf
(code_convert_string_norecord): New function.
Karl Heuer <kwzh@gnu.org>
parents:
22329
diff
changeset
|
7869 { |
|
88430
6418a272b97e
* coding.c: Delete unused variables.
Kenichi Handa <handa@m17n.org>
parents:
88365
diff
changeset
|
7870 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
|
7871 } |
| 88365 | 7872 |
| 7873 | |
| 7874 DEFUN ("decode-coding-string", Fdecode_coding_string, Sdecode_coding_string, | |
| 7875 2, 4, 0, | |
| 7876 doc: /* Decode STRING which is encoded in CODING-SYSTEM, and return the result. | |
| 7877 | |
| 7878 Optional third arg NOCOPY non-nil means it is OK to return STRING itself | |
| 7879 if the decoding operation is trivial. | |
| 7880 | |
| 7881 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
|
7882 inserted in BUFFER instead of returned as a string. In this case, |
| 88365 | 7883 the return value is BUFFER. |
| 7884 | |
| 7885 This function sets `last-coding-system-used' to the precise coding system | |
| 7886 used (which may be different from CODING-SYSTEM if CODING-SYSTEM is | |
| 7887 not fully specified. */) | |
| 7888 (string, coding_system, nocopy, buffer) | |
| 7889 Lisp_Object string, coding_system, nocopy, buffer; | |
| 7890 { | |
| 7891 return code_convert_string (string, coding_system, buffer, | |
| 7892 0, ! NILP (nocopy), 0); | |
| 7893 } | |
| 7894 | |
| 7895 DEFUN ("encode-coding-string", Fencode_coding_string, Sencode_coding_string, | |
| 7896 2, 4, 0, | |
| 7897 doc: /* Encode STRING to CODING-SYSTEM, and return the result. | |
| 7898 | |
| 7899 Optional third arg NOCOPY non-nil means it is OK to return STRING | |
| 7900 itself if the encoding operation is trivial. | |
| 7901 | |
| 7902 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
|
7903 inserted in BUFFER instead of returned as a string. In this case, |
| 88365 | 7904 the return value is BUFFER. |
| 7905 | |
| 7906 This function sets `last-coding-system-used' to the precise coding system | |
| 7907 used (which may be different from CODING-SYSTEM if CODING-SYSTEM is | |
| 7908 not fully specified.) */) | |
| 7909 (string, coding_system, nocopy, buffer) | |
| 7910 Lisp_Object string, coding_system, nocopy, buffer; | |
| 7911 { | |
| 7912 return code_convert_string (string, coding_system, buffer, | |
| 88856 | 7913 1, ! NILP (nocopy), 1); |
| 88365 | 7914 } |
| 7915 | |
|
20680
dd46027e8412
(code_convert_region): Always count chars inserted
Richard M. Stallman <rms@gnu.org>
parents:
20668
diff
changeset
|
7916 |
| 17052 | 7917 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
|
7918 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
|
7919 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
|
7920 (code) |
| 17052 | 7921 Lisp_Object code; |
| 7922 { | |
| 88365 | 7923 Lisp_Object spec, attrs, val; |
| 7924 struct charset *charset_roman, *charset_kanji, *charset_kana, *charset; | |
| 7925 int c; | |
| 7926 | |
| 7927 CHECK_NATNUM (code); | |
| 7928 c = XFASTINT (code); | |
| 7929 CHECK_CODING_SYSTEM_GET_SPEC (Vsjis_coding_system, spec); | |
| 7930 attrs = AREF (spec, 0); | |
| 7931 | |
| 7932 if (ASCII_BYTE_P (c) | |
| 7933 && ! NILP (CODING_ATTR_ASCII_COMPAT (attrs))) | |
| 7934 return code; | |
| 7935 | |
| 7936 val = CODING_ATTR_CHARSET_LIST (attrs); | |
| 7937 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
|
7938 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
|
7939 charset_kanji = CHARSET_FROM_ID (XINT (XCAR (val))); |
| 88365 | 7940 |
| 7941 if (c <= 0x7F) | |
| 7942 charset = charset_roman; | |
| 7943 else if (c >= 0xA0 && c < 0xDF) | |
| 7944 { | |
| 7945 charset = charset_kana; | |
| 7946 c -= 0x80; | |
|
24065
7e291dea6141
(Fdecode_sjis_char): Decode Japanese Katakana character
Kenichi Handa <handa@m17n.org>
parents:
24056
diff
changeset
|
7947 } |
|
7e291dea6141
(Fdecode_sjis_char): Decode Japanese Katakana character
Kenichi Handa <handa@m17n.org>
parents:
24056
diff
changeset
|
7948 else |
|
7e291dea6141
(Fdecode_sjis_char): Decode Japanese Katakana character
Kenichi Handa <handa@m17n.org>
parents:
24056
diff
changeset
|
7949 { |
|
88497
d2b9e0d4c2f6
(Fdecode_sjis_char): Fix typo (0x7F->0xFF). Fix the
Kenichi Handa <handa@m17n.org>
parents:
88485
diff
changeset
|
7950 int s1 = c >> 8, s2 = c & 0xFF; |
| 88365 | 7951 |
| 7952 if (s1 < 0x81 || (s1 > 0x9F && s1 < 0xE0) || s1 > 0xEF | |
| 7953 || s2 < 0x40 || s2 == 0x7F || s2 > 0xFC) | |
| 7954 error ("Invalid code: %d", code); | |
| 7955 SJIS_TO_JIS (c); | |
| 7956 charset = charset_kanji; | |
| 7957 } | |
| 7958 c = DECODE_CHAR (charset, c); | |
| 7959 if (c < 0) | |
| 7960 error ("Invalid code: %d", code); | |
| 7961 return make_number (c); | |
| 17052 | 7962 } |
| 7963 | |
| 88365 | 7964 |
| 17052 | 7965 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
|
7966 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
|
7967 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
|
7968 (ch) |
| 88365 | 7969 Lisp_Object ch; |
| 17052 | 7970 { |
| 88365 | 7971 Lisp_Object spec, attrs, charset_list; |
| 7972 int c; | |
| 7973 struct charset *charset; | |
| 7974 unsigned code; | |
| 7975 | |
| 7976 CHECK_CHARACTER (ch); | |
| 7977 c = XFASTINT (ch); | |
| 7978 CHECK_CODING_SYSTEM_GET_SPEC (Vsjis_coding_system, spec); | |
| 7979 attrs = AREF (spec, 0); | |
| 7980 | |
| 7981 if (ASCII_CHAR_P (c) | |
| 7982 && ! NILP (CODING_ATTR_ASCII_COMPAT (attrs))) | |
| 7983 return ch; | |
| 7984 | |
| 7985 charset_list = CODING_ATTR_CHARSET_LIST (attrs); | |
| 7986 charset = char_charset (c, charset_list, &code); | |
| 7987 if (code == CHARSET_INVALID_CODE (charset)) | |
| 7988 error ("Can't encode by shift_jis encoding: %d", c); | |
| 7989 JIS_TO_SJIS (code); | |
| 7990 | |
| 7991 return make_number (code); | |
| 17052 | 7992 } |
| 7993 | |
| 7994 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
|
7995 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
|
7996 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
|
7997 (code) |
| 17052 | 7998 Lisp_Object code; |
| 7999 { | |
| 88365 | 8000 Lisp_Object spec, attrs, val; |
| 8001 struct charset *charset_roman, *charset_big5, *charset; | |
| 8002 int c; | |
| 8003 | |
| 8004 CHECK_NATNUM (code); | |
| 8005 c = XFASTINT (code); | |
| 8006 CHECK_CODING_SYSTEM_GET_SPEC (Vbig5_coding_system, spec); | |
| 8007 attrs = AREF (spec, 0); | |
| 8008 | |
| 8009 if (ASCII_BYTE_P (c) | |
| 8010 && ! NILP (CODING_ATTR_ASCII_COMPAT (attrs))) | |
| 8011 return code; | |
| 8012 | |
| 8013 val = CODING_ATTR_CHARSET_LIST (attrs); | |
| 8014 charset_roman = CHARSET_FROM_ID (XINT (XCAR (val))), val = XCDR (val); | |
| 8015 charset_big5 = CHARSET_FROM_ID (XINT (XCAR (val))); | |
| 8016 | |
| 8017 if (c <= 0x7F) | |
| 8018 charset = charset_roman; | |
|
24324
2eec590faf26
(Fdecode_sjis_char, Fencode_sjis_char): Hanlde
Kenichi Handa <handa@m17n.org>
parents:
24316
diff
changeset
|
8019 else |
|
2eec590faf26
(Fdecode_sjis_char, Fencode_sjis_char): Hanlde
Kenichi Handa <handa@m17n.org>
parents:
24316
diff
changeset
|
8020 { |
| 88365 | 8021 int b1 = c >> 8, b2 = c & 0x7F; |
| 8022 if (b1 < 0xA1 || b1 > 0xFE | |
| 8023 || b2 < 0x40 || (b2 > 0x7E && b2 < 0xA1) || b2 > 0xFE) | |
| 8024 error ("Invalid code: %d", code); | |
| 8025 charset = charset_big5; | |
| 8026 } | |
| 8027 c = DECODE_CHAR (charset, (unsigned )c); | |
| 8028 if (c < 0) | |
| 8029 error ("Invalid code: %d", code); | |
| 8030 return make_number (c); | |
| 17052 | 8031 } |
| 8032 | |
| 8033 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
|
8034 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
|
8035 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
|
8036 (ch) |
| 17052 | 8037 Lisp_Object ch; |
| 8038 { | |
| 88365 | 8039 Lisp_Object spec, attrs, charset_list; |
| 8040 struct charset *charset; | |
| 8041 int c; | |
| 8042 unsigned code; | |
| 8043 | |
| 8044 CHECK_CHARACTER (ch); | |
| 8045 c = XFASTINT (ch); | |
| 8046 CHECK_CODING_SYSTEM_GET_SPEC (Vbig5_coding_system, spec); | |
| 8047 attrs = AREF (spec, 0); | |
| 8048 if (ASCII_CHAR_P (c) | |
| 8049 && ! NILP (CODING_ATTR_ASCII_COMPAT (attrs))) | |
| 8050 return ch; | |
| 8051 | |
| 8052 charset_list = CODING_ATTR_CHARSET_LIST (attrs); | |
| 8053 charset = char_charset (c, charset_list, &code); | |
| 8054 if (code == CHARSET_INVALID_CODE (charset)) | |
| 8055 error ("Can't encode by Big5 encoding: %d", c); | |
| 8056 | |
| 8057 return make_number (code); | |
| 17052 | 8058 } |
| 88365 | 8059 |
|
20680
dd46027e8412
(code_convert_region): Always count chars inserted
Richard M. Stallman <rms@gnu.org>
parents:
20668
diff
changeset
|
8060 |
|
18002
a14261786239
(encode_invocation_designation): Use macro
Kenichi Handa <handa@m17n.org>
parents:
17835
diff
changeset
|
8061 DEFUN ("set-terminal-coding-system-internal", |
|
a14261786239
(encode_invocation_designation): Use macro
Kenichi Handa <handa@m17n.org>
parents:
17835
diff
changeset
|
8062 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
|
8063 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
|
8064 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
|
8065 (coding_system) |
| 88473 | 8066 Lisp_Object coding_system; |
| 17052 | 8067 { |
|
40656
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Jan?k <Pavel@Janik.cz>
parents:
40461
diff
changeset
|
8068 CHECK_SYMBOL (coding_system); |
| 88365 | 8069 setup_coding_system (Fcheck_coding_system (coding_system), |
| 8070 &terminal_coding); | |
| 89483 | 8071 |
|
20150
402b6e5f4b58
(encode_designation_at_bol): Fix bug of finding graphic
Kenichi Handa <handa@m17n.org>
parents:
20105
diff
changeset
|
8072 /* We had better not send unsafe characters to terminal. */ |
| 88365 | 8073 terminal_coding.mode |= CODING_MODE_SAFE_ENCODING; |
| 8074 /* Characer composition should be disabled. */ | |
| 8075 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
|
8076 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
|
8077 terminal_coding.dst_multibyte = 0; |
| 17052 | 8078 return Qnil; |
| 8079 } | |
| 8080 | |
|
19280
e755044718ee
(ENCODE_ISO_CHARACTER_DIMENSION1): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
19193
diff
changeset
|
8081 DEFUN ("set-safe-terminal-coding-system-internal", |
|
e755044718ee
(ENCODE_ISO_CHARACTER_DIMENSION1): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
19193
diff
changeset
|
8082 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
|
8083 Sset_safe_terminal_coding_system_internal, 1, 1, 0, |
| 41006 | 8084 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
|
8085 (coding_system) |
| 88473 | 8086 Lisp_Object coding_system; |
|
19280
e755044718ee
(ENCODE_ISO_CHARACTER_DIMENSION1): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
19193
diff
changeset
|
8087 { |
|
40656
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Jan?k <Pavel@Janik.cz>
parents:
40461
diff
changeset
|
8088 CHECK_SYMBOL (coding_system); |
|
19280
e755044718ee
(ENCODE_ISO_CHARACTER_DIMENSION1): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
19193
diff
changeset
|
8089 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
|
8090 &safe_terminal_coding); |
| 88365 | 8091 /* Characer composition should be disabled. */ |
| 8092 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
|
8093 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
|
8094 safe_terminal_coding.dst_multibyte = 0; |
|
19280
e755044718ee
(ENCODE_ISO_CHARACTER_DIMENSION1): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
19193
diff
changeset
|
8095 return Qnil; |
|
e755044718ee
(ENCODE_ISO_CHARACTER_DIMENSION1): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
19193
diff
changeset
|
8096 } |
|
e755044718ee
(ENCODE_ISO_CHARACTER_DIMENSION1): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
19193
diff
changeset
|
8097 |
| 17052 | 8098 DEFUN ("terminal-coding-system", |
| 8099 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
|
8100 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
|
8101 () |
| 17052 | 8102 { |
| 88365 | 8103 return CODING_ID_NAME (terminal_coding.id); |
| 17052 | 8104 } |
| 8105 | |
|
18002
a14261786239
(encode_invocation_designation): Use macro
Kenichi Handa <handa@m17n.org>
parents:
17835
diff
changeset
|
8106 DEFUN ("set-keyboard-coding-system-internal", |
|
a14261786239
(encode_invocation_designation): Use macro
Kenichi Handa <handa@m17n.org>
parents:
17835
diff
changeset
|
8107 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
|
8108 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
|
8109 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
|
8110 (coding_system) |
| 17052 | 8111 Lisp_Object coding_system; |
| 8112 { | |
|
40656
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Jan?k <Pavel@Janik.cz>
parents:
40461
diff
changeset
|
8113 CHECK_SYMBOL (coding_system); |
| 88365 | 8114 setup_coding_system (Fcheck_coding_system (coding_system), |
| 8115 &keyboard_coding); | |
| 8116 /* Characer composition should be disabled. */ | |
| 8117 keyboard_coding.common_flags &= ~CODING_ANNOTATE_COMPOSITION_MASK; | |
| 17052 | 8118 return Qnil; |
| 8119 } | |
| 8120 | |
| 8121 DEFUN ("keyboard-coding-system", | |
| 8122 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
|
8123 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
|
8124 () |
| 17052 | 8125 { |
| 88365 | 8126 return CODING_ID_NAME (keyboard_coding.id); |
| 17052 | 8127 } |
| 8128 | |
| 8129 | |
|
18536
69c0e220b626
(Vstandard_character_unification_table_for_decode):
Kenichi Handa <handa@m17n.org>
parents:
18523
diff
changeset
|
8130 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
|
8131 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
|
8132 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
|
8133 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
|
8134 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
|
8135 \(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
|
8136 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
|
8137 |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
8138 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
|
8139 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
|
8140 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
|
8141 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
|
8142 |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
8143 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
|
8144 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
|
8145 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
|
8146 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
|
8147 |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
8148 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
|
8149 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
|
8150 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
|
8151 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
|
8152 |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
8153 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
|
8154 `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
|
8155 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
|
8156 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
|
8157 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
|
8158 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
|
8159 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
|
8160 |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
8161 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
|
8162 (nargs, args) |
| 17052 | 8163 int nargs; |
| 8164 Lisp_Object *args; | |
| 8165 { | |
| 8166 Lisp_Object operation, target_idx, target, val; | |
| 8167 register Lisp_Object chain; | |
| 8168 | |
| 8169 if (nargs < 2) | |
| 8170 error ("Too few arguments"); | |
| 8171 operation = args[0]; | |
| 8172 if (!SYMBOLP (operation) | |
| 8173 || !INTEGERP (target_idx = Fget (operation, Qtarget_idx))) | |
| 88365 | 8174 error ("Invalid first arguement"); |
| 17052 | 8175 if (nargs < 1 + XINT (target_idx)) |
| 8176 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
|
8177 SDATA (SYMBOL_NAME (operation))); |
| 17052 | 8178 target = args[XINT (target_idx) + 1]; |
| 8179 if (!(STRINGP (target) | |
| 8180 || (EQ (operation, Qopen_network_stream) && INTEGERP (target)))) | |
| 88365 | 8181 error ("Invalid %dth argument", XINT (target_idx) + 1); |
| 17052 | 8182 |
|
18613
614b916ff5bf
Fix bugs with inappropriate mixing of Lisp_Object with int.
Richard M. Stallman <rms@gnu.org>
parents:
18536
diff
changeset
|
8183 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
|
8184 || EQ (operation, Qwrite_region)) |
|
18180
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
8185 ? 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
|
8186 : (EQ (operation, Qopen_network_stream) |
|
18180
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
8187 ? Vnetwork_coding_system_alist |
|
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
8188 : Vprocess_coding_system_alist)); |
| 17052 | 8189 if (NILP (chain)) |
| 8190 return Qnil; | |
| 8191 | |
|
25662
0a7261c1d487
Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25370
diff
changeset
|
8192 for (; CONSP (chain); chain = XCDR (chain)) |
| 17052 | 8193 { |
|
19747
bed06df9cbc5
(setup_coding_system, Ffind_operation_coding_system)
Richard M. Stallman <rms@gnu.org>
parents:
19743
diff
changeset
|
8194 Lisp_Object elt; |
| 88365 | 8195 |
|
25662
0a7261c1d487
Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25370
diff
changeset
|
8196 elt = XCAR (chain); |
| 17052 | 8197 if (CONSP (elt) |
| 8198 && ((STRINGP (target) | |
|
25662
0a7261c1d487
Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25370
diff
changeset
|
8199 && STRINGP (XCAR (elt)) |
|
0a7261c1d487
Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25370
diff
changeset
|
8200 && 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
|
8201 || (INTEGERP (target) && EQ (target, XCAR (elt))))) |
|
18180
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
8202 { |
|
25662
0a7261c1d487
Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25370
diff
changeset
|
8203 val = XCDR (elt); |
|
19763
ab2fd2c85986
(Ffind_operation_coding_system): If a function in
Kenichi Handa <handa@m17n.org>
parents:
19758
diff
changeset
|
8204 /* 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
|
8205 function symbol, we return VAL as a coding system. */ |
|
18180
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
8206 if (CONSP (val)) |
|
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
8207 return val; |
|
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
8208 if (! SYMBOLP (val)) |
|
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
8209 return Qnil; |
|
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
8210 if (! NILP (Fcoding_system_p (val))) |
|
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
8211 return Fcons (val, val); |
|
19763
ab2fd2c85986
(Ffind_operation_coding_system): If a function in
Kenichi Handa <handa@m17n.org>
parents:
19758
diff
changeset
|
8212 if (! NILP (Ffboundp (val))) |
|
ab2fd2c85986
(Ffind_operation_coding_system): If a function in
Kenichi Handa <handa@m17n.org>
parents:
19758
diff
changeset
|
8213 { |
|
ab2fd2c85986
(Ffind_operation_coding_system): If a function in
Kenichi Handa <handa@m17n.org>
parents:
19758
diff
changeset
|
8214 val = call1 (val, Flist (nargs, args)); |
|
ab2fd2c85986
(Ffind_operation_coding_system): If a function in
Kenichi Handa <handa@m17n.org>
parents:
19758
diff
changeset
|
8215 if (CONSP (val)) |
|
ab2fd2c85986
(Ffind_operation_coding_system): If a function in
Kenichi Handa <handa@m17n.org>
parents:
19758
diff
changeset
|
8216 return val; |
|
ab2fd2c85986
(Ffind_operation_coding_system): If a function in
Kenichi Handa <handa@m17n.org>
parents:
19758
diff
changeset
|
8217 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
|
8218 return Fcons (val, val); |
|
ab2fd2c85986
(Ffind_operation_coding_system): If a function in
Kenichi Handa <handa@m17n.org>
parents:
19758
diff
changeset
|
8219 } |
|
18180
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
8220 return Qnil; |
|
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
8221 } |
| 17052 | 8222 } |
| 8223 return Qnil; | |
| 8224 } | |
| 8225 | |
| 88365 | 8226 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
|
8227 Sset_coding_system_priority, 0, MANY, 0, |
| 88645 | 8228 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
|
8229 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
|
8230 all but the first one are ignored. |
|
040a08a2a879
(Fread_coding_system): Fix arg of XSETSTRING.
Dave Love <fx@gnu.org>
parents:
89483
diff
changeset
|
8231 |
|
040a08a2a879
(Fread_coding_system): Fix arg of XSETSTRING.
Dave Love <fx@gnu.org>
parents:
89483
diff
changeset
|
8232 usage: (set-coding-system-priority ...) */) |
| 88365 | 8233 (nargs, args) |
| 8234 int nargs; | |
| 8235 Lisp_Object *args; | |
| 8236 { | |
| 8237 int i, j; | |
| 8238 int changed[coding_category_max]; | |
| 8239 enum coding_category priorities[coding_category_max]; | |
| 8240 | |
| 8241 bzero (changed, sizeof changed); | |
| 8242 | |
| 8243 for (i = j = 0; i < nargs; i++) | |
| 8244 { | |
| 8245 enum coding_category category; | |
| 8246 Lisp_Object spec, attrs; | |
| 8247 | |
| 8248 CHECK_CODING_SYSTEM_GET_SPEC (args[i], spec); | |
| 8249 attrs = AREF (spec, 0); | |
| 8250 category = XINT (CODING_ATTR_CATEGORY (attrs)); | |
| 8251 if (changed[category]) | |
| 8252 /* Ignore this coding system because a coding system of the | |
| 8253 same category already had a higher priority. */ | |
| 8254 continue; | |
| 8255 changed[category] = 1; | |
| 8256 priorities[j++] = category; | |
| 8257 if (coding_categories[category].id >= 0 | |
| 8258 && ! EQ (args[i], CODING_ID_NAME (coding_categories[category].id))) | |
| 8259 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
|
8260 Fset (AREF (Vcoding_category_table, category), args[i]); |
| 88365 | 8261 } |
| 8262 | |
| 8263 /* Now we have decided top J priorities. Reflect the order of the | |
| 8264 original priorities to the remaining priorities. */ | |
| 8265 | |
| 8266 for (i = j, j = 0; i < coding_category_max; i++, j++) | |
| 8267 { | |
| 8268 while (j < coding_category_max | |
| 8269 && changed[coding_priorities[j]]) | |
| 8270 j++; | |
| 8271 if (j == coding_category_max) | |
| 8272 abort (); | |
| 8273 priorities[i] = coding_priorities[j]; | |
| 8274 } | |
| 8275 | |
| 8276 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
|
8277 |
|
e911ca706166
(Fset_coding_system_priority): Doc fix. Update values
Kenichi Handa <handa@m17n.org>
parents:
89462
diff
changeset
|
8278 /* Update `coding-category-list'. */ |
|
e911ca706166
(Fset_coding_system_priority): Doc fix. Update values
Kenichi Handa <handa@m17n.org>
parents:
89462
diff
changeset
|
8279 Vcoding_category_list = Qnil; |
|
e911ca706166
(Fset_coding_system_priority): Doc fix. Update values
Kenichi Handa <handa@m17n.org>
parents:
89462
diff
changeset
|
8280 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
|
8281 Vcoding_category_list |
|
e911ca706166
(Fset_coding_system_priority): Doc fix. Update values
Kenichi Handa <handa@m17n.org>
parents:
89462
diff
changeset
|
8282 = 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
|
8283 Vcoding_category_list); |
|
e911ca706166
(Fset_coding_system_priority): Doc fix. Update values
Kenichi Handa <handa@m17n.org>
parents:
89462
diff
changeset
|
8284 |
| 88365 | 8285 return Qnil; |
| 8286 } | |
| 8287 | |
| 8288 DEFUN ("coding-system-priority-list", Fcoding_system_priority_list, | |
| 8289 Scoding_system_priority_list, 0, 1, 0, | |
| 88645 | 8290 doc: /* Return a list of coding systems ordered by their priorities. |
| 8291 HIGHESTP non-nil means just return the highest priority one. */) | |
| 88365 | 8292 (highestp) |
| 8293 Lisp_Object highestp; | |
|
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
8294 { |
|
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
8295 int i; |
| 88365 | 8296 Lisp_Object val; |
| 8297 | |
| 8298 for (i = 0, val = Qnil; i < coding_category_max; i++) | |
| 8299 { | |
| 8300 enum coding_category category = coding_priorities[i]; | |
| 8301 int id = coding_categories[category].id; | |
| 8302 Lisp_Object attrs; | |
| 8303 | |
| 8304 if (id < 0) | |
| 8305 continue; | |
| 8306 attrs = CODING_ID_ATTRS (id); | |
| 8307 if (! NILP (highestp)) | |
| 8308 return CODING_ATTR_BASE_NAME (attrs); | |
| 8309 val = Fcons (CODING_ATTR_BASE_NAME (attrs), val); | |
| 8310 } | |
| 8311 return Fnreverse (val); | |
| 8312 } | |
| 8313 | |
|
88631
780b91d4a7e5
(setup_iso_safe_charsets): Fix arg decl for K&R.
Dave Love <fx@gnu.org>
parents:
88607
diff
changeset
|
8314 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
|
8315 |
| 88365 | 8316 static Lisp_Object |
| 8317 make_subsidiaries (base) | |
| 8318 Lisp_Object base; | |
| 8319 { | |
| 8320 Lisp_Object subsidiaries; | |
| 89483 | 8321 int base_name_len = SBYTES (SYMBOL_NAME (base)); |
| 88365 | 8322 char *buf = (char *) alloca (base_name_len + 6); |
| 8323 int i; | |
| 89483 | 8324 |
| 8325 bcopy (SDATA (SYMBOL_NAME (base)), buf, base_name_len); | |
| 88365 | 8326 subsidiaries = Fmake_vector (make_number (3), Qnil); |
| 8327 for (i = 0; i < 3; i++) | |
| 8328 { | |
| 8329 bcopy (suffixes[i], buf + base_name_len, strlen (suffixes[i]) + 1); | |
| 8330 ASET (subsidiaries, i, intern (buf)); | |
| 8331 } | |
| 8332 return subsidiaries; | |
| 8333 } | |
| 8334 | |
| 8335 | |
| 8336 DEFUN ("define-coding-system-internal", Fdefine_coding_system_internal, | |
| 8337 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
|
8338 doc: /* For internal use only. |
|
f464d728344c
(Vchar_coding_system_table, Qchar_coding_system):
Dave Love <fx@gnu.org>
parents:
88510
diff
changeset
|
8339 usage: (define-coding-system-internal ...) */) |
| 88365 | 8340 (nargs, args) |
| 8341 int nargs; | |
| 8342 Lisp_Object *args; | |
| 8343 { | |
| 8344 Lisp_Object name; | |
| 8345 Lisp_Object spec_vec; /* [ ATTRS ALIASE EOL_TYPE ] */ | |
| 8346 Lisp_Object attrs; /* Vector of attributes. */ | |
| 8347 Lisp_Object eol_type; | |
| 8348 Lisp_Object aliases; | |
| 8349 Lisp_Object coding_type, charset_list, safe_charsets; | |
| 8350 enum coding_category category; | |
| 8351 Lisp_Object tail, val; | |
| 8352 int max_charset_id = 0; | |
| 8353 int i; | |
| 8354 | |
| 8355 if (nargs < coding_arg_max) | |
| 8356 goto short_args; | |
| 8357 | |
| 8358 attrs = Fmake_vector (make_number (coding_attr_last_index), Qnil); | |
| 8359 | |
| 8360 name = args[coding_arg_name]; | |
| 8361 CHECK_SYMBOL (name); | |
| 8362 CODING_ATTR_BASE_NAME (attrs) = name; | |
| 8363 | |
| 8364 val = args[coding_arg_mnemonic]; | |
| 8365 if (! STRINGP (val)) | |
| 8366 CHECK_CHARACTER (val); | |
| 8367 CODING_ATTR_MNEMONIC (attrs) = val; | |
| 8368 | |
| 8369 coding_type = args[coding_arg_coding_type]; | |
| 8370 CHECK_SYMBOL (coding_type); | |
| 8371 CODING_ATTR_TYPE (attrs) = coding_type; | |
| 8372 | |
| 8373 charset_list = args[coding_arg_charset_list]; | |
| 8374 if (SYMBOLP (charset_list)) | |
| 8375 { | |
| 8376 if (EQ (charset_list, Qiso_2022)) | |
| 8377 { | |
| 8378 if (! EQ (coding_type, Qiso_2022)) | |
| 8379 error ("Invalid charset-list"); | |
| 8380 charset_list = Viso_2022_charset_list; | |
| 8381 } | |
| 8382 else if (EQ (charset_list, Qemacs_mule)) | |
| 8383 { | |
| 8384 if (! EQ (coding_type, Qemacs_mule)) | |
| 8385 error ("Invalid charset-list"); | |
| 8386 charset_list = Vemacs_mule_charset_list; | |
| 8387 } | |
| 8388 for (tail = charset_list; CONSP (tail); tail = XCDR (tail)) | |
| 8389 if (max_charset_id < XFASTINT (XCAR (tail))) | |
| 8390 max_charset_id = XFASTINT (XCAR (tail)); | |
| 8391 } | |
| 8392 else | |
| 8393 { | |
| 8394 charset_list = Fcopy_sequence (charset_list); | |
| 8395 for (tail = charset_list; !NILP (tail); tail = Fcdr (tail)) | |
| 8396 { | |
| 8397 struct charset *charset; | |
| 8398 | |
| 8399 val = Fcar (tail); | |
| 8400 CHECK_CHARSET_GET_CHARSET (val, charset); | |
| 8401 if (EQ (coding_type, Qiso_2022) | |
| 8402 ? CHARSET_ISO_FINAL (charset) < 0 | |
| 8403 : EQ (coding_type, Qemacs_mule) | |
| 8404 ? CHARSET_EMACS_MULE_ID (charset) < 0 | |
| 8405 : 0) | |
| 8406 error ("Can't handle charset `%s'", | |
| 89483 | 8407 SDATA (SYMBOL_NAME (CHARSET_NAME (charset)))); |
| 8408 | |
| 8409 XSETCAR (tail, make_number (charset->id)); | |
| 88365 | 8410 if (max_charset_id < charset->id) |
| 8411 max_charset_id = charset->id; | |
| 8412 } | |
| 8413 } | |
| 8414 CODING_ATTR_CHARSET_LIST (attrs) = charset_list; | |
| 8415 | |
| 8416 safe_charsets = Fmake_string (make_number (max_charset_id + 1), | |
| 8417 make_number (255)); | |
| 8418 for (tail = charset_list; CONSP (tail); tail = XCDR (tail)) | |
| 89483 | 8419 SSET (safe_charsets, XFASTINT (XCAR (tail)), 0); |
| 88365 | 8420 CODING_ATTR_SAFE_CHARSETS (attrs) = safe_charsets; |
| 8421 | |
|
89225
32058afc72e2
(detect_coding_charset): If only ASCII bytes are found, return 0.
Kenichi Handa <handa@m17n.org>
parents:
89221
diff
changeset
|
8422 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
|
8423 |
| 88365 | 8424 val = args[coding_arg_decode_translation_table]; |
|
89759
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
8425 if (! CHAR_TABLE_P (val) && ! CONSP (val)) |
|
89732
8acde12aba89
(get_translation_table): New function.
Kenichi Handa <handa@m17n.org>
parents:
89730
diff
changeset
|
8426 CHECK_SYMBOL (val); |
| 88365 | 8427 CODING_ATTR_DECODE_TBL (attrs) = val; |
| 8428 | |
| 8429 val = args[coding_arg_encode_translation_table]; | |
|
89759
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
8430 if (! CHAR_TABLE_P (val) && ! CONSP (val)) |
|
89732
8acde12aba89
(get_translation_table): New function.
Kenichi Handa <handa@m17n.org>
parents:
89730
diff
changeset
|
8431 CHECK_SYMBOL (val); |
| 88365 | 8432 CODING_ATTR_ENCODE_TBL (attrs) = val; |
| 8433 | |
| 8434 val = args[coding_arg_post_read_conversion]; | |
| 8435 CHECK_SYMBOL (val); | |
| 8436 CODING_ATTR_POST_READ (attrs) = val; | |
| 8437 | |
| 8438 val = args[coding_arg_pre_write_conversion]; | |
| 8439 CHECK_SYMBOL (val); | |
| 8440 CODING_ATTR_PRE_WRITE (attrs) = val; | |
| 8441 | |
| 8442 val = args[coding_arg_default_char]; | |
| 8443 if (NILP (val)) | |
| 8444 CODING_ATTR_DEFAULT_CHAR (attrs) = make_number (' '); | |
| 8445 else | |
| 8446 { | |
| 89483 | 8447 CHECK_CHARACTER (val); |
| 88365 | 8448 CODING_ATTR_DEFAULT_CHAR (attrs) = val; |
| 8449 } | |
| 8450 | |
| 89483 | 8451 val = args[coding_arg_for_unibyte]; |
| 8452 CODING_ATTR_FOR_UNIBYTE (attrs) = NILP (val) ? Qnil : Qt; | |
| 8453 | |
| 88365 | 8454 val = args[coding_arg_plist]; |
| 8455 CHECK_LIST (val); | |
| 8456 CODING_ATTR_PLIST (attrs) = val; | |
| 8457 | |
| 8458 if (EQ (coding_type, Qcharset)) | |
| 8459 { | |
|
88597
74b74f59bc09
(decode_coding_charset): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
88587
diff
changeset
|
8460 /* 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
|
8461 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
|
8462 |
|
74b74f59bc09
(decode_coding_charset): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
88587
diff
changeset
|
8463 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
|
8464 coding system. |
|
74b74f59bc09
(decode_coding_charset): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
88587
diff
changeset
|
8465 |
|
74b74f59bc09
(decode_coding_charset): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
88587
diff
changeset
|
8466 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
|
8467 charset whose ID is NUM. |
|
74b74f59bc09
(decode_coding_charset): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
88587
diff
changeset
|
8468 |
|
74b74f59bc09
(decode_coding_charset): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
88587
diff
changeset
|
8469 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
|
8470 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
|
8471 charsets. A charset of smaller dimension comes firtst. */ |
| 88365 | 8472 val = Fmake_vector (make_number (256), Qnil); |
| 8473 | |
|
89653
cbaa9fd1aa5c
(Fdefine_coding_system_internal): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89648
diff
changeset
|
8474 for (tail = charset_list; CONSP (tail); tail = XCDR (tail)) |
| 88365 | 8475 { |
|
88597
74b74f59bc09
(decode_coding_charset): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
88587
diff
changeset
|
8476 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
|
8477 int dim = CHARSET_DIMENSION (charset); |
|
74b74f59bc09
(decode_coding_charset): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
88587
diff
changeset
|
8478 int idx = (dim - 1) * 4; |
| 89483 | 8479 |
|
89653
cbaa9fd1aa5c
(Fdefine_coding_system_internal): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89648
diff
changeset
|
8480 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
|
8481 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
|
8482 |
|
88477
5f974cbba7b3
(coding_set_source): Delete the local variable beg_byte.
Kenichi Handa <handa@m17n.org>
parents:
88473
diff
changeset
|
8483 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
|
8484 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
|
8485 { |
|
88597
74b74f59bc09
(decode_coding_charset): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
88587
diff
changeset
|
8486 Lisp_Object tmp, tmp2; |
|
74b74f59bc09
(decode_coding_charset): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
88587
diff
changeset
|
8487 int dim2; |
|
74b74f59bc09
(decode_coding_charset): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
88587
diff
changeset
|
8488 |
|
74b74f59bc09
(decode_coding_charset): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
88587
diff
changeset
|
8489 tmp = AREF (val, i); |
|
74b74f59bc09
(decode_coding_charset): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
88587
diff
changeset
|
8490 if (NILP (tmp)) |
|
74b74f59bc09
(decode_coding_charset): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
88587
diff
changeset
|
8491 tmp = XCAR (tail); |
|
74b74f59bc09
(decode_coding_charset): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
88587
diff
changeset
|
8492 else if (NUMBERP (tmp)) |
|
74b74f59bc09
(decode_coding_charset): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
88587
diff
changeset
|
8493 { |
|
74b74f59bc09
(decode_coding_charset): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
88587
diff
changeset
|
8494 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
|
8495 if (dim < dim2) |
|
88607
18436bf3d6dd
(Fdefine_coding_system_internal): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
88598
diff
changeset
|
8496 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
|
8497 else |
|
88607
18436bf3d6dd
(Fdefine_coding_system_internal): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
88598
diff
changeset
|
8498 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
|
8499 } |
|
88477
5f974cbba7b3
(coding_set_source): Delete the local variable beg_byte.
Kenichi Handa <handa@m17n.org>
parents:
88473
diff
changeset
|
8500 else |
|
88597
74b74f59bc09
(decode_coding_charset): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
88587
diff
changeset
|
8501 { |
|
74b74f59bc09
(decode_coding_charset): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
88587
diff
changeset
|
8502 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
|
8503 { |
|
74b74f59bc09
(decode_coding_charset): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
88587
diff
changeset
|
8504 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
|
8505 if (dim < dim2) |
|
74b74f59bc09
(decode_coding_charset): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
88587
diff
changeset
|
8506 break; |
|
74b74f59bc09
(decode_coding_charset): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
88587
diff
changeset
|
8507 } |
|
74b74f59bc09
(decode_coding_charset): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
88587
diff
changeset
|
8508 if (NILP (tmp2)) |
|
74b74f59bc09
(decode_coding_charset): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
88587
diff
changeset
|
8509 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
|
8510 else |
|
74b74f59bc09
(decode_coding_charset): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
88587
diff
changeset
|
8511 { |
|
74b74f59bc09
(decode_coding_charset): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
88587
diff
changeset
|
8512 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
|
8513 XSETCAR (tmp2, XCAR (tail)); |
|
74b74f59bc09
(decode_coding_charset): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
88587
diff
changeset
|
8514 } |
|
74b74f59bc09
(decode_coding_charset): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
88587
diff
changeset
|
8515 } |
|
74b74f59bc09
(decode_coding_charset): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
88587
diff
changeset
|
8516 ASET (val, i, tmp); |
|
88477
5f974cbba7b3
(coding_set_source): Delete the local variable beg_byte.
Kenichi Handa <handa@m17n.org>
parents:
88473
diff
changeset
|
8517 } |
| 88365 | 8518 } |
| 8519 ASET (attrs, coding_attr_charset_valids, val); | |
| 8520 category = coding_category_charset; | |
| 8521 } | |
| 8522 else if (EQ (coding_type, Qccl)) | |
| 8523 { | |
| 8524 Lisp_Object valids; | |
| 89483 | 8525 |
| 88365 | 8526 if (nargs < coding_arg_ccl_max) |
| 8527 goto short_args; | |
| 8528 | |
| 8529 val = args[coding_arg_ccl_decoder]; | |
| 8530 CHECK_CCL_PROGRAM (val); | |
| 8531 if (VECTORP (val)) | |
| 8532 val = Fcopy_sequence (val); | |
| 8533 ASET (attrs, coding_attr_ccl_decoder, val); | |
| 8534 | |
| 8535 val = args[coding_arg_ccl_encoder]; | |
| 8536 CHECK_CCL_PROGRAM (val); | |
| 8537 if (VECTORP (val)) | |
| 8538 val = Fcopy_sequence (val); | |
| 8539 ASET (attrs, coding_attr_ccl_encoder, val); | |
| 8540 | |
| 8541 val = args[coding_arg_ccl_valids]; | |
| 8542 valids = Fmake_string (make_number (256), make_number (0)); | |
| 8543 for (tail = val; !NILP (tail); tail = Fcdr (tail)) | |
| 8544 { | |
|
89373
4cc9e57fcabc
(decode_coding_ccl, encode_coding_ccl): Call ccl_driver
Kenichi Handa <handa@m17n.org>
parents:
89331
diff
changeset
|
8545 int from, to; |
|
4cc9e57fcabc
(decode_coding_ccl, encode_coding_ccl): Call ccl_driver
Kenichi Handa <handa@m17n.org>
parents:
89331
diff
changeset
|
8546 |
| 88365 | 8547 val = Fcar (tail); |
| 8548 if (INTEGERP (val)) | |
|
89373
4cc9e57fcabc
(decode_coding_ccl, encode_coding_ccl): Call ccl_driver
Kenichi Handa <handa@m17n.org>
parents:
89331
diff
changeset
|
8549 { |
|
4cc9e57fcabc
(decode_coding_ccl, encode_coding_ccl): Call ccl_driver
Kenichi Handa <handa@m17n.org>
parents:
89331
diff
changeset
|
8550 from = to = XINT (val); |
|
4cc9e57fcabc
(decode_coding_ccl, encode_coding_ccl): Call ccl_driver
Kenichi Handa <handa@m17n.org>
parents:
89331
diff
changeset
|
8551 if (from < 0 || from > 255) |
|
4cc9e57fcabc
(decode_coding_ccl, encode_coding_ccl): Call ccl_driver
Kenichi Handa <handa@m17n.org>
parents:
89331
diff
changeset
|
8552 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
|
8553 } |
| 88365 | 8554 else |
| 8555 { | |
| 8556 CHECK_CONS (val); | |
| 89483 | 8557 CHECK_NATNUM_CAR (val); |
| 8558 CHECK_NATNUM_CDR (val); | |
| 88365 | 8559 from = XINT (XCAR (val)); |
| 89483 | 8560 if (from > 255) |
|
89373
4cc9e57fcabc
(decode_coding_ccl, encode_coding_ccl): Call ccl_driver
Kenichi Handa <handa@m17n.org>
parents:
89331
diff
changeset
|
8561 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
|
8562 make_number (0), make_number (255)); |
| 88365 | 8563 to = XINT (XCDR (val)); |
|
89373
4cc9e57fcabc
(decode_coding_ccl, encode_coding_ccl): Call ccl_driver
Kenichi Handa <handa@m17n.org>
parents:
89331
diff
changeset
|
8564 if (to < from || to > 255) |
|
4cc9e57fcabc
(decode_coding_ccl, encode_coding_ccl): Call ccl_driver
Kenichi Handa <handa@m17n.org>
parents:
89331
diff
changeset
|
8565 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
|
8566 XCAR (val), make_number (255)); |
| 88365 | 8567 } |
|
89373
4cc9e57fcabc
(decode_coding_ccl, encode_coding_ccl): Call ccl_driver
Kenichi Handa <handa@m17n.org>
parents:
89331
diff
changeset
|
8568 for (i = from; i <= to; i++) |
| 89483 | 8569 SSET (valids, i, 1); |
| 88365 | 8570 } |
| 8571 ASET (attrs, coding_attr_ccl_valids, valids); | |
| 89483 | 8572 |
| 88365 | 8573 category = coding_category_ccl; |
| 8574 } | |
| 8575 else if (EQ (coding_type, Qutf_16)) | |
| 8576 { | |
| 8577 Lisp_Object bom, endian; | |
| 8578 | |
|
89225
32058afc72e2
(detect_coding_charset): If only ASCII bytes are found, return 0.
Kenichi Handa <handa@m17n.org>
parents:
89221
diff
changeset
|
8579 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
|
8580 |
| 88365 | 8581 if (nargs < coding_arg_utf16_max) |
| 8582 goto short_args; | |
| 8583 | |
| 8584 bom = args[coding_arg_utf16_bom]; | |
| 8585 if (! NILP (bom) && ! EQ (bom, Qt)) | |
|
22874
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
8586 { |
| 88365 | 8587 CHECK_CONS (bom); |
| 89483 | 8588 val = XCAR (bom); |
| 8589 CHECK_CODING_SYSTEM (val); | |
| 8590 val = XCDR (bom); | |
| 8591 CHECK_CODING_SYSTEM (val); | |
| 88365 | 8592 } |
| 8593 ASET (attrs, coding_attr_utf_16_bom, bom); | |
| 8594 | |
| 8595 endian = args[coding_arg_utf16_endian]; | |
|
89420
c3e67ce6ee0f
(Qsignature, Qendian): Delete these variables.
Kenichi Handa <handa@m17n.org>
parents:
89418
diff
changeset
|
8596 CHECK_SYMBOL (endian); |
|
c3e67ce6ee0f
(Qsignature, Qendian): Delete these variables.
Kenichi Handa <handa@m17n.org>
parents:
89418
diff
changeset
|
8597 if (NILP (endian)) |
|
c3e67ce6ee0f
(Qsignature, Qendian): Delete these variables.
Kenichi Handa <handa@m17n.org>
parents:
89418
diff
changeset
|
8598 endian = Qbig; |
|
c3e67ce6ee0f
(Qsignature, Qendian): Delete these variables.
Kenichi Handa <handa@m17n.org>
parents:
89418
diff
changeset
|
8599 else if (! EQ (endian, Qbig) && ! EQ (endian, Qlittle)) |
| 89483 | 8600 error ("Invalid endian: %s", SDATA (SYMBOL_NAME (endian))); |
| 88365 | 8601 ASET (attrs, coding_attr_utf_16_endian, endian); |
| 8602 | |
| 8603 category = (CONSP (bom) | |
| 8604 ? coding_category_utf_16_auto | |
| 8605 : NILP (bom) | |
|
89420
c3e67ce6ee0f
(Qsignature, Qendian): Delete these variables.
Kenichi Handa <handa@m17n.org>
parents:
89418
diff
changeset
|
8606 ? (EQ (endian, Qbig) |
| 88365 | 8607 ? coding_category_utf_16_be_nosig |
| 8608 : coding_category_utf_16_le_nosig) | |
|
89420
c3e67ce6ee0f
(Qsignature, Qendian): Delete these variables.
Kenichi Handa <handa@m17n.org>
parents:
89418
diff
changeset
|
8609 : (EQ (endian, Qbig) |
| 88365 | 8610 ? coding_category_utf_16_be |
| 8611 : coding_category_utf_16_le)); | |
| 8612 } | |
| 8613 else if (EQ (coding_type, Qiso_2022)) | |
| 8614 { | |
| 8615 Lisp_Object initial, reg_usage, request, flags; | |
|
89442
7349f4473e7f
(detected_mask): Delete unused variable.
Kenichi Handa <handa@m17n.org>
parents:
89429
diff
changeset
|
8616 int i; |
| 88365 | 8617 |
| 8618 if (nargs < coding_arg_iso2022_max) | |
| 8619 goto short_args; | |
| 8620 | |
| 8621 initial = Fcopy_sequence (args[coding_arg_iso2022_initial]); | |
| 8622 CHECK_VECTOR (initial); | |
| 8623 for (i = 0; i < 4; i++) | |
| 8624 { | |
| 8625 val = Faref (initial, make_number (i)); | |
| 8626 if (! NILP (val)) | |
| 8627 { | |
|
89225
32058afc72e2
(detect_coding_charset): If only ASCII bytes are found, return 0.
Kenichi Handa <handa@m17n.org>
parents:
89221
diff
changeset
|
8628 struct charset *charset; |
|
32058afc72e2
(detect_coding_charset): If only ASCII bytes are found, return 0.
Kenichi Handa <handa@m17n.org>
parents:
89221
diff
changeset
|
8629 |
|
32058afc72e2
(detect_coding_charset): If only ASCII bytes are found, return 0.
Kenichi Handa <handa@m17n.org>
parents:
89221
diff
changeset
|
8630 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
|
8631 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
|
8632 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
|
8633 CODING_ATTR_ASCII_COMPAT (attrs) = Qt; |
| 88365 | 8634 } |
| 8635 else | |
| 8636 ASET (initial, i, make_number (-1)); | |
| 8637 } | |
| 8638 | |
| 8639 reg_usage = args[coding_arg_iso2022_reg_usage]; | |
| 8640 CHECK_CONS (reg_usage); | |
| 89483 | 8641 CHECK_NUMBER_CAR (reg_usage); |
| 8642 CHECK_NUMBER_CDR (reg_usage); | |
| 88365 | 8643 |
| 8644 request = Fcopy_sequence (args[coding_arg_iso2022_request]); | |
| 8645 for (tail = request; ! NILP (tail); tail = Fcdr (tail)) | |
| 8646 { | |
| 8647 int id; | |
| 89483 | 8648 Lisp_Object tmp; |
| 88365 | 8649 |
| 8650 val = Fcar (tail); | |
| 8651 CHECK_CONS (val); | |
| 89483 | 8652 tmp = XCAR (val); |
| 8653 CHECK_CHARSET_GET_ID (tmp, id); | |
| 8654 CHECK_NATNUM_CDR (val); | |
| 88365 | 8655 if (XINT (XCDR (val)) >= 4) |
| 8656 error ("Invalid graphic register number: %d", XINT (XCDR (val))); | |
| 89483 | 8657 XSETCAR (val, make_number (id)); |
| 88365 | 8658 } |
| 8659 | |
| 8660 flags = args[coding_arg_iso2022_flags]; | |
| 8661 CHECK_NATNUM (flags); | |
| 8662 i = XINT (flags); | |
| 8663 if (EQ (args[coding_arg_charset_list], Qiso_2022)) | |
| 8664 flags = make_number (i | CODING_ISO_FLAG_FULL_SUPPORT); | |
| 8665 | |
| 8666 ASET (attrs, coding_attr_iso_initial, initial); | |
| 8667 ASET (attrs, coding_attr_iso_usage, reg_usage); | |
| 8668 ASET (attrs, coding_attr_iso_request, request); | |
| 8669 ASET (attrs, coding_attr_iso_flags, flags); | |
| 8670 setup_iso_safe_charsets (attrs); | |
| 8671 | |
| 8672 if (i & CODING_ISO_FLAG_SEVEN_BITS) | |
| 8673 category = ((i & (CODING_ISO_FLAG_LOCKING_SHIFT | |
| 8674 | CODING_ISO_FLAG_SINGLE_SHIFT)) | |
| 8675 ? coding_category_iso_7_else | |
| 8676 : EQ (args[coding_arg_charset_list], Qiso_2022) | |
| 8677 ? coding_category_iso_7 | |
| 8678 : coding_category_iso_7_tight); | |
| 8679 else | |
| 8680 { | |
| 8681 int id = XINT (AREF (initial, 1)); | |
| 8682 | |
|
88977
3b05c02eebf2
(Fdefine_coding_system_internal): Fix category setting
Kenichi Handa <handa@m17n.org>
parents:
88950
diff
changeset
|
8683 category = (((i & CODING_ISO_FLAG_LOCKING_SHIFT) |
| 88365 | 8684 || EQ (args[coding_arg_charset_list], Qiso_2022) |
| 8685 || id < 0) | |
| 8686 ? coding_category_iso_8_else | |
| 8687 : (CHARSET_DIMENSION (CHARSET_FROM_ID (id)) == 1) | |
| 8688 ? coding_category_iso_8_1 | |
| 8689 : coding_category_iso_8_2); | |
|
22874
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
8690 } |
|
89227
101ee928c088
(Fdefine_coding_system_internal): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89225
diff
changeset
|
8691 if (category != coding_category_iso_8_1 |
|
101ee928c088
(Fdefine_coding_system_internal): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89225
diff
changeset
|
8692 && category != coding_category_iso_8_2) |
|
101ee928c088
(Fdefine_coding_system_internal): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89225
diff
changeset
|
8693 CODING_ATTR_ASCII_COMPAT (attrs) = Qnil; |
| 88365 | 8694 } |
| 8695 else if (EQ (coding_type, Qemacs_mule)) | |
| 8696 { | |
| 8697 if (EQ (args[coding_arg_charset_list], Qemacs_mule)) | |
| 8698 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
|
8699 CODING_ATTR_ASCII_COMPAT (attrs) = Qt; |
| 88365 | 8700 category = coding_category_emacs_mule; |
| 8701 } | |
| 8702 else if (EQ (coding_type, Qshift_jis)) | |
| 8703 { | |
| 8704 | |
| 8705 struct charset *charset; | |
| 8706 | |
|
89732
8acde12aba89
(get_translation_table): New function.
Kenichi Handa <handa@m17n.org>
parents:
89730
diff
changeset
|
8707 if (XINT (Flength (charset_list)) != 3 |
|
89739
293c9235be3f
(Fdefine_coding_system_internal): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89732
diff
changeset
|
8708 && XINT (Flength (charset_list)) != 4) |
|
89732
8acde12aba89
(get_translation_table): New function.
Kenichi Handa <handa@m17n.org>
parents:
89730
diff
changeset
|
8709 error ("There should be three or four charsets"); |
| 88365 | 8710 |
| 8711 charset = CHARSET_FROM_ID (XINT (XCAR (charset_list))); | |
| 8712 if (CHARSET_DIMENSION (charset) != 1) | |
| 8713 error ("Dimension of charset %s is not one", | |
| 89483 | 8714 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
|
8715 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
|
8716 CODING_ATTR_ASCII_COMPAT (attrs) = Qt; |
| 88365 | 8717 |
| 8718 charset_list = XCDR (charset_list); | |
| 8719 charset = CHARSET_FROM_ID (XINT (XCAR (charset_list))); | |
| 8720 if (CHARSET_DIMENSION (charset) != 1) | |
| 8721 error ("Dimension of charset %s is not one", | |
| 89483 | 8722 SDATA (SYMBOL_NAME (CHARSET_NAME (charset)))); |
| 88365 | 8723 |
| 8724 charset_list = XCDR (charset_list); | |
| 8725 charset = CHARSET_FROM_ID (XINT (XCAR (charset_list))); | |
| 8726 if (CHARSET_DIMENSION (charset) != 2) | |
| 8727 error ("Dimension of charset %s is not two", | |
| 89483 | 8728 SDATA (SYMBOL_NAME (CHARSET_NAME (charset)))); |
| 88365 | 8729 |
|
89732
8acde12aba89
(get_translation_table): New function.
Kenichi Handa <handa@m17n.org>
parents:
89730
diff
changeset
|
8730 charset_list = XCDR (charset_list); |
|
89740
78c1fd14ed42
(Fdefine_coding_system_internal): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89739
diff
changeset
|
8731 if (! NILP (charset_list)) |
|
78c1fd14ed42
(Fdefine_coding_system_internal): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89739
diff
changeset
|
8732 { |
|
78c1fd14ed42
(Fdefine_coding_system_internal): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89739
diff
changeset
|
8733 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
|
8734 if (CHARSET_DIMENSION (charset) != 2) |
|
78c1fd14ed42
(Fdefine_coding_system_internal): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89739
diff
changeset
|
8735 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
|
8736 SDATA (SYMBOL_NAME (CHARSET_NAME (charset)))); |
|
78c1fd14ed42
(Fdefine_coding_system_internal): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89739
diff
changeset
|
8737 } |
|
89732
8acde12aba89
(get_translation_table): New function.
Kenichi Handa <handa@m17n.org>
parents:
89730
diff
changeset
|
8738 |
| 88365 | 8739 category = coding_category_sjis; |
| 8740 Vsjis_coding_system = name; | |
| 8741 } | |
| 8742 else if (EQ (coding_type, Qbig5)) | |
| 8743 { | |
| 8744 struct charset *charset; | |
| 8745 | |
| 8746 if (XINT (Flength (charset_list)) != 2) | |
| 8747 error ("There should be just two charsets"); | |
| 8748 | |
| 8749 charset = CHARSET_FROM_ID (XINT (XCAR (charset_list))); | |
| 8750 if (CHARSET_DIMENSION (charset) != 1) | |
| 8751 error ("Dimension of charset %s is not one", | |
| 89483 | 8752 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
|
8753 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
|
8754 CODING_ATTR_ASCII_COMPAT (attrs) = Qt; |
| 88365 | 8755 |
| 8756 charset_list = XCDR (charset_list); | |
| 8757 charset = CHARSET_FROM_ID (XINT (XCAR (charset_list))); | |
| 8758 if (CHARSET_DIMENSION (charset) != 2) | |
| 8759 error ("Dimension of charset %s is not two", | |
| 89483 | 8760 SDATA (SYMBOL_NAME (CHARSET_NAME (charset)))); |
| 88365 | 8761 |
| 8762 category = coding_category_big5; | |
| 8763 Vbig5_coding_system = name; | |
| 8764 } | |
| 8765 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
|
8766 { |
|
32058afc72e2
(detect_coding_charset): If only ASCII bytes are found, return 0.
Kenichi Handa <handa@m17n.org>
parents:
89221
diff
changeset
|
8767 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
|
8768 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
|
8769 } |
| 88365 | 8770 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
|
8771 { |
|
32058afc72e2
(detect_coding_charset): If only ASCII bytes are found, return 0.
Kenichi Handa <handa@m17n.org>
parents:
89221
diff
changeset
|
8772 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
|
8773 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
|
8774 } |
| 88365 | 8775 else if (EQ (coding_type, Qundecided)) |
| 8776 category = coding_category_undecided; | |
| 8777 else | |
| 8778 error ("Invalid coding system type: %s", | |
| 89483 | 8779 SDATA (SYMBOL_NAME (coding_type))); |
| 88365 | 8780 |
| 8781 CODING_ATTR_CATEGORY (attrs) = make_number (category); | |
|
89468
7dbbe692f70c
* coding.c (QCcategory): New variable.
Kenichi Handa <handa@m17n.org>
parents:
89467
diff
changeset
|
8782 CODING_ATTR_PLIST (attrs) |
|
7dbbe692f70c
* coding.c (QCcategory): New variable.
Kenichi Handa <handa@m17n.org>
parents:
89467
diff
changeset
|
8783 = Fcons (QCcategory, Fcons (AREF (Vcoding_category_table, category), |
|
7dbbe692f70c
* coding.c (QCcategory): New variable.
Kenichi Handa <handa@m17n.org>
parents:
89467
diff
changeset
|
8784 CODING_ATTR_PLIST (attrs))); |
| 88365 | 8785 |
| 8786 eol_type = args[coding_arg_eol_type]; | |
| 8787 if (! NILP (eol_type) | |
| 8788 && ! EQ (eol_type, Qunix) | |
| 8789 && ! EQ (eol_type, Qdos) | |
| 8790 && ! EQ (eol_type, Qmac)) | |
| 8791 error ("Invalid eol-type"); | |
| 8792 | |
| 8793 aliases = Fcons (name, Qnil); | |
| 8794 | |
| 8795 if (NILP (eol_type)) | |
| 8796 { | |
| 8797 eol_type = make_subsidiaries (name); | |
| 8798 for (i = 0; i < 3; i++) | |
|
22874
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
8799 { |
| 88365 | 8800 Lisp_Object this_spec, this_name, this_aliases, this_eol_type; |
| 8801 | |
| 8802 this_name = AREF (eol_type, i); | |
| 8803 this_aliases = Fcons (this_name, Qnil); | |
| 8804 this_eol_type = (i == 0 ? Qunix : i == 1 ? Qdos : Qmac); | |
| 8805 this_spec = Fmake_vector (make_number (3), attrs); | |
| 8806 ASET (this_spec, 1, this_aliases); | |
| 8807 ASET (this_spec, 2, this_eol_type); | |
| 8808 Fputhash (this_name, this_spec, Vcoding_system_hash_table); | |
| 8809 Vcoding_system_list = Fcons (this_name, Vcoding_system_list); | |
| 8810 Vcoding_system_alist = Fcons (Fcons (Fsymbol_name (this_name), Qnil), | |
| 8811 Vcoding_system_alist); | |
|
22874
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
8812 } |
|
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
8813 } |
|
22874
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
8814 |
| 88365 | 8815 spec_vec = Fmake_vector (make_number (3), attrs); |
| 8816 ASET (spec_vec, 1, aliases); | |
| 8817 ASET (spec_vec, 2, eol_type); | |
| 8818 | |
| 8819 Fputhash (name, spec_vec, Vcoding_system_hash_table); | |
| 8820 Vcoding_system_list = Fcons (name, Vcoding_system_list); | |
| 8821 Vcoding_system_alist = Fcons (Fcons (Fsymbol_name (name), Qnil), | |
| 8822 Vcoding_system_alist); | |
| 8823 | |
| 8824 { | |
| 8825 int id = coding_categories[category].id; | |
| 8826 | |
| 8827 if (id < 0 || EQ (name, CODING_ID_NAME (id))) | |
| 8828 setup_coding_system (name, &coding_categories[category]); | |
| 8829 } | |
| 8830 | |
| 8831 return Qnil; | |
| 8832 | |
| 8833 short_args: | |
| 8834 return Fsignal (Qwrong_number_of_arguments, | |
| 8835 Fcons (intern ("define-coding-system-internal"), | |
| 8836 make_number (nargs))); | |
| 8837 } | |
| 8838 | |
|
89571
242f2cc0134b
(Fdefine_coding_system_alias): Update Vcoding_system_list.
Kenichi Handa <handa@m17n.org>
parents:
89562
diff
changeset
|
8839 |
|
89759
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
8840 DEFUN ("coding-system-put", Fcoding_system_put, Scoding_system_put, |
|
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
8841 3, 3, 0, |
|
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
8842 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
|
8843 (coding_system, prop, val) |
|
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
8844 Lisp_Object coding_system, prop, val; |
|
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
8845 { |
|
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
8846 Lisp_Object spec, attrs, plist; |
|
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
8847 |
|
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
8848 CHECK_CODING_SYSTEM_GET_SPEC (coding_system, spec); |
|
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
8849 attrs = AREF (spec, 0); |
|
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
8850 if (EQ (prop, QCmnemonic)) |
|
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
8851 { |
|
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
8852 if (! STRINGP (val)) |
|
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
8853 CHECK_CHARACTER (val); |
|
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
8854 CODING_ATTR_MNEMONIC (attrs) = val; |
|
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
8855 } |
|
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
8856 else if (EQ (prop, QCdefalut_char)) |
|
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
8857 { |
|
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
8858 if (NILP (val)) |
|
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
8859 val = make_number (' '); |
|
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
8860 else |
|
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
8861 CHECK_CHARACTER (val); |
|
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
8862 CODING_ATTR_DEFAULT_CHAR (attrs) = val; |
|
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
8863 } |
|
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
8864 else if (EQ (prop, QCdecode_translation_table)) |
|
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
8865 { |
|
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
8866 if (! CHAR_TABLE_P (val) && ! CONSP (val)) |
|
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
8867 CHECK_SYMBOL (val); |
|
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
8868 CODING_ATTR_DECODE_TBL (attrs) = val; |
|
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
8869 } |
|
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
8870 else if (EQ (prop, QCencode_translation_table)) |
|
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
8871 { |
|
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
8872 if (! CHAR_TABLE_P (val) && ! CONSP (val)) |
|
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
8873 CHECK_SYMBOL (val); |
|
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
8874 CODING_ATTR_ENCODE_TBL (attrs) = val; |
|
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
8875 } |
|
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
8876 else if (EQ (prop, QCpost_read_conversion)) |
|
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
8877 { |
|
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
8878 CHECK_SYMBOL (val); |
|
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
8879 CODING_ATTR_POST_READ (attrs) = val; |
|
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
8880 } |
|
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
8881 else if (EQ (prop, QCpre_write_conversion)) |
|
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
8882 { |
|
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
8883 CHECK_SYMBOL (val); |
|
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
8884 CODING_ATTR_PRE_WRITE (attrs) = val; |
|
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
8885 } |
|
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
8886 |
|
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
8887 CODING_ATTR_PLIST (attrs) |
|
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
8888 = Fplist_put (CODING_ATTR_PLIST (attrs), prop, val); |
|
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
8889 return val; |
|
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
8890 } |
|
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
8891 |
|
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
8892 |
| 88365 | 8893 DEFUN ("define-coding-system-alias", Fdefine_coding_system_alias, |
| 8894 Sdefine_coding_system_alias, 2, 2, 0, | |
| 8895 doc: /* Define ALIAS as an alias for CODING-SYSTEM. */) | |
| 8896 (alias, coding_system) | |
| 8897 Lisp_Object alias, coding_system; | |
| 8898 { | |
| 8899 Lisp_Object spec, aliases, eol_type; | |
| 8900 | |
| 8901 CHECK_SYMBOL (alias); | |
| 8902 CHECK_CODING_SYSTEM_GET_SPEC (coding_system, spec); | |
| 8903 aliases = AREF (spec, 1); | |
|
89571
242f2cc0134b
(Fdefine_coding_system_alias): Update Vcoding_system_list.
Kenichi Handa <handa@m17n.org>
parents:
89562
diff
changeset
|
8904 /* 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
|
8905 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
|
8906 list. */ |
| 88365 | 8907 while (!NILP (XCDR (aliases))) |
| 8908 aliases = XCDR (aliases); | |
| 89483 | 8909 XSETCDR (aliases, Fcons (alias, Qnil)); |
| 88365 | 8910 |
| 8911 eol_type = AREF (spec, 2); | |
| 8912 if (VECTORP (eol_type)) | |
| 8913 { | |
| 8914 Lisp_Object subsidiaries; | |
| 8915 int i; | |
| 8916 | |
| 8917 subsidiaries = make_subsidiaries (alias); | |
| 8918 for (i = 0; i < 3; i++) | |
| 8919 Fdefine_coding_system_alias (AREF (subsidiaries, i), | |
| 8920 AREF (eol_type, i)); | |
| 8921 } | |
| 8922 | |
| 8923 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
|
8924 Vcoding_system_list = Fcons (alias, Vcoding_system_list); |
| 88485 | 8925 Vcoding_system_alist = Fcons (Fcons (Fsymbol_name (alias), Qnil), |
| 8926 Vcoding_system_alist); | |
| 88365 | 8927 |
|
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
8928 return Qnil; |
|
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
8929 } |
|
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
8930 |
| 88365 | 8931 DEFUN ("coding-system-base", Fcoding_system_base, Scoding_system_base, |
| 8932 1, 1, 0, | |
| 8933 doc: /* Return the base of CODING-SYSTEM. | |
| 88645 | 8934 Any alias or subsidiary coding system is not a base coding system. */) |
| 88365 | 8935 (coding_system) |
| 8936 Lisp_Object coding_system; | |
| 8937 { | |
| 8938 Lisp_Object spec, attrs; | |
| 8939 | |
| 8940 if (NILP (coding_system)) | |
| 8941 return (Qno_conversion); | |
| 8942 CHECK_CODING_SYSTEM_GET_SPEC (coding_system, spec); | |
| 8943 attrs = AREF (spec, 0); | |
| 8944 return CODING_ATTR_BASE_NAME (attrs); | |
| 8945 } | |
| 8946 | |
| 8947 DEFUN ("coding-system-plist", Fcoding_system_plist, Scoding_system_plist, | |
| 8948 1, 1, 0, | |
| 8949 doc: "Return the property list of CODING-SYSTEM.") | |
| 8950 (coding_system) | |
| 8951 Lisp_Object coding_system; | |
|
22226
557fac086b1b
(ascii_skip_code): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22186
diff
changeset
|
8952 { |
| 88365 | 8953 Lisp_Object spec, attrs; |
| 8954 | |
| 8955 if (NILP (coding_system)) | |
| 8956 coding_system = Qno_conversion; | |
| 8957 CHECK_CODING_SYSTEM_GET_SPEC (coding_system, spec); | |
| 8958 attrs = AREF (spec, 0); | |
| 8959 return CODING_ATTR_PLIST (attrs); | |
| 8960 } | |
| 8961 | |
| 8962 | |
| 8963 DEFUN ("coding-system-aliases", Fcoding_system_aliases, Scoding_system_aliases, | |
| 8964 1, 1, 0, | |
| 88645 | 8965 doc: /* Return the list of aliases of CODING-SYSTEM. */) |
| 88365 | 8966 (coding_system) |
| 8967 Lisp_Object coding_system; | |
| 8968 { | |
| 8969 Lisp_Object spec; | |
| 8970 | |
| 8971 if (NILP (coding_system)) | |
| 8972 coding_system = Qno_conversion; | |
| 8973 CHECK_CODING_SYSTEM_GET_SPEC (coding_system, spec); | |
| 88645 | 8974 return AREF (spec, 1); |
| 88365 | 8975 } |
| 8976 | |
| 8977 DEFUN ("coding-system-eol-type", Fcoding_system_eol_type, | |
| 8978 Scoding_system_eol_type, 1, 1, 0, | |
| 8979 doc: /* Return eol-type of CODING-SYSTEM. | |
| 8980 An eol-type is integer 0, 1, 2, or a vector of coding systems. | |
| 8981 | |
| 8982 Integer values 0, 1, and 2 indicate a format of end-of-line; LF, CRLF, | |
| 8983 and CR respectively. | |
| 8984 | |
| 8985 A vector value indicates that a format of end-of-line should be | |
| 8986 detected automatically. Nth element of the vector is the subsidiary | |
| 8987 coding system whose eol-type is N. */) | |
| 8988 (coding_system) | |
| 8989 Lisp_Object coding_system; | |
| 8990 { | |
| 8991 Lisp_Object spec, eol_type; | |
| 8992 int n; | |
| 8993 | |
| 8994 if (NILP (coding_system)) | |
| 8995 coding_system = Qno_conversion; | |
| 8996 if (! CODING_SYSTEM_P (coding_system)) | |
| 8997 return Qnil; | |
| 8998 spec = CODING_SYSTEM_SPEC (coding_system); | |
| 8999 eol_type = AREF (spec, 2); | |
| 9000 if (VECTORP (eol_type)) | |
| 9001 return Fcopy_sequence (eol_type); | |
| 9002 n = EQ (eol_type, Qunix) ? 0 : EQ (eol_type, Qdos) ? 1 : 2; | |
| 9003 return make_number (n); | |
|
22226
557fac086b1b
(ascii_skip_code): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22186
diff
changeset
|
9004 } |
|
557fac086b1b
(ascii_skip_code): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22186
diff
changeset
|
9005 |
| 17052 | 9006 #endif /* emacs */ |
| 9007 | |
| 9008 | |
|
22874
b133f07a76db
(Qvalid_codes): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22812
diff
changeset
|
9009 /*** 9. Post-amble ***/ |
| 17052 | 9010 |
| 21514 | 9011 void |
| 17052 | 9012 init_coding_once () |
| 9013 { | |
| 9014 int i; | |
| 9015 | |
| 88365 | 9016 for (i = 0; i < coding_category_max; i++) |
| 9017 { | |
| 9018 coding_categories[i].id = -1; | |
| 9019 coding_priorities[i] = i; | |
| 9020 } | |
| 17052 | 9021 |
| 9022 /* ISO2022 specific initialize routine. */ | |
| 9023 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
|
9024 iso_code_class[i] = ISO_control_0; |
| 17052 | 9025 for (i = 0x21; i < 0x7F; i++) |
| 9026 iso_code_class[i] = ISO_graphic_plane_0; | |
| 9027 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
|
9028 iso_code_class[i] = ISO_control_1; |
| 17052 | 9029 for (i = 0xA1; i < 0xFF; i++) |
| 9030 iso_code_class[i] = ISO_graphic_plane_1; | |
| 9031 iso_code_class[0x20] = iso_code_class[0x7F] = ISO_0x20_or_0x7F; | |
| 9032 iso_code_class[0xA0] = iso_code_class[0xFF] = ISO_0xA0_or_0xFF; | |
| 9033 iso_code_class[ISO_CODE_SO] = ISO_shift_out; | |
| 9034 iso_code_class[ISO_CODE_SI] = ISO_shift_in; | |
| 9035 iso_code_class[ISO_CODE_SS2_7] = ISO_single_shift_2_7; | |
| 9036 iso_code_class[ISO_CODE_ESC] = ISO_escape; | |
| 9037 iso_code_class[ISO_CODE_SS2] = ISO_single_shift_2; | |
| 9038 iso_code_class[ISO_CODE_SS3] = ISO_single_shift_3; | |
| 9039 iso_code_class[ISO_CODE_CSI] = ISO_control_sequence_introducer; | |
| 9040 | |
| 88365 | 9041 for (i = 0; i < 256; i++) |
| 9042 { | |
| 9043 emacs_mule_bytes[i] = 1; | |
| 9044 } | |
|
88876
af9012fdad56
(LEADING_CODE_PRIVATE_11, LEADING_CODE_PRIVATE_12,
Kenichi Handa <handa@m17n.org>
parents:
88862
diff
changeset
|
9045 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
|
9046 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
|
9047 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
|
9048 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
|
9049 } |
|
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
9050 |
|
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
9051 #ifdef emacs |
|
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
9052 |
| 21514 | 9053 void |
|
17119
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
9054 syms_of_coding () |
|
2cfb31c15ced
(create_process, Fopen_network_stream): Typo in indexes
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
9055 { |
| 88365 | 9056 staticpro (&Vcoding_system_hash_table); |
| 89483 | 9057 { |
| 9058 Lisp_Object args[2]; | |
| 9059 args[0] = QCtest; | |
| 9060 args[1] = Qeq; | |
| 9061 Vcoding_system_hash_table = Fmake_hash_table (2, args); | |
| 9062 } | |
| 88365 | 9063 |
| 9064 staticpro (&Vsjis_coding_system); | |
| 9065 Vsjis_coding_system = Qnil; | |
| 9066 | |
| 9067 staticpro (&Vbig5_coding_system); | |
| 9068 Vbig5_coding_system = Qnil; | |
| 9069 | |
|
89665
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
9070 staticpro (&Vcode_conversion_reused_workbuf); |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
9071 Vcode_conversion_reused_workbuf = Qnil; |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
9072 |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
9073 staticpro (&Vcode_conversion_workbuf_name); |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
9074 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
|
9075 |
|
9010cefe8d29
(enum iso_code_class_type): Delete ISO_carriage_return.
Kenichi Handa <handa@m17n.org>
parents:
89653
diff
changeset
|
9076 reused_workbuf_in_use = 0; |
| 88365 | 9077 |
| 9078 DEFSYM (Qcharset, "charset"); | |
| 9079 DEFSYM (Qtarget_idx, "target-idx"); | |
| 9080 DEFSYM (Qcoding_system_history, "coding-system-history"); | |
|
19750
95e4e1cba6ac
(Qcoding_system_history): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
19747
diff
changeset
|
9081 Fset (Qcoding_system_history, Qnil); |
|
95e4e1cba6ac
(Qcoding_system_history): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
19747
diff
changeset
|
9082 |
|
18650
aa3f2820e2ac
(Qemacs_mule, inhibit_eol_conversion): New variables.
Kenichi Handa <handa@m17n.org>
parents:
18613
diff
changeset
|
9083 /* 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
|
9084 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
|
9085 /* 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
|
9086 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
|
9087 |
| 88365 | 9088 DEFSYM (Qcall_process, "call-process"); |
|
18650
aa3f2820e2ac
(Qemacs_mule, inhibit_eol_conversion): New variables.
Kenichi Handa <handa@m17n.org>
parents:
18613
diff
changeset
|
9089 /* 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
|
9090 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
|
9091 |
| 88365 | 9092 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
|
9093 /* 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
|
9094 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
|
9095 |
| 88365 | 9096 DEFSYM (Qstart_process, "start-process"); |
|
18650
aa3f2820e2ac
(Qemacs_mule, inhibit_eol_conversion): New variables.
Kenichi Handa <handa@m17n.org>
parents:
18613
diff
changeset
|
9097 /* 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
|
9098 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
|
9099 |
| 88365 | 9100 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
|
9101 /* 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
|
9102 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
|
9103 |
| 88365 | 9104 DEFSYM (Qcoding_system, "coding-system"); |
| 9105 DEFSYM (Qcoding_aliases, "coding-aliases"); | |
| 9106 | |
| 9107 DEFSYM (Qeol_type, "eol-type"); | |
| 9108 DEFSYM (Qunix, "unix"); | |
| 9109 DEFSYM (Qdos, "dos"); | |
| 9110 | |
| 9111 DEFSYM (Qbuffer_file_coding_system, "buffer-file-coding-system"); | |
| 9112 DEFSYM (Qpost_read_conversion, "post-read-conversion"); | |
| 9113 DEFSYM (Qpre_write_conversion, "pre-write-conversion"); | |
| 9114 DEFSYM (Qdefault_char, "default-char"); | |
| 9115 DEFSYM (Qundecided, "undecided"); | |
| 9116 DEFSYM (Qno_conversion, "no-conversion"); | |
| 9117 DEFSYM (Qraw_text, "raw-text"); | |
| 9118 | |
| 9119 DEFSYM (Qiso_2022, "iso-2022"); | |
| 9120 | |
| 9121 DEFSYM (Qutf_8, "utf-8"); | |
| 89483 | 9122 DEFSYM (Qutf_8_emacs, "utf-8-emacs"); |
| 88365 | 9123 |
| 9124 DEFSYM (Qutf_16, "utf-16"); | |
| 9125 DEFSYM (Qbig, "big"); | |
| 9126 DEFSYM (Qlittle, "little"); | |
| 9127 | |
| 9128 DEFSYM (Qshift_jis, "shift-jis"); | |
| 9129 DEFSYM (Qbig5, "big5"); | |
| 9130 | |
| 9131 DEFSYM (Qcoding_system_p, "coding-system-p"); | |
| 9132 | |
| 9133 DEFSYM (Qcoding_system_error, "coding-system-error"); | |
| 17052 | 9134 Fput (Qcoding_system_error, Qerror_conditions, |
| 9135 Fcons (Qcoding_system_error, Fcons (Qerror, Qnil))); | |
| 9136 Fput (Qcoding_system_error, Qerror_message, | |
|
18650
aa3f2820e2ac
(Qemacs_mule, inhibit_eol_conversion): New variables.
Kenichi Handa <handa@m17n.org>
parents:
18613
diff
changeset
|
9137 build_string ("Invalid coding system")); |
| 17052 | 9138 |
|
30487
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
9139 /* 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
|
9140 Setting this variable twice is harmless. |
|
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
9141 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
|
9142 Qchar_table_extra_slots = intern ("char-table-extra-slots"); |
| 88365 | 9143 |
| 9144 DEFSYM (Qtranslation_table, "translation-table"); | |
|
89856
18b52da60a76
(get_translation): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89852
diff
changeset
|
9145 Fput (Qtranslation_table, Qchar_table_extra_slots, make_number (2)); |
| 88365 | 9146 DEFSYM (Qtranslation_table_id, "translation-table-id"); |
| 9147 DEFSYM (Qtranslation_table_for_decode, "translation-table-for-decode"); | |
| 9148 DEFSYM (Qtranslation_table_for_encode, "translation-table-for-encode"); | |
| 9149 | |
| 9150 DEFSYM (Qvalid_codes, "valid-codes"); | |
| 9151 | |
| 9152 DEFSYM (Qemacs_mule, "emacs-mule"); | |
| 9153 | |
|
89468
7dbbe692f70c
* coding.c (QCcategory): New variable.
Kenichi Handa <handa@m17n.org>
parents:
89467
diff
changeset
|
9154 DEFSYM (QCcategory, ":category"); |
|
89759
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
9155 DEFSYM (QCmnemonic, ":mnemonic"); |
|
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
9156 DEFSYM (QCdefalut_char, ":default-char"); |
|
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
9157 DEFSYM (QCdecode_translation_table, ":decode-translation-table"); |
|
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
9158 DEFSYM (QCencode_translation_table, ":encode-translation-table"); |
|
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
9159 DEFSYM (QCpost_read_conversion, ":post-read-conversion"); |
|
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
9160 DEFSYM (QCpre_write_conversion, ":pre-write-conversion"); |
|
89468
7dbbe692f70c
* coding.c (QCcategory): New variable.
Kenichi Handa <handa@m17n.org>
parents:
89467
diff
changeset
|
9161 |
| 88365 | 9162 Vcoding_category_table |
| 9163 = Fmake_vector (make_number (coding_category_max), Qnil); | |
| 9164 staticpro (&Vcoding_category_table); | |
| 9165 /* Followings are target of code detection. */ | |
| 9166 ASET (Vcoding_category_table, coding_category_iso_7, | |
| 9167 intern ("coding-category-iso-7")); | |
| 9168 ASET (Vcoding_category_table, coding_category_iso_7_tight, | |
| 9169 intern ("coding-category-iso-7-tight")); | |
| 9170 ASET (Vcoding_category_table, coding_category_iso_8_1, | |
| 9171 intern ("coding-category-iso-8-1")); | |
| 9172 ASET (Vcoding_category_table, coding_category_iso_8_2, | |
| 9173 intern ("coding-category-iso-8-2")); | |
| 9174 ASET (Vcoding_category_table, coding_category_iso_7_else, | |
| 9175 intern ("coding-category-iso-7-else")); | |
| 9176 ASET (Vcoding_category_table, coding_category_iso_8_else, | |
| 9177 intern ("coding-category-iso-8-else")); | |
| 9178 ASET (Vcoding_category_table, coding_category_utf_8, | |
| 9179 intern ("coding-category-utf-8")); | |
| 9180 ASET (Vcoding_category_table, coding_category_utf_16_be, | |
| 9181 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
|
9182 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
|
9183 intern ("coding-category-utf-16-auto")); |
| 88365 | 9184 ASET (Vcoding_category_table, coding_category_utf_16_le, |
| 9185 intern ("coding-category-utf-16-le")); | |
| 9186 ASET (Vcoding_category_table, coding_category_utf_16_be_nosig, | |
| 9187 intern ("coding-category-utf-16-be-nosig")); | |
| 9188 ASET (Vcoding_category_table, coding_category_utf_16_le_nosig, | |
| 9189 intern ("coding-category-utf-16-le-nosig")); | |
| 9190 ASET (Vcoding_category_table, coding_category_charset, | |
| 9191 intern ("coding-category-charset")); | |
| 9192 ASET (Vcoding_category_table, coding_category_sjis, | |
| 9193 intern ("coding-category-sjis")); | |
| 9194 ASET (Vcoding_category_table, coding_category_big5, | |
| 9195 intern ("coding-category-big5")); | |
| 9196 ASET (Vcoding_category_table, coding_category_ccl, | |
| 9197 intern ("coding-category-ccl")); | |
| 9198 ASET (Vcoding_category_table, coding_category_emacs_mule, | |
| 9199 intern ("coding-category-emacs-mule")); | |
| 9200 /* Followings are NOT target of code detection. */ | |
| 9201 ASET (Vcoding_category_table, coding_category_raw_text, | |
| 9202 intern ("coding-category-raw-text")); | |
| 9203 ASET (Vcoding_category_table, coding_category_undecided, | |
| 9204 intern ("coding-category-undecided")); | |
| 9205 | |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
9206 DEFSYM (Qinsufficient_source, "insufficient-source"); |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
9207 DEFSYM (Qinconsistent_eol, "inconsistent-eol"); |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
9208 DEFSYM (Qinvalid_source, "invalid-source"); |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
9209 DEFSYM (Qinterrupted, "interrupted"); |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
9210 DEFSYM (Qinsufficient_memory, "insufficient-memory"); |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
9211 |
| 17052 | 9212 defsubr (&Scoding_system_p); |
| 9213 defsubr (&Sread_coding_system); | |
| 9214 defsubr (&Sread_non_nil_coding_system); | |
| 9215 defsubr (&Scheck_coding_system); | |
| 9216 defsubr (&Sdetect_coding_region); | |
|
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
9217 defsubr (&Sdetect_coding_string); |
|
30487
6165da9c89c6
(Qsafe_charsets): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
30384
diff
changeset
|
9218 defsubr (&Sfind_coding_systems_region_internal); |
|
46859
a26dd8891732
(unencodable_char_position): New function.
Kenichi Handa <handa@m17n.org>
parents:
46839
diff
changeset
|
9219 defsubr (&Sunencodable_char_position); |
| 88365 | 9220 defsubr (&Scheck_coding_systems_region); |
| 17052 | 9221 defsubr (&Sdecode_coding_region); |
| 9222 defsubr (&Sencode_coding_region); | |
| 9223 defsubr (&Sdecode_coding_string); | |
| 9224 defsubr (&Sencode_coding_string); | |
| 9225 defsubr (&Sdecode_sjis_char); | |
| 9226 defsubr (&Sencode_sjis_char); | |
| 9227 defsubr (&Sdecode_big5_char); | |
| 9228 defsubr (&Sencode_big5_char); | |
|
18002
a14261786239
(encode_invocation_designation): Use macro
Kenichi Handa <handa@m17n.org>
parents:
17835
diff
changeset
|
9229 defsubr (&Sset_terminal_coding_system_internal); |
|
19280
e755044718ee
(ENCODE_ISO_CHARACTER_DIMENSION1): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
19193
diff
changeset
|
9230 defsubr (&Sset_safe_terminal_coding_system_internal); |
| 17052 | 9231 defsubr (&Sterminal_coding_system); |
|
18002
a14261786239
(encode_invocation_designation): Use macro
Kenichi Handa <handa@m17n.org>
parents:
17835
diff
changeset
|
9232 defsubr (&Sset_keyboard_coding_system_internal); |
| 17052 | 9233 defsubr (&Skeyboard_coding_system); |
|
18536
69c0e220b626
(Vstandard_character_unification_table_for_decode):
Kenichi Handa <handa@m17n.org>
parents:
18523
diff
changeset
|
9234 defsubr (&Sfind_operation_coding_system); |
| 88365 | 9235 defsubr (&Sset_coding_system_priority); |
| 9236 defsubr (&Sdefine_coding_system_internal); | |
| 9237 defsubr (&Sdefine_coding_system_alias); | |
|
89759
d11866e9fbf4
(QCmnemonic, QCdefalut_char)
Kenichi Handa <handa@m17n.org>
parents:
89740
diff
changeset
|
9238 defsubr (&Scoding_system_put); |
| 88365 | 9239 defsubr (&Scoding_system_base); |
| 9240 defsubr (&Scoding_system_plist); | |
| 9241 defsubr (&Scoding_system_aliases); | |
| 9242 defsubr (&Scoding_system_eol_type); | |
| 9243 defsubr (&Scoding_system_priority_list); | |
| 17052 | 9244 |
|
20105
c017642863c2
(Qcoding_system_spec): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
19824
diff
changeset
|
9245 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
|
9246 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
|
9247 |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
9248 Do not alter the value of this variable manually. This variable should be |
| 88365 | 9249 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
|
9250 `define-coding-system-alias'. */); |
|
20105
c017642863c2
(Qcoding_system_spec): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
19824
diff
changeset
|
9251 Vcoding_system_list = Qnil; |
|
c017642863c2
(Qcoding_system_spec): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
19824
diff
changeset
|
9252 |
|
c017642863c2
(Qcoding_system_spec): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
19824
diff
changeset
|
9253 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
|
9254 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
|
9255 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
|
9256 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
|
9257 |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
9258 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
|
9259 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
|
9260 `define-coding-system-alias'. */); |
|
20105
c017642863c2
(Qcoding_system_spec): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
19824
diff
changeset
|
9261 Vcoding_system_alist = Qnil; |
|
c017642863c2
(Qcoding_system_spec): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
19824
diff
changeset
|
9262 |
| 17052 | 9263 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
|
9264 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
|
9265 |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
9266 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
|
9267 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
|
9268 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
|
9269 system bound to the corresponding coding-category is selected. */); |
| 17052 | 9270 { |
| 9271 int i; | |
| 9272 | |
| 9273 Vcoding_category_list = Qnil; | |
| 88365 | 9274 for (i = coding_category_max - 1; i >= 0; i--) |
| 17052 | 9275 Vcoding_category_list |
|
20718
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
9276 = Fcons (XVECTOR (Vcoding_category_table)->contents[i], |
|
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
9277 Vcoding_category_list); |
| 17052 | 9278 } |
| 9279 | |
| 9280 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
|
9281 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
|
9282 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
|
9283 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
|
9284 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
|
9285 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
|
9286 `process-coding-system-alist', and `network-coding-system-alist'. */); |
| 17052 | 9287 Vcoding_system_for_read = Qnil; |
| 9288 | |
| 9289 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
|
9290 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
|
9291 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
|
9292 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
|
9293 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
|
9294 |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
9295 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
|
9296 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
|
9297 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
|
9298 `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
|
9299 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
|
9300 the value of `buffer-file-coding-system' is used. */); |
| 17052 | 9301 Vcoding_system_for_write = Qnil; |
| 9302 | |
| 9303 DEFVAR_LISP ("last-coding-system-used", &Vlast_coding_system_used, | |
| 88365 | 9304 doc: /* |
| 9305 Coding system used in the latest file or process I/O. */); | |
| 17052 | 9306 Vlast_coding_system_used = Qnil; |
| 9307 | |
|
89686
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
9308 DEFVAR_LISP ("last-code-conversion-error", &Vlast_code_conversion_error, |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
9309 doc: /* |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
9310 Error status of the last code conversion. |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
9311 |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
9312 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
|
9313 is set to one of the following symbols. |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
9314 `insufficient-source' |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
9315 `inconsistent-eol' |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
9316 `invalid-source' |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
9317 `interrupted' |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
9318 `insufficient-memory' |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
9319 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
|
9320 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
|
9321 explicitly set this variable to nil before performing code |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
9322 conversion. */); |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
9323 Vlast_code_conversion_error = Qnil; |
|
9bfefb13fe83
(Qinsufficient_source, Qinconsistent_eol)
Kenichi Handa <handa@m17n.org>
parents:
89676
diff
changeset
|
9324 |
|
18650
aa3f2820e2ac
(Qemacs_mule, inhibit_eol_conversion): New variables.
Kenichi Handa <handa@m17n.org>
parents:
18613
diff
changeset
|
9325 DEFVAR_BOOL ("inhibit-eol-conversion", &inhibit_eol_conversion, |
| 88365 | 9326 doc: /* |
| 9327 *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
|
9328 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
|
9329 such conversion. */); |
|
18650
aa3f2820e2ac
(Qemacs_mule, inhibit_eol_conversion): New variables.
Kenichi Handa <handa@m17n.org>
parents:
18613
diff
changeset
|
9330 inhibit_eol_conversion = 0; |
|
aa3f2820e2ac
(Qemacs_mule, inhibit_eol_conversion): New variables.
Kenichi Handa <handa@m17n.org>
parents:
18613
diff
changeset
|
9331 |
|
21574
30394e3ae7f8
(syms_of_coding): Declare and define inherit-process-coding-system.
Eli Zaretskii <eliz@gnu.org>
parents:
21520
diff
changeset
|
9332 DEFVAR_BOOL ("inherit-process-coding-system", &inherit_process_coding_system, |
| 88365 | 9333 doc: /* |
| 9334 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
|
9335 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
|
9336 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
|
9337 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
|
9338 |
|
18180
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
9339 DEFVAR_LISP ("file-coding-system-alist", &Vfile_coding_system_alist, |
| 88365 | 9340 doc: /* |
| 9341 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
|
9342 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
|
9343 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
|
9344 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
|
9345 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
|
9346 the file contents. |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
9347 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
|
9348 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
|
9349 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
|
9350 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
|
9351 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
|
9352 |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
9353 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
|
9354 and the variable `auto-coding-alist'. */); |
|
18180
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
9355 Vfile_coding_system_alist = Qnil; |
|
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
9356 |
|
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
9357 DEFVAR_LISP ("process-coding-system-alist", &Vprocess_coding_system_alist, |
| 88365 | 9358 doc: /* |
| 9359 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
|
9360 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
|
9361 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
|
9362 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
|
9363 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
|
9364 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
|
9365 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
|
9366 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
|
9367 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
|
9368 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
|
9369 |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
9370 See also the function `find-operation-coding-system'. */); |
|
18180
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
9371 Vprocess_coding_system_alist = Qnil; |
|
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
9372 |
|
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
9373 DEFVAR_LISP ("network-coding-system-alist", &Vnetwork_coding_system_alist, |
| 88365 | 9374 doc: /* |
| 9375 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
|
9376 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
|
9377 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
|
9378 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
|
9379 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
|
9380 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
|
9381 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
|
9382 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
|
9383 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
|
9384 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
|
9385 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
|
9386 |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
9387 See also the function `find-operation-coding-system'. */); |
|
18180
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
9388 Vnetwork_coding_system_alist = Qnil; |
| 17052 | 9389 |
|
26088
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
26067
diff
changeset
|
9390 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
|
9391 doc: /* Coding system to use with system messages. |
|
6f20449b7e12
(syms_of_coding): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
41006
diff
changeset
|
9392 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
|
9393 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
|
9394 |
|
29182
1d1c27067af4
(encode_eol): Add null statement after label.
Dave Love <fx@gnu.org>
parents:
29172
diff
changeset
|
9395 /* 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
|
9396 DEFVAR_LISP ("eol-mnemonic-unix", &eol_mnemonic_unix, |
| 88365 | 9397 doc: /* |
| 9398 *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
|
9399 eol_mnemonic_unix = build_string (":"); |
|
b9d9fccad516
(syms_of_coding): eol-mnemonic-* variables are now
Eli Zaretskii <eliz@gnu.org>
parents:
24178
diff
changeset
|
9400 |
|
b9d9fccad516
(syms_of_coding): eol-mnemonic-* variables are now
Eli Zaretskii <eliz@gnu.org>
parents:
24178
diff
changeset
|
9401 DEFVAR_LISP ("eol-mnemonic-dos", &eol_mnemonic_dos, |
| 88365 | 9402 doc: /* |
| 9403 *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
|
9404 eol_mnemonic_dos = build_string ("\\"); |
|
b9d9fccad516
(syms_of_coding): eol-mnemonic-* variables are now
Eli Zaretskii <eliz@gnu.org>
parents:
24178
diff
changeset
|
9405 |
|
b9d9fccad516
(syms_of_coding): eol-mnemonic-* variables are now
Eli Zaretskii <eliz@gnu.org>
parents:
24178
diff
changeset
|
9406 DEFVAR_LISP ("eol-mnemonic-mac", &eol_mnemonic_mac, |
| 88365 | 9407 doc: /* |
| 9408 *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
|
9409 eol_mnemonic_mac = build_string ("/"); |
|
b9d9fccad516
(syms_of_coding): eol-mnemonic-* variables are now
Eli Zaretskii <eliz@gnu.org>
parents:
24178
diff
changeset
|
9410 |
|
b9d9fccad516
(syms_of_coding): eol-mnemonic-* variables are now
Eli Zaretskii <eliz@gnu.org>
parents:
24178
diff
changeset
|
9411 DEFVAR_LISP ("eol-mnemonic-undecided", &eol_mnemonic_undecided, |
| 88365 | 9412 doc: /* |
| 9413 *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
|
9414 eol_mnemonic_undecided = build_string (":"); |
| 17052 | 9415 |
|
22119
592bb8b9bcfd
Change terms unify/unification to
Kenichi Handa <handa@m17n.org>
parents:
22020
diff
changeset
|
9416 DEFVAR_LISP ("enable-character-translation", &Venable_character_translation, |
| 88365 | 9417 doc: /* |
| 9418 *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
|
9419 Venable_character_translation = Qt; |
|
592bb8b9bcfd
Change terms unify/unification to
Kenichi Handa <handa@m17n.org>
parents:
22020
diff
changeset
|
9420 |
|
22186
fc4aaf1b1772
Change term "character translation table" to "translation table".
Kenichi Handa <handa@m17n.org>
parents:
22166
diff
changeset
|
9421 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
|
9422 &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
|
9423 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
|
9424 Vstandard_translation_table_for_decode = Qnil; |
|
fc4aaf1b1772
Change term "character translation table" to "translation table".
Kenichi Handa <handa@m17n.org>
parents:
22166
diff
changeset
|
9425 |
|
fc4aaf1b1772
Change term "character translation table" to "translation table".
Kenichi Handa <handa@m17n.org>
parents:
22166
diff
changeset
|
9426 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
|
9427 &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
|
9428 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
|
9429 Vstandard_translation_table_for_encode = Qnil; |
| 17052 | 9430 |
| 88365 | 9431 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
|
9432 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
|
9433 While encoding, if a charset (car part of an element) is found, |
| 88365 | 9434 designate it with the escape sequence identifying revision (cdr part |
| 9435 of the element). */); | |
| 9436 Vcharset_revision_table = Qnil; | |
|
18180
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
9437 |
|
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
9438 DEFVAR_LISP ("default-process-coding-system", |
|
5f4c4da24e75
(Vcoding_system_alist): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
18002
diff
changeset
|
9439 &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
|
9440 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
|
9441 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
|
9442 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
|
9443 Vdefault_process_coding_system = Qnil; |
|
19280
e755044718ee
(ENCODE_ISO_CHARACTER_DIMENSION1): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
19193
diff
changeset
|
9444 |
|
19365
d9374f5ebd3a
(CODING_FLAG_ISO_LATIN_EXTRA): New macro.
Kenichi Handa <handa@m17n.org>
parents:
19285
diff
changeset
|
9445 DEFVAR_LISP ("latin-extra-code-table", &Vlatin_extra_code_table, |
| 88365 | 9446 doc: /* |
| 9447 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
|
9448 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
|
9449 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
|
9450 \(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
|
9451 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
|
9452 `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
|
9453 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
|
9454 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
|
9455 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
|
9456 |
|
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
9457 DEFVAR_LISP ("select-safe-coding-system-function", |
|
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
9458 &Vselect_safe_coding_system_function, |
| 88365 | 9459 doc: /* |
| 9460 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
|
9461 |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
9462 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
|
9463 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
|
9464 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
|
9465 |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
9466 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
|
9467 Vselect_safe_coding_system_function = Qnil; |
|
c600dea3b06b
Vselect_safe_coding_system_function): New variable.
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
9468 |
|
48874
3002a87cc629
(coding_system_require_warning): New variable.
Kenichi Handa <handa@m17n.org>
parents:
48829
diff
changeset
|
9469 DEFVAR_BOOL ("coding-system-require-warning", |
|
3002a87cc629
(coding_system_require_warning): New variable.
Kenichi Handa <handa@m17n.org>
parents:
48829
diff
changeset
|
9470 &coding_system_require_warning, |
|
3002a87cc629
(coding_system_require_warning): New variable.
Kenichi Handa <handa@m17n.org>
parents:
48829
diff
changeset
|
9471 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
|
9472 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
|
9473 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
|
9474 `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
|
9475 coding_system_require_warning = 0; |
|
3002a87cc629
(coding_system_require_warning): New variable.
Kenichi Handa <handa@m17n.org>
parents:
48829
diff
changeset
|
9476 |
|
3002a87cc629
(coding_system_require_warning): New variable.
Kenichi Handa <handa@m17n.org>
parents:
48829
diff
changeset
|
9477 |
|
30292
14a9937df1f5
(syms_of_coding): Fix typo in spelling of variable
Gerd Moellmann <gerd@gnu.org>
parents:
30263
diff
changeset
|
9478 DEFVAR_BOOL ("inhibit-iso-escape-detection", |
|
30204
35aec8514228
(inhibit_iso_escape_detection): New variable.
Kenichi Handa <handa@m17n.org>
parents:
29985
diff
changeset
|
9479 &inhibit_iso_escape_detection, |
| 88365 | 9480 doc: /* |
| 9481 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
|
9482 |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
9483 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
|
9484 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
|
9485 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
|
9486 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
|
9487 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
|
9488 |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
9489 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
|
9490 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
|
9491 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
|
9492 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
|
9493 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
|
9494 |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
9495 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
|
9496 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
|
9497 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
|
9498 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
|
9499 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
|
9500 |
|
42351475da08
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
9501 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
|
9502 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
|
9503 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
|
9504 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
|
9505 |
|
48182
9474e269efd1
Reformat some DEFUNs so that etags works.
Dave Love <fx@gnu.org>
parents:
48125
diff
changeset
|
9506 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
|
9507 doc: /* Char table for translating self-inserting characters. |
|
c2ce8280fb97
(Vtranslation_table_for_input): New.
Dave Love <fx@gnu.org>
parents:
48182
diff
changeset
|
9508 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
|
9509 `keyboard-translate-table'. */); |
|
48182
9474e269efd1
Reformat some DEFUNs so that etags works.
Dave Love <fx@gnu.org>
parents:
48125
diff
changeset
|
9510 Vtranslation_table_for_input = Qnil; |
| 89483 | 9511 |
|
88456
a7b309f72920
(coding_alloc_by_making_gap): Check the case that the
Kenichi Handa <handa@m17n.org>
parents:
88443
diff
changeset
|
9512 { |
|
a7b309f72920
(coding_alloc_by_making_gap): Check the case that the
Kenichi Handa <handa@m17n.org>
parents:
88443
diff
changeset
|
9513 Lisp_Object args[coding_arg_max]; |
| 89483 | 9514 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
|
9515 int i; |
|
a7b309f72920
(coding_alloc_by_making_gap): Check the case that the
Kenichi Handa <handa@m17n.org>
parents:
88443
diff
changeset
|
9516 |
|
a7b309f72920
(coding_alloc_by_making_gap): Check the case that the
Kenichi Handa <handa@m17n.org>
parents:
88443
diff
changeset
|
9517 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
|
9518 args[i] = Qnil; |
|
a7b309f72920
(coding_alloc_by_making_gap): Check the case that the
Kenichi Handa <handa@m17n.org>
parents:
88443
diff
changeset
|
9519 |
|
a7b309f72920
(coding_alloc_by_making_gap): Check the case that the
Kenichi Handa <handa@m17n.org>
parents:
88443
diff
changeset
|
9520 plist[0] = intern (":name"); |
|
a7b309f72920
(coding_alloc_by_making_gap): Check the case that the
Kenichi Handa <handa@m17n.org>
parents:
88443
diff
changeset
|
9521 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
|
9522 plist[2] = intern (":mnemonic"); |
|
a7b309f72920
(coding_alloc_by_making_gap): Check the case that the
Kenichi Handa <handa@m17n.org>
parents:
88443
diff
changeset
|
9523 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
|
9524 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
|
9525 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
|
9526 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
|
9527 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
|
9528 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
|
9529 plist[9] = args[coding_arg_default_char] = make_number (0); |
| 89483 | 9530 plist[10] = intern (":for-unibyte"); |
| 9531 plist[11] = args[coding_arg_for_unibyte] = Qt; | |
| 9532 plist[12] = intern (":docstring"); | |
| 9533 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
|
9534 \n\ |
|
a7b309f72920
(coding_alloc_by_making_gap): Check the case that the
Kenichi Handa <handa@m17n.org>
parents:
88443
diff
changeset
|
9535 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
|
9536 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
|
9537 character."); |
| 89483 | 9538 plist[14] = intern (":eol-type"); |
| 9539 plist[15] = args[coding_arg_eol_type] = Qunix; | |
| 9540 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
|
9541 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
|
9542 } |
|
a7b309f72920
(coding_alloc_by_making_gap): Check the case that the
Kenichi Handa <handa@m17n.org>
parents:
88443
diff
changeset
|
9543 |
|
a7b309f72920
(coding_alloc_by_making_gap): Check the case that the
Kenichi Handa <handa@m17n.org>
parents:
88443
diff
changeset
|
9544 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
|
9545 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
|
9546 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
|
9547 |
|
e911ca706166
(Fset_coding_system_priority): Doc fix. Update values
Kenichi Handa <handa@m17n.org>
parents:
89462
diff
changeset
|
9548 { |
|
e911ca706166
(Fset_coding_system_priority): Doc fix. Update values
Kenichi Handa <handa@m17n.org>
parents:
89462
diff
changeset
|
9549 int i; |
|
e911ca706166
(Fset_coding_system_priority): Doc fix. Update values
Kenichi Handa <handa@m17n.org>
parents:
89462
diff
changeset
|
9550 |
|
e911ca706166
(Fset_coding_system_priority): Doc fix. Update values
Kenichi Handa <handa@m17n.org>
parents:
89462
diff
changeset
|
9551 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
|
9552 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
|
9553 } |
| 17052 | 9554 } |
| 9555 | |
|
26088
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
26067
diff
changeset
|
9556 char * |
|
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
26067
diff
changeset
|
9557 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
|
9558 int error_number; |
|
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
26067
diff
changeset
|
9559 { |
|
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
26067
diff
changeset
|
9560 char *str; |
|
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
26067
diff
changeset
|
9561 |
|
26526
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26240
diff
changeset
|
9562 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
|
9563 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
|
9564 |
|
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
26067
diff
changeset
|
9565 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
|
9566 { |
|
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
26067
diff
changeset
|
9567 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
|
9568 Vlocale_coding_system, |
|
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
26067
diff
changeset
|
9569 0); |
|
46370
40db0673e6f0
Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents:
46293
diff
changeset
|
9570 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
|
9571 } |
|
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
26067
diff
changeset
|
9572 |
|
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
26067
diff
changeset
|
9573 return str; |
|
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
26067
diff
changeset
|
9574 } |
|
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
26067
diff
changeset
|
9575 |
| 17052 | 9576 #endif /* emacs */ |
