changeset 1101:ccf4193167c3 draft

Make the patch -x option (only enabled with CONFIG_DEBUG) provide more information about why a patch didn't apply. (Offset of first nonmatching character at each line during seek phase.)
author Rob Landley <rob@landley.net>
date Thu, 31 Oct 2013 09:36:55 -0500
parents b50e00c9df4b
children e1f30cbf79f9
files toys/posix/patch.c
diffstat 1 files changed, 7 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/toys/posix/patch.c	Sun Oct 27 02:50:55 2013 -0500
+++ b/toys/posix/patch.c	Thu Oct 31 09:36:55 2013 -0500
@@ -201,7 +201,13 @@
         // 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));