Skip to content

Commit

Permalink
Merge pull request #354 from mknos/ed-rtidy
Browse files Browse the repository at this point in the history
ed: simplify code for r command
  • Loading branch information
briandfoy authored Nov 30, 2023
2 parents 282619b + 1746b2b commit ca92c4c
Showing 1 changed file with 3 additions and 10 deletions.
13 changes: 3 additions & 10 deletions bin/ed
Original file line number Diff line number Diff line change
Expand Up @@ -726,16 +726,10 @@ sub edEdit {
push(@lines,@tmp_lines);
$CurrentLineNum = maxline();
} elsif ($adrs[0] == 0) {
shift(@lines); # get rid of undefined line
unshift(@lines,@tmp_lines);
unshift(@lines,undef); # put 0 line back
splice @lines, 1, 0, @tmp_lines;
$CurrentLineNum = scalar(@tmp_lines);
} else {
shift(@lines); # get rid 0 line
@tmp_lines2 = splice(@lines,0,$adrs[0]);
unshift(@lines,@tmp_lines);
unshift(@lines,@tmp_lines2);
unshift(@lines,undef); # put 0 line back
splice @lines, $adrs[0] + 1, 0, @tmp_lines;
$CurrentLineNum = $adrs[0] + scalar(@tmp_lines);
}

Expand All @@ -747,8 +741,7 @@ sub edEdit {
return;
}

@lines = @tmp_lines;
unshift(@lines,undef); # line 0 is not used
@lines = (undef, @tmp_lines);
$NeedToSave = 0;
$CurrentLineNum = maxline();
}
Expand Down

0 comments on commit ca92c4c

Please sign in to comment.