External Libraries: Update the Text_Diff_Engine_native
class for PHP 7.2 compatibility.
This removes usage of `each()` and usage of text strings passed to `assert()`. Props bor0 Fixes #41526 git-svn-id: https://develop.svn.wordpress.org/trunk@41633 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
345aac85a6
commit
bbf0683deb
@ -18,10 +18,10 @@
|
|||||||
* Geoffrey T. Dairiki <dairiki@dairiki.org>. The original PHP version of this
|
* Geoffrey T. Dairiki <dairiki@dairiki.org>. The original PHP version of this
|
||||||
* code was written by him, and is used/adapted with his permission.
|
* code was written by him, and is used/adapted with his permission.
|
||||||
*
|
*
|
||||||
* Copyright 2004-2010 The Horde Project (http://www.horde.org/)
|
* Copyright 2004-2017 Horde LLC (http://www.horde.org/)
|
||||||
*
|
*
|
||||||
* See the enclosed file COPYING for license information (LGPL). If you did
|
* See the enclosed file COPYING for license information (LGPL). If you did
|
||||||
* not receive this file, see http://opensource.org/licenses/lgpl-license.php.
|
* not receive this file, see http://www.horde.org/licenses/lgpl21.
|
||||||
*
|
*
|
||||||
* @author Geoffrey T. Dairiki <dairiki@dairiki.org>
|
* @author Geoffrey T. Dairiki <dairiki@dairiki.org>
|
||||||
* @package Text_Diff
|
* @package Text_Diff
|
||||||
@ -189,27 +189,17 @@ class Text_Diff_Engine_native {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$matches = $ymatches[$line];
|
$matches = $ymatches[$line];
|
||||||
reset($matches);
|
foreach ($matches as $y) {
|
||||||
while (list(, $y) = each($matches)) {
|
|
||||||
if (empty($this->in_seq[$y])) {
|
if (empty($this->in_seq[$y])) {
|
||||||
$k = $this->_lcsPos($y);
|
$k = $this->_lcsPos($y);
|
||||||
assert($k > 0);
|
assert($k > 0);
|
||||||
$ymids[$k] = $ymids[$k - 1];
|
$ymids[$k] = $ymids[$k - 1];
|
||||||
break;
|
break;
|
||||||
}
|
} elseif ($y > $this->seq[$k - 1]) {
|
||||||
}
|
|
||||||
while (list(, $y) = each($matches)) {
|
|
||||||
if ($y > $this->seq[$k - 1]) {
|
|
||||||
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;
|
$this->in_seq[$this->seq[$k]] = false;
|
||||||
$this->seq[$k] = $y;
|
$this->seq[$k] = $y;
|
||||||
$this->in_seq[$y] = 1;
|
$this->in_seq[$y] = 1;
|
||||||
} elseif (empty($this->in_seq[$y])) {
|
|
||||||
$k = $this->_lcsPos($y);
|
|
||||||
assert($k > 0);
|
|
||||||
$ymids[$k] = $ymids[$k - 1];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -330,7 +320,7 @@ class Text_Diff_Engine_native {
|
|||||||
$i = 0;
|
$i = 0;
|
||||||
$j = 0;
|
$j = 0;
|
||||||
|
|
||||||
assert('count($lines) == count($changed)');
|
assert(count($lines) == count($changed));
|
||||||
$len = count($lines);
|
$len = count($lines);
|
||||||
$other_len = count($other_changed);
|
$other_len = count($other_changed);
|
||||||
|
|
||||||
@ -351,7 +341,7 @@ class Text_Diff_Engine_native {
|
|||||||
}
|
}
|
||||||
|
|
||||||
while ($i < $len && ! $changed[$i]) {
|
while ($i < $len && ! $changed[$i]) {
|
||||||
assert('$j < $other_len && ! $other_changed[$j]');
|
assert($j < $other_len && ! $other_changed[$j]);
|
||||||
$i++; $j++;
|
$i++; $j++;
|
||||||
while ($j < $other_len && $other_changed[$j]) {
|
while ($j < $other_len && $other_changed[$j]) {
|
||||||
$j++;
|
$j++;
|
||||||
@ -383,11 +373,11 @@ class Text_Diff_Engine_native {
|
|||||||
while ($start > 0 && $changed[$start - 1]) {
|
while ($start > 0 && $changed[$start - 1]) {
|
||||||
$start--;
|
$start--;
|
||||||
}
|
}
|
||||||
assert('$j > 0');
|
assert($j > 0);
|
||||||
while ($other_changed[--$j]) {
|
while ($other_changed[--$j]) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
assert('$j >= 0 && !$other_changed[$j]');
|
assert($j >= 0 && !$other_changed[$j]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Set CORRESPONDING to the end of the changed run, at the
|
/* Set CORRESPONDING to the end of the changed run, at the
|
||||||
@ -408,7 +398,7 @@ class Text_Diff_Engine_native {
|
|||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
assert('$j < $other_len && ! $other_changed[$j]');
|
assert($j < $other_len && ! $other_changed[$j]);
|
||||||
$j++;
|
$j++;
|
||||||
if ($j < $other_len && $other_changed[$j]) {
|
if ($j < $other_len && $other_changed[$j]) {
|
||||||
$corresponding = $i;
|
$corresponding = $i;
|
||||||
@ -424,11 +414,11 @@ class Text_Diff_Engine_native {
|
|||||||
while ($corresponding < $i) {
|
while ($corresponding < $i) {
|
||||||
$changed[--$start] = 1;
|
$changed[--$start] = 1;
|
||||||
$changed[--$i] = 0;
|
$changed[--$i] = 0;
|
||||||
assert('$j > 0');
|
assert($j > 0);
|
||||||
while ($other_changed[--$j]) {
|
while ($other_changed[--$j]) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
assert('$j >= 0 && !$other_changed[$j]');
|
assert($j >= 0 && !$other_changed[$j]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user