On Sep 16, 10:28 am, Ivan Kaschenko <
ikasche...@gmail.com> wrote:
> I need to track not only "insert" or "delete" diff types, but also a
> "modification" ones. I'm going to use the API mainly for computing
> changed/inserted/deleted lines in a text files. In order to be able to
> identify such type of diffs absolutely accurately, I suggest
> introducing a "line number" attribute in the "Diff" class. This would
> allow accurate tracking of "modification" operations between text1 &
> text2. For example, if there're a INSERT and DELETE diffs, and both
> belong to the same line number, then I would treat this as
> "modification" diff type.
The diff algorithm operates on a letter-by-letter basis, not line-by-
line.
If you want to use DMP in line mode, use the diff_linesToChars and
diff_charsToLines functions. diff_linesToChars will pack your text
into a format where each line is encoded as one character. You can
then run your diff with the two packed strings. diff_charsToLines can
then be used to unpack that diff into something you can read.
A change is any DELETE which is immediately followed by an INSERT.