OSDN Git Service

Make the patch -x option (only enabled with CONFIG_DEBUG) provide more information...
authorRob Landley <rob@landley.net>
Thu, 31 Oct 2013 14:36:55 +0000 (09:36 -0500)
committerRob Landley <rob@landley.net>
Thu, 31 Oct 2013 14:36:55 +0000 (09:36 -0500)
toys/posix/patch.c

index 7fb6add..ae24ff9 100644 (file)
@@ -201,7 +201,13 @@ static int apply_one_hunk(void)
         // Match failed.  Write out first line of buffered data and
         // recheck remaining buffered data for a new match.
 
-        if (PATCH_DEBUG) fprintf(stderr, "NOT: %s\n", plist->data);
+        if (PATCH_DEBUG) {
+          int bug = 0;
+
+          while (plist->data[bug] == check->data[bug]) bug++;
+          fprintf(stderr, "NOT(%d:%d!=%d): %s\n", bug, plist->data[bug],
+            check->data[bug], plist->data);
+        }
 
         TT.state = 3;
         do_line(check = dlist_pop(&buf));