ed

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

commit 7cbfcd7c0bb79bae25cc05deddaa1bf4e684ec6f
parent 2ddf19b7be2f1f680c52341017f6d83d56ae106a
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Thu Dec 10 20:01:40 +0100

Fix commands in the form g/re/

When a global command has no command list then
it must print the matching line, not the next line,
like is done in normal commands. The only way of
doing it is adding a new global flag which
indicates to docmd() in which state we are.

Diffstat:
ed.c | 9+++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/ed.c b/ed.c @@ -40,7 +40,7 @@ char savfname[FILENAME_MAX]; char tmpname[FILENAME_MAX]; size_t sizetxt, memtxt; int scratch; -int pflag, modflag, uflag; +int pflag, modflag, uflag, gflag; size_t csize; char *cmdline; char *ocmdline; @@ -771,8 +771,10 @@ repeat: case '!': execsh(); break; + case EOF: case '\n': - deflines(curln+1, curln+1); + num = gflag ? curln : curln+1; + deflines(num, num); pflag = 'p'; goto print; case 'l': @@ -954,6 +956,7 @@ chkglobal(void) int delim, c, nmatch, i; uflag = 1; + gflag = 0; skipblank(); switch (c = input()) { @@ -971,6 +974,7 @@ chkglobal(void) back(c); return 0; } + gflag = 1; deflines(nextln(0), lastln); delim = input(); compile(delim); @@ -989,6 +993,7 @@ doglobal(void) skipblank(); cmdsiz = 0; + gflag = 1; if (uflag) chkprint(0);