# HG changeset patch # User Richard M. Stallman # Date 868361852 0 # Node ID 554594d88cd33407424323e55fbf3eb913ce30b2 # Parent d26f9720e55f1f0a14aea07d0cb828a4ddf3f9c4 (Finsert_file_contents): Give up match-end only if coding requires conversion. Adjust end of non-matching text area to multibyte character boundary if enable_multibyte_character is non-nil. diff -r d26f9720e55f -r 554594d88cd3 src/fileio.c --- a/src/fileio.c Tue Jul 08 11:12:53 1997 +0000 +++ b/src/fileio.c Tue Jul 08 11:37:32 1997 +0000 @@ -3291,7 +3291,8 @@ we cannot use this method; giveup and try the other. */ if (same_at_end > same_at_start && FETCH_BYTE (same_at_end - 1) >= 0200 - && ! NILP (current_buffer->enable_multibyte_characters)) + && ! NILP (current_buffer->enable_multibyte_characters) + && CODING_REQUIRE_CONVERSION (&coding)) giveup_match_end = 1; break; } @@ -3302,6 +3303,12 @@ { /* We win! We can handle REPLACE the optimized way. */ + /* Extends the end of non-matching text area to multibyte + character boundary. */ + if (! NILP (current_buffer->enable_multibyte_characters)) + while (same_at_end < ZV && ! CHAR_HEAD_P (POS_ADDR (same_at_end))) + same_at_end++; + /* Don't try to reuse the same piece of text twice. */ overlap = same_at_start - BEGV - (same_at_end + st.st_size - ZV); if (overlap > 0)