ed

simple ed
git clone git://git.2f30.org/ed.git
Log | Files | Refs

commit 2cb6506991da516f7a9fda8f08d21379aaa56495
parent b650b37d083f2db4efe9bb5e2b3ea53530ba04d4
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Sun Dec 13 21:51:09 +0100

Restore curln in undo()

Undo() must restore curln to the value that it had
at the beginning of the command which is being
undo.

Diffstat:
ed.c | 10+++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/ed.c b/ed.c @@ -41,7 +41,7 @@ char *lastre; int optverbose, optprompt, exstatus, optdiag = 1; int marks['z' - 'a']; int nlines, line1, line2; -int curln, lastln; +int curln, lastln, ocurln; jmp_buf savesp; char *lasterr; size_t idxsize, lastidx; @@ -239,8 +239,10 @@ relink(int to1, int from1, int from2, int to2) { struct link *p; - if (newcmd) + if (newcmd) { clearundo(); + udata.curln = ocurln; + } if (udata.nr >= udata.cap) { size_t siz = (udata.cap + 10) * sizeof(struct link); if ((p = realloc(udata.vec, siz)) == NULL) @@ -274,6 +276,7 @@ undo(void) free(udata.vec); udata.vec = NULL; udata.cap = 0; + curln = udata.curln; } static void @@ -1084,7 +1087,7 @@ repeat: case 'u': if (nlines > 0) goto bad_address; - chkprint(0); + chkprint(1); undo(); break; case 's': @@ -1364,6 +1367,7 @@ main(int argc, char *argv[]) for (;;) { newcmd = 1; + ocurln = curln; cmdsiz = 0; repidx = -1; if (optprompt)