aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard M. Stallman1993-11-10 07:59:21 +0000
committerRichard M. Stallman1993-11-10 07:59:21 +0000
commitc975dd7a6574bb95aabc88977a6dbb7155e1df8b (patch)
tree576652c6576447dc25e49159ecda7d5c2d85f1e2
parentb5e59c0380f2093f135d8c6b86610a877a87676d (diff)
downloademacs-c975dd7a6574bb95aabc88977a6dbb7155e1df8b.tar.gz
emacs-c975dd7a6574bb95aabc88977a6dbb7155e1df8b.zip
(Fwrite_region): Fix minor bugs in POS arg to awrite.
-rw-r--r--src/fileio.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/src/fileio.c b/src/fileio.c
index 129438fa07a..4b3a60e904c 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.")
2610 int save_errno; 2610 int save_errno;
2611 unsigned char *fn; 2611 unsigned char *fn;
2612 struct stat st; 2612 struct stat st;
2613 int tem, tem2; 2613 int tem;
2614 int count = specpdl_ptr - specpdl; 2614 int count = specpdl_ptr - specpdl;
2615#ifdef VMS 2615#ifdef VMS
2616 unsigned char *fname = 0; /* If non-0, original filename (must rename) */ 2616 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.")
2783 } 2783 }
2784 else if (XINT (start) != XINT (end)) 2784 else if (XINT (start) != XINT (end))
2785 { 2785 {
2786 tem2 = 1; 2786 int nwritten = 0;
2787 if (XINT (start) < GPT) 2787 if (XINT (start) < GPT)
2788 { 2788 {
2789 register int end1 = XINT (end); 2789 register int end1 = XINT (end);
2790 tem = XINT (start); 2790 tem = XINT (start);
2791 failure = 0 > a_write (desc, &FETCH_CHAR (tem), 2791 failure = 0 > a_write (desc, &FETCH_CHAR (tem),
2792 min (GPT, end1) - tem, 1, &annotations); 2792 min (GPT, end1) - tem, tem, &annotations);
2793 tem2 += min (GPT, end1) - tem; 2793 nwritten += min (GPT, end1) - tem;
2794 save_errno = errno; 2794 save_errno = errno;
2795 } 2795 }
2796 2796
@@ -2799,14 +2799,15 @@ to the file, instead of any buffer contents, and END is ignored.")
2799 tem = XINT (start); 2799 tem = XINT (start);
2800 tem = max (tem, GPT); 2800 tem = max (tem, GPT);
2801 failure = 0 > a_write (desc, &FETCH_CHAR (tem), XINT (end) - tem, 2801 failure = 0 > a_write (desc, &FETCH_CHAR (tem), XINT (end) - tem,
2802 tem2, &annotations); 2802 tem, &annotations);
2803 tem2 += XINT (end) - tem; 2803 nwritten += XINT (end) - tem;
2804 save_errno = errno; 2804 save_errno = errno;
2805 } 2805 }
2806 if (tem2 == 1) 2806
2807 if (nwritten == 0)
2807 { 2808 {
2808 /* If file was empty, still need to write the annotations */ 2809 /* If file was empty, still need to write the annotations */
2809 failure = 0 > a_write (desc, "", 0, 1, &annotations); 2810 failure = 0 > a_write (desc, "", 0, XINT (start), &annotations);
2810 save_errno = errno; 2811 save_errno = errno;
2811 } 2812 }
2812 } 2813 }