From 7ed41c4de14e5b454e8935c35edef4a0b3c400a9 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Wed, 29 Nov 2006 15:51:54 +0000 Subject: updates for the updater and the diff engine. - this update also includes an important change for including the diff engine, since we may need to include an updated engine before updating. This basically means that for a future update (B4 to another version) requires copying the new diff files first... the new include method should prevent this needed handwork for later versions then. git-svn-id: file:///svn/phpbb/trunk@6695 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/diff/engine.php | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) (limited to 'phpBB/includes/diff/engine.php') diff --git a/phpBB/includes/diff/engine.php b/phpBB/includes/diff/engine.php index e7740a0584..456b5233d3 100644 --- a/phpBB/includes/diff/engine.php +++ b/phpBB/includes/diff/engine.php @@ -47,11 +47,32 @@ if (!defined('IN_PHPBB')) */ class diff_engine { - function diff($from_lines, $to_lines) + function diff(&$from_lines, &$to_lines, $preserve_cr = true) { // Remove empty lines... -// array_walk($from_lines, array('diff', 'trim_newlines')); -// array_walk($to_lines, array('diff', 'trim_newlines')); + // If preserve_cr is true, we basically only change \r\n and bare \r to \n to get the same carriage returns for both files + // If it is false, we try to only use \n once per line and ommit all empty lines to be able to get a proper data diff + + if (is_array($from_lines)) + { + $from_lines = implode("\n", $from_lines); + } + + if (is_array($to_lines)) + { + $to_lines = implode("\n", $to_lines); + } + + if ($preserve_cr) + { + $from_lines = explode("\n", str_replace("\r", "\n", str_replace("\r\n", "\n", $from_lines))); + $to_lines = explode("\n", str_replace("\r", "\n", str_replace("\r\n", "\n", $to_lines))); + } + else + { + $from_lines = explode("\n", preg_replace('#[\n\r]+#', "\n", $from_lines)); + $to_lines = explode("\n", preg_replace('#[\n\r]+#', "\n", $to_lines)); + } $n_from = sizeof($from_lines); $n_to = sizeof($to_lines); -- cgit v1.2.1