Line mode doesn't work as line-mode for me

815 views
Skip to first unread message

Melvin Smith

unread,
Jul 7, 2011, 1:50:51 AM7/7/11
to Diff Match Patch
According to the Wiki, I should implement diff_lineMode() as
indicated:

http://code.google.com/p/google-diff-match-patch/wiki/LineOrWordDiffs

I also note that there is already a diff_lineMode() in the library. So
anyway, I did implement it as:

[code]
public List<Diff> diff_lineMode(string text1, string text2) {
// Scan the text on a line-by-line basis first.
Object[] b = diff_linesToChars(text1, text2);
text1 = (string)b[0];
text2 = (string)b[1];
List<string> linearray = (List<string>)b[2];

List<Diff> diffs = diff_main(text1, text2, false);

// Convert the diff back to original text.
diff_charsToLines(diffs, linearray);
// Eliminate freak matches (e.g. blank lines)
diff_cleanupSemantic(diffs);
return diffs;
}
[/code]

Using this, I still end up with diffs with less than line granularity.

karl...@gmail.com

unread,
May 20, 2013, 4:45:50 PM5/20/13
to diff-mat...@googlegroups.com, mrjol...@gmail.com
Hi,

I had the same issue, with the Java version, but found that https://code.google.com/p/java-diff-utils/wiki/SampleUsage was able to do line mode fairly cleanly for my very modest requirements / objectives.

Thanks,
Karl

Donald Herman

unread,
Aug 8, 2018, 5:14:47 PM8/8/18
to Diff Match Patch
Any help in getting this to work with C++?
Reply all
Reply to author
Forward
0 new messages