Skip to content

Commit

Permalink
ed: support '^' address (#797)
Browse files Browse the repository at this point in the history
* For greater compatibility with BSD, either '-' or '^' can be specified to mean CurrentLine - 1
* GNU ed 1.19 doesn't support '^'; I didn't test if v1.20 supports it
* Standards document mentions '^' is considered a historical feature; however POSIX does not prohibit it [1]

1. https://pubs.opengroup.org/onlinepubs/9699919799/utilities/ed.html
  • Loading branch information
mknos authored Nov 12, 2024
1 parent 707ad88 commit 9813b88
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions bin/ed
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ my $NO_QUESTIONS_MODE = 0;
my $PRINT_NUM = 1;
my $PRINT_BIN = 2;

our $VERSION = '0.15';
our $VERSION = '0.16';

my @ESC = (
'\\000', '\\001', '\\002', '\\003', '\\004', '\\005', '\\006', '\\a',
Expand Down Expand Up @@ -963,7 +963,7 @@ sub edParse {

sub getAddr {
my $n;
if (s/\A([\-\+]+)//) { # '++--' == current+0
if (s/\A([\-\^\+]+)//) { # '++--' == current+0
$n = $CurrentLineNum;
foreach my $c (split //, $1) {
$n += $c eq '+' ? 1 : -1;
Expand Down

0 comments on commit 9813b88

Please sign in to comment.