note 51588 added to ref.xdiff

From: Date: Tue, 05 Apr 2005 09:09:13 +0000
Subject: note 51588 added to ref.xdiff
Groups: php.notes 
Request: Send a blank email to php-notes+get-87482@lists.php.net to get a copy of this message
the xdiff functions require your initial string to end with a \n character. When you use xdiff_string_diff, the initial string must either be zero-length or end with \n eg. $patch= xdiff_string_diff($string,$string2); if not, the patch will return an empty string. xdiff_string_patch($string,$patch); This will not normally affect xdiff_file_diff, but it's annoying nevertheless. To prevent this unexpected effect, I append a \n to the string before applying the initial diff, as follows. if (!ereg("\n$",$string)) $string.="\n"; ---- Manual Page -- http://www.php.net/manual/en/ref.xdiff.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+51588 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+51588&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+51588&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+51588&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+51588&report=yes&reason=useless Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+51588&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+51588&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#87482) next »