From 13e0b6c60596cbcbc83fc99a330044d310878f69 Mon Sep 17 00:00:00 2001 From: "Roberto E. Vargas Caballero" Date: Mon, 14 Dec 2015 15:18:33 +0100 Subject: [PATCH] Do not modify curln with w commands POSIX declares that dot is not modified by w commands --- ed.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ed.c b/ed.c index 4878654..b6b74a2 100644 --- 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