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.
This commit is contained in:
parent
504dde1373
commit
9781959581
11
ed.c
11
ed.c
|
@ -854,14 +854,19 @@ scroll(int num)
|
||||||
static void
|
static void
|
||||||
copy(int where)
|
copy(int where)
|
||||||
{
|
{
|
||||||
int i;
|
|
||||||
|
|
||||||
if (!line1)
|
if (!line1)
|
||||||
error("incorrect address");
|
error("incorrect address");
|
||||||
curln = where;
|
curln = where;
|
||||||
|
|
||||||
for (i = line1; i <= line2; ++i)
|
while (line1 <= line2) {
|
||||||
inject(gettxt(i), AFTER);
|
inject(gettxt(line1), AFTER);
|
||||||
|
if (line2 >= curln)
|
||||||
|
line2 = nextln(line2);
|
||||||
|
line1 = nextln(line1);
|
||||||
|
if (line1 >= curln)
|
||||||
|
line1 = nextln(line1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
Loading…
Reference in New Issue
Block a user