From 20f6783d3c7efe13beda2f1531ddfe71dfaa1d22 Mon Sep 17 00:00:00 2001 From: "Richard M. Stallman" Date: Mon, 13 Jul 1998 22:11:54 +0000 Subject: [PATCH] (Finsert_file_contents): When replacing, in multibyte bfr, always extend the range to a character boundary. --- src/fileio.c | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/src/fileio.c b/src/fileio.c index e444b1474d2..e3ca6cd4e2a 100644 --- a/src/fileio.c +++ b/src/fileio.c @@ -3698,7 +3698,14 @@ actually used.") /* We win! We can handle REPLACE the optimized way. */ - /* Extends the end of non-matching text area to multibyte + /* Extend the start of non-matching text area to multibyte + character boundary. */ + if (! NILP (current_buffer->enable_multibyte_characters)) + while (same_at_start > BEGV_BYTE + && ! CHAR_HEAD_P (FETCH_BYTE (same_at_start))) + same_at_start--; + + /* Extend the end of non-matching text area to multibyte character boundary. */ if (! NILP (current_buffer->enable_multibyte_characters)) while (same_at_end < ZV_BYTE @@ -3853,6 +3860,13 @@ actually used.") goto handled; } + /* Extend the start of non-matching text area to multibyte + character boundary. */ + if (! NILP (current_buffer->enable_multibyte_characters)) + while (same_at_start > BEGV_BYTE + && ! CHAR_HEAD_P (FETCH_BYTE (same_at_start))) + same_at_start--; + /* Scan this bufferful from the end, comparing with the Emacs buffer. */ bufpos = inserted; @@ -3863,6 +3877,13 @@ actually used.") && FETCH_BYTE (same_at_end - 1) == conversion_buffer[bufpos - 1]) same_at_end--, bufpos--; + /* Extend the end of non-matching text area to multibyte + character boundary. */ + if (! NILP (current_buffer->enable_multibyte_characters)) + while (same_at_end < ZV_BYTE + && ! CHAR_HEAD_P (FETCH_BYTE (same_at_end))) + same_at_end++; + /* Don't try to reuse the same piece of text twice. */ overlap = same_at_start - BEGV_BYTE - (same_at_end + inserted - ZV_BYTE); if (overlap > 0) -- 2.39.2