Re: cvs: pecl /xdiff CREDITS config.m4 php_xdiff.h xdiff.c xdiff.php
| From: | Marcin Gibula | Date: | Thu, 25 Dec 2003 11:20:27 +0000 |
| Subject: | Re: cvs: pecl /xdiff CREDITS config.m4 php_xdiff.h xdiff.c xdiff.php | ||
| References: | 1 2 3 | Groups: | php.pecl.cvs |
| Request: | Send a blank email to pecl-cvs+get-624@lists.php.net to get a copy of this message | ||
> 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:
No, _patch is for normal (text) diff, and _bpatch is for binary diff, those
two formats are totaly different. To merge them into one, additional
parameter would be needed:
string xdiff_patch(mixed file1, mixed file2, int format);
where 'format' indicates patch format. And I'm not sure if it's a good idea.
> 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 :)
I think you are right, I'll try to do it.
--
mg