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

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


Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know! Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem : 40 - 10 = ?

 
 [2005-12-15 17: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 11:08 UTC] User who submitted this comment has not confirmed identity
If you submitted this note, check your email.If you do not have a message, click here to re-send
MANUAL CONFIRMATION IS NOT POSSIBLE.  Write a message to pear-dev@lists.php.net
to request the confirmation link.  All bugs/comments/patches associated with this

email address will be deleted within 48 hours if the account request is not confirmed!