ed

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

commit f37932bc4091a70b98fdf49dc76814bcec8ab2f5
parent 9998c75785e816148cc95f3b0032d14b53946d07
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Thu Dec 10 11:57:36 +0100

Save last command in docmd()

In global commands (and in the rest like an extension) & means repeat
last command, so a good aproach is to save all the parameters of the
last command and call the command function with this parameters.

Diffstat:
ed.c | 22++++++++++++++--------
1 file changed, 14 insertions(+), 8 deletions(-)
diff --git a/ed.c b/ed.c @@ -719,13 +719,15 @@ execsh(void) } static void -docmd(char cmd) +docmd(char c) { - char c, *s; - int num, trunc, line3; - static int lline1, lline2, lline3; - static int ocmd, oline1, oline2, oline3; + char *s; + int cmd, num, trunc, lline1, lline2; + static int ocmd, oline1, oline2, line3; + lline1 = line1; + lline2 = line2; + cmd = c; repeat: trunc = pflag = 0; switch (cmd) { @@ -735,7 +737,6 @@ repeat: cmd = ocmd; line1 = oline1; line2 = oline2; - line3 = oline3; goto repeat; case '!': execsh(); @@ -807,7 +808,7 @@ repeat: break; case 'm': deflines(curln, curln); - if (!address(&line3)) + if (c != '&' && !address(&line3)) line3 = curln; chkprint(1); move(line3); @@ -900,11 +901,16 @@ repeat: } if (!pflag) - return; + goto update_last_cmd; line1 = line2 = curln; print: doprint(); + +update_last_cmd: + oline1 = lline1; + oline2 = lline2; + ocmd = cmd; } static int