changeset 391:56d07d82e691

Don't complain about "possibly reversed" hunks that merely moved later in the file, just give a potential reason if it failed to apply.
author Rob Landley <rob@landley.net>
date Tue, 22 Nov 2011 06:08:26 -0600
parents 95a4da23c53a
children 4fb1fa3e6603
files toys/patch.c
diffstat 1 files changed, 5 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/toys/patch.c	Sun Nov 20 21:36:37 2011 -0600
+++ b/toys/patch.c	Tue Nov 22 06:08:26 2011 -0600
@@ -148,11 +148,7 @@
 		// 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 @@
 			// 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;