uptate tex diff library to 1.1.1 ver

skala
Juan Carlos Raña 17 years ago
parent d477a7ce9d
commit 563545c258
  1. 4
      main/inc/lib/pear/Text/Diff.php
  2. 4
      main/inc/lib/pear/Text/Diff/Engine/native.php
  3. 4
      main/inc/lib/pear/Text/Diff/Engine/shell.php
  4. 19
      main/inc/lib/pear/Text/Diff/Engine/string.php
  5. 7
      main/inc/lib/pear/Text/Diff/Engine/xdiff.php
  6. 4
      main/inc/lib/pear/Text/Diff/Mapped.php
  7. 8
      main/inc/lib/pear/Text/Diff/Renderer.php
  8. 4
      main/inc/lib/pear/Text/Diff/Renderer/context.php
  9. 14
      main/inc/lib/pear/Text/Diff/Renderer/inline.php
  10. 4
      main/inc/lib/pear/Text/Diff/Renderer/unified.php
  11. 4
      main/inc/lib/pear/Text/Diff/ThreeWay.php
  12. 4
      main/inc/lib/pear/Text/Diff3.php

@ -6,10 +6,10 @@
* The original PHP version of this code was written by Geoffrey T. Dairiki
* <dairiki@dairiki.org>, and is used/adapted with his permission.
*
* $Horde: framework/Text_Diff/Diff.php,v 1.11.2.11 2008/02/24 10:57:46 jan Exp $
* $Horde: framework/Text_Diff/Diff.php,v 1.11.2.12 2009/01/06 15:23:41 jan Exp $
*
* Copyright 2004 Geoffrey T. Dairiki <dairiki@dairiki.org>
* Copyright 2004-2008 The Horde Project (http://www.horde.org/)
* Copyright 2004-2009 The Horde Project (http://www.horde.org/)
*
* See the enclosed file COPYING for license information (LGPL). If you did
* not receive this file, see http://opensource.org/licenses/lgpl-license.php.

@ -18,9 +18,9 @@
* Geoffrey T. Dairiki <dairiki@dairiki.org>. The original PHP version of this
* code was written by him, and is used/adapted with his permission.
*
* $Horde: framework/Text_Diff/Diff/Engine/native.php,v 1.7.2.4 2008/01/04 10:38:10 jan Exp $
* $Horde: framework/Text_Diff/Diff/Engine/native.php,v 1.7.2.5 2009/01/06 15:23:41 jan Exp $
*
* Copyright 2004-2008 The Horde Project (http://www.horde.org/)
* Copyright 2004-2009 The Horde Project (http://www.horde.org/)
*
* See the enclosed file COPYING for license information (LGPL). If you did
* not receive this file, see http://opensource.org/licenses/lgpl-license.php.

@ -5,9 +5,9 @@
* This class uses the Unix `diff` program via shell_exec to compute the
* differences between the two input arrays.
*
* $Horde: framework/Text_Diff/Diff/Engine/shell.php,v 1.6.2.3 2008/01/04 10:37:27 jan Exp $
* $Horde: framework/Text_Diff/Diff/Engine/shell.php,v 1.6.2.4 2009/01/06 15:23:41 jan Exp $
*
* Copyright 2007-2008 The Horde Project (http://www.horde.org/)
* Copyright 2007-2009 The Horde Project (http://www.horde.org/)
*
* See the enclosed file COPYING for license information (LGPL). If you did
* not receive this file, see http://opensource.org/licenses/lgpl-license.php.

@ -10,10 +10,10 @@
* echo $renderer->render($diff);
* </code>
*
* $Horde: framework/Text_Diff/Diff/Engine/string.php,v 1.5.2.5 2008/09/10 08:31:58 jan Exp $
* $Horde: framework/Text_Diff/Diff/Engine/string.php,v 1.5.2.7 2009/07/24 13:04:43 jan Exp $
*
* Copyright 2005 Örjan Persson <o@42mm.org>
* Copyright 2005-2008 The Horde Project (http://www.horde.org/)
* Copyright 2005-2009 The Horde Project (http://www.horde.org/)
*
* See the enclosed file COPYING for license information (LGPL). If you did
* not receive this file, see http://opensource.org/licenses/lgpl-license.php.
@ -39,6 +39,19 @@ class Text_Diff_Engine_string {
*/
function diff($diff, $mode = 'autodetect')
{
// Detect line breaks.
$lnbr = "\n";
if (strpos($diff, "\r\n") !== false) {
$lnbr = "\r\n";
} elseif (strpos($diff, "\r") !== false) {
$lnbr = "\r";
}
// Make sure we have a line break at the EOF.
if (substr($diff, -strlen($lnbr)) != $lnbr) {
$diff .= $lnbr;
}
if ($mode != 'autodetect' && $mode != 'context' && $mode != 'unified') {
return PEAR::raiseError('Type of diff is unsupported');
}
@ -56,7 +69,7 @@ class Text_Diff_Engine_string {
}
// Split by new line and remove the diff header, if there is one.
$diff = explode("\n", $diff);
$diff = explode($lnbr, $diff);
if (($mode == 'context' && strpos($diff[0], '***') === 0) ||
($mode == 'unified' && strpos($diff[0], '---') === 0)) {
array_shift($diff);

@ -5,9 +5,9 @@
* This class uses the xdiff PECL package (http://pecl.php.net/package/xdiff)
* to compute the differences between the two input arrays.
*
* $Horde: framework/Text_Diff/Diff/Engine/xdiff.php,v 1.4.2.3 2008/01/04 10:37:27 jan Exp $
* $Horde: framework/Text_Diff/Diff/Engine/xdiff.php,v 1.4.2.5 2009/07/24 13:06:24 jan Exp $
*
* Copyright 2004-2008 The Horde Project (http://www.horde.org/)
* Copyright 2004-2009 The Horde Project (http://www.horde.org/)
*
* See the enclosed file COPYING for license information (LGPL). If you did
* not receive this file, see http://opensource.org/licenses/lgpl-license.php.
@ -42,6 +42,9 @@ class Text_Diff_Engine_xdiff {
* valid, albeit a little less descriptive and efficient. */
$edits = array();
foreach ($diff as $line) {
if (!strlen($line)) {
continue;
}
switch ($line[0]) {
case ' ':
$edits[] = &new Text_Diff_Op_copy(array(substr($line, 1)));

@ -1,8 +1,8 @@
<?php
/**
* $Horde: framework/Text_Diff/Diff/Mapped.php,v 1.3.2.3 2008/01/04 10:37:27 jan Exp $
* $Horde: framework/Text_Diff/Diff/Mapped.php,v 1.3.2.4 2009/01/06 15:23:41 jan Exp $
*
* Copyright 2007-2008 The Horde Project (http://www.horde.org/)
* Copyright 2007-2009 The Horde Project (http://www.horde.org/)
*
* See the enclosed file COPYING for license information (LGPL). If you did
* not receive this file, see http://opensource.org/licenses/lgpl-license.php.

@ -5,9 +5,9 @@
* This class renders the diff in classic diff format. It is intended that
* this class be customized via inheritance, to obtain fancier outputs.
*
* $Horde: framework/Text_Diff/Diff/Renderer.php,v 1.5.10.10 2008/01/04 10:37:27 jan Exp $
* $Horde: framework/Text_Diff/Diff/Renderer.php,v 1.5.10.12 2009/07/24 13:26:40 jan Exp $
*
* Copyright 2004-2008 The Horde Project (http://www.horde.org/)
* Copyright 2004-2009 The Horde Project (http://www.horde.org/)
*
* See the enclosed file COPYING for license information (LGPL). If you did
* not receive this file, see http://opensource.org/licenses/lgpl-license.php.
@ -100,7 +100,7 @@ class Text_Diff_Renderer {
/* Create a new block with as many lines as we need
* for the trailing context. */
$context = array_slice($edit->orig, 0, $ntrail);
$block[] = &new Text_Diff_Op_copy($context);
$block[] = new Text_Diff_Op_copy($context);
}
/* @todo */
$output .= $this->_block($x0, $ntrail + $xi - $x0,
@ -120,7 +120,7 @@ class Text_Diff_Renderer {
$y0 = $yi - count($context);
$block = array();
if ($context) {
$block[] = &new Text_Diff_Op_copy($context);
$block[] = new Text_Diff_Op_copy($context);
}
}
$block[] = $edit;

@ -4,9 +4,9 @@
*
* This class renders the diff in classic "context diff" format.
*
* $Horde: framework/Text_Diff/Diff/Renderer/context.php,v 1.3.2.3 2008/01/04 10:37:27 jan Exp $
* $Horde: framework/Text_Diff/Diff/Renderer/context.php,v 1.3.2.4 2009/01/06 15:23:42 jan Exp $
*
* Copyright 2004-2008 The Horde Project (http://www.horde.org/)
* Copyright 2004-2009 The Horde Project (http://www.horde.org/)
*
* See the enclosed file COPYING for license information (LGPL). If you did
* not receive this file, see http://opensource.org/licenses/lgpl-license.php.

@ -2,9 +2,9 @@
/**
* "Inline" diff renderer.
*
* $Horde: framework/Text_Diff/Diff/Renderer/inline.php,v 1.4.10.14 2008/01/04 10:37:27 jan Exp $
* $Horde: framework/Text_Diff/Diff/Renderer/inline.php,v 1.4.10.16 2009/07/24 13:25:29 jan Exp $
*
* Copyright 2004-2008 The Horde Project (http://www.horde.org/)
* Copyright 2004-2009 The Horde Project (http://www.horde.org/)
*
* See the enclosed file COPYING for license information (LGPL). If you did
* not receive this file, see http://opensource.org/licenses/lgpl-license.php.
@ -131,12 +131,14 @@ class Text_Diff_Renderer_inline extends Text_Diff_Renderer {
/* We want to split on word boundaries, but we need to
* preserve whitespace as well. Therefore we split on words,
* but include all blocks of whitespace in the wordlist. */
$diff = new Text_Diff($this->_splitOnWords($text1, $nl),
$this->_splitOnWords($text2, $nl));
$diff = new Text_Diff('native',
array($this->_splitOnWords($text1, $nl),
$this->_splitOnWords($text2, $nl)));
/* Get the diff in inline format. */
$renderer = new Text_Diff_Renderer_inline(array_merge($this->getParams(),
array('split_level' => 'words')));
$renderer = new Text_Diff_Renderer_inline
(array_merge($this->getParams(),
array('split_level' => 'words')));
/* Run the diff and get the output. */
return str_replace($nl, "\n", $renderer->render($diff)) . "\n";

@ -4,9 +4,9 @@
*
* This class renders the diff in classic "unified diff" format.
*
* $Horde: framework/Text_Diff/Diff/Renderer/unified.php,v 1.3.10.6 2008/01/04 10:37:27 jan Exp $
* $Horde: framework/Text_Diff/Diff/Renderer/unified.php,v 1.3.10.7 2009/01/06 15:23:42 jan Exp $
*
* Copyright 2004-2008 The Horde Project (http://www.horde.org/)
* Copyright 2004-2009 The Horde Project (http://www.horde.org/)
*
* See the enclosed file COPYING for license information (LGPL). If you did
* not receive this file, see http://opensource.org/licenses/lgpl-license.php.

@ -2,9 +2,9 @@
/**
* A class for computing three way diffs.
*
* $Horde: framework/Text_Diff/Diff/ThreeWay.php,v 1.3.2.3 2008/01/04 10:37:27 jan Exp $
* $Horde: framework/Text_Diff/Diff/ThreeWay.php,v 1.3.2.4 2009/01/06 15:23:41 jan Exp $
*
* Copyright 2007-2008 The Horde Project (http://www.horde.org/)
* Copyright 2007-2009 The Horde Project (http://www.horde.org/)
*
* See the enclosed file COPYING for license information (LGPL). If you did
* not receive this file, see http://opensource.org/licenses/lgpl-license.php.

@ -2,9 +2,9 @@
/**
* A class for computing three way diffs.
*
* $Horde: framework/Text_Diff/Diff3.php,v 1.2.10.6 2008/01/04 10:37:26 jan Exp $
* $Horde: framework/Text_Diff/Diff3.php,v 1.2.10.7 2009/01/06 15:23:41 jan Exp $
*
* Copyright 2007-2008 The Horde Project (http://www.horde.org/)
* Copyright 2007-2009 The Horde Project (http://www.horde.org/)
*
* See the enclosed file COPYING for license information (LGPL). If you did
* not receive this file, see http://opensource.org/licenses/lgpl-license.php.

Loading…
Cancel
Save