Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ed: implement ';' addressing mode #792

Merged
merged 1 commit into from
Nov 9, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 8 additions & 13 deletions bin/ed
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,7 @@ use Getopt::Std qw(getopts);

use constant A_NOMATCH => -1;
use constant A_NOPAT => -2;
use constant A_ALL => -3;
use constant A_PATTERN => -4;
use constant A_PATTERN => -3;

use constant E_ADDREXT => 'unexpected address';
use constant E_ADDRBAD => 'invalid address';
Expand Down Expand Up @@ -110,7 +109,7 @@ my $NO_QUESTIONS_MODE = 0;
my $PRINT_NUM = 1;
my $PRINT_BIN = 2;

our $VERSION = '0.13';
our $VERSION = '0.14';

my @ESC = (
'\\000', '\\001', '\\002', '\\003', '\\004', '\\005', '\\006', '\\a',
Expand Down Expand Up @@ -917,16 +916,14 @@ sub edParse {
if (defined($adrs[0]) && ($adrs[0] == A_NOPAT || $adrs[0] == A_NOMATCH)) {
return 1;
}
if (defined($adrs[0]) && $adrs[0] == A_ALL) {
$adrs[0] = 1;
$adrs[1] = maxline();
} elsif (s/\A,//) { # ',' and '%' cannot be combined
if (s/\A([,;\%])//) {
my $sep = $1;
return 0 if $sep eq '%' && defined($adrs[0]);
$adrs[1] = getAddr();
if (defined($adrs[1]) && $adrs[1] < 0) {
return 1;
}
return 1 if defined($adrs[1]) && $adrs[1] < 0;

unless (defined $adrs[0]) {
$adrs[0] = 1;
$adrs[0] = $sep eq ';' ? $CurrentLineNum : 1;
$adrs[1] = maxline() unless defined $adrs[1];
}
}
Expand Down Expand Up @@ -977,8 +974,6 @@ sub getAddr {
foreach my $c (split //, $1) {
$n += $c eq '+' ? 1 : -1;
}
} elsif (s/\A\%//) {
$n = A_ALL;
} elsif (s/\A([0-9]+)//) { # '10' == 10
$n = $1;
} elsif (s/\A\.//) { # '.' == current line
Expand Down
Loading