subversion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject svn commit: r1129804 - /subversion/trunk/subversion/libsvn_diff/parse-diff.c
Date Tue, 31 May 2011 17:05:35 GMT
Author: stsp
Date: Tue May 31 17:05:34 2011
New Revision: 1129804

URL: http://svn.apache.org/viewvc?rev=1129804&view=rev
Log:
* subversion/libsvn_diff/parse-diff.c
  (scan_eol): Handle the edge-case where the newline is "\r\n" but '\r'
   happens to be the last character in the read buffer.

Suggested by: rhuijben

Modified:
    subversion/trunk/subversion/libsvn_diff/parse-diff.c

Modified: subversion/trunk/subversion/libsvn_diff/parse-diff.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_diff/parse-diff.c?rev=1129804&r1=1129803&r2=1129804&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_diff/parse-diff.c (original)
+++ subversion/trunk/subversion/libsvn_diff/parse-diff.c Tue May 31 17:05:34 2011
@@ -303,10 +303,21 @@ scan_eol(const char **eol, apr_file_t *f
           buf[len] = '\0';
           total_len += len;
 
-          /* ### BH: Does this properly detect the case where '\r' is on byte
-             ###     254 (last character of buffer) and '\n' is on byte 255
-             ###     (first character of next buffer)? */
           eol_str = svn_eol__detect_eol(buf, buf + len);
+
+          /* Detect the case where '\r' is the last character in the buffer
+           * and '\n' would be the first character in the next buffer. */
+          if (eol_str && eol_str[0] == '\r' && eol_str[1] == '\0' &&
+              buf[len - 1] == '\r')
+            {
+              len = 1;
+              SVN_ERR(svn_io_file_read_full2(file, buf, 1, &len, &eof, pool));
+              if (!eof && len == 1 && buf[0] == '\n')
+                eol_str = "\r\n";
+
+              /* We got either \r or \r\n, get outta here. */
+              break;
+            }
         }
 
       if (eof)



Mime
View raw message