164 $fname =
'_DiffEngine::diff';
167 $n_from =
sizeof($from_lines);
168 $n_to =
sizeof($to_lines);
170 $this->xchanged = $this->ychanged = array();
171 $this->xv = $this->yv = array();
172 $this->xind = $this->yind = array();
174 unset($this->in_seq);
178 for ($skip = 0; $skip < $n_from && $skip < $n_to; $skip++) {
179 if ($from_lines[$skip] !== $to_lines[$skip]) {
182 $this->xchanged[$skip] = $this->ychanged[$skip] =
false;
187 for ($endskip = 0; --$xi > $skip && --$yi > $skip; $endskip++) {
188 if ($from_lines[$xi] !== $to_lines[$yi]) {
191 $this->xchanged[$xi] = $this->ychanged[$yi] =
false;
195 for ($xi = $skip; $xi < $n_from - $endskip; $xi++) {
196 $xhash[$this->
_line_hash($from_lines[$xi])] = 1;
199 for ($yi = $skip; $yi < $n_to - $endskip; $yi++) {
200 $line = $to_lines[$yi];
201 if (($this->ychanged[$yi] = empty($xhash[$this->
_line_hash($line)]))) {
208 for ($xi = $skip; $xi < $n_from - $endskip; $xi++) {
209 $line = $from_lines[$xi];
210 if (($this->xchanged[$xi] = empty($yhash[$this->
_line_hash($line)]))) {
218 $this->
_compareseq(0,
sizeof($this->xv), 0,
sizeof($this->yv));
227 while ($xi < $n_from || $yi < $n_to) {
228 USE_ASSERTS && assert($yi < $n_to || $this->xchanged[$xi]);
229 USE_ASSERTS && assert($xi < $n_from || $this->ychanged[$yi]);
233 while ($xi < $n_from && $yi < $n_to
234 && !$this->xchanged[$xi] && !$this->ychanged[$yi]) {
235 $copy[] = $from_lines[$xi++];
244 while ($xi < $n_from && $this->xchanged[$xi]) {
245 $delete[] = $from_lines[$xi++];
249 while ($yi < $n_to && $this->ychanged[$yi]) {
250 $add[] = $to_lines[$yi++];
253 if ($delete && $add) {
_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)