downloads | documentation | faq | getting help | mailing lists | licenses | wiki | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

xdiff_file_diff_binary> <xattr_supported
[edit] Last updated: Mon, 01 Nov 2010

view this page in

CLXX. xdiff 関数

導入

xdiff 拡張モジュールは、テキストファイルおよびバイナリファイルに対しての パッチの作成および適用を行います。

要件

xdiff を使用するには libxdiff がインストールされている必要があります。 これは libxdiff のホームページ http://www.xmailserver.org/xdiff-lib.html で取得可能です。

注意: memory_limit を考慮してこれらの関数を使用するには、すくなくとも libxdiff 0.7 が必要です。

インストール手順

xdiff は、現在は PECL http://pecl.php.net/package/xdiff から取得可能です。

*nix-like システムを使用しており PEAR が使用可能な場合は、pear インストーラを使用して xdiff 拡張モジュールを インストールすることが可能です。そのためには以下のコマンドを使用します。 pear -v install xdiff

tar.gz パッケージをダウンロードし、xdiff を手動でインストールすることも 常に可能です。

例 1. xdiff の手動インストール

gunzip xdiff-xxx.tgz
tar -xvf xdiff-xxx.tar
cd xdiff-xxx
phpize
./configure && make && make install

定義済み定数

以下の定数が定義されています。 この関数の拡張モジュールが PHP 組み込みでコンパイルされているか、 実行時に動的にロードされている場合のみ使用可能です。

XDIFF_PATCH_NORMAL (integer)

XDIFF_PATCH_REVERSE (integer)

目次
xdiff_file_diff_binary --  2 つのファイルのバイナリ diff を作成する
xdiff_file_diff --  2 つのファイルの unified diff を作成する
xdiff_file_merge3 --  3 つのファイルをひとつに統合する
xdiff_file_patch_binary --  ファイルにバイナリ diff 形式のパッチを適用する
xdiff_file_patch --  ファイルに unified diff 形式のパッチを適用する
xdiff_string_diff_binary --  2 つの文字列のバイナリ diff を作成する
xdiff_string_diff --  2 つの文字列の unified diff を作成する
xdiff_string_merge3 --  3 つの文字列をひとつに統合する
xdiff_string_patch_binary --  文字列にバイナリ diff 形式のパッチを適用する
xdiff_string_patch --  文字列に unified diff 形式のパッチを適用する


add a note add a note User Contributed Notes xdiff 関数
mg 01-Jul-2008 09:00
This seems to be fixed with newer version of libxdiff (which is used by xdiff extension).

According to library changelog:
--------------------------------------
* Sun, Mar 26 2006 - Davide Libenzi
  Fixed the missing end of line problem for text diff and patch.
--------------------------------------
amir.laher 05-Apr-2005 02:09
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";

 
show source | credits | sitemap | contact | advertising | mirror sites