Mercurial > emacs
comparison src/coding.c @ 35587:7e767148cfdc
(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.
| author | Kenichi Handa <handa@m17n.org> |
|---|---|
| date | Fri, 26 Jan 2001 06:10:21 +0000 |
| parents | 36de5bf9969c |
| children | b511edc4a348 |
comparison
equal
deleted
inserted
replaced
| 35586:6c84d7800dd2 | 35587:7e767148cfdc |
|---|---|
| 4677 if (coding->type == coding_type_undecided) | 4677 if (coding->type == coding_type_undecided) |
| 4678 detect_coding (coding, source, src_bytes); | 4678 detect_coding (coding, source, src_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; |
| 4686 coding->errors = 0; | 4691 coding->errors = 0; |
| 4687 coding->result = CODING_FINISH_NORMAL; | 4692 coding->result = CODING_FINISH_NORMAL; |
| 5302 int orig_point = PT, orig_len = len; | 5307 int orig_point = PT, orig_len = len; |
| 5303 int prev_Z; | 5308 int prev_Z; |
| 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 { |
| 5311 TEMP_SET_PT_BOTH (from, from_byte); | 5316 TEMP_SET_PT_BOTH (from, from_byte); |
| 5312 orig_point = from; | 5317 orig_point = from; |
| 5354 } | 5359 } |
| 5355 } | 5360 } |
| 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; |
| 5363 /* We had better recover the original eol format if we | 5367 /* We had better recover the original eol format if we |
| 5364 encounter an inconsitent eol format while decoding. */ | 5368 encounter an inconsitent eol format while decoding. */ |
| 5792 int consumed, consumed_char, produced, produced_char; | 5796 int consumed, consumed_char, produced, produced_char; |
| 5793 | 5797 |
| 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)) |
| 5801 { | 5805 { |
| 5802 /* See the comments in code_convert_region. */ | 5806 /* See the comments in code_convert_region. */ |
| 5881 coding_allocate_composition_data (coding, from + produced_char); | 5885 coding_allocate_composition_data (coding, from + produced_char); |
| 5882 else if (result == CODING_FINISH_INSUFFICIENT_DST) | 5886 else if (result == CODING_FINISH_INSUFFICIENT_DST) |
| 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 { |
| 5889 unsigned char *p; | 5895 unsigned char *p; |
| 5890 for (p = buf.data; p < buf.data + produced; p++) | 5896 for (p = buf.data; p < buf.data + produced; p++) |
| 5904 if (*p0 == '\n') *--p1 = '\r'; | 5910 if (*p0 == '\n') *--p1 = '\r'; |
| 5905 } | 5911 } |
| 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 |
| 5914 coding->consumed = consumed; | 5931 coding->consumed = consumed; |
| 5915 coding->consumed_char = consumed_char; | 5932 coding->consumed_char = consumed_char; |
