Re: cvs: pecl /xdiff CREDITS config.m4 php_xdiff.h xdiff.c xdiff.php
| From: | Derick Rethans | Date: | Thu, 25 Dec 2003 11:05:09 +0000 |
| Subject: | Re: cvs: pecl /xdiff CREDITS config.m4 php_xdiff.h xdiff.c xdiff.php | ||
| References: | 1 2 3 4 | Groups: | php.pecl.cvs |
| Request: | Send a blank email to pecl-cvs+get-622@lists.php.net to get a copy of this message | ||
On Thu, 25 Dec 2003, Marcin Gibula wrote:
> > proto string xdiff_merge3(string file, string file2, string file2, string
> > dest)
> > But I now see that there is two times "file2" :)
>
> Sorry... my mistake.
>
> > BTW, is this extension/library also going to support a two-way merge
> > then?
>
> Yes, it can create text diff (or binary diff) and then patch original file
> using it, just like unix tools 'diff' and 'patch' do.
But which PHP function can I use for this then? Ah, xdiff_patch() of
course. I do see another 'problem' though and that is that the functions
do not make use of any of PHP's stream functions which would really make
a nice addition. Another point (heh, I keep on bitching ;-) is that
there are now two functions to patch (_patch and _bpatch). Wouldn't it
be possible to merge those two into one function? Perhaps the proto's
could be like this:
string xdiff_compare(mixed file1, mixed file2);
string xdiff_patch(mixed file1, mixed file2);
string xdiff_merge3(mixed file1, mixed file2, mixed file3);
where the mixed points to either a stream resource (returned from
fopen() or a string). You can also just use strings so that you can use
the functions like this (this would in my opinion the most powerful and
flexible way):
<?php
$file1 = file_get_contents("input1.txt");
$file2 = file_get_contents("input2.txt");
file_put_contents('result.txt', xdiff_patch($file1, $file2));
?>
I admit it's a bit more code to write...
You can also of course add this additional function:
xdiff_patch_file('result.txt', 'input1.txt', 'input2.txt');
(I'm only shooting comments because I'm interested in this stuff :)
regards,
Derick