sbase

suckless unix tools
git clone git://git.suckless.org/sbase
Log | Files | Refs | README | LICENSE

commit 0ae546333bdbf9f489f8a9508711bf5081bff1cc
parent 54ccddd2e752372b98e85fce355d0d28e7621f75
Author: Roberto E. Vargas Caballero <k0ga@shike2.net>
Date:   Mon,  3 Nov 2025 13:06:56 +0100

ed: Validate better range for k and z

The k and z commands require 1 and only one address
so checking for != 1 catches the unsual case when
nlines == 0, that only can happen when we are editing
an empty file.

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

diff --git a/ed.c b/ed.c @@ -1383,7 +1383,7 @@ repeat: join(); break; case 'z': - if (nlines > 1) + if (nlines != 1) goto bad_address; if (isdigit(back(input()))) num = getnum(); @@ -1393,7 +1393,7 @@ repeat: scroll(num); break; case 'k': - if (nlines > 1) + if (nlines != 1) goto bad_address; if (!islower(c = input())) error("invalid mark character");