Mercurial > emacs
changeset 90378:0aec08f4c729
(decode_eol): Pay attention to buffer relocation in
del_range_2.
(decode_coding): Call decode_eol before restoring undo_list.
author | Kenichi Handa <handa@m17n.org> |
---|---|
date | Fri, 07 Apr 2006 05:26:46 +0000 |
parents | 482dfed28bee |
children | f3408d3c3e15 |
files | src/coding.c |
diffstat | 1 files changed, 20 insertions(+), 11 deletions(-) [+] |
line wrap: on
line diff
--- a/src/coding.c Sun Apr 02 01:10:03 2006 +0000 +++ b/src/coding.c Fri Apr 07 05:26:46 2006 +0000 @@ -5623,6 +5623,8 @@ if (NILP (coding->dst_object)) { + /* Start deleting '\r' from the tail to minimize the memory + movement. */ for (p = pend - 2; p >= pbeg; p--) if (*p == '\r') { @@ -5632,15 +5634,22 @@ } else { - for (p = pend - 2; p >= pbeg; p--) - if (*p == '\r') - { - int pos_byte = coding->dst_pos_byte + (p - pbeg); - int pos = BYTE_TO_CHAR (pos_byte); - - del_range_2 (pos, pos_byte, pos + 1, pos_byte + 1, 0); - n++; - } + int pos_byte = coding->dst_pos_byte; + int pos = coding->dst_pos; + int pos_end = pos + coding->produced_char - 1; + + while (pos < pos_end) + { + p = BYTE_POS_ADDR (pos_byte); + if (*p == '\r' && p[1] == '\n') + { + del_range_2 (pos, pos_byte, pos + 1, pos_byte + 1, 0); + n++; + pos_end--; + } + pos++; + pos_byte += BYTES_BY_CHAR_HEAD (*p); + } } coding->produced -= n; coding->produced_char -= n; @@ -6258,13 +6267,13 @@ coding->consumed = coding->src_bytes; } + if (! EQ (CODING_ID_EOL_TYPE (coding->id), Qunix)) + decode_eol (coding); if (BUFFERP (coding->dst_object)) { current_buffer->undo_list = undo_list; record_insert (coding->dst_pos, coding->produced_char); } - if (! EQ (CODING_ID_EOL_TYPE (coding->id), Qunix)) - decode_eol (coding); return coding->result; }