ed

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

commit 21e629b74ab0765a86290576098c12e5fdda27fa
parent 0e3e318245c9265a6f81e91985b5de3e81205c24
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Sat, 28 Nov 2015 21:06:35 +0100

Avoid use of deflines(1, ...)

This usage is incorrect because in an empty file
we don't have line 1, so it will generate an error
always. In other hand, it is better to check valid
lines in chkglobal only when we are sure that it
is a global command, because we can generate errors
in valid command that accept another default lines.

Diffstat:
Med.c | 4++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/ed.c b/ed.c @@ -734,7 +734,7 @@ docmd() trunc = 1; case 'W': chkprint(0); - deflines(1, lastln); + deflines(nextln(0), lastln); dowrite(getfname(cmdp), trunc); break; case 'r': @@ -881,7 +881,6 @@ chkglobal(void) uflag = 1; skipblank(); - deflines(1, lastln); switch (*cmdp++) { case 'g': @@ -898,6 +897,7 @@ chkglobal(void) --cmdp; return 0; } + deflines(nextln(0), lastln); compile(); ++cmdp; /* skip trailing '/' */