diff options
| author | Paul Eggert | 2012-12-13 11:35:10 -0800 |
|---|---|---|
| committer | Paul Eggert | 2012-12-13 11:35:10 -0800 |
| commit | 4c95c9a594ade5a642e32be77ff58b60a89b7a7a (patch) | |
| tree | 8bd6a1b65c19498962b63f6bac7ce610b32675d4 | |
| parent | ce0440ff9661d84a7632379923af8449986ca56e (diff) | |
| download | emacs-4c95c9a594ade5a642e32be77ff58b60a89b7a7a.tar.gz emacs-4c95c9a594ade5a642e32be77ff58b60a89b7a7a.zip | |
* fileio.c (Finsert_file_contents): Don't put tail into head area,
as that confuses set-auto-coding, so insist on the head-read
returning the full 1024 bytes. Let lseek compute the tail offset;
less work for us. Do not ignore I/O errors when reading the tail.
| -rw-r--r-- | src/ChangeLog | 5 | ||||
| -rw-r--r-- | src/fileio.c | 8 |
2 files changed, 10 insertions, 3 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 939fd61c87f..c64416a6454 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,5 +1,10 @@ | |||
| 1 | 2012-12-13 Paul Eggert <eggert@cs.ucla.edu> | 1 | 2012-12-13 Paul Eggert <eggert@cs.ucla.edu> |
| 2 | 2 | ||
| 3 | * fileio.c (Finsert_file_contents): Don't put tail into head area, | ||
| 4 | as that confuses set-auto-coding, so insist on the head-read | ||
| 5 | returning the full 1024 bytes. Let lseek compute the tail offset; | ||
| 6 | less work for us. Do not ignore I/O errors when reading the tail. | ||
| 7 | |||
| 3 | * xdisp.c: Minor style fixes. | 8 | * xdisp.c: Minor style fixes. |
| 4 | (init_iterator): Hoist assignment out of if-expression. | 9 | (init_iterator): Hoist assignment out of if-expression. |
| 5 | (markpos_of_region): Callers now test for sign, not for -1. | 10 | (markpos_of_region): Callers now test for sign, not for -1. |
diff --git a/src/fileio.c b/src/fileio.c index 874162c5bb6..c7df87bcdda 100644 --- a/src/fileio.c +++ b/src/fileio.c | |||
| @@ -3487,12 +3487,14 @@ variable `last-coding-system-used' to the coding system actually used. */) | |||
| 3487 | else | 3487 | else |
| 3488 | { | 3488 | { |
| 3489 | nread = emacs_read (fd, read_buf, 1024); | 3489 | nread = emacs_read (fd, read_buf, 1024); |
| 3490 | if (nread >= 0) | 3490 | if (nread == 1024) |
| 3491 | { | 3491 | { |
| 3492 | if (lseek (fd, st.st_size - (1024 * 3), SEEK_SET) < 0) | 3492 | int ntail; |
| 3493 | if (lseek (fd, - (1024 * 3), SEEK_END) < 0) | ||
| 3493 | report_file_error ("Setting file position", | 3494 | report_file_error ("Setting file position", |
| 3494 | Fcons (orig_filename, Qnil)); | 3495 | Fcons (orig_filename, Qnil)); |
| 3495 | nread += emacs_read (fd, read_buf + nread, 1024 * 3); | 3496 | ntail = emacs_read (fd, read_buf + nread, 1024 * 3); |
| 3497 | nread = ntail < 0 ? ntail : nread + ntail; | ||
| 3496 | } | 3498 | } |
| 3497 | } | 3499 | } |
| 3498 | 3500 | ||