commit 13e0b6c60596cbcbc83fc99a330044d310878f69
parent 25f87bc360cb6c21f5ffcb6e46d2876a2ae52ee6
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date: Mon, 14 Dec 2015 15:18:33 +0100
Do not modify curln with w commands
POSIX declares that dot is not modified by w commands
Diffstat:
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/ed.c b/ed.c
@@ -561,11 +561,12 @@ static void
dowrite(char *fname, int trunc)
{
FILE *fp;
- int i;
+ int i, line;
if (!(fp = fopen(fname, (trunc) ? "w" : "a")))
error("input/output error");
+ line = curln;
for (i = line1; i <= line2; ++i)
fputs(gettxt(i), fp);
@@ -574,6 +575,7 @@ dowrite(char *fname, int trunc)
error("input/output error");
strcpy(savfname, fname);
modflag = 0;
+ curln = line;
}
static void