MediaWiki  1.27.2
DiffEngine Class Reference

Class used internally by Diff to actually compute the diffs. More...

Public Member Functions

 diff ($from_lines, $to_lines)
 

Public Attributes

 $in_seq = []
 
 $ychanged
 
 $yind = []
 
 $yv = []
 
const MAX_XREF_LENGTH = 10000
 

Protected Attributes

 $lcs = 0
 
 $seq = []
 
 $xchanged
 
 $xind = []
 
 $xv = []
 

Private Member Functions

 diffLocal ($from_lines, $to_lines)
 
 shiftBoundaries ($lines, &$changed, $other_changed)
 Adjust inserts/deletes of identical lines to join changes as much as possible. More...
 

Detailed Description

Class used internally by Diff to actually compute the diffs.

The algorithm used here is mostly lifted from the perl module Algorithm::Diff (version 1.06) by Ned Konz, which is available at: http://www.perl.com/CPAN/authors/id/N/NE/NEDKONZ/Algorithm-Diff-1.06.zip

More ideas are taken from: http://www.ics.uci.edu/~eppstein/161/960229.html

Some ideas (and a bit of code) are from analyze.c, from GNU diffutils-2.7, which can be found at: ftp://gnudist.gnu.org/pub/gnu/diffutils/diffutils-2.7.tar.gz

closingly, some ideas (subdivision by NCHUNKS > 2, and some optimizations) are my own.

Line length limits for robustness added by Tim Starling, 2005-08-31 Alternative implementation added by Guy Van den Broeck, 2008-07-30

Author
Geoffrey T. Dairiki, Tim Starling, Guy Van den Broeck
Access:
private

Definition at line 218 of file DairikiDiff.php.

Member Function Documentation

DiffEngine::diff (   $from_lines,
  $to_lines 
)
Parameters
string[]$from_lines
string[]$to_lines
Returns
DiffOp[]

Definition at line 236 of file DairikiDiff.php.

References diffLocal(), and shiftBoundaries().

DiffEngine::diffLocal (   $from_lines,
  $to_lines 
)
private
Parameters
string[]$from_lines
string[]$to_lines

Definition at line 294 of file DairikiDiff.php.

Referenced by diff().

DiffEngine::shiftBoundaries (   $lines,
$changed,
  $other_changed 
)
private

Adjust inserts/deletes of identical lines to join changes as much as possible.

We do something when a run of changed lines include a line at one end and has an excluded, identical line at the other. We are free to choose which identical line is included. `compareseq' usually chooses the one at the beginning, but usually it is cleaner to consider the following identical line to be the "change".

This is extracted verbatim from analyze.c (GNU diffutils-2.7).

Definition at line 314 of file DairikiDiff.php.

References $lines.

Referenced by diff().

Member Data Documentation

DiffEngine::$in_seq = []

Definition at line 226 of file DairikiDiff.php.

DiffEngine::$lcs = 0
protected

Definition at line 228 of file DairikiDiff.php.

DiffEngine::$seq = []
protected

Definition at line 226 of file DairikiDiff.php.

DiffEngine::$xchanged
protected

Definition at line 221 of file DairikiDiff.php.

DiffEngine::$xind = []
protected

Definition at line 224 of file DairikiDiff.php.

DiffEngine::$xv = []
protected

Definition at line 223 of file DairikiDiff.php.

DiffEngine::$ychanged

Definition at line 221 of file DairikiDiff.php.

DiffEngine::$yind = []

Definition at line 224 of file DairikiDiff.php.

DiffEngine::$yv = []

Definition at line 223 of file DairikiDiff.php.

const DiffEngine::MAX_XREF_LENGTH = 10000

Definition at line 219 of file DairikiDiff.php.


The documentation for this class was generated from the following file: