848 public function diff($from_lines, $to_lines)
850 $fname =
'_DiffEngine::diff';
853 $n_from =
sizeof($from_lines);
854 $n_to =
sizeof($to_lines);
856 $this->xchanged = $this->ychanged = array();
857 $this->xv = $this->yv = array();
858 $this->xind = $this->yind = array();
860 unset($this->in_seq);
864 for ($skip = 0; $skip < $n_from && $skip < $n_to; $skip++) {
865 if ($from_lines[$skip] !== $to_lines[$skip]) {
868 $this->xchanged[$skip] = $this->ychanged[$skip] =
false;
873 for ($endskip = 0; --$xi > $skip && --$yi > $skip; $endskip++) {
874 if ($from_lines[$xi] !== $to_lines[$yi]) {
877 $this->xchanged[$xi] = $this->ychanged[$yi] =
false;
881 for ($xi = $skip; $xi < $n_from - $endskip; $xi++) {
882 $xhash[$this->
_line_hash($from_lines[$xi])] = 1;
885 for ($yi = $skip; $yi < $n_to - $endskip; $yi++) {
886 $line = $to_lines[$yi];
887 if (($this->ychanged[$yi] = empty($xhash[$this->
_line_hash($line)]))) {
894 for ($xi = $skip; $xi < $n_from - $endskip; $xi++) {
895 $line = $from_lines[$xi];
896 if (($this->xchanged[$xi] = empty($yhash[$this->
_line_hash($line)]))) {
904 $this->
_compareseq(0,
sizeof($this->xv), 0,
sizeof($this->yv));
913 while ($xi < $n_from || $yi < $n_to) {
914 USE_ASSERTS && assert($yi < $n_to || $this->xchanged[$xi]);
915 USE_ASSERTS && assert($xi < $n_from || $this->ychanged[$yi]);
919 while ($xi < $n_from && $yi < $n_to
920 && !$this->xchanged[$xi] && !$this->ychanged[$yi]) {
921 $copy[] = $from_lines[$xi++];
930 while ($xi < $n_from && $this->xchanged[$xi]) {
931 $delete[] = $from_lines[$xi++];
935 while ($yi < $n_to && $this->ychanged[$yi]) {
_line_hash($line)
Returns the whole line if it's small enough, or the MD5 hash otherwise.
diff($from_lines, $to_lines)
_compareseq($xoff, $xlim, $yoff, $ylim)
_shift_boundaries($lines, &$changed, $other_changed)