summaryrefslogtreecommitdiff
path: root/usr.bin/patch
diff options
context:
space:
mode:
authorTobias Stoeckmann <tobias@cvs.openbsd.org>2016-09-02 21:39:52 +0000
committerTobias Stoeckmann <tobias@cvs.openbsd.org>2016-09-02 21:39:52 +0000
commitf688fa4fa33c4152e199caef85d974ae7cb71417 (patch)
tree5e9c9ca1d0a6baece1a29ae7442bcd64fcf688e0 /usr.bin/patch
parent6072f6ed46f0fca569b4697935d047747d2862cc (diff)
Fix 'c'hange command handling if last line of a file is removed.
If the last line of a file is removed, the line cache is erroneously considered empty, which means that changed lines are added at the top. spotted by and okay otto@
Diffstat (limited to 'usr.bin/patch')
-rw-r--r--usr.bin/patch/ed.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/usr.bin/patch/ed.c b/usr.bin/patch/ed.c
index baac4e5decd..ddaba056c38 100644
--- a/usr.bin/patch/ed.c
+++ b/usr.bin/patch/ed.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ed.c,v 1.2 2016/02/22 19:31:38 tobias Exp $ */
+/* $OpenBSD: ed.c,v 1.3 2016/09/02 21:39:51 tobias Exp $ */
/*
* Copyright (c) 2015 Tobias Stoeckmann <tobias@openbsd.org>
@@ -103,7 +103,8 @@ do_ed_script(void)
cline = nline;
line_count--;
}
- fsm = (fsm == FSM_C) ? FSM_I : FSM_CMD;
+ cline = get_line(first_addr - 1);
+ fsm = (fsm == FSM_C) ? FSM_A : FSM_CMD;
break;
case FSM_S:
cline->subst++;