diff options
Diffstat (limited to 'src/coding.c')
| -rw-r--r-- | src/coding.c | 48 |
1 files changed, 19 insertions, 29 deletions
diff --git a/src/coding.c b/src/coding.c index e591bedc3e5..f5fe52e04c0 100644 --- a/src/coding.c +++ b/src/coding.c | |||
| @@ -6814,39 +6814,29 @@ decode_eol (struct coding_system *coding) | |||
| 6814 | else if (EQ (eol_type, Qdos)) | 6814 | else if (EQ (eol_type, Qdos)) |
| 6815 | { | 6815 | { |
| 6816 | ptrdiff_t n = 0; | 6816 | ptrdiff_t n = 0; |
| 6817 | ptrdiff_t pos = coding->dst_pos; | ||
| 6818 | ptrdiff_t pos_byte = coding->dst_pos_byte; | ||
| 6819 | ptrdiff_t pos_end = pos_byte + coding->produced - 1; | ||
| 6817 | 6820 | ||
| 6818 | if (NILP (coding->dst_object)) | 6821 | /* This assertion is here instead of code, now deleted, that |
| 6819 | { | 6822 | handled the NILP case, which no longer happens with the |
| 6820 | /* Start deleting '\r' from the tail to minimize the memory | 6823 | current codebase. */ |
| 6821 | movement. */ | 6824 | eassert (!NILP (coding->dst_object)); |
| 6822 | for (p = pend - 2; p >= pbeg; p--) | ||
| 6823 | if (*p == '\r') | ||
| 6824 | { | ||
| 6825 | memmove (p, p + 1, pend-- - p - 1); | ||
| 6826 | n++; | ||
| 6827 | } | ||
| 6828 | } | ||
| 6829 | else | ||
| 6830 | { | ||
| 6831 | ptrdiff_t pos = coding->dst_pos; | ||
| 6832 | ptrdiff_t pos_byte = coding->dst_pos_byte; | ||
| 6833 | ptrdiff_t pos_end = pos_byte + coding->produced - 1; | ||
| 6834 | 6825 | ||
| 6835 | while (pos_byte < pos_end) | 6826 | while (pos_byte < pos_end) |
| 6827 | { | ||
| 6828 | p = BYTE_POS_ADDR (pos_byte); | ||
| 6829 | if (*p == '\r' && p[1] == '\n') | ||
| 6836 | { | 6830 | { |
| 6837 | p = BYTE_POS_ADDR (pos_byte); | 6831 | del_range_2 (pos, pos_byte, pos + 1, pos_byte + 1, 0); |
| 6838 | if (*p == '\r' && p[1] == '\n') | 6832 | n++; |
| 6839 | { | 6833 | pos_end--; |
| 6840 | del_range_2 (pos, pos_byte, pos + 1, pos_byte + 1, 0); | ||
| 6841 | n++; | ||
| 6842 | pos_end--; | ||
| 6843 | } | ||
| 6844 | pos++; | ||
| 6845 | if (coding->dst_multibyte) | ||
| 6846 | pos_byte += BYTES_BY_CHAR_HEAD (*p); | ||
| 6847 | else | ||
| 6848 | pos_byte++; | ||
| 6849 | } | 6834 | } |
| 6835 | pos++; | ||
| 6836 | if (coding->dst_multibyte) | ||
| 6837 | pos_byte += BYTES_BY_CHAR_HEAD (*p); | ||
| 6838 | else | ||
| 6839 | pos_byte++; | ||
| 6850 | } | 6840 | } |
| 6851 | coding->produced -= n; | 6841 | coding->produced -= n; |
| 6852 | coding->produced_char -= n; | 6842 | coding->produced_char -= n; |