diff options
| author | Kenichi Handa | 2001-01-26 06:10:21 +0000 |
|---|---|---|
| committer | Kenichi Handa | 2001-01-26 06:10:21 +0000 |
| commit | 8844fa83d302c082faf9976fa3253709afda0d2c (patch) | |
| tree | 0c05a00dbb45537e118adc34631fce1ba4c9a39c /src/coding.c | |
| parent | 73df2b1e651c196db84a671dbbdae6c7e5fb21e2 (diff) | |
| download | emacs-8844fa83d302c082faf9976fa3253709afda0d2c.tar.gz emacs-8844fa83d302c082faf9976fa3253709afda0d2c.zip | |
(decode_coding): Set a flag for inhibiting
inconsistent eol.
(code_convert_region): Always set saved_coding_symbol.
(decode_coding_string): Likewise. Update coding->symbol when we
encounter a inconsistent eol by the same way as
code_convert_region.
Diffstat (limited to 'src/coding.c')
| -rw-r--r-- | src/coding.c | 27 |
1 files changed, 22 insertions, 5 deletions
diff --git a/src/coding.c b/src/coding.c index 08b8935e056..250977eb5f2 100644 --- a/src/coding.c +++ b/src/coding.c | |||
| @@ -4679,7 +4679,12 @@ decode_coding (coding, source, destination, src_bytes, dst_bytes) | |||
| 4679 | 4679 | ||
| 4680 | if (coding->eol_type == CODING_EOL_UNDECIDED | 4680 | if (coding->eol_type == CODING_EOL_UNDECIDED |
| 4681 | && coding->type != coding_type_ccl) | 4681 | && coding->type != coding_type_ccl) |
| 4682 | detect_eol (coding, source, src_bytes); | 4682 | { |
| 4683 | detect_eol (coding, source, src_bytes); | ||
| 4684 | /* We had better recover the original eol format if we | ||
| 4685 | encounter an inconsitent eol format while decoding. */ | ||
| 4686 | coding->mode |= CODING_MODE_INHIBIT_INCONSISTENT_EOL; | ||
| 4687 | } | ||
| 4683 | 4688 | ||
| 4684 | coding->produced = coding->produced_char = 0; | 4689 | coding->produced = coding->produced_char = 0; |
| 4685 | coding->consumed = coding->consumed_char = 0; | 4690 | coding->consumed = coding->consumed_char = 0; |
| @@ -5304,7 +5309,7 @@ code_convert_region (from, from_byte, to, to_byte, coding, encodep, replace) | |||
| 5304 | int multibyte_p = !NILP (current_buffer->enable_multibyte_characters); | 5309 | int multibyte_p = !NILP (current_buffer->enable_multibyte_characters); |
| 5305 | 5310 | ||
| 5306 | deletion = Qnil; | 5311 | deletion = Qnil; |
| 5307 | saved_coding_symbol = Qnil; | 5312 | saved_coding_symbol = coding->symbol; |
| 5308 | 5313 | ||
| 5309 | if (from < PT && PT < to) | 5314 | if (from < PT && PT < to) |
| 5310 | { | 5315 | { |
| @@ -5356,7 +5361,6 @@ code_convert_region (from, from_byte, to, to_byte, coding, encodep, replace) | |||
| 5356 | if (coding->eol_type == CODING_EOL_UNDECIDED | 5361 | if (coding->eol_type == CODING_EOL_UNDECIDED |
| 5357 | && coding->type != coding_type_ccl) | 5362 | && coding->type != coding_type_ccl) |
| 5358 | { | 5363 | { |
| 5359 | saved_coding_symbol = coding->symbol; | ||
| 5360 | detect_eol (coding, BYTE_POS_ADDR (from_byte), len_byte); | 5364 | detect_eol (coding, BYTE_POS_ADDR (from_byte), len_byte); |
| 5361 | if (coding->eol_type == CODING_EOL_UNDECIDED) | 5365 | if (coding->eol_type == CODING_EOL_UNDECIDED) |
| 5362 | coding->eol_type = CODING_EOL_LF; | 5366 | coding->eol_type = CODING_EOL_LF; |
| @@ -5794,7 +5798,7 @@ decode_coding_string (str, coding, nocopy) | |||
| 5794 | from = 0; | 5798 | from = 0; |
| 5795 | to_byte = STRING_BYTES (XSTRING (str)); | 5799 | to_byte = STRING_BYTES (XSTRING (str)); |
| 5796 | 5800 | ||
| 5797 | saved_coding_symbol = Qnil; | 5801 | saved_coding_symbol = coding->symbol; |
| 5798 | coding->src_multibyte = STRING_MULTIBYTE (str); | 5802 | coding->src_multibyte = STRING_MULTIBYTE (str); |
| 5799 | coding->dst_multibyte = 1; | 5803 | coding->dst_multibyte = 1; |
| 5800 | if (CODING_REQUIRE_DETECTION (coding)) | 5804 | if (CODING_REQUIRE_DETECTION (coding)) |
| @@ -5883,6 +5887,8 @@ decode_coding_string (str, coding, nocopy) | |||
| 5883 | extend_conversion_buffer (&buf); | 5887 | extend_conversion_buffer (&buf); |
| 5884 | else if (result == CODING_FINISH_INCONSISTENT_EOL) | 5888 | else if (result == CODING_FINISH_INCONSISTENT_EOL) |
| 5885 | { | 5889 | { |
| 5890 | Lisp_Object eol_type; | ||
| 5891 | |||
| 5886 | /* Recover the original EOL format. */ | 5892 | /* Recover the original EOL format. */ |
| 5887 | if (coding->eol_type == CODING_EOL_CR) | 5893 | if (coding->eol_type == CODING_EOL_CR) |
| 5888 | { | 5894 | { |
| @@ -5906,8 +5912,19 @@ decode_coding_string (str, coding, nocopy) | |||
| 5906 | produced += num_eol; | 5912 | produced += num_eol; |
| 5907 | produced_char += num_eol; | 5913 | produced_char += num_eol; |
| 5908 | } | 5914 | } |
| 5915 | /* Suppress eol-format conversion in the further conversion. */ | ||
| 5909 | coding->eol_type = CODING_EOL_LF; | 5916 | coding->eol_type = CODING_EOL_LF; |
| 5910 | coding->symbol = saved_coding_symbol; | 5917 | |
| 5918 | /* Set the coding system symbol to that for Unix-like EOL. */ | ||
| 5919 | eol_type = Fget (saved_coding_symbol, Qeol_type); | ||
| 5920 | if (VECTORP (eol_type) | ||
| 5921 | && XVECTOR (eol_type)->size == 3 | ||
| 5922 | && SYMBOLP (XVECTOR (eol_type)->contents[CODING_EOL_LF])) | ||
| 5923 | coding->symbol = XVECTOR (eol_type)->contents[CODING_EOL_LF]; | ||
| 5924 | else | ||
| 5925 | coding->symbol = saved_coding_symbol; | ||
| 5926 | |||
| 5927 | |||
| 5911 | } | 5928 | } |
| 5912 | } | 5929 | } |
| 5913 | 5930 | ||