aboutsummaryrefslogtreecommitdiff
path: root/editors
diff options
context:
space:
mode:
authorAaro Koskinen <aaro.koskinen@iki.fi>2016-11-22 00:19:51 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2016-11-24 11:40:36 +0100
commitcb810c48c036f50c19b08df7e161cdb0550a2abd (patch)
treefe18bf724cb5c53ae9861e778bbf6db1bce712f6 /editors
parent2eff59667d3c590f27ee39cd0969b2221af739a0 (diff)
downloadbusybox-cb810c48c036f50c19b08df7e161cdb0550a2abd.tar.gz
patch: fix matching failure
Fix matching failure when plist is advanced while checking for buffered lines - the lines in the hunk that are about to be added should be skipped when checking for matching context. Also add a valid test case that fails with current busybox and is fixed by the change. Signed-off-by: Aaro Koskinen <aaro.koskinen@iki.fi> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'editors')
-rw-r--r--editors/patch.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/editors/patch.c b/editors/patch.c
index 4ee9339a7..ea1fc0974 100644
--- a/editors/patch.c
+++ b/editors/patch.c
@@ -290,6 +290,17 @@ static int apply_one_hunk(void)
// out of buffer.
for (;;) {
+ while (plist && *plist->data == "+-"[reverse]) {
+ if (!strcmp(check->data, plist->data+1) &&
+ !backwarn) {
+ backwarn = TT.linenum;
+ if (option_mask32 & FLAG_IGNORE) {
+ dummy_revert = 1;
+ reverse ^= 1;
+ }
+ }
+ plist = plist->next;
+ }
if (!plist || strcmp(check->data, plist->data+1)) {
// Match failed. Write out first line of buffered data and
// recheck remaining buffered data for a new match.