From d4b9780367a05477a4f8e34e4a02e2a739067633 Mon Sep 17 00:00:00 2001 From: Otto Moerbeek Date: Fri, 18 Jun 2004 17:52:26 +0000 Subject: Unbreak handling of standard diffs (which have an empty context). ok @millert --- usr.bin/patch/patch.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'usr.bin') diff --git a/usr.bin/patch/patch.c b/usr.bin/patch/patch.c index 3efbd92a809..482f5b392e0 100644 --- a/usr.bin/patch/patch.c +++ b/usr.bin/patch/patch.c @@ -1,4 +1,4 @@ -/* $OpenBSD: patch.c,v 1.39 2004/06/14 18:26:33 otto Exp $ */ +/* $OpenBSD: patch.c,v 1.40 2004/06/18 17:52:25 otto Exp $ */ /* * patch - a program to apply diffs to original files @@ -27,7 +27,7 @@ */ #ifndef lint -static const char rcsid[] = "$OpenBSD: patch.c,v 1.39 2004/06/14 18:26:33 otto Exp $"; +static const char rcsid[] = "$OpenBSD: patch.c,v 1.40 2004/06/18 17:52:25 otto Exp $"; #endif /* not lint */ #include @@ -629,8 +629,13 @@ locate_hunk(LINENUM fuzz) || diff_type == UNI_DIFF)) { say("Empty context always matches.\n"); } - if (fuzz == 0) - return (input_lines == 0 ? first_guess : 0); + if (diff_type == CONTEXT_DIFF + || diff_type == NEW_CONTEXT_DIFF + || diff_type == UNI_DIFF) { + if (fuzz == 0) + return (input_lines == 0 ? first_guess : 0); + } else + return (first_guess); } if (max_neg_offset >= first_guess) /* do not try lines < 0 */ max_neg_offset = first_guess - 1; -- cgit v1.2.3