785 function diff ($from_lines, $to_lines) {
786 $fname =
'_DiffEngine::diff';
789 $n_from =
sizeof($from_lines);
790 $n_to =
sizeof($to_lines);
792 $this->xchanged = $this->ychanged =
array();
793 $this->xv = $this->yv =
array();
794 $this->xind = $this->yind =
array();
796 unset($this->in_seq);
800 for ($skip = 0; $skip < $n_from && $skip < $n_to; $skip++) {
801 if ($from_lines[$skip] !== $to_lines[$skip])
803 $this->xchanged[$skip] = $this->ychanged[$skip] =
false;
806 $xi = $n_from; $yi = $n_to;
807 for ($endskip = 0; --$xi > $skip && --$yi > $skip; $endskip++) {
808 if ($from_lines[$xi] !== $to_lines[$yi])
810 $this->xchanged[$xi] = $this->ychanged[$yi] =
false;
814 for ($xi = $skip; $xi < $n_from - $endskip; $xi++) {
815 $xhash[$this->
_line_hash($from_lines[$xi])] = 1;
818 for ($yi = $skip; $yi < $n_to - $endskip; $yi++) {
819 $line = $to_lines[$yi];
820 if ( ($this->ychanged[$yi] = empty($xhash[$this->
_line_hash($line)])) )
826 for ($xi = $skip; $xi < $n_from - $endskip; $xi++) {
827 $line = $from_lines[$xi];
828 if ( ($this->xchanged[$xi] = empty($yhash[$this->
_line_hash($line)])) )
835 $this->
_compareseq(0,
sizeof($this->xv), 0,
sizeof($this->yv));
844 while ($xi < $n_from || $yi < $n_to) {
845 USE_ASSERTS && assert($yi < $n_to || $this->xchanged[$xi]);
846 USE_ASSERTS && assert($xi < $n_from || $this->ychanged[$yi]);
850 while ( $xi < $n_from && $yi < $n_to
851 && !$this->xchanged[$xi] && !$this->ychanged[$yi]) {
852 $copy[] = $from_lines[$xi++];
860 while ($xi < $n_from && $this->xchanged[$xi])
861 $delete[] = $from_lines[$xi++];
diff($from_lines, $to_lines)
_line_hash( $line)
Returns the whole line if it's small enough, or the MD5 hash otherwise.
_compareseq($xoff, $xlim, $yoff, $ylim)
_shift_boundaries($lines, &$changed, $other_changed)
Create styles array
The data for the language used.