Mercurial > emacs
comparison src/coding.c @ 102334:7baaea85626e
(decode_coding_utf_8, decode_coding_utf_16, decode_coding_emacs_mule,
decode_coding_iso_2022, encode_coding_iso_2022, decode_coding_sjis,
decode_coding_big5, decode_coding_raw_text, decode_coding_charset,
setup_coding_system, decode_eol, decode_coding, consume_chars): Honor
inhibit-eol-conversion. (Bug #2186)
| author | Eli Zaretskii <eliz@gnu.org> |
|---|---|
| date | Sat, 28 Feb 2009 15:52:23 +0000 |
| parents | a1f0d8fadbb1 |
| children | 82f82b92314e |
comparison
equal
deleted
inserted
replaced
| 102333:f6fa57b5c954 | 102334:7baaea85626e |
|---|---|
| 1372 int *charbuf_end = coding->charbuf + coding->charbuf_size; | 1372 int *charbuf_end = coding->charbuf + coding->charbuf_size; |
| 1373 int consumed_chars = 0, consumed_chars_base = 0; | 1373 int consumed_chars = 0, consumed_chars_base = 0; |
| 1374 int multibytep = coding->src_multibyte; | 1374 int multibytep = coding->src_multibyte; |
| 1375 enum utf_bom_type bom = CODING_UTF_8_BOM (coding); | 1375 enum utf_bom_type bom = CODING_UTF_8_BOM (coding); |
| 1376 Lisp_Object attr, charset_list; | 1376 Lisp_Object attr, charset_list; |
| 1377 int eol_crlf = EQ (CODING_ID_EOL_TYPE (coding->id), Qdos); | 1377 int eol_crlf = |
| 1378 !inhibit_eol_conversion && EQ (CODING_ID_EOL_TYPE (coding->id), Qdos); | |
| 1378 int byte_after_cr = -1; | 1379 int byte_after_cr = -1; |
| 1379 | 1380 |
| 1380 CODING_GET_INFO (coding, attr, charset_list); | 1381 CODING_GET_INFO (coding, attr, charset_list); |
| 1381 | 1382 |
| 1382 if (bom != utf_without_bom) | 1383 if (bom != utf_without_bom) |
| 1694 int multibytep = coding->src_multibyte; | 1695 int multibytep = coding->src_multibyte; |
| 1695 enum utf_bom_type bom = CODING_UTF_16_BOM (coding); | 1696 enum utf_bom_type bom = CODING_UTF_16_BOM (coding); |
| 1696 enum utf_16_endian_type endian = CODING_UTF_16_ENDIAN (coding); | 1697 enum utf_16_endian_type endian = CODING_UTF_16_ENDIAN (coding); |
| 1697 int surrogate = CODING_UTF_16_SURROGATE (coding); | 1698 int surrogate = CODING_UTF_16_SURROGATE (coding); |
| 1698 Lisp_Object attr, charset_list; | 1699 Lisp_Object attr, charset_list; |
| 1699 int eol_crlf = EQ (CODING_ID_EOL_TYPE (coding->id), Qdos); | 1700 int eol_crlf = |
| 1701 !inhibit_eol_conversion && EQ (CODING_ID_EOL_TYPE (coding->id), Qdos); | |
| 1700 int byte_after_cr1 = -1, byte_after_cr2 = -1; | 1702 int byte_after_cr1 = -1, byte_after_cr2 = -1; |
| 1701 | 1703 |
| 1702 CODING_GET_INFO (coding, attr, charset_list); | 1704 CODING_GET_INFO (coding, attr, charset_list); |
| 1703 | 1705 |
| 1704 if (bom == utf_with_bom) | 1706 if (bom == utf_with_bom) |
| 2328 int multibytep = coding->src_multibyte; | 2330 int multibytep = coding->src_multibyte; |
| 2329 Lisp_Object attrs, charset_list; | 2331 Lisp_Object attrs, charset_list; |
| 2330 int char_offset = coding->produced_char; | 2332 int char_offset = coding->produced_char; |
| 2331 int last_offset = char_offset; | 2333 int last_offset = char_offset; |
| 2332 int last_id = charset_ascii; | 2334 int last_id = charset_ascii; |
| 2333 int eol_crlf = EQ (CODING_ID_EOL_TYPE (coding->id), Qdos); | 2335 int eol_crlf = |
| 2336 !inhibit_eol_conversion && EQ (CODING_ID_EOL_TYPE (coding->id), Qdos); | |
| 2334 int byte_after_cr = -1; | 2337 int byte_after_cr = -1; |
| 2335 | 2338 |
| 2336 CODING_GET_INFO (coding, attrs, charset_list); | 2339 CODING_GET_INFO (coding, attrs, charset_list); |
| 2337 | 2340 |
| 2338 while (1) | 2341 while (1) |
| 3239 int component_len; | 3242 int component_len; |
| 3240 Lisp_Object attrs, charset_list; | 3243 Lisp_Object attrs, charset_list; |
| 3241 int char_offset = coding->produced_char; | 3244 int char_offset = coding->produced_char; |
| 3242 int last_offset = char_offset; | 3245 int last_offset = char_offset; |
| 3243 int last_id = charset_ascii; | 3246 int last_id = charset_ascii; |
| 3244 int eol_crlf = EQ (CODING_ID_EOL_TYPE (coding->id), Qdos); | 3247 int eol_crlf = |
| 3248 !inhibit_eol_conversion && EQ (CODING_ID_EOL_TYPE (coding->id), Qdos); | |
| 3245 int byte_after_cr = -1; | 3249 int byte_after_cr = -1; |
| 3246 | 3250 |
| 3247 CODING_GET_INFO (coding, attrs, charset_list); | 3251 CODING_GET_INFO (coding, attrs, charset_list); |
| 3248 setup_iso_safe_charsets (attrs); | 3252 setup_iso_safe_charsets (attrs); |
| 3249 /* Charset list may have been changed. */ | 3253 /* Charset list may have been changed. */ |
| 4126 int ascii_compatible; | 4130 int ascii_compatible; |
| 4127 int c; | 4131 int c; |
| 4128 int preferred_charset_id = -1; | 4132 int preferred_charset_id = -1; |
| 4129 | 4133 |
| 4130 CODING_GET_INFO (coding, attrs, charset_list); | 4134 CODING_GET_INFO (coding, attrs, charset_list); |
| 4131 eol_type = CODING_ID_EOL_TYPE (coding->id); | 4135 eol_type = inhibit_eol_conversion ? Qunix : CODING_ID_EOL_TYPE (coding->id); |
| 4132 if (VECTORP (eol_type)) | 4136 if (VECTORP (eol_type)) |
| 4133 eol_type = Qunix; | 4137 eol_type = Qunix; |
| 4134 | 4138 |
| 4135 setup_iso_safe_charsets (attrs); | 4139 setup_iso_safe_charsets (attrs); |
| 4136 /* Charset list may have been changed. */ | 4140 /* Charset list may have been changed. */ |
| 4414 struct charset *charset_kanji2; | 4418 struct charset *charset_kanji2; |
| 4415 Lisp_Object attrs, charset_list, val; | 4419 Lisp_Object attrs, charset_list, val; |
| 4416 int char_offset = coding->produced_char; | 4420 int char_offset = coding->produced_char; |
| 4417 int last_offset = char_offset; | 4421 int last_offset = char_offset; |
| 4418 int last_id = charset_ascii; | 4422 int last_id = charset_ascii; |
| 4419 int eol_crlf = EQ (CODING_ID_EOL_TYPE (coding->id), Qdos); | 4423 int eol_crlf = |
| 4424 !inhibit_eol_conversion && EQ (CODING_ID_EOL_TYPE (coding->id), Qdos); | |
| 4420 int byte_after_cr = -1; | 4425 int byte_after_cr = -1; |
| 4421 | 4426 |
| 4422 CODING_GET_INFO (coding, attrs, charset_list); | 4427 CODING_GET_INFO (coding, attrs, charset_list); |
| 4423 | 4428 |
| 4424 val = charset_list; | 4429 val = charset_list; |
| 4529 struct charset *charset_roman, *charset_big5; | 4534 struct charset *charset_roman, *charset_big5; |
| 4530 Lisp_Object attrs, charset_list, val; | 4535 Lisp_Object attrs, charset_list, val; |
| 4531 int char_offset = coding->produced_char; | 4536 int char_offset = coding->produced_char; |
| 4532 int last_offset = char_offset; | 4537 int last_offset = char_offset; |
| 4533 int last_id = charset_ascii; | 4538 int last_id = charset_ascii; |
| 4534 int eol_crlf = EQ (CODING_ID_EOL_TYPE (coding->id), Qdos); | 4539 int eol_crlf = |
| 4540 !inhibit_eol_conversion && EQ (CODING_ID_EOL_TYPE (coding->id), Qdos); | |
| 4535 int byte_after_cr = -1; | 4541 int byte_after_cr = -1; |
| 4536 | 4542 |
| 4537 CODING_GET_INFO (coding, attrs, charset_list); | 4543 CODING_GET_INFO (coding, attrs, charset_list); |
| 4538 val = charset_list; | 4544 val = charset_list; |
| 4539 charset_roman = CHARSET_FROM_ID (XINT (XCAR (val))), val = XCDR (val); | 4545 charset_roman = CHARSET_FROM_ID (XINT (XCAR (val))), val = XCDR (val); |
| 4981 | 4987 |
| 4982 static void | 4988 static void |
| 4983 decode_coding_raw_text (coding) | 4989 decode_coding_raw_text (coding) |
| 4984 struct coding_system *coding; | 4990 struct coding_system *coding; |
| 4985 { | 4991 { |
| 4986 int eol_crlf = EQ (CODING_ID_EOL_TYPE (coding->id), Qdos); | 4992 int eol_crlf = |
| 4993 !inhibit_eol_conversion && EQ (CODING_ID_EOL_TYPE (coding->id), Qdos); | |
| 4987 | 4994 |
| 4988 coding->chars_at_source = 1; | 4995 coding->chars_at_source = 1; |
| 4989 coding->consumed_char = coding->src_chars; | 4996 coding->consumed_char = coding->src_chars; |
| 4990 coding->consumed = coding->src_bytes; | 4997 coding->consumed = coding->src_bytes; |
| 4991 if (eol_crlf && coding->source[coding->src_bytes - 1] == '\r') | 4998 if (eol_crlf && coding->source[coding->src_bytes - 1] == '\r') |
| 5200 int multibytep = coding->src_multibyte; | 5207 int multibytep = coding->src_multibyte; |
| 5201 Lisp_Object attrs, charset_list, valids; | 5208 Lisp_Object attrs, charset_list, valids; |
| 5202 int char_offset = coding->produced_char; | 5209 int char_offset = coding->produced_char; |
| 5203 int last_offset = char_offset; | 5210 int last_offset = char_offset; |
| 5204 int last_id = charset_ascii; | 5211 int last_id = charset_ascii; |
| 5205 int eol_crlf = EQ (CODING_ID_EOL_TYPE (coding->id), Qdos); | 5212 int eol_crlf = |
| 5213 !inhibit_eol_conversion && EQ (CODING_ID_EOL_TYPE (coding->id), Qdos); | |
| 5206 int byte_after_cr = -1; | 5214 int byte_after_cr = -1; |
| 5207 | 5215 |
| 5208 CODING_GET_INFO (coding, attrs, charset_list); | 5216 CODING_GET_INFO (coding, attrs, charset_list); |
| 5209 valids = AREF (attrs, coding_attr_charset_valids); | 5217 valids = AREF (attrs, coding_attr_charset_valids); |
| 5210 | 5218 |
| 5397 coding_system = Qundecided; | 5405 coding_system = Qundecided; |
| 5398 | 5406 |
| 5399 CHECK_CODING_SYSTEM_GET_ID (coding_system, coding->id); | 5407 CHECK_CODING_SYSTEM_GET_ID (coding_system, coding->id); |
| 5400 | 5408 |
| 5401 attrs = CODING_ID_ATTRS (coding->id); | 5409 attrs = CODING_ID_ATTRS (coding->id); |
| 5402 eol_type = CODING_ID_EOL_TYPE (coding->id); | 5410 eol_type = inhibit_eol_conversion ? Qunix : CODING_ID_EOL_TYPE (coding->id); |
| 5403 | 5411 |
| 5404 coding->mode = 0; | 5412 coding->mode = 0; |
| 5405 coding->head_ascii = -1; | 5413 coding->head_ascii = -1; |
| 5406 if (VECTORP (eol_type)) | 5414 if (VECTORP (eol_type)) |
| 5407 coding->common_flags = (CODING_REQUIRE_DECODING_MASK | 5415 coding->common_flags = (CODING_REQUIRE_DECODING_MASK |
| 6142 { | 6150 { |
| 6143 Lisp_Object eol_type; | 6151 Lisp_Object eol_type; |
| 6144 unsigned char *p, *pbeg, *pend; | 6152 unsigned char *p, *pbeg, *pend; |
| 6145 | 6153 |
| 6146 eol_type = CODING_ID_EOL_TYPE (coding->id); | 6154 eol_type = CODING_ID_EOL_TYPE (coding->id); |
| 6147 if (EQ (eol_type, Qunix)) | 6155 if (EQ (eol_type, Qunix) || inhibit_eol_conversion) |
| 6148 return; | 6156 return; |
| 6149 | 6157 |
| 6150 if (NILP (coding->dst_object)) | 6158 if (NILP (coding->dst_object)) |
| 6151 pbeg = coding->destination; | 6159 pbeg = coding->destination; |
| 6152 else | 6160 else |
| 6818 *p++ = *src++; | 6826 *p++ = *src++; |
| 6819 } | 6827 } |
| 6820 coding->consumed = coding->src_bytes; | 6828 coding->consumed = coding->src_bytes; |
| 6821 } | 6829 } |
| 6822 | 6830 |
| 6823 if (! EQ (CODING_ID_EOL_TYPE (coding->id), Qunix)) | 6831 if (! EQ (CODING_ID_EOL_TYPE (coding->id), Qunix) |
| 6832 && !inhibit_eol_conversion) | |
| 6824 decode_eol (coding); | 6833 decode_eol (coding); |
| 6825 if (BUFFERP (coding->dst_object)) | 6834 if (BUFFERP (coding->dst_object)) |
| 6826 { | 6835 { |
| 6827 current_buffer->undo_list = undo_list; | 6836 current_buffer->undo_list = undo_list; |
| 6828 record_insert (coding->dst_pos, coding->produced_char); | 6837 record_insert (coding->dst_pos, coding->produced_char); |
| 6969 int *lookup_buf = NULL; | 6978 int *lookup_buf = NULL; |
| 6970 | 6979 |
| 6971 if (! NILP (translation_table)) | 6980 if (! NILP (translation_table)) |
| 6972 lookup_buf = alloca (sizeof (int) * max_lookup); | 6981 lookup_buf = alloca (sizeof (int) * max_lookup); |
| 6973 | 6982 |
| 6974 eol_type = CODING_ID_EOL_TYPE (coding->id); | 6983 eol_type = inhibit_eol_conversion ? Qunix : CODING_ID_EOL_TYPE (coding->id); |
| 6975 if (VECTORP (eol_type)) | 6984 if (VECTORP (eol_type)) |
| 6976 eol_type = Qunix; | 6985 eol_type = Qunix; |
| 6977 | 6986 |
| 6978 /* Note: composition handling is not yet implemented. */ | 6987 /* Note: composition handling is not yet implemented. */ |
| 6979 coding->common_flags &= ~CODING_ANNOTATE_COMPOSITION_MASK; | 6988 coding->common_flags &= ~CODING_ANNOTATE_COMPOSITION_MASK; |
