Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 1.1.1

Bug #6251 Unified diffs get too much trailing context
Submitted: 2005-12-15 12:45 UTC Modified: 2006-12-17 11:11 UTC
From: mb at computer-leipzig dot com Assigned: yunosh
Status: Closed Package: Text_Diff
PHP Version: Irrelevant OS: Irrelevant
Roadmaps: (Not assigned)    
Subscription  


 [2005-12-15 12:45 UTC] mb at computer-leipzig dot com
Description: ------------ This bug is present in Version 0.1.1 of Text_Diff, more exactly in its diff Renderer (and likely also in earlier versions). Wether the xdiff PECL extension is loaded or not - too much trailing context is added to the generated unified diff hunks. A patch to fix this is available from http://www.computer-leipzig.com/~mb/Text_Diff/ Test script: --------------- <?php // run me from the commandline // uncomment the following line to try it with xdiff //dl('xdiff.so'); require_once 'Text/Diff.php'; require_once 'Text/Diff/Renderer.php'; require_once 'Text/Diff/Renderer/unified.php'; // i don't use php5 function my_file_put_contents($filename, $contents) { $h = fopen($filename, 'w'); fwrite($h, $contents); fclose($h); } my_file_put_contents("dt.orig", "\nOriginal Text\n\n\n\nss\nttt\n"); my_file_put_contents("dt.new", "\nModified Text\n\n\n\nss\nttt\n"); $o = explode("\n", file_get_contents("dt.orig")); $n = explode("\n", file_get_contents("dt.new")); $diffobj = new Text_Diff($o, $n); $renderer = new Text_Diff_Renderer_unified( array(leading_context_lines=>3, trailing_context_lines=>3)); echo $renderer->render($diffobj); // baseline :) //system('diff -u dt.orig dt.new'); Expected result: ---------------- @@ -1,5 +1,5 @@ -Original Text +Modified Text Actual result: -------------- @@ -1,7 +1,7 @@ -Original Text +Modified Text ss ttt

Comments

 [2005-12-16 06:08 UTC] yunosh
This bug has been fixed in CVS. If this was a documentation problem, the fix will appear on pear.php.net by the end of next Sunday (CET). If this was a problem with the pear.php.net website, the change should be live shortly. Otherwise, the fix will appear in the package's next release. Thank you for the report and for helping us make PEAR better.