function _DiffEngine::_shift_boundaries in Diff 5
Same name and namespace in other branches
- 5.2 DiffEngine.php \_DiffEngine::_shift_boundaries()
- 6.2 DiffEngine.php \_DiffEngine::_shift_boundaries()
- 6 DiffEngine.php \_DiffEngine::_shift_boundaries()
- 7.3 DiffEngine.php \_DiffEngine::_shift_boundaries()
- 7.2 DiffEngine.php \_DiffEngine::_shift_boundaries()
1 call to _DiffEngine::_shift_boundaries()
- _DiffEngine::diff in ./DiffEngine.php
File
- ./DiffEngine.php, line 423
Class
- _DiffEngine
- Class used internally by Diff to actually compute the diffs.
Code
function _shift_boundaries($lines, &$changed, $other_changed) {
$i = 0;
$j = 0;
USE_ASSERTS && assert('sizeof($lines) == sizeof($changed)');
$len = sizeof($lines);
$other_len = sizeof($other_changed);
while (1) {
while ($j < $other_len && $other_changed[$j]) {
$j++;
}
while ($i < $len && !$changed[$i]) {
USE_ASSERTS && assert('$j < $other_len && ! $other_changed[$j]');
$i++;
$j++;
while ($j < $other_len && $other_changed[$j]) {
$j++;
}
}
if ($i == $len) {
break;
}
$start = $i;
while (++$i < $len && $changed[$i]) {
continue;
}
do {
$runlength = $i - $start;
while ($start > 0 && $lines[$start - 1] == $lines[$i - 1]) {
$changed[--$start] = 1;
$changed[--$i] = false;
while ($start > 0 && $changed[$start - 1]) {
$start--;
}
USE_ASSERTS && assert('$j > 0');
while ($other_changed[--$j]) {
continue;
}
USE_ASSERTS && assert('$j >= 0 && !$other_changed[$j]');
}
$corresponding = $j < $other_len ? $i : $len;
while ($i < $len && $lines[$start] == $lines[$i]) {
$changed[$start++] = false;
$changed[$i++] = 1;
while ($i < $len && $changed[$i]) {
$i++;
}
USE_ASSERTS && assert('$j < $other_len && ! $other_changed[$j]');
$j++;
if ($j < $other_len && $other_changed[$j]) {
$corresponding = $i;
while ($j < $other_len && $other_changed[$j]) {
$j++;
}
}
}
} while ($runlength != $i - $start);
while ($corresponding < $i) {
$changed[--$start] = 1;
$changed[--$i] = 0;
USE_ASSERTS && assert('$j > 0');
while ($other_changed[--$j]) {
continue;
}
USE_ASSERTS && assert('$j >= 0 && !$other_changed[$j]');
}
}
}