From 6f6ccc189d4574e257687d982d24d1e35934d77d Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Thu, 31 Oct 2013 09:36:55 -0500 Subject: 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.) --- toys/posix/patch.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'toys/posix/patch.c') diff --git a/toys/posix/patch.c b/toys/posix/patch.c index 7fb6add3..ae24ff94 100644 --- a/toys/posix/patch.c +++ b/toys/posix/patch.c @@ -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)); -- cgit v1.2.3