From 0cd385d16413e631222cdd73d141d4cb72b854a1 Mon Sep 17 00:00:00 2001 From: "Roberto E. Vargas Caballero" Date: Mon, 14 Dec 2015 15:38:46 +0100 Subject: [PATCH] Restore state of buffer in errors When a error occurs it is important to remove all the modifications done by the offending command and restore the value of dot to the state before of executing the command. --- ed.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ed.c b/ed.c index b6b74a2..1944fae 100644 --- a/ed.c +++ b/ed.c @@ -62,6 +62,9 @@ static char *lastmatch; static struct undo udata; static int newcmd; + +static void undo(void); + static void error(char *msg) { @@ -80,6 +83,9 @@ error(char *msg) /* nothing */; } + if (!newcmd) + undo(); + curln = ocurln; longjmp(savesp, 1); }