]> git.eshelyaron.com Git - emacs.git/commitdiff
(Finsert_file_contents): When replacing, in multibyte bfr,
authorRichard M. Stallman <rms@gnu.org>
Mon, 13 Jul 1998 22:11:54 +0000 (22:11 +0000)
committerRichard M. Stallman <rms@gnu.org>
Mon, 13 Jul 1998 22:11:54 +0000 (22:11 +0000)
always extend the range to a character boundary.

src/fileio.c

index e444b1474d2d535ded4683d0657616ba37a29b20..e3ca6cd4e2a769d5d7c2df0e506bc3ed9a2b7c53 100644 (file)
@@ -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)