emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] /srv/bzr/emacs/trunk r111221: * fileio.c (Finsert_file_con


From: Paul Eggert
Subject: [Emacs-diffs] /srv/bzr/emacs/trunk r111221: * fileio.c (Finsert_file_contents): Don't put tail into head area,
Date: Thu, 13 Dec 2012 11:35:10 -0800
User-agent: Bazaar (2.5.0)

------------------------------------------------------------
revno: 111221
committer: Paul Eggert <address@hidden>
branch nick: trunk
timestamp: Thu 2012-12-13 11:35:10 -0800
message:
  * 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.
modified:
  src/ChangeLog
  src/fileio.c
=== modified file 'src/ChangeLog'
--- a/src/ChangeLog     2012-12-13 16:55:28 +0000
+++ b/src/ChangeLog     2012-12-13 19:35:10 +0000
@@ -1,5 +1,10 @@
 2012-12-13  Paul Eggert  <address@hidden>
 
+       * 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.

=== modified file 'src/fileio.c'
--- a/src/fileio.c      2012-12-13 05:29:15 +0000
+++ b/src/fileio.c      2012-12-13 19:35:10 +0000
@@ -3487,12 +3487,14 @@
              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;
                    }
                }
 


reply via email to

[Prev in Thread] Current Thread [Next in Thread]