sbase

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

commit 9781959581c4c150decd0c7cbc325da23eb009d3
parent 504dde13739b2f92e4d9b0a9773408c86506c12a
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Sun,  4 Mar 2018 17:08:14 +0100

Fix copy()

Copy was using directly the line numbers and incrementing them
without calling nextln(). It also didn't worry about how
line numbers are modified when we insert new lines.

Diffstat:
Med.c | 11++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/ed.c b/ed.c @@ -854,14 +854,19 @@ scroll(int num) static void copy(int where) { - int i; if (!line1) error("incorrect address"); curln = where; - for (i = line1; i <= line2; ++i) - inject(gettxt(i), AFTER); + while (line1 <= line2) { + inject(gettxt(line1), AFTER); + if (line2 >= curln) + line2 = nextln(line2); + line1 = nextln(line1); + if (line1 >= curln) + line1 = nextln(line1); + } } static void