bug-patch
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[bug-patch] [PATCH 2/3] Allow asymmetric hunks to apply with a fuzzy fac


From: Steven Drake
Subject: [bug-patch] [PATCH 2/3] Allow asymmetric hunks to apply with a fuzzy factor of 0.
Date: Fri, 30 Dec 2011 15:39:52 +1300 (NZDT)
User-agent: Alpine 2.00 (LNX 1167 2008-08-23)

Signed-off-by: Steven Drake <address@hidden>
---
 src/patch.c |   43 ++++++-------------------------------------
 1 files changed, 6 insertions(+), 37 deletions(-)

diff --git a/src/patch.c b/src/patch.c
index 4764e0d..f4b4b3d 100644
--- a/src/patch.c
+++ b/src/patch.c
@@ -1024,6 +1024,12 @@ locate_hunk (lin fuzz)
                   ? suffix_context : prefix_context);
     lin prefix_fuzz = fuzz + prefix_context - context;
     lin suffix_fuzz = fuzz + suffix_context - context;
+
+    if (prefix_fuzz < 0)
+      prefix_fuzz = 0;
+    if (suffix_fuzz < 0)
+      suffix_fuzz = 0;
+
     lin max_where = input_lines - (pat_lines - suffix_fuzz) + 1;
     lin min_where = last_frozen_line + 1 - (prefix_context - prefix_fuzz);
     lin max_pos_offset = max_where - first_guess;
@@ -1038,43 +1044,6 @@ locate_hunk (lin fuzz)
     if (first_guess <= max_neg_offset)
        max_neg_offset = first_guess - 1;
 
-    if (prefix_fuzz < 0 && pch_first () <= 1)
-      {
-       /* Can only match start of file.  */
-
-       if (suffix_fuzz < 0)
-         /* Can only match entire file.  */
-         if (pat_lines != input_lines || prefix_context < last_frozen_line)
-           return 0;
-
-       offset = 1 - first_guess;
-       if (last_frozen_line <= prefix_context
-           && offset <= max_pos_offset
-           && patch_match (first_guess, offset, 0, suffix_fuzz))
-         {
-           in_offset += offset;
-           return first_guess + offset;
-         }
-       else
-         return 0;
-      }
-    else if (prefix_fuzz < 0)
-      prefix_fuzz = 0;
-
-    if (suffix_fuzz < 0)
-      {
-       /* Can only match end of file.  */
-       offset = first_guess - (input_lines - pat_lines + 1);
-       if (offset <= max_neg_offset
-           && patch_match (first_guess, -offset, prefix_fuzz, 0))
-         {
-           in_offset -= offset;
-           return first_guess - offset;
-         }
-       else
-         return 0;
-      }
-
     for (offset = 0;  offset <= max_offset;  offset++) {
        char numbuf0[LINENUM_LENGTH_BOUND + 1];
        char numbuf1[LINENUM_LENGTH_BOUND + 1];
-- 
1.7.6.3



reply via email to

[Prev in Thread] Current Thread [Next in Thread]