← Commit list

26895db35

Ron Yorston
Ron Yorston
2024-09-27
SUCCESS Duration: 156s

Subject

ed: fix line insertion before current line. Closes 15081

Binary

No binary (build failed)

Architecture & Compiler Flags

Architecture: x86_64-linux-gnu Compiler: gcc (Ubuntu 11.4.0-1ubuntu1~22.04.3) 11.4.0

—

Build Log

(log yok)

Commit Diff GitHub →

editors/ed.c+2 -0
@@ -345,6 +345,8 @@ static int insertLine(int num, const char *data, int len)
lp->prev->next = newLp;
lp->prev = newLp;
+ if (num <= curNum)
+ curLine = curLine->prev;
lastNum++;
dirty = TRUE;
return setCurNum(num);
testsuite/ed.tests+21 -0
@@ -0,0 +1,21 @@
+#!/bin/sh
+
+. ./testing.sh
+
+# testing "test name" "command" "expected result" "file input" "stdin"
+
+testing "ed insert text before current line" \
+ "ed input" "8\n1\ntext\n2\n3\n4\n13\n" "1\n2\n3\n4\n" '2i
+text
+.
+,p
+w
+q
+'
+
+testing "ed read text before current line" \
+ "ed input" "8\n8\n1\n2\n1\n2\n3\n4\n3\n4\n16\n" "1\n2\n3\n4\n" '2r input
+,p
+w
+q
+'