2012-12-13 Paul Eggert <eggert@cs.ucla.edu>
+ * 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.
+
* xdisp.c: Minor style fixes.
(init_iterator): Hoist assignment out of if-expression.
(markpos_of_region): Callers now test for sign, not for -1.
else
{
nread = emacs_read (fd, read_buf, 1024);
- if (nread >= 0)
+ if (nread == 1024)
{
- if (lseek (fd, st.st_size - (1024 * 3), SEEK_SET) < 0)
+ int ntail;
+ if (lseek (fd, - (1024 * 3), SEEK_END) < 0)
report_file_error ("Setting file position",
Fcons (orig_filename, Qnil));
- nread += emacs_read (fd, read_buf + nread, 1024 * 3);
+ ntail = emacs_read (fd, read_buf + nread, 1024 * 3);
+ nread = ntail < 0 ? ntail : nread + ntail;
}
}