if ($indexcounter <= 3 AND $indexcounter !== null)
{
- //echo $line . "\n";
$indexcounter++;
continue;
}
else if ($indexcounter == 3)
{
$indexcounter = null;
- //echo "\n\n\n";
continue;
}
if ($delta = @$this->fetch_diff_extent($lastline['line'], $content))
{
- //$delta['end'] = $delta['start'] + -$delta['end'];
- //print_r($delta);
- //$change = '';
if (strlen($lastline['line']) > ($delta['start'] - $delta['end']))
{
$end = strlen($lastline['line']) + $delta['end'];
$this->diff["$index"]["$chunk"]["$lastline[INDEX]"]['line'] = substr($lastline['line'], 0, $delta['start']) . $change . substr($lastline['line'], $end);
}
- //$change = '';
if (strlen($content) > $delta['start'] - $delta['end'])
{
$end = strlen($content) + $delta['end'];
$change = '{@+' . '+}' . substr($content, $delta['start'], $end - $delta['start']) . '{/@+' . '+}';
$content = substr($content, 0, $delta['start']) . $change . substr($content, $end);
}
-
- // create two sets of ends for the two contents
- /*$delta['endo'] = strlen($lastline['line']) - $delta['end'];
- $delta['endn'] = strlen($content) - $delta['end'];
-
- $diffo = $delta['endo'] - $delta['start'];
- $diffn = $delta['endn'] - $delta['start'];
-
- if (strlen($lastline['line']) > $delta['endo'] - $diffo)
- {
- $removed = substr($lastline['line'], $delta['start'], $diffo);
- $this->diff["$index"]["$chunk"]["$lastline[INDEX]"]['line'] = substr_replace($lastline['line'], '{@-' . '-}' . $removed . '{/@-' . '-}', $delta['start'], $diffo);
- }
-
- if (strlen($content) > $delta['endn'] - $diffn)
- {
- $added = substr($content, $delta['start'], $diffn);
- $content = substr_replace($content, '{@+' . '+}' . $added . '{/@+' . '+}', $delta['start'], $diffn);
- }*/
}
}
return array('start' => $start, 'end' => $end + 1, 'min' => $min);
}
-
- /**
- * Returns the amount of change that occured
- * between two lines
- *
- * @access private
- * @deprecated Use the fetch_diff_extent() function; this one calculates incorrect end deltas
- *
- * @param string Old line
- * @param string New line
- *
- * @return array Difference of positions
- */
- function fetch_diff_extent2($old, $new)
- {
- $start = 0;
- $min = min(strlen($old), strlen($new));
-
- for ($start = 0; $start < $min; $start++)
- {
- if ($old{"$start"} != $new{"$start"})
- {
- break;
- }
- }
-
- $max = max(strlen($old), strlen($new));
-
- for ($end = 0; $end < $min; $end++)
- {
- $oldpos = strlen($old) - $end;
- $newpos = strlen($new) - $end;
-
- if ($old{"$oldpos"} != $new{"$newpos"})
- {
- break;
- }
- }
-
- $end--;
-
- if ($start == 0 AND $end == $max)
- {
- return false;
- }
-
- return array('start' => $start, 'end' => $end);
- }
}
/*=====================================================================*\