testing/edward: upgrade to 1.1.0

This commit is contained in:
Sören Tempel 2024-09-04 19:47:32 +02:00 committed by Sören Tempel
parent ec6184ce2b
commit 985053b2f1
3 changed files with 4 additions and 133 deletions

View file

@ -1,60 +0,0 @@
From 7f85285e784002921f22db29f6724f10bbea1182 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C3=B6ren=20Tempel?= <soeren+git@soeren-tempel.net>
Date: Thu, 17 Aug 2023 07:16:14 +0200
Subject: [PATCH] editor: fix current address when moving a single line
When moving a single line, we only want to return the destination line.
---
lib/ed/editor.scm | 6 +++++-
tests/integration/move-update-current-on-single-line/cmds | 3 +++
tests/integration/move-update-current-on-single-line/opts | 1 +
.../move-update-current-on-single-line/testdata/input-file | 5 +++++
4 files changed, 14 insertions(+), 1 deletion(-)
create mode 100644 tests/integration/move-update-current-on-single-line/cmds
create mode 100644 tests/integration/move-update-current-on-single-line/opts
create mode 100644 tests/integration/move-update-current-on-single-line/testdata/input-file
diff --git a/lib/ed/editor.scm b/lib/ed/editor.scm
index ccadd0b..9790407 100644
--- a/lib/ed/editor.scm
+++ b/lib/ed/editor.scm
@@ -452,7 +452,11 @@
(buffer-move! buffer sline eline dest-line)
(min
(editor-lines editor)
- (+ dest-line (inc (- eline sline))))))
+ (let ((diff (- eline sline)))
+ (+ dest-line
+ ;; If we moved multiple lines, we need to increment
+ ;; the destination lines by the amount of lines moved.
+ (if (zero? diff) diff (inc diff)))))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
diff --git a/tests/integration/move-update-current-on-single-line/cmds b/tests/integration/move-update-current-on-single-line/cmds
new file mode 100644
index 0000000..34eb4a1
--- /dev/null
+++ b/tests/integration/move-update-current-on-single-line/cmds
@@ -0,0 +1,3 @@
+2m3
+.=
+Q
diff --git a/tests/integration/move-update-current-on-single-line/opts b/tests/integration/move-update-current-on-single-line/opts
new file mode 100644
index 0000000..778c17f
--- /dev/null
+++ b/tests/integration/move-update-current-on-single-line/opts
@@ -0,0 +1 @@
+testdata/input-file
diff --git a/tests/integration/move-update-current-on-single-line/testdata/input-file b/tests/integration/move-update-current-on-single-line/testdata/input-file
new file mode 100644
index 0000000..6392fd1
--- /dev/null
+++ b/tests/integration/move-update-current-on-single-line/testdata/input-file
@@ -0,0 +1,5 @@
+foo
+bar
+baz
+bla
+blubb

View file

@ -1,65 +0,0 @@
From 66979c7d506ab89555cdc281c6ea6f89f92ee87e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C3=B6ren=20Tempel?= <soeren+git@soeren-tempel.net>
Date: Sat, 9 Dec 2023 00:25:10 +0100
Subject: [PATCH] editor: Fix discarding of addrs for cmds expecting a single
addr
Previously, the second address was discarded. That is, the first
was passed to the command. This is, however, incorrect as addresses
must be discarded starting at the beginning of an address list.
From POSIX:
If more than the required number of addresses are provided
to a command, the addresses specified first shall be
evaluated and then discarded until the maximum number of
valid addresses remain, for the specified command.
The addrlst->lpair function also correctly implements this algorithm, it
is just incorrectly implemented in the editor-xexec function. The
editor-exec function is fixed in this commit.
---
lib/ed/editor.scm | 2 +-
tests/integration/discard-first-addr/cmds | 1 +
tests/integration/discard-first-addr/opts | 1 +
tests/integration/discard-first-addr/testdata/input-file | 2 ++
4 files changed, 5 insertions(+), 1 deletion(-)
create mode 100644 tests/integration/discard-first-addr/cmds
create mode 100644 tests/integration/discard-first-addr/opts
create mode 100644 tests/integration/discard-first-addr/testdata/input-file
diff --git a/lib/ed/editor.scm b/lib/ed/editor.scm
index 9790407..f5a7f73 100644
--- a/lib/ed/editor.scm
+++ b/lib/ed/editor.scm
@@ -674,7 +674,7 @@
;; or a line pair (depending on default address).
(line-addr (if (or (not line-pair) (range? default-addr))
line-pair
- (car line-pair))))
+ (cdr line-pair))))
(editor-xexec editor line-addr cmd))))
;;> Execute given `cmd` using given `editor` state on the address
diff --git a/tests/integration/discard-first-addr/cmds b/tests/integration/discard-first-addr/cmds
new file mode 100644
index 0000000..752f603
--- /dev/null
+++ b/tests/integration/discard-first-addr/cmds
@@ -0,0 +1 @@
+1;/stdout/
diff --git a/tests/integration/discard-first-addr/opts b/tests/integration/discard-first-addr/opts
new file mode 100644
index 0000000..778c17f
--- /dev/null
+++ b/tests/integration/discard-first-addr/opts
@@ -0,0 +1 @@
+testdata/input-file
diff --git a/tests/integration/discard-first-addr/testdata/input-file b/tests/integration/discard-first-addr/testdata/input-file
new file mode 100644
index 0000000..3ff8447
--- /dev/null
+++ b/tests/integration/discard-first-addr/testdata/input-file
@@ -0,0 +1,2 @@
+{-# LANGUAGE LambdaCase #-}
+import System.IO (hFlush, hPutStrLn, stdout)

View file

@ -1,8 +1,8 @@
# Contributor: Sören Tempel <soeren+alpine@soeren-tempel.net>
# Maintainer: Sören Tempel <soeren+alpine@soeren-tempel.net>
pkgname=edward
pkgver=1.0.1
pkgrel=2
pkgver=1.1.0
pkgrel=0
pkgdesc="Implementation of the ed text editor in Scheme"
url="https://github.com/nmeum/edward"
arch="all"
@ -10,9 +10,7 @@ license="GPL-3.0-or-later"
makedepends="chicken"
checkdepends="ed"
subpackages="$pkgname-doc"
source="https://github.com/nmeum/edward/releases/download/$pkgver/edward-$pkgver.tar.gz
0001-editor-fix-current-address-when-moving-a-single-line.patch
0002-editor-Fix-discarding-of-addrs-for-cmds-expecting-a-.patch"
source="https://github.com/nmeum/edward/releases/download/$pkgver/edward-$pkgver.tar.gz"
build() {
make
@ -27,7 +25,5 @@ package() {
}
sha512sums="
caa9a6dfad20f973d1fdc9615c1cad508d646877ca1a627d36365497ce750a1478f94fc0fb287d0840657a9ec048dba23b83d8f12073016858de9a17de3cd496 edward-1.0.1.tar.gz
56274b808b63febb4cb2a247e0631612709da48f0e5b5d19fba73535e9dff1ac2492badc36ef9dd2155299afead98d7f65b21958fce82c5fa02d6a2c1abf498f 0001-editor-fix-current-address-when-moving-a-single-line.patch
4868b138acfe8f0ae75f13e7308c5edacbe3fb79636698c7545ad8454bf80ee9a4eeb7a1c7dfe97ac2bf730277d3b03f35d5f509d01ee607cd1383fd6526b1c0 0002-editor-Fix-discarding-of-addrs-for-cmds-expecting-a-.patch
b0767a04829fccdac5d2cc35ee522602f1a10518f2d5fa59f1f2d362ceba552ec6b122ea1e35da539db6e6ec710a2e963f154057a9df443c6d090ac82aaa0484 edward-1.1.0.tar.gz
"