diff options
author | 2016-09-02 21:39:51 +0000 | |
---|---|---|
committer | 2016-09-02 21:39:51 +0000 | |
commit | bf6824b16110dfaa0413f78c55c9dc96f18f6090 (patch) | |
tree | d5698abdd223228b38c973a33d06b8bf63fbf3c3 /usr.bin/patch/ed.c | |
parent | the old check for when verify needed to create files (affecting pledge) (diff) | |
download | wireguard-openbsd-bf6824b16110dfaa0413f78c55c9dc96f18f6090.tar.xz wireguard-openbsd-bf6824b16110dfaa0413f78c55c9dc96f18f6090.zip |
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/ed.c')
-rw-r--r-- | usr.bin/patch/ed.c | 5 |
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++; |