FAQ
Edit report at http://pear.php.net/bugs/bug.php?id=16552&edit=1

ID: 16552
Updated by: jan@horde.org
Reported By: sepehriraad at gmail dot com
Summary: not expected diff output when a line splitted in two
lines
-Status: Open
+Status: Duplicate
Type: Bug
Package: Text_Diff
Operating System: Mac Leopard
Package Version: 1.1.1
PHP Version: 5.3.0
Roadmap Versions:
New Comment:

-Status: Open
+Status: Duplicate
Duplicate of #4982


Previous Comments:
------------------------------------------------------------------------

[2009-08-29 03:12:15] hodasepehrir

Description:
------------
I don't know if this is a bug or what expected; But, it's not what I
expected. First, when a line is split into two lines, I expected to see
that the splitted part was deleted from the old version and a new line
containing that in the new version was inserted. But, the diff output
ignores the line ("\n") boundaries and match the first word of the
splitted part + "\n" character from the old version with that first word
in the new version.

Also, in the output of diff, I expected to see the insertion and
deletion tag of each line on that line. But, as shows below sometimes
the opening tag of delete or insert of some line is show on its previous
line which again may shows incorrect treating of "\n" character.

These might not be a problem for a html output, but for a program that
wants to process the diff output, it will create problems.





Test script:
---------------
$lines1 = array(
"This is a test.",
"Adding random text to simulate files. Inserting a line.",
"Various Content.",
"More Content.",
"Testing diff and renderer.",
"cathy"
);
$lines2 = array(
"This is a test.",
"Adding random text to simulate files.",
"Inserting a line.",
"Various Content.",
"Replacing content.",
"Testing similarities and renderer.",
"cat"
);

$diff = new Text_Diff('native', array($lines1, $lines2));
$renderer = &new Text_Diff_Renderer_inline();
$diffout = $renderer->render($diff);






Expected result:
----------------
This is a test.
Adding random text to simulate files.<del> Inserting a line</del>
<ins>Inserting a line.</ins>
Various Content.
<del>More Content.</del><ins>Replacing content.</ins>
Testing <del>diff</del><ins>similarities</ins> and renderer.
<del>cathy</del><ins>cat</ins>

Actual result:
--------------
This is a test.
Adding random text to simulate files.<del> Inserting</del><ins>
Inserting</ins> a line.
Various Content.
<del>More Content.</del><ins>Replacing content.</ins>
Testing <del>diff</del><ins>similarities</ins> and renderer.<del>
cathy</del><ins>
cat</ins>

------------------------------------------------------------------------

Search Discussions

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppear-bugs @
categoriesphp
postedAug 30, '09 at 10:36a
activeAug 30, '09 at 10:36a
posts1
users1
websitepear.php.net

1 user in discussion

Jan: 1 post

People

Translate

site design / logo © 2022 Grokbase