changeset 38619:879c6b736b9f

(Finsert_file_contents): Don't treat a return value of 0 from emacs_read as an IO error.
author Gerd Moellmann <gerd@gnu.org>
date Tue, 31 Jul 2001 14:40:50 +0000
parents c41fb9fae096
children fb9c902157a4
files src/fileio.c
diffstat 1 files changed, 5 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/fileio.c	Tue Jul 31 14:04:50 2001 +0000
+++ b/src/fileio.c	Tue Jul 31 14:40:50 2001 +0000
@@ -3863,14 +3863,18 @@
 	  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