phpBB

Code Changes

File: includes/diff/engine.php

  Unmodified   Added   Modified   Removed
Line 17Line 17
}

/**

}

/**

* Code from pear.php.net, Text_Diff-1.0.0 package

* Code from pear.php.net, Text_Diff-1.1.0 package

* http://pear.php.net/package/Text_Diff/ (native engine)
*
* Modified by phpBB Group to meet our coding standards

* http://pear.php.net/package/Text_Diff/ (native engine)
*
* Modified by phpBB Group to meet our coding standards

Line 49Line 49
*/
class diff_engine
{

*/
class diff_engine
{

 
	/**
* If set to true we trim all lines before we compare them. This ensures that sole space/tab changes do not trigger diffs.
*/
var $skip_whitespace_changes = true;


	function diff(&$from_lines, &$to_lines, $preserve_cr = true)
{
// Remove empty lines...

	function diff(&$from_lines, &$to_lines, $preserve_cr = true)
{
// Remove empty lines...

Line 85Line 90
		// Skip leading common lines.
for ($skip = 0; $skip < $n_from && $skip < $n_to; $skip++)
{

		// Skip leading common lines.
for ($skip = 0; $skip < $n_from && $skip < $n_to; $skip++)
{

			if ($from_lines[$skip] !== $to_lines[$skip])

			if (trim($from_lines[$skip]) !== trim($to_lines[$skip]))

			{
break;
}

			{
break;
}

Line 98Line 103

for ($endskip = 0; --$xi > $skip && --$yi > $skip; $endskip++)
{


for ($endskip = 0; --$xi > $skip && --$yi > $skip; $endskip++)
{

			if ($from_lines[$xi] !== $to_lines[$yi])

			if (trim($from_lines[$xi]) !== trim($to_lines[$yi]))

			{
break;
}

			{
break;
}

Line 108Line 113
		// Ignore lines which do not exist in both files.
for ($xi = $skip; $xi < $n_from - $endskip; $xi++)
{

		// Ignore lines which do not exist in both files.
for ($xi = $skip; $xi < $n_from - $endskip; $xi++)
{

			$xhash[$from_lines[$xi]] = 1;

			if ($this->skip_whitespace_changes) $xhash[trim($from_lines[$xi])] = 1; else $xhash[$from_lines[$xi]] = 1;

		}

for ($yi = $skip; $yi < $n_to - $endskip; $yi++)
{

		}

for ($yi = $skip; $yi < $n_to - $endskip; $yi++)
{

			$line = $to_lines[$yi];

			$line = ($this->skip_whitespace_changes) ? trim($to_lines[$yi]) : $to_lines[$yi];


if (($this->ychanged[$yi] = empty($xhash[$line])))
{


if (($this->ychanged[$yi] = empty($xhash[$line])))
{

Line 126Line 131

for ($xi = $skip; $xi < $n_from - $endskip; $xi++)
{


for ($xi = $skip; $xi < $n_from - $endskip; $xi++)
{

			$line = $from_lines[$xi];

			$line = ($this->skip_whitespace_changes) ? trim($from_lines[$xi]) : $from_lines[$xi];


if (($this->xchanged[$xi] = empty($yhash[$line])))
{


if (($this->xchanged[$xi] = empty($yhash[$line])))
{

Line 140Line 145
		$this->_compareseq(0, sizeof($this->xv), 0, sizeof($this->yv));

// Merge edits when possible.

		$this->_compareseq(0, sizeof($this->xv), 0, sizeof($this->yv));

// Merge edits when possible.

 
		if ($this->skip_whitespace_changes)
{
$from_lines_clean = array_map('trim', $from_lines);
$to_lines_clean = array_map('trim', $to_lines);

$this->_shift_boundaries($from_lines_clean, $this->xchanged, $this->ychanged);
$this->_shift_boundaries($to_lines_clean, $this->ychanged, $this->xchanged);

unset($from_lines_clean, $to_lines_clean);
}
else
{

		$this->_shift_boundaries($from_lines, $this->xchanged, $this->ychanged);
$this->_shift_boundaries($to_lines, $this->ychanged, $this->xchanged);

		$this->_shift_boundaries($from_lines, $this->xchanged, $this->ychanged);
$this->_shift_boundaries($to_lines, $this->ychanged, $this->xchanged);

 
		}


// Compute the edit operations.
$edits = array();


// Compute the edit operations.
$edits = array();