Skip to content

Commit

Permalink
Updating the Diff module to 7.x-3.4
Browse files Browse the repository at this point in the history
  • Loading branch information
mwanberg committed Dec 4, 2018
1 parent 17a9124 commit 717c40b
Show file tree
Hide file tree
Showing 20 changed files with 1,051 additions and 577 deletions.
166 changes: 0 additions & 166 deletions sites/all/modules/contrib/diff/CHANGELOG.txt

This file was deleted.

59 changes: 33 additions & 26 deletions sites/all/modules/contrib/diff/DiffEngine.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ function nclosing() {
class _DiffOp_Copy extends _DiffOp {
var $type = 'copy';

function _DiffOp_Copy($orig, $closing = FALSE) {
function __construct($orig, $closing = FALSE) {
if (!is_array($closing)) {
$closing = $orig;
}
Expand All @@ -62,7 +62,7 @@ function reverse() {
class _DiffOp_Delete extends _DiffOp {
var $type = 'delete';

function _DiffOp_Delete($lines) {
function __construct($lines) {
$this->orig = $lines;
$this->closing = FALSE;
}
Expand All @@ -80,7 +80,7 @@ function reverse() {
class _DiffOp_Add extends _DiffOp {
var $type = 'add';

function _DiffOp_Add($lines) {
function __construct($lines) {
$this->closing = $lines;
$this->orig = FALSE;
}
Expand All @@ -98,7 +98,7 @@ function reverse() {
class _DiffOp_Change extends _DiffOp {
var $type = 'change';

function _DiffOp_Change($orig, $closing) {
function __construct($orig, $closing) {
$this->orig = $orig;
$this->closing = $closing;
}
Expand Down Expand Up @@ -215,11 +215,17 @@ function diff($from_lines, $to_lines) {
// Find deletes & adds.
$delete = array();
while ($xi < $n_from && $this->xchanged[$xi]) {
$delete[] = $from_lines[$xi++];
$_fl = $from_lines[$xi++];
if (strlen($_fl)) {
$delete[] = $_fl;
}
}
$add = array();
while ($yi < $n_to && $this->ychanged[$yi]) {
$add[] = $to_lines[$yi++];
$_tl = $to_lines[$yi++];
if (strlen($_tl)) {
$add[] = $_tl;
}
}
if ($delete && $add) {
$edits[] = new _DiffOp_Change($delete, $add);
Expand Down Expand Up @@ -306,15 +312,17 @@ function _diag($xoff, $xlim, $yoff, $ylim, $nchunks) {
}
$matches = $ymatches[$line];
reset($matches);
while (list ($junk, $y) = each($matches)) {
while ($y = current($matches)) {
next($matches);
if (empty($this->in_seq[$y])) {
$k = $this->_lcs_pos($y);
USE_ASSERTS && assert($k > 0);
$ymids[$k] = $ymids[$k-1];
break;
}
}
while (list ($junk, $y) = each($matches)) {
while ($y = current($matches)) {
next($matches);
if ($y > $this->seq[$k-1]) {
USE_ASSERTS && assert($y < $this->seq[$k]);
// Optimization: this is a common case:
Expand Down Expand Up @@ -448,7 +456,7 @@ function _shift_boundaries($lines, &$changed, $other_changed) {
$i = 0;
$j = 0;

USE_ASSERTS && assert('sizeof($lines) == sizeof($changed)');
USE_ASSERTS && assert(sizeof($lines) == sizeof($changed));
$len = sizeof($lines);
$other_len = sizeof($other_changed);

Expand All @@ -468,7 +476,7 @@ function _shift_boundaries($lines, &$changed, $other_changed) {
$j++;
}
while ($i < $len && ! $changed[$i]) {
USE_ASSERTS && assert('$j < $other_len && ! $other_changed[$j]');
USE_ASSERTS && assert($j < $other_len && ! $other_changed[$j]);
$i++;
$j++;
while ($j < $other_len && $other_changed[$j]) {
Expand Down Expand Up @@ -504,11 +512,11 @@ function _shift_boundaries($lines, &$changed, $other_changed) {
while ($start > 0 && $changed[$start - 1]) {
$start--;
}
USE_ASSERTS && assert('$j > 0');
USE_ASSERTS && assert($j > 0);
while ($other_changed[--$j]) {
continue;
}
USE_ASSERTS && assert('$j >= 0 && !$other_changed[$j]');
USE_ASSERTS && assert($j >= 0 && !$other_changed[$j]);
}

/*
Expand All @@ -531,7 +539,7 @@ function _shift_boundaries($lines, &$changed, $other_changed) {
while ($i < $len && $changed[$i]) {
$i++;
}
USE_ASSERTS && assert('$j < $other_len && ! $other_changed[$j]');
USE_ASSERTS && assert($j < $other_len && ! $other_changed[$j]);
$j++;
if ($j < $other_len && $other_changed[$j]) {
$corresponding = $i;
Expand All @@ -549,11 +557,11 @@ function _shift_boundaries($lines, &$changed, $other_changed) {
while ($corresponding < $i) {
$changed[--$start] = 1;
$changed[--$i] = 0;
USE_ASSERTS && assert('$j > 0');
USE_ASSERTS && assert($j > 0);
while ($other_changed[--$j]) {
continue;
}
USE_ASSERTS && assert('$j >= 0 && !$other_changed[$j]');
USE_ASSERTS && assert($j >= 0 && !$other_changed[$j]);
}
}
}
Expand All @@ -576,7 +584,7 @@ class Diff {
* (Typically these are lines from a file.)
* @param $to_lines array An array of strings.
*/
function Diff($from_lines, $to_lines) {
function __construct($from_lines, $to_lines) {
$eng = new _DiffEngine;
$this->edits = $eng->diff($from_lines, $to_lines);
//$this->_check($from_lines, $to_lines);
Expand Down Expand Up @@ -735,12 +743,11 @@ class MappedDiff extends Diff {
* @param $mapped_to_lines array This array should
* have the same number of elements as $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));
function __construct($from_lines, $to_lines, $mapped_from_lines, $mapped_to_lines) {
USE_ASSERTS && assert(sizeof($from_lines) == sizeof($mapped_from_lines));
USE_ASSERTS && assert(sizeof($to_lines) == sizeof($mapped_to_lines));

$this->Diff($mapped_from_lines, $mapped_to_lines);
parent::__construct($mapped_from_lines, $mapped_to_lines);

$xi = $yi = 0;
for ($i = 0; $i < sizeof($this->edits); $i++) {
Expand Down Expand Up @@ -950,7 +957,7 @@ function _changed($orig, $closing) {
* @subpackage DifferenceEngine
*/
class _HWLDF_WordAccumulator {
function _HWLDF_WordAccumulator() {
function __construct() {
$this->_lines = array();
$this->_line = '';
$this->_group = '';
Expand Down Expand Up @@ -995,7 +1002,7 @@ function addWords($words, $tag = '') {
$this->_flushLine($tag);
$word = drupal_substr($word, 1);
}
assert(!strstr($word, "\n"));
USE_ASSERTS && assert(!strstr($word, "\n"));
$this->_group .= $word;
}
}
Expand All @@ -1016,11 +1023,11 @@ function MAX_LINE_LENGTH() {
return 10000;
}

function WordLevelDiff($orig_lines, $closing_lines) {
function __construct($orig_lines, $closing_lines) {
list($orig_words, $orig_stripped) = $this->_split($orig_lines);
list($closing_words, $closing_stripped) = $this->_split($closing_lines);

$this->MappedDiff($orig_words, $closing_words, $orig_stripped, $closing_stripped);
parent::__construct($orig_words, $closing_words, $orig_stripped, $closing_stripped);
}

function _split($lines) {
Expand Down Expand Up @@ -1095,7 +1102,7 @@ class DrupalDiffFormatter extends DiffFormatter {
'offset' => array('x' => 0, 'y' => 0),
);

function DrupalDiffFormatter() {
function __construct() {
$this->leading_context_lines = variable_get('diff_context_lines_leading', 2);
$this->trailing_context_lines = variable_get('diff_context_lines_trailing', 2);
}
Expand Down
Loading

0 comments on commit 717c40b

Please sign in to comment.