comparison src/fileio.c @ 24877:f0aa6266cd12

(Finsert_file_contents): In the case of REPALCE, call del_range_byte instead off del_range_1, set `inserted' to the number of characters actually inserted.
author Kenichi Handa <handa@m17n.org>
date Tue, 22 Jun 1999 23:25:16 +0000
parents 31a648f12180
children 804955a16819
comparison
equal deleted inserted replaced
24876:89317671e948 24877:f0aa6266cd12
3861 { 3861 {
3862 free (conversion_buffer); 3862 free (conversion_buffer);
3863 close (fd); 3863 close (fd);
3864 specpdl_ptr--; 3864 specpdl_ptr--;
3865 /* Truncate the buffer to the size of the file. */ 3865 /* Truncate the buffer to the size of the file. */
3866 del_range_1 (same_at_start, same_at_end, 0); 3866 del_range_byte (same_at_start, same_at_end, 0);
3867 inserted = 0;
3867 goto handled; 3868 goto handled;
3868 } 3869 }
3869 3870
3870 /* Extend the start of non-matching text area to multibyte 3871 /* Extend the start of non-matching text area to multibyte
3871 character boundary. */ 3872 character boundary. */
3903 3904
3904 /* Replace the chars that we need to replace, 3905 /* Replace the chars that we need to replace,
3905 and update INSERTED to equal the number of bytes 3906 and update INSERTED to equal the number of bytes
3906 we are taking from the file. */ 3907 we are taking from the file. */
3907 inserted -= (Z_BYTE - same_at_end) + (same_at_start - BEG_BYTE); 3908 inserted -= (Z_BYTE - same_at_end) + (same_at_start - BEG_BYTE);
3908 del_range_byte (same_at_start, same_at_end, 0); 3909
3909 if (same_at_end != same_at_start) 3910 if (same_at_end != same_at_start)
3910 SET_PT_BOTH (GPT, GPT_BYTE); 3911 {
3912 del_range_byte (same_at_start, same_at_end, 0);
3913 temp = GPT;
3914 same_at_start = GPT_BYTE;
3915 }
3911 else 3916 else
3912 { 3917 {
3913 /* Insert from the file at the proper position. */
3914 temp = BYTE_TO_CHAR (same_at_start); 3918 temp = BYTE_TO_CHAR (same_at_start);
3915 SET_PT_BOTH (temp, same_at_start); 3919 }
3916 } 3920 /* Insert from the file at the proper position. */
3917 3921 SET_PT_BOTH (temp, same_at_start);
3918 insert_1 (conversion_buffer + same_at_start - BEG_BYTE, inserted, 3922 insert_1 (conversion_buffer + same_at_start - BEG_BYTE, inserted,
3919 0, 0, 0); 3923 0, 0, 0);
3924 /* Set `inserted' to the number of inserted characters. */
3925 inserted = PT - temp;
3920 3926
3921 free (conversion_buffer); 3927 free (conversion_buffer);
3922 close (fd); 3928 close (fd);
3923 specpdl_ptr--; 3929 specpdl_ptr--;
3924 3930