sbase

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

commit ae50e31d532df74e97d2e0525d0f282cf3377142
parent 0190f5e7bf8985af3ed768f7d17d192c23beb5d1
Author: Roberto E. Vargas Caballero <k0ga@shike2.net>
Date:   Mon,  8 Dec 2025 17:01:30 +0100

ed: Allow z commands with no address

When a single z commit is executed then nlines == 0, and
we don't have a value for the line where scroll and this
is why we have to call deflines() to setup the default
value.

Diffstat:
Med.c | 3++-
Atests/0006-ed.sh | 14++++++++++++++
2 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/ed.c b/ed.c @@ -1385,13 +1385,14 @@ repeat: join(); break; case 'z': - if (nlines != 1) + if (nlines > 1) goto bad_address; if (isdigit(back(input()))) num = getnum(); else num = 24; chkprint(1); + deflines(curln, curln); scroll(num); break; case 'k': diff --git a/tests/0006-ed.sh b/tests/0006-ed.sh @@ -0,0 +1,14 @@ +#!/bin/sh + +../ed <<EOF | (read a && read b && test $a-$b == 1-2) +0a +1 +2 +3 +4 +5 +6 +. +1z1 +z1 +EOF