aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/includes/diff/engine.php
diff options
context:
space:
mode:
authorMeik Sievertsen <acydburn@phpbb.com>2006-11-29 15:51:54 +0000
committerMeik Sievertsen <acydburn@phpbb.com>2006-11-29 15:51:54 +0000
commit7ed41c4de14e5b454e8935c35edef4a0b3c400a9 (patch)
tree6d3b94b57fc947d57ad19cdcfb2e617c001614ae /phpBB/includes/diff/engine.php
parentd417d53c0aceb79f18df31a372f78f9dc44519c7 (diff)
downloadforums-7ed41c4de14e5b454e8935c35edef4a0b3c400a9.tar
forums-7ed41c4de14e5b454e8935c35edef4a0b3c400a9.tar.gz
forums-7ed41c4de14e5b454e8935c35edef4a0b3c400a9.tar.bz2
forums-7ed41c4de14e5b454e8935c35edef4a0b3c400a9.tar.xz
forums-7ed41c4de14e5b454e8935c35edef4a0b3c400a9.zip
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
Diffstat (limited to 'phpBB/includes/diff/engine.php')
-rw-r--r--phpBB/includes/diff/engine.php27
1 files changed, 24 insertions, 3 deletions
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);