From 5c3e23cd18c3508d975b259c6615f0900fcdcb47 Mon Sep 17 00:00:00 2001 From: Michael Mikonos <127171689+mknos@users.noreply.github.com> Date: Sun, 16 Jun 2024 18:25:39 +0800 Subject: [PATCH] ed: 2-address insert command * When testing against GNU and OpenBSD versions, "i" command was with a 2-address prefix was treated as invalid * Be compatible and treat effective address as 2nd address if 2 were specified * ed commands "a" and "i" are both handled in edInsert(), so this patch covers both * test1: "1,2i" --> 2i * test2: ",2i" --> 2i * test3: "1,2a" --> 2a * test4: ",2a" --> 2a --- bin/ed | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/bin/ed b/bin/ed index 6b8e75a6..995f8423 100755 --- a/bin/ed +++ b/bin/ed @@ -749,14 +749,13 @@ sub edInsert { my $append = shift; my(@tmp_lines); - if (defined($adrs[1])) { - edWarn(E_ADDREXT); - return; - } if (defined($args[0])) { edWarn(E_ARGEXT); return; } + if (defined($adrs[1])) { + $adrs[0] = $adrs[1]; + } if (!defined($adrs[0])) { $adrs[0] = $CurrentLineNum; }