Skip to content
57 changes: 41 additions & 16 deletions reference/xdiff/functions/xdiff-string-rabdiff.xml
Original file line number Diff line number Diff line change
@@ -1,29 +1,34 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<!-- Generated by xml_proto.php v2.0. Found in /scripts directory of phpdoc. -->
<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>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not how union types are tagged.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My bad. I didn't see that.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixing it

<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 +40,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,22 +59,42 @@
<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,&return.falseforfailure;.
</para>
</refsect1>

<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title>Creation of a binary diff between two strings</title>
<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
Expand Down