]> git.eshelyaron.com Git - emacs.git/commitdiff
* fileio.c (Finsert_file_contents): Don't put tail into head area,
authorPaul Eggert <eggert@cs.ucla.edu>
Thu, 13 Dec 2012 19:35:10 +0000 (11:35 -0800)
committerPaul Eggert <eggert@cs.ucla.edu>
Thu, 13 Dec 2012 19:35:10 +0000 (11:35 -0800)
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.

src/ChangeLog
src/fileio.c

index 939fd61c87f661ea031667724d0f1769133abc9e..c64416a645460b96c501070833b9c256b82eb9ac 100644 (file)
@@ -1,5 +1,10 @@
 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.
index 874162c5bb62faf6df0049b4ef0203b1a6f476eb..c7df87bcddab77d82ad93846b5b44b61d0ffeb51 100644 (file)
@@ -3487,12 +3487,14 @@ variable `last-coding-system-used' to the coding system actually used.  */)
              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;
                    }
                }