comparison src/fileio.c @ 7595:9f0893928a4d

(Finsert_file_contents): Declare buffer as unsigned char. When comparing with file size convert same_at_start to distance to buffer start. If the file matches the buffer contents truncate the buffer to the size of the file.
author Richard M. Stallman <rms@gnu.org>
date Fri, 20 May 1994 23:14:58 +0000
parents 69f20f10799a
children f93e2ddcf8c2
comparison
equal deleted inserted replaced
7594:23edba0a5c5e 7595:9f0893928a4d
2692 break; 2692 break;
2693 } 2693 }
2694 immediate_quit = 0; 2694 immediate_quit = 0;
2695 /* If the file matches the buffer completely, 2695 /* If the file matches the buffer completely,
2696 there's no need to replace anything. */ 2696 there's no need to replace anything. */
2697 if (same_at_start == st.st_size) 2697 if (same_at_start - BEGV == st.st_size)
2698 { 2698 {
2699 close (fd); 2699 close (fd);
2700 specpdl_ptr--; 2700 specpdl_ptr--;
2701 /* Truncate the buffer to the size of the file. */
2702 del_range_1 (same_at_start, same_at_end, 0);
2701 goto handled; 2703 goto handled;
2702 } 2704 }
2703 immediate_quit = 1; 2705 immediate_quit = 1;
2704 QUIT; 2706 QUIT;
2705 /* Count how many chars at the end of the file 2707 /* Count how many chars at the end of the file