3
* $Horde: framework/Text_Diff/Diff/Mapped.php,v 1.3.2.3 2008/01/04 10:37:27 jan Exp $
5
* Copyright 2007-2008 The Horde Project (http://www.horde.org/)
7
* See the enclosed file COPYING for license information (LGPL). If you did
8
* not receive this file, see http://opensource.org/licenses/lgpl-license.php.
11
* @author Geoffrey T. Dairiki <dairiki@dairiki.org>
13
class Text_Diff_Mapped extends Text_Diff {
16
* Computes a diff between sequences of strings.
18
* This can be used to compute things like case-insensitve diffs, or diffs
19
* which ignore changes in white-space.
21
* @param array $from_lines An array of strings.
22
* @param array $to_lines An array of strings.
23
* @param array $mapped_from_lines This array should have the same size
24
* number of elements as $from_lines. The
25
* elements in $mapped_from_lines and
26
* $mapped_to_lines are what is actually
27
* compared when computing the diff.
28
* @param array $mapped_to_lines This array should have the same number
29
* of elements as $to_lines.
31
function Text_Diff_Mapped($from_lines, $to_lines,
32
$mapped_from_lines, $mapped_to_lines)
34
assert(count($from_lines) == count($mapped_from_lines));
35
assert(count($to_lines) == count($mapped_to_lines));
37
parent::Text_Diff($mapped_from_lines, $mapped_to_lines);
40
for ($i = 0; $i < count($this->_edits); $i++) {
41
$orig = &$this->_edits[$i]->orig;
42
if (is_array($orig)) {
43
$orig = array_slice($from_lines, $xi, count($orig));
47
$final = &$this->_edits[$i]->final;
48
if (is_array($final)) {
49
$final = array_slice($to_lines, $yi, count($final));