summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGerd Moellmann <gerd@gnu.org>2001-07-31 14:40:50 +0000
committerGerd Moellmann <gerd@gnu.org>2001-07-31 14:40:50 +0000
commit2bd2273e7b54afb820a5897f3c1f368a64dfca97 (patch)
tree33a09d368915d8e6aac2756f8c081118f3f54b52
parent7642acca1e2fdbca53a065065d9d28c7c8de40d0 (diff)
downloademacs-2bd2273e7b54afb820a5897f3c1f368a64dfca97.tar.gz
(Finsert_file_contents): Don't treat a return value
of 0 from emacs_read as an IO error.
-rw-r--r--src/fileio.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/fileio.c b/src/fileio.c
index e09fac7e79b..a8edc2f75b7 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -3863,14 +3863,18 @@ actually used.")
while (total_read < trial)
{
nread = emacs_read (fd, buffer + total_read, trial - total_read);
- if (nread <= 0)
+ if (nread < 0)
error ("IO error reading %s: %s",
XSTRING (orig_filename)->data, emacs_strerror (errno));
+ else if (nread == 0)
+ break;
total_read += nread;
}
+
/* Scan this bufferful from the end, comparing with
the Emacs buffer. */
bufpos = total_read;
+
/* Compare with same_at_start to avoid counting some buffer text
as matching both at the file's beginning and at the end. */
while (bufpos > 0 && same_at_end > same_at_start