ed: Validate better range for k and z - sbase - suckless unix tools
(HTM) git clone git://git.suckless.org/sbase
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) README
(DIR) LICENSE
---
(DIR) commit 0ae546333bdbf9f489f8a9508711bf5081bff1cc
(DIR) parent 54ccddd2e752372b98e85fce355d0d28e7621f75
(HTM) 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:
M ed.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
---
(DIR) 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");