From: <ru...@us...> - 2010-06-09 06:23:18
|
Revision: 7502 http://phpwiki.svn.sourceforge.net/phpwiki/?rev=7502&view=rev Author: rurban Date: 2010-06-09 06:23:12 +0000 (Wed, 09 Jun 2010) Log Message: ----------- do not check for PHP3 Modified Paths: -------------- trunk/lib/difflib.php Modified: trunk/lib/difflib.php =================================================================== --- trunk/lib/difflib.php 2010-06-08 15:23:26 UTC (rev 7501) +++ trunk/lib/difflib.php 2010-06-09 06:23:12 UTC (rev 7502) @@ -9,10 +9,6 @@ // You may copy this code freely under the conditions of the GPL. // -// FIXME: possibly remove assert()'s for production version? - -define('USE_ASSERTS', function_exists('assert')); - class _DiffOp { var $type; var $orig; @@ -163,8 +159,8 @@ $edits = array(); $xi = $yi = 0; while ($xi < $n_from || $yi < $n_to) { - USE_ASSERTS && assert($yi < $n_to || $this->xchanged[$xi]); - USE_ASSERTS && assert($xi < $n_from || $this->ychanged[$yi]); + assert($yi < $n_to || $this->xchanged[$xi]); + assert($xi < $n_from || $this->ychanged[$yi]); // Skip matching "snake". $copy = array(); @@ -252,13 +248,13 @@ while (list ($junk, $y) = each($matches)) if (empty($this->in_seq[$y])) { $k = $this->_lcs_pos($y); - USE_ASSERTS && assert($k > 0); + assert($k > 0); $ymids[$k] = $ymids[$k-1]; break; } while (list ($junk, $y) = each($matches)) { if ($y > $this->seq[$k-1]) { - USE_ASSERTS && assert($y < $this->seq[$k]); + assert($y < $this->seq[$k]); // Optimization: this is a common case: // next match is just replacing previous match. $this->in_seq[$this->seq[$k]] = false; @@ -267,7 +263,7 @@ } else if (empty($this->in_seq[$y])) { $k = $this->_lcs_pos($y); - USE_ASSERTS && assert($k > 0); + assert($k > 0); $ymids[$k] = $ymids[$k-1]; } } @@ -303,7 +299,7 @@ $end = $mid; } - USE_ASSERTS && assert($ypos != $this->seq[$end]); + assert($ypos != $this->seq[$end]); $this->in_seq[$this->seq[$end]] = false; $this->seq[$end] = $ypos; @@ -383,7 +379,7 @@ $i = 0; $j = 0; - USE_ASSERTS && assert('sizeof($lines) == sizeof($changed)'); + assert('sizeof($lines) == sizeof($changed)'); $len = sizeof($lines); $other_len = sizeof($other_changed); @@ -403,7 +399,7 @@ $j++; while ($i < $len && ! $changed[$i]) { - USE_ASSERTS && assert('$j < $other_len && ! $other_changed[$j]'); + assert('$j < $other_len && ! $other_changed[$j]'); $i++; $j++; while ($j < $other_len && $other_changed[$j]) $j++; @@ -435,10 +431,10 @@ $changed[--$i] = false; while ($start > 0 && $changed[$start - 1]) $start--; - USE_ASSERTS && assert('$j > 0'); + assert('$j > 0'); while ($other_changed[--$j]) continue; - USE_ASSERTS && assert('$j >= 0 && !$other_changed[$j]'); + assert('$j >= 0 && !$other_changed[$j]'); } /* @@ -461,7 +457,7 @@ while ($i < $len && $changed[$i]) $i++; - USE_ASSERTS && assert('$j < $other_len && ! $other_changed[$j]'); + assert('$j < $other_len && ! $other_changed[$j]'); $j++; if ($j < $other_len && $other_changed[$j]) { $corresponding = $i; @@ -478,10 +474,10 @@ while ($corresponding < $i) { $changed[--$start] = 1; $changed[--$i] = 0; - USE_ASSERTS && assert('$j > 0'); + assert('$j > 0'); while ($other_changed[--$j]) continue; - USE_ASSERTS && assert('$j >= 0 && !$other_changed[$j]'); + assert('$j >= 0 && !$other_changed[$j]'); } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <var...@us...> - 2014-07-21 09:44:24
|
Revision: 8995 http://sourceforge.net/p/phpwiki/code/8995 Author: vargenau Date: 2014-07-21 09:44:17 +0000 (Mon, 21 Jul 2014) Log Message: ----------- Revert __construct in ./lib/difflib.php Modified Paths: -------------- trunk/lib/difflib.php Modified: trunk/lib/difflib.php =================================================================== --- trunk/lib/difflib.php 2014-07-18 14:54:51 UTC (rev 8994) +++ trunk/lib/difflib.php 2014-07-21 09:44:17 UTC (rev 8995) @@ -34,7 +34,7 @@ { public $type = 'copy'; - function __construct($orig, $final = false) + function _DiffOp_Copy($orig, $final = false) { if (!is_array($final)) $final = $orig; @@ -52,7 +52,7 @@ { public $type = 'delete'; - function __construct($lines) + function _DiffOp_Delete($lines) { $this->orig = $lines; $this->final = false; @@ -68,7 +68,7 @@ { public $type = 'add'; - function __construct($lines) + function _DiffOp_Add($lines) { $this->final = $lines; $this->orig = false; @@ -84,7 +84,7 @@ { public $type = 'change'; - function __construct($orig, $final) + function _DiffOp_Change($orig, $final) { $this->orig = $orig; $this->final = $final; @@ -508,13 +508,14 @@ public $edits; /** + * Constructor. * Computes diff between sequences of strings. * * @param $from_lines array An array of strings. * (Typically these are lines from a file.) * @param $to_lines array An array of strings. */ - function __construct($from_lines, $to_lines) + function Diff($from_lines, $to_lines) { $eng = new _DiffEngine; $this->edits = $eng->diff($from_lines, $to_lines); @@ -647,6 +648,8 @@ extends Diff { /** + * Constructor. + * * Computes diff between sequences of strings. * * This can be used to compute things like @@ -667,9 +670,10 @@ * @param $mapped_to_lines array This array should * have the same number of elements as $to_lines. */ - function __construct($from_lines, $to_lines, - $mapped_from_lines, $mapped_to_lines) + function MappedDiff($from_lines, $to_lines, + $mapped_from_lines, $mapped_to_lines) { + assert(sizeof($from_lines) == sizeof($mapped_from_lines)); assert(sizeof($to_lines) == sizeof($mapped_to_lines)); @@ -862,7 +866,7 @@ */ class UnifiedDiffFormatter extends DiffFormatter { - function __construct($context_lines = 4) + function UnifiedDiffFormatter($context_lines = 4) { $this->leading_context_lines = $context_lines; $this->trailing_context_lines = $context_lines; @@ -907,7 +911,7 @@ */ class BlockDiffFormatter extends DiffFormatter { - function __construct($context_lines = 4) + function BlockDiffFormatter($context_lines = 4) { $this->leading_context_lines = $context_lines; $this->trailing_context_lines = $context_lines; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <var...@us...> - 2015-12-08 09:48:01
|
Revision: 9735 http://sourceforge.net/p/phpwiki/code/9735 Author: vargenau Date: 2015-12-08 09:47:59 +0000 (Tue, 08 Dec 2015) Log Message: ----------- Initialize x0 and y0 Modified Paths: -------------- trunk/lib/difflib.php Modified: trunk/lib/difflib.php =================================================================== --- trunk/lib/difflib.php 2015-12-08 09:47:06 UTC (rev 9734) +++ trunk/lib/difflib.php 2015-12-08 09:47:59 UTC (rev 9735) @@ -680,6 +680,8 @@ $ntrail = $this->trailing_context_lines; $this->_start_diff(); + $x0 = 0; + $y0 = 0; foreach ($diff->edits as $edit) { if ($edit->type == 'copy') { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |