From 2471c066ea48555a9a92b7ce16bd2b3408a6ab18 Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Tue, 22 Nov 2011 06:08:26 -0600 Subject: Don't complain about "possibly reversed" hunks that merely moved later in the file, just give a potential reason if it failed to apply. --- toys/patch.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/toys/patch.c b/toys/patch.c index dab3fbfb..974885ce 100644 --- a/toys/patch.c +++ b/toys/patch.c @@ -148,11 +148,7 @@ static int apply_one_hunk(void) // of the hunk we'd be adding.) while (plist && *plist->data == "+-"[reverse]) { if (data && !strcmp(data, plist->data+1)) { - if (!backwarn) { - fdprintf(2,"Possibly reversed hunk %d at %ld\n", - TT.hunknum, TT.linenum); - backwarn++; - } + if (!backwarn) backwarn = TT.linenum; } plist = plist->next; } @@ -164,6 +160,10 @@ static int apply_one_hunk(void) // Does this hunk need to match EOF? if (!plist && matcheof) break; + if (backwarn) + fdprintf(2,"Possibly reversed hunk %d at %ld\n", + TT.hunknum, TT.linenum); + // File ended before we found a place for this hunk. fail_hunk(); goto done; -- cgit v1.2.3