Skip to content

Commit

Permalink
Merge pull request #156 from mknos/ed-n-cmd
Browse files Browse the repository at this point in the history
ed: numbered print command
  • Loading branch information
briandfoy committed May 8, 2023
2 parents cd68bf5 + 235dda8 commit d074f50
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion bin/ed
Expand Up @@ -235,6 +235,8 @@ while(<>) {
&edQuit($NO_QUESTIONS_MODE);
} elsif ($command eq 'h') {
print("$Error\n") if (defined $Error);
} elsif ($command eq 'n') {
edPrint(1);
}

} else {
Expand All @@ -249,6 +251,7 @@ while(<>) {
#

sub edPrint {
my $do_lineno = shift;

$adrs[0] = $CurrentLineNum unless (defined($adrs[0]));
$adrs[1] = $adrs[0] unless (defined($adrs[1]));
Expand All @@ -264,6 +267,7 @@ sub edPrint {
}

for my $i ($adrs[0]..$adrs[1]) {
print "$i\t" if $do_lineno;
print "$lines[$i]";
}

Expand Down Expand Up @@ -757,7 +761,7 @@ sub edParse {
(([+-])?(\d+))? # [+]num | -num
(([\+]+)|([-^]+))? # + | -
)?
([acdeEfhipPqQrswW=])? # command char
([acdeEfhinpPqQrswW=])? # command char
\s*(\S+)? # argument (filename, etc.)
)$/x);

Expand Down Expand Up @@ -1056,6 +1060,10 @@ Display last error
Insert text
=item n
Print from buffer with line number prefix
=item P
=item p
Expand Down

0 comments on commit d074f50

Please sign in to comment.