mirror of
https://github.com/phpbb/phpbb.git
synced 2025-07-28 12:30:42 +02:00
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
This commit is contained in:
@@ -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);
|
||||
|
Reference in New Issue
Block a user