From c975dd7a6574bb95aabc88977a6dbb7155e1df8b Mon Sep 17 00:00:00 2001 From: "Richard M. Stallman" Date: Wed, 10 Nov 1993 07:59:21 +0000 Subject: [PATCH] (Fwrite_region): Fix minor bugs in POS arg to awrite. --- src/fileio.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/fileio.c b/src/fileio.c index 129438fa07..4b3a60e904 100644 --- a/src/fileio.c +++ b/src/fileio.c @@ -2610,7 +2610,7 @@ to the file, instead of any buffer contents, and END is ignored.") 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 @@ to the file, instead of any buffer contents, and END is ignored.") } 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 @@ to the file, instead of any buffer contents, and END is ignored.") 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; } } -- 2.20.1