Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
99 changes: 64 additions & 35 deletions reference/xdiff/functions/xdiff-string-rabdiff.xml
Original file line number Diff line number Diff line change
@@ -1,29 +1,33 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<!-- Generated by xml_proto.php v2.0. Found in /scripts directory of phpdoc. -->
<!-- Corrected function signature and description for xdiff_string_rabdiff -->
<refentry xml:id="function.xdiff-string-rabdiff" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>xdiff_string_rabdiff</refname>
<refpurpose>Make binary diff of two strings using the Rabin's polynomial fingerprinting algorithm</refpurpose>
<refpurpose>Make a binary diff of two strings using the Rabin's polynomial fingerprinting algorithm</refpurpose>
</refnamediv>

<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<type>string</type><methodname>xdiff_string_bdiff</methodname>
<type>string|false</type><methodname>xdiff_string_rabdiff</methodname>
<methodparam><type>string</type><parameter>old_data</parameter></methodparam>
<methodparam><type>string</type><parameter>new_data</parameter></methodparam>
</methodsynopsis>
<para>
Makes a binary diff of two strings and returns the result.
The difference between this function and <function>xdiff_string_bdiff</function> is different
algorithm used which should result in faster execution and smaller diff produced.
This function works with both text and binary data. Resulting patch
can be later applied using <function>xdiff_string_bpatch</function>/<function>xdiff_file_bpatch</function>.
Makes a binary diff of two strings using the Rabin's polynomial fingerprinting algorithm implemented by
<link xlink:href="&url.xdiff;">libxdiff</link>. Compared to
<function>xdiff_string_bdiff</function>, this algorithm generally produces smaller diffs and operates faster,
while remaining fully compatible with <function>xdiff_string_bpatch</function> and
<function>xdiff_file_bpatch</function> for applying patches.
</para>
<para>
This function can be used with both text and binary data. The resulting diff data can later be applied to recreate
the new version from the old one.
</para>
<para>
For more details about differences between algorithm used please check <link xlink:href="&url.xdiff;">libxdiff</link>
website.
For further information about the algorithm, see the
<link xlink:href="https://www.xmailserver.org/xdiff-lib.html">libxdiff documentation</link>.
</para>
</refsect1>

Expand All @@ -35,15 +39,15 @@
<term><parameter>old_data</parameter></term>
<listitem>
<para>
First string with binary data. It acts as "old" data.
The first string containing the "old" binary data.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>new_data</parameter></term>
<listitem>
<para>
Second string with binary data. It acts as "new" data.
The second string containing the "new" binary data.
</para>
</listitem>
</varlistentry>
Expand All @@ -54,39 +58,64 @@
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
Returns string with binary diff containing differences between "old" and "new"
data or &false; if an internal error occurred.
Returns a binary diff string containing the differences between the old and new data, or
<constant>false</constant> if an internal error occurred.
</para>
</refsect1>

<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title><function>xdiff_string_rabdiff</function> example</title>
<para>
The following example creates a binary diff between two strings and stores it for later patching.
</para>
<programlisting role="php">
<![CDATA[
<?php
$old = file_get_contents('file_v1.txt');
$new = file_get_contents('file_v2.txt');

$diff = xdiff_string_rabdiff($old, $new);
file_put_contents('patch.rdiff', $diff);
?>
]]>
</programlisting>
</example>
</para>
</refsect1>

<refsect1 role="seealso">
&reftitle.seealso;
<para>
<simplelist>
<member><function>xdiff_string_bdiff</function></member>
<member><function>xdiff_string_bpatch</function></member>
<member><function>xdiff_file_bpatch</function></member>
</simplelist>
</para>
</refsect1>

</refentry>

<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->