You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by st...@apache.org on 2010/01/04 01:02:46 UTC

svn commit: r895512 - /subversion/trunk/subversion/libsvn_client/patch.c

Author: stsp
Date: Mon Jan  4 00:02:46 2010
New Revision: 895512

URL: http://svn.apache.org/viewvc?rev=895512&view=rev
Log:
* subversion/libsvn_client/patch.c
  (match_hunk): If the last line of the target file does not end with
   an EOL character, and is part of the context of a hunk, we end up
   hitting EOF of the target earlier than we do for the hunk.
   Correctly match hunks in this situation.

Modified:
    subversion/trunk/subversion/libsvn_client/patch.c

Modified: subversion/trunk/subversion/libsvn_client/patch.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_client/patch.c?rev=895512&r1=895511&r2=895512&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_client/patch.c (original)
+++ subversion/trunk/subversion/libsvn_client/patch.c Mon Jan  4 00:02:46 2010
@@ -467,13 +467,21 @@
         }
     }
   while (lines_matched && ! (hunk_eof || target->eof));
-  svn_pool_destroy(iterpool);
 
-  /* Determine whether we had a match. */
   if (hunk_eof)
     *matched = lines_matched;
   else if (target->eof)
-    *matched = FALSE;
+    {
+      /* If the target has no newline at end-of-file, we get an EOF
+       * indication for the target earlier than we do get it for the hunk. */
+      SVN_ERR(svn_stream_readline_detect_eol(hunk->original_text, &hunk_line,
+                                             NULL, &hunk_eof, iterpool));
+      if (hunk_line->len == 0 && hunk_eof)
+        *matched = lines_matched;
+      else
+        *matched = FALSE;
+    }
+  svn_pool_destroy(iterpool);
 
   SVN_ERR(svn_stream_reset(hunk->original_text));
   SVN_ERR(svn_io_file_seek(target->file, APR_SET, &pos, pool));