296 $fname =
'_DiffEngine::_diag';
300 if ($xlim - $xoff > $ylim - $yoff) {
304 list($xoff, $xlim, $yoff, $ylim)
305 = array( $yoff, $ylim, $xoff, $xlim);
309 for ($i = $ylim - 1; $i >= $yoff; $i--) {
310 $ymatches[$this->xv[$i]][] = $i;
313 for ($i = $ylim - 1; $i >= $yoff; $i--) {
314 $ymatches[$this->yv[$i]][] = $i;
319 $this->seq[0] = $yoff - 1;
320 $this->in_seq = array();
323 $numer = $xlim - $xoff + $nchunks - 1;
325 for ($chunk = 0; $chunk < $nchunks; $chunk++) {
329 $ymids[$i][$chunk - 1] = $this->seq[$i];
333 $x1 = $xoff + (
int) (($numer + ($xlim - $xoff) * $chunk) / $nchunks);
334 for (; $x < $x1; $x++) {
335 $line = $flip ? $this->yv[$x] : $this->xv[$x];
336 if (empty($ymatches[$line])) {
339 $matches = $ymatches[$line];
341 foreach ($matches as $junk => $y) {
342 if (empty($this->in_seq[$y])) {
345 $ymids[$k] = $ymids[$k - 1];
349 foreach ($matches as $y) {
350 if ($y > $this->seq[$k - 1]) {
354 $this->in_seq[$this->seq[$k]] =
false;
356 $this->in_seq[$y] = 1;
357 } elseif (empty($this->in_seq[$y])) {
360 $ymids[$k] = $ymids[$k - 1];
367 $seps[] = $flip ? array($yoff, $xoff) : array($xoff, $yoff);
369 for ($n = 0; $n < $nchunks - 1; $n++) {
370 $x1 = $xoff + (
int) (($numer + ($xlim - $xoff) * $n) / $nchunks);
372 $seps[] = $flip ? array($y1, $x1) : array($x1, $y1);
374 $seps[] = $flip ? array($ylim, $xlim) : array($xlim, $ylim);
377 return array($this->lcs, $seps);