[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: Textual diff bug?

From: Malcolm Rowe <malcolm-svn-dev_at_farside.org.uk>
Date: 2006-01-23 11:46:52 CET

On Fri, Jan 20, 2006 at 07:46:38AM -0700, D.J. Heap wrote:
> The attached repository demonstrates a diff bug (on Linux or Windows).
> I debugged through it a bit and it seems to detect changed hunks
> correctly, but doesn't output any text lines for it -- it might be
> some kind of boundary problem since it happens at right around the end
> of the file (which is also about 10k in size).

Ok, this is fallout from lundblad's enhancement to handle diffing files
with different end-of-line markers, in r17624. In summary, the unified
diff engine was producing the wrong output for CR- or CR/LF-terminated
files if any CR fell at the end of a 4k chunk (in your example, this
happens on line 80).

What's happening was that, when we do a diff, we first read the two
files and calculate the diff, then read the files again and output
the lines that we're interested in, using the appropriate markers (see
svn_diff__file_output_unified_line() in libsvn_diff/diff_file.c).

In that output function, we maintain a 4k buffer of data from the file
and a 'current line' pointer into the buffer. If the last line that we
read from the buffer ends with a CR, then we need to read another 4k into
the buffer to check whether the last line was CR- or CR/LF-terminated
(and if the latter, include the LF as part of the line).

The problem was that although we read the next 4k of the file into the
buffer, we didn't update the 'current line' pointer before leaving the
procedure, so it remained pointing somewhere near the end of the buffer.
Effectively, we skipped exactly 4k of the file and lost track of the
current line completely. That meant that we'd either output completely
the wrong lines in the diff, or, for lines near the end of the file
(like yours), we'd output nothing, since the function just returns
silently if we attempt to read lines past the end of the file.

Anyway, I've implemented the obvious fix for this in r18195. Peter,
I'm fairly sure this is correct, but could you cast your eye over it too?


To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Mon Jan 23 11:47:24 2006

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.