Hi guys, I have ported the Fossil delta algorithm to PHP from the C code.
I was looking for a usable and light delta algorithm for PHP without having to install a PHP extension (like xdiff is available but only as a PECL extension), because I have to ship PHP apps to people that can't manage the installed extensions (they often use mass hosting providers). And I have to admit that I found no PHP implementation of a delta algorithm. I looked at different delta algorithms and the one used in Fossil seemed simple and powerful enough, as well as being well-documented, and because I use Fossil and SQLite everyday and enjoy their reliability I trust the algorithm to be as well-written and efficient as they are. So here it is: http://fossil.kd2.org/kd2fw/artifact/35c4f172ad2977cc0c4f06e29b4b8e473bcdee37 A simple example of use: <?php namespace KD2; require 'Delta.php'; $delta = new Delta; $d = $delta->create( file_get_contents('orig.txt'), file_get_contents('target.txt') ); file_put_contents('delta.txt', $d); ?> It's a first shot, trying to port directly from C to PHP, my first hope was to have something that would work, and it actually works. But it's probably not very efficient and it's quite slow with large binary blobs. So there's probably a lot of room for improvement because I'm not very familiar with C types and PHP has a very special way (some may say a very PHP way) of handling integers so all the code concerning integers might look a bit hacky, sorry for that. If you have any idea on how to improve my bad handling of integers, feel free. I wrote this to be able to store deltas between revisions of text content for a PHP wiki, but if that may be of any use to anybody: just use it. Cheers, -- BohwaZ _______________________________________________ fossil-users mailing list [email protected] http://lists.fossil-scm.org:8080/cgi-bin/mailman/listinfo/fossil-users

