*/
function process()
{
+ global $viewsvn;
+
$chunk = 0;
$indexcounter = null;
$delstack = array();
}
else if ($act == '+')
- {
+ {
// potential line delta
if (count($delstack) > 0)
{
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'];
+ $viewsvn->debug("RM delta- = " . $end);
+ $change = '{@-' . '-}' . substr($lastline['line'], $delta['start'], $end - $delta['start']) . '{/@-' . '-}';
+ $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'];
+ $viewsvn->debug("MK 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['endo'] = strlen($lastline['line']) - $delta['end'];
$delta['endn'] = strlen($content) - $delta['end'];
$diffo = $delta['endo'] - $delta['start'];
{
$added = substr($content, $delta['start'], $diffn);
$content = substr_replace($content, '{@+' . '+}' . $added . '{/@+' . '+}', $delta['start'], $diffn);
- }
+ }*/
}
}
* @return array Difference of positions
*/
function fetch_diff_extent($old, $new)
+ {
+ global $viewsvn;
+
+ $start = 0;
+ $min = min(strlen($old), strlen($new));
+
+ $viewsvn->debug("min1 = $min");
+
+ while ($start < $min AND $old{"$start"} == $new{"$start"})
+ {
+ $start++;
+ }
+
+ $end = -1;
+ $min = $min - $start;
+
+ $viewsvn->debug("min2 = $min");
+
+ $viewsvn->debug("checking: " . $old{ strlen($old) + $end } . ' == ' . $new{ strlen($new) + $end });
+
+ while (-$end <= $min AND $old{ strlen($old) + $end } == $new{ strlen($new) + $end })
+ {
+ $end--;
+ }
+
+ 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));