changeset 4950:145c69e39666

(Fwrite_region): Fix minor bugs in POS arg to awrite.
author Richard M. Stallman <rms@gnu.org>
date Wed, 10 Nov 1993 07:59:21 +0000
parents 4b50104fbdec
children be690aaa7194
files src/fileio.c
diffstat 1 files changed, 9 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/src/fileio.c	Wed Nov 10 07:10:58 1993 +0000
+++ b/src/fileio.c	Wed Nov 10 07:59:21 1993 +0000
@@ -2610,7 +2610,7 @@
   int save_errno;
   unsigned char *fn;
   struct stat st;
-  int tem, tem2;
+  int tem;
   int count = specpdl_ptr - specpdl;
 #ifdef VMS
   unsigned char *fname = 0;	/* If non-0, original filename (must rename) */
@@ -2783,14 +2783,14 @@
     }
   else if (XINT (start) != XINT (end))
     {
-      tem2 = 1;
+      int nwritten = 0;
       if (XINT (start) < GPT)
 	{
 	  register int end1 = XINT (end);
 	  tem = XINT (start);
 	  failure = 0 > a_write (desc, &FETCH_CHAR (tem),
-				 min (GPT, end1) - tem, 1, &annotations);
-	  tem2 += min (GPT, end1) - tem;
+				 min (GPT, end1) - tem, tem, &annotations);
+	  nwritten += min (GPT, end1) - tem;
 	  save_errno = errno;
 	}
 
@@ -2799,14 +2799,15 @@
 	  tem = XINT (start);
 	  tem = max (tem, GPT);
 	  failure = 0 > a_write (desc, &FETCH_CHAR (tem), XINT (end) - tem,
-				 tem2, &annotations);
-	  tem2 += XINT (end) - tem;
+				 tem, &annotations);
+	  nwritten += XINT (end) - tem;
 	  save_errno = errno;
 	}
-      if (tem2 == 1)
+
+      if (nwritten == 0)
 	{
 	  /* If file was empty, still need to write the annotations */
-	  failure = 0 > a_write (desc, "", 0, 1, &annotations);
+	  failure = 0 > a_write (desc, "", 0, XINT (start), &annotations);
 	  save_errno = errno;
 	}
     }