diff options
| author | Kenichi Handa | 2002-04-09 07:42:06 +0000 |
|---|---|---|
| committer | Kenichi Handa | 2002-04-09 07:42:06 +0000 |
| commit | 50342b352008fb2695ffbd1ae1f98c26c6937878 (patch) | |
| tree | 9738c01fc084fd34965da9b0ad7083977d3749b8 | |
| parent | 6a709baf2a6cb7932fbc00080212294d39bb5781 (diff) | |
| download | emacs-50342b352008fb2695ffbd1ae1f98c26c6937878.tar.gz emacs-50342b352008fb2695ffbd1ae1f98c26c6937878.zip | |
(Finsert_file_contents): Fix calculation of `inserted'.
Fix arguments to insert_from_buffer.
| -rw-r--r-- | src/fileio.c | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/src/fileio.c b/src/fileio.c index eb12810eeaa..90856d75555 100644 --- a/src/fileio.c +++ b/src/fileio.c | |||
| @@ -4025,6 +4025,8 @@ actually used. */) | |||
| 4025 | { | 4025 | { |
| 4026 | int same_at_start = BEGV_BYTE; | 4026 | int same_at_start = BEGV_BYTE; |
| 4027 | int same_at_end = ZV_BYTE; | 4027 | int same_at_end = ZV_BYTE; |
| 4028 | int same_at_start_charpos; | ||
| 4029 | int inserted_chars; | ||
| 4028 | int overlap; | 4030 | int overlap; |
| 4029 | int bufpos; | 4031 | int bufpos; |
| 4030 | unsigned char *decoded; | 4032 | unsigned char *decoded; |
| @@ -4103,7 +4105,8 @@ actually used. */) | |||
| 4103 | } | 4105 | } |
| 4104 | 4106 | ||
| 4105 | decoded = BUF_BEG_ADDR (XBUFFER (conversion_buffer)); | 4107 | decoded = BUF_BEG_ADDR (XBUFFER (conversion_buffer)); |
| 4106 | inserted = BUF_Z_BYTE (XBUFFER (conversion_buffer)); | 4108 | inserted = (BUF_Z_BYTE (XBUFFER (conversion_buffer)) |
| 4109 | - BUF_BEG_BYTE (XBUFFER (conversion_buffer))); | ||
| 4107 | 4110 | ||
| 4108 | /* Compare the beginning of the converted string with the buffer | 4111 | /* Compare the beginning of the converted string with the buffer |
| 4109 | text. */ | 4112 | text. */ |
| @@ -4176,12 +4179,15 @@ actually used. */) | |||
| 4176 | } | 4179 | } |
| 4177 | /* Insert from the file at the proper position. */ | 4180 | /* Insert from the file at the proper position. */ |
| 4178 | SET_PT_BOTH (temp, same_at_start); | 4181 | SET_PT_BOTH (temp, same_at_start); |
| 4182 | same_at_start_charpos | ||
| 4183 | = buf_bytepos_to_charpos (XBUFFER (conversion_buffer), | ||
| 4184 | same_at_start); | ||
| 4185 | inserted_chars | ||
| 4186 | = (buf_bytepos_to_charpos (XBUFFER (conversion_buffer), | ||
| 4187 | same_at_start + inserted) | ||
| 4188 | - same_at_start_charpos); | ||
| 4179 | insert_from_buffer (XBUFFER (conversion_buffer), | 4189 | insert_from_buffer (XBUFFER (conversion_buffer), |
| 4180 | buf_bytepos_to_charpos (XBUFFER (conversion_buffer), | 4190 | same_at_start_charpos, inserted_chars, 0); |
| 4181 | same_at_start), | ||
| 4182 | buf_bytepos_to_charpos (XBUFFER (conversion_buffer), | ||
| 4183 | same_at_start + inserted), | ||
| 4184 | 0); | ||
| 4185 | /* Set `inserted' to the number of inserted characters. */ | 4191 | /* Set `inserted' to the number of inserted characters. */ |
| 4186 | inserted = PT - temp; | 4192 | inserted = PT - temp; |
| 4187 | 4193 | ||