changeset 91848:75f72cab9771

(Finsert_file_contents): Adjust offsets when replacing within a narrowed buffer.
author Stefan Monnier <monnier@iro.umontreal.ca>
date Thu, 14 Feb 2008 19:41:43 +0000
parents b842643f6e24
children 6c35c4ccf09e
files src/ChangeLog src/fileio.c
diffstat 2 files changed, 9 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/ChangeLog	Thu Feb 14 18:46:06 2008 +0000
+++ b/src/ChangeLog	Thu Feb 14 19:41:43 2008 +0000
@@ -1,3 +1,8 @@
+2008-02-14  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+	* fileio.c (Finsert_file_contents): Adjust offsets when replacing
+	within a narrowed buffer.
+
 2008-02-14  Kenichi Handa  <handa@ni.aist.go.jp>
 
 	* coding.c (decode_coding_object, encode_coding_object):
--- a/src/fileio.c	Thu Feb 14 18:46:06 2008 +0000
+++ b/src/fileio.c	Thu Feb 14 19:41:43 2008 +0000
@@ -4338,10 +4338,12 @@
       SET_PT_BOTH (temp, same_at_start);
       same_at_start_charpos
 	= buf_bytepos_to_charpos (XBUFFER (conversion_buffer),
-				  same_at_start);
+				  same_at_start - BEGV_BYTE
+				  + BUF_BEG_BYTE (XBUFFER (conversion_buffer)));
       inserted_chars
 	= (buf_bytepos_to_charpos (XBUFFER (conversion_buffer),
-				   same_at_start + inserted)
+				   same_at_start + inserted - BEGV_BYTE
+				  + BUF_BEG_BYTE (XBUFFER (conversion_buffer)))
 	   - same_at_start_charpos);
       /* This binding is to avoid ask-user-about-supersession-threat
 	 being called in insert_from_buffer (via in