[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Branko Čibej: VCDIFF patch

From: Greg Hudson <ghudson_at_MIT.EDU>
Date: 2000-10-06 18:35:43 CEST

So, it looks like we won't have actual vcdiff support for milestone 1.
I've looked over the vcdiff draft and Branko's stuff, and instruction
code sets make life kind of complicated; there's no way I could finish
up his work today.

(I'm kind of thinking that vcdiff is actually a more complicated
encoding format than we really want, given that no one else uses it
that we know of. This is a flip-flop from my earlier position, but I
hadn't realized that the encoding of vcdiff instructions was such a
complicated thing.)

I'm willing to implement partial solutions for milestone 1 if people
can identify what work they want done.

------- Forwarded Message

Replied: Fri, 06 Oct 2000 10:33:32 -0400
Replied: "brane@xbc.nu "
Return-Path: <branko.cibej@hermes.si>
Received: from MIT.EDU by po12.mit.edu (8.9.2/4.7) id JAA09151; Fri, 6 Oct 2000 09:37:31 -0400 (EDT)
Received: from guardian.hermes.si by MIT.EDU with SMTP
        id AA20639; Fri, 6 Oct 00 09:38:07 EDT
Received: from hermes.si (primus.hermes.si [193.77.5.98])
        by guardian.hermes.si (8.9.3/8.9.3) with ESMTP id PAA00975;
        Fri, 6 Oct 2000 15:36:19 +0200 (METDST)
Received: (from uucp@localhost)
        by hermes.si (8.9.3/8.9.3) id PAA22876;
        Fri, 6 Oct 2000 15:36:16 +0200
Received: from lux.hermes.si(10.17.4.137) by primus.hermes.si via smap (V2.1)
        id xma021742; Fri, 6 Oct 00 15:35:42 +0200
Received: from hermes.si by lux.hermes.si (8.8.8+Sun/SMI-SVR4)
        id PAA22634; Fri, 6 Oct 2000 15:35:42 +0200 (MET DST)
Message-Id: <39DDD52E.568EBF2A@hermes.si>
Date: Fri, 06 Oct 2000 15:35:42 +0200
From: Branko =?iso-8859-2?Q?=C8ibej?= <branko.cibej@hermes.si>
Reply-To: brane@xbc.nu
Organization: HERMES SoftLab
X-Mailer: Mozilla 4.75 [en] (Windows NT 5.0; U)
X-Accept-Language: sl,en-GB,en
Mime-Version: 1.0
To: ghudson@MIT.EDU
Cc: brane@xbc.nu
Subject: VCDIFF patch
Content-Type: multipart/mixed;
 boundary="------------8A24BE8C29DBEB9B8DB05FC7"

This is a multi-part message in MIME format.
- --------------8A24BE8C29DBEB9B8DB05FC7
Content-Type: text/plain; charset=iso-8859-2
Content-Transfer-Encoding: 7bit

Hi Greg,

I should have done this sooner, but I've been absolutely swamped
at work the last two weeks, and probably won't be able to do any
more work on SVN this month.

I'm sending you the VCDIFF stuff I managed to do. The basic infrastructure
is complete, together with the vcdiff encoder. You'll have to write the
decoder and of course hook it all up into the text delta interfaces.

Oh yeah, you'll also find that comments are a bit scarce ... but I'm sure
you'll find your way around.

As you'll see from the infrastructure, I was hoping to be able to
optimize the vcdiff stream (you'll see some magic being done about
finding the best instruction/addressing mode pair for a copy).

Obviously I should have started simpler, if I'd just copied the code
from the vcdiff paper, it would've all been done by now. Stupid me.
So right now I don't generate any instruction pairs in the encoder at all.

One caveat: encode_address_mode (in the encoder) and decode_address_mode
(in the decoder) should be called *exactly once* for each instruction,
otherwise the address cache won't be updated correctly. Yes, the address
cache is used for one window, then thrown away. This is as per spec.

Again, I apologize for not speaking up earlier. Hope I haven't
done too much harm by that.

    Brane

P.S.: Feel free to forward this to the list, if you like.
- --------------8A24BE8C29DBEB9B8DB05FC7
Content-Type: text/plain; charset=iso-8859-2;
 name="vcdiff.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="vcdiff.patch"

Index: .cvsignore
===================================================================
RCS file: /cvs/subversion/subversion/libsvn_delta/.cvsignore,v
retrieving revision 1.5
diff -u -p -r1.5 .cvsignore
- --- .cvsignore 2000/10/05 00:07:15 1.5
+++ .cvsignore 2000/10/06 13:13:33
@@ -5,3 +5,4 @@ Makefile
 *.la
 .deps
 .libs
+vcdiff_tables.c
Index: Makefile.am
===================================================================
RCS file: /cvs/subversion/subversion/libsvn_delta/Makefile.am,v
retrieving revision 1.11
diff -u -p -r1.11 Makefile.am
- --- Makefile.am 2000/10/05 00:15:55 1.11
+++ Makefile.am 2000/10/06 13:13:33
@@ -9,7 +9,8 @@ lib_LTLIBRARIES = libsvn_delta.la
 
 ## Sources needed to build each library (names canonicalized)
 libsvn_delta_la_SOURCES = xml_parse.c xml_output.c vcdiff_parse.c \
- - text_delta.c vdelta.c
+ text_delta.c vdelta.c \
+ vcdiff.c vcdiff_tables.c
 
 ## Build flags ---------
 
@@ -22,3 +23,8 @@ SUBDIRS = . tests
 
 ## Make libtool be quiet
 LIBTOOL = @LIBTOOL@ --silent
+
+
+## Additional targets
+vcdiff_tables.c: vcdiff_tables.def gen_vcdiff_tables.pl
+ perl gen_vcdiff_tables.pl > $@

- --------------8A24BE8C29DBEB9B8DB05FC7
Content-Type: application/x-unknown-content-type-hfile;
 name="vcdiff.h"
Content-Transfer-Encoding: base64
Content-Disposition: inline;
 filename="vcdiff.h"

LyogdmNkaWZmLmggLS0gUHJpdmF0ZSBoZWFkZXIgZm9yIFZDRElGRi4KICoKICogPT09PT09
PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09
PT09PQogKiBDb3B5cmlnaHQgKGMpIDIwMDAgQ29sbGFiTmV0LiAgQWxsIHJpZ2h0cyByZXNl
cnZlZC4KICogCiAqIFJlZGlzdHJpYnV0aW9uIGFuZCB1c2UgaW4gc291cmNlIGFuZCBiaW5h
cnkgZm9ybXMsIHdpdGggb3Igd2l0aG91dAogKiBtb2RpZmljYXRpb24sIGFyZSBwZXJtaXR0
ZWQgcHJvdmlkZWQgdGhhdCB0aGUgZm9sbG93aW5nIGNvbmRpdGlvbnMgYXJlCiAqIG1ldDoK
ICogCiAqIDEuIFJlZGlzdHJpYnV0aW9ucyBvZiBzb3VyY2UgY29kZSBtdXN0IHJldGFpbiB0
aGUgYWJvdmUgY29weXJpZ2h0CiAqIG5vdGljZSwgdGhpcyBsaXN0IG9mIGNvbmRpdGlvbnMg
YW5kIHRoZSBmb2xsb3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hfdCBjb3B5W1NWTl9WQ0RJRkZfQUREUl9NT0RFX0NPVU5UXTsK
fSBzdm5fdmNkaWZmX2ludl9pbnNuX3RhYmxlX3Q7CgoKLyogVGhlIGFycmF5IG9mIHN0YW5k
YXJkIGluc3RydWN0aW9uIHRhYmxlcyAqLwojZGVmaW5lIFNWTl9WQ0RJRkZfU1REX1RBQkxF
U19TSVpFIDgKZXh0ZXJuIGNvbnN0IHN2bl92Y2RpZmZfaW5zbl90YWJsZV90ICoKY29uc3Qg
c3ZuX3ZjZGlmZl9zdGRfdGFibGVzW1NWTl9WQ0RJRkZfU1REX1RBQkxFU19TSVpFXTsKCmV4
dGVybiBjb25zdCBzdm5fdmNkaWZmX2ludl9pbnNuX3RhYmxlX3QgKgpjb25zdCBzdm5fdmNk
aWZmX3N0ZF9pbnZfdGFibGVzW1NWTl9WQ0RJRkZfU1REX1RBQkxFU19TSVpFXTsKCgoKI2Vu
ZGlmIC8qIFZDRElGRl9IICovCgoKDAovKiAKICogbG9jYWwgdmFyaWFibGVzOgogKiBldmFs
OiAobG9hZC1maWxlICIuLi9zdm4tZGV2LmVsIikKICogZW5kOgogKi8K
- --------------8A24BE8C29DBEB9B8DB05FC7
Content-Type: application/x-unknown-content-type-cfile;
 name="vcdiff.c"
Content-Transfer-Encoding: base64
Content-Disposition: inline;
 filename="vcdiff.c"

LyogdmNkaWZmLmMgLS0gdmNkaWZmIGltcGxlbWVudGF0aW9uCiAqCiAqID09PT09PT09PT09
PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0K
ICogQ29weXJpZ2h0IChjKSAyMDAwIENvbGxhYk5ldC4gIEFsbCByaWdodHMgcmVzZXJ2ZWQu
CiAqIAogKiBSZWRpc3RyaWJ1dGlvbiBhbmQgdXNlIGluIHNvdXJjZSBhbmQgYmluYXJ5IGZv
cm1zLCB3aXRoIG9yIHdpdGhvdXQKICogbW9kaWZpY2F0aW9uLCBhcmUgcGVybWl0dGVkI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IGhlcmUsIGNhY2hlLCAmZW5jb2RlZCk7CiAgICAgIGluc24gPSAtMTsKICAgICAgZm9y
IChpID0gMDsgaSA8IDQ7ICsraSkKICAgICAgICB7CiAgICAgICAgICBpbnQgaW5kZXggPSBm
aW5kX2luc25faW5kZXggKCZpbnZfdGFibGUtPmNvcHlbZW5jb2RlZC50eXBlc1tpXS5tb2Rl
XSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2l6ZSwgJnplcm9f
c2l6ZSk7CiAgICAgICAgICBpZiAoaW5kZXggPj0gMCkKICAgICAgICAgICAgewogICAgICAg
ICAgICAgICphZGRyX2NvZGUgPSBlbmNvZGVkLnR5cGVzW2ldLmNvZGU7CiAgICAgICAgICAg
ICAgaWYgKCF6ZXJvX3NpemUpCiAgICAgICAgICAgICAgICByZXR1cm4gaW5kZXg7CiAgICAg
ICAgICAgICAgZWxzZSBpZiAoaW5zbiA8IDApCiAgICAgICAgICAgICAgICBpbnNuID0gaW5k
ZXg7CiAgICAgICAgICAgIH0KICAgICAgICB9CiAgICAgIHJldHVybiBpbnNuOwoKICAgIGRl
ZmF1bHQ6CiAgICAgIGFzc2VydCAoISJXcm9uZyBWQ0RJRkYgb3Bjb2RlLiIpOwogICAgfQoK
ICBhc3NlcnQgKCEiT29wcywgaG93IGRpZCBJIGdldCBoZXJlPyIpOwogIHJldHVybiAtMTsK
fQoKCgwKLyogTWFrZSBWQ0RJRkYgd2luZG93IGZyb20gZGVsdGEgd2luZG93LiBBbGxvY2F0
ZSBmcm9tIFBPT0wgKi8Kc3ZuX2Vycm9yX3QgKgpzdm5fdmNkaWZmX19lbmNvZGVfd2luZG93
ICh1bnNpZ25lZCBjaGFyICoqdmNkaWZmX3dpbmRvdywKICAgICAgICAgICAgICAgICAgICAg
ICAgICAgYXByX3NpemVfdCAqdmNkaWZmX3dpbmRvd19zaXplLAogICAgICAgICAgICAgICAg
ICAgICAgICAgICBzdm5fdHhkZWx0YV93aW5kb3dfdCAq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gICAgICAgICAgICAgICAgICAgICAg
ICAgICAKICAgICAgICBjYXNlIHN2bl90eGRlbHRhX3RhcmdldDoKICAgICAgICAgIGFkZHIg
PSBkZWx0YV93aW5kb3ctPm9wc1tpXS5vZmZzZXQgKyBkZWx0YV93aW5kb3ctPnN2aWV3X2xl
bjsKICAgICAgICBnZXRfY29weV9pbnNuOgogICAgICAgICAgaW5zbl9pbmRleCA9IGZpbmRf
aW5zbiAoaW5zbl90YWJsZSwgaW52X2luc25fdGFibGUsCiAgICAgICAgICAgICAgICAgICAg
ICAgICAgICAgICAgICAmY2FjaGUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg
ICBzdm5fdmNkaWZmX29wX2NvcHksCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg
ICBkZWx0YV93aW5kb3ctPm9wc1tpXS5sZW5ndGgsCiAgICAgICAgICAgICAgICAgICAgICAg
ICAgICAgICAgICBhZGRyLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaW5z
bl9zdHJlYW0tPmxlbiwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICZhZGRy
X2NvZGUpOwogICAgICAgICAgYnJlYWs7CgogICAgICAgIGNhc2Ugc3ZuX3R4ZGVsdGFfbmV3
OgogICAgICAgICAgaW5zbl9pbmRleCA9IGZpbmRfaW5zbiAoaW5zbl90YWJsZSwgaW52X2lu
c25fdGFibGUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAmY2FjaGUsCiAg
ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdm5fdmNkaWZmX29wX2FkZCwKICAg
ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRlbHRhX3dpbmRvdy0+b3BzW2ldLmxl
bmd0aCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIDAsIDAsIE5VTEwpOwog
ICAgICAgICAgYnJlYWs7CgogICAgICAgIGRlZmF1bHQ6CiAgICAgICAgICBhc3N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GxlbiA9IGVuY29kZV92Y2RpZmZfbnVtIChhZGRyX2NvZGUsCiAgICAg
ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpbnNuX2J1ZiArIGluc25fcG9zLAog
ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2l6ZW9mKGluc25fYnVmKSAt
IGluc25fcG9zKTsKICAgICAgICAgICAgYXNzZXJ0IChsZW4gPiAwKTsKICAgICAgICAgICAg
aW5zbl9wb3MgKz0gbGVuOwogICAgICAgICAgICBicmVhazsKCiAgICAgICAgICBjYXNlIHN2
bl92Y2RpZmZfYWRkcl9zZWxmOgogICAgICAgICAgICBsZW4gPSBlbmNvZGVfdmNkaWZmX3Jh
bmdlIChhZGRyX2NvZGUsIGluc25fc3RyZWFtLT5sZW4sCiAgICAgICAgICAgICAgICAgICAg
ICAgICAgICAgICAgICAgICAgIGluc25fYnVmICsgaW5zbl9wb3MsCiAgICAgICAgICAgICAg
ICAgICAgICAgICAgICAgICAgICAgICAgIHNpemVvZihpbnNuX2J1ZikgLSBpbnNuX3Bvcyk7
CiAgICAgICAgICAgIGFzc2VydCAobGVuID4gMCk7CiAgICAgICAgICAgIGluc25fcG9zICs9
IGxlbjsKICAgICAgICAgICAgYnJlYWs7CgogICAgICAgICAgZGVmYXVsdDoKICAgICAgICAg
ICAgYXNzZXJ0ICghIkJhZCBhZGRyZXNzaW5nIG1vZGUgaW4gVkNESUZGIGluc24uIik7CiAg
ICAgICAgICB9CgogICAgICBzdm5fc3RyaW5nX2FwcGVuZGJ5dGVzIChpbnNuX3N0cmVhbSwg
aW5zbl9idWYsIGluc25fcG9zLCBwb29sKTsKICAgIH0KCiAgLyogU3BsaWNlIHRoZSB3aW5k
b3cgdG9nZXRoZXIuICovCgogICp2Y2RpZmZfd2luZG93ID0gYXByX3BhbGxvYyAocG9vbCwg
KGluc25fc3RyZWFtLT5sZW4KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg
ICArIGRlbHRhX3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gICAgICAgICAgICAgICAgICAgICgqdmNkaWZmX3dpbmRvdykgKyB2
Y2RpZmZfcG9zLAogICAgICAgICAgICAgICAgICAgICAgICAgICBTVk5fVkNESUZGX01BWF9I
RUFERVJfU0laRSAtIHZjZGlmZl9wb3MpOwogIGFzc2VydCAobGVuID4gMCk7CiAgdmNkaWZm
X3BvcyArPSBsZW47CgogIC8qIEVuY29kZSB0aGUgc291cmNlIHNlZ21lbnQgc2l6ZSBhbmQg
cG9zaXRpb24uICovCiAgaWYgKGRlbHRhX3dpbmRvdy0+c3ZpZXdfbGVuID4gMCkKICAgIHsK
ICAgICAgbGVuID0gZW5jb2RlX3ZjZGlmZl9udW0gKGRlbHRhX3dpbmRvdy0+c3ZpZXdfbGVu
LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKCp2Y2RpZmZfd2luZG93KSArIHZj
ZGlmZl9wb3MsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBTVk5fVkNESUZGX01B
WF9IRUFERVJfU0laRSAtIHZjZGlmZl9wb3MpOwogICAgICBhc3NlcnQgKGxlbiA+IDApOwog
ICAgICB2Y2RpZmZfcG9zICs9IGxlbjsKCiAgICAgIGxlbiA9IGVuY29kZV92Y2RpZmZfbnVt
IChkZWx0YV93aW5kb3ctPnN2aWV3X29mZnNldCwKICAgICAgICAgICAgICAgICAgICAgICAg
ICAgICAgICgqdmNkaWZmX3dpbmRvdykgKyB2Y2RpZmZfcG9zLAogICAgICAgICAgICAgICAg
ICAgICAgICAgICAgICAgU1ZOX1ZDRElGRl9NQVhfSEVBREVSX1NJWkUgLSB2Y2RpZmZfcG9z
KTsKICAgICAgYXNzZXJ0IChsZW4gPiAwKTsKICAgICAgdmNkaWZmX3BvcyArPSBsZW47CiAg
ICB9CgogIGFzc2VydCAodmNkaWZmX3BvcyA8PSBTVk5fVkNESUZGX01BWF9IRUFERVJfU0la
RSk7CgogIC8qIENvcHkgdGhlIGluc3RydWN0aW9ucyBhbmQgZGF0YSBpbnRvIHRoZSB3aW5k
b3cuICovCiAgbWVtY3B5ICgoKnZjZGlmZl93aW5kb3cpICsgdmNkaWZmX3BvcywgaW5zbl9z
dHJlYW0tPmRhdGEsIGluc25fc3RyZWFtLT5sZW4pOwogIG1lbWNweSAoKCp2Y2RpZmZfd2lu
ZG93KSArIHZjZGlmZl9wb3MgKyBpbnNuX3N0cmVhbS0+bGVuLAogICAgICAgICAgZGVsdGFf
d2luZG93LT5uZXctPmRhdGEsIGRlbHRhX3dpbmRvdy0+bmV3LT5sZW4pOwogICp2Y2RpZmZf
d2luZG93X3NpemUgPSB2Y2RpZmZfcG9zICsgaW5zbl9zdHJlYW0tPmxlbiArIGRlbHRhX3dp
bmRvdy0+bmV3LT5sZW47CiAgCiAgcmV0dXJuIFNWTl9OT19FUlJPUjsKfQoKCgwKCgoKDAov
KiAKICogbG9jYWwgdmFyaWFibGVzOgogKiBldmFsOiAobG9hZC1maWxlICIuLi9zdm4tZGV2
LmVsIikKICogZW5kOgogKi8K
- --------------8A24BE8C29DBEB9B8DB05FC7
Content-Type: application/x-perl;
 name="gen_vcdiff_tables.pl"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="gen_vcdiff_tables.pl"

# gen_vcdiff_tables.pl -- Generate standard vcdiff (en|de)coding tables.
#
# ================================================================
# Copyright (c) 2000 CollabNet. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
#
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# 3. The end-user documentation included with the redistribution, if
# any, must include the following acknowlegement: "This product includes
# software developed by CollabNet (http://www.Collab.Net)."
# Alternately, this acknowlegement may appear in the software itself, if
# and wherever such third-party acknowlegements normally appear.
#
# 4. The hosted project names must not be used to endorse or promote
# products derived from this software without prior written
# permission. For written permission, please contact info@collab.net.
#
# 5. Products derived from this software may not use the "Tigris" name
# nor may "Tigris" appear in their names without prior written
# permission of CollabNet.
#
# THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
# IN NO EVENT SHALL COLLABNET OR ITS CONTRIBUTORS BE LIABLE FOR ANY
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
# GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
# ====================================================================
#
# This software may consist of voluntary contributions made by many
# individuals on behalf of CollabNet.

use strict;
use integer;

########
# "Constant" data.

# Opcodes and addressing modes.
my @opcodes = ('svn_vcdiff_op_noop',
               'svn_vcdiff_op_add',
               'svn_vcdiff_op_run',
               'svn_vcdiff_op_copy');
my @addrmodes = ('svn_vcdiff_addr_self',
                 'svn_vcdiff_addr_here',
                 'svn_vcdiff_addr_same',
                 'svn_vcdiff_addr_near_0',
                 'svn_vcdiff_addr_near_1',
                 'svn_vcdiff_addr_near_2',
                 'svn_vcdiff_addr_near_3');
my $noaddrmode = 'svn_vcdiff_addr_none';

# All addressing modes, for looping.
my @all_modes = ('self', 'here', 'same', 'near0', 'near1', 'near2', 'near3');

########
# Globals.
my $insn_count; # Number of instructions
my $code_count; # Number of instruction pairs
my $table_name; # Current table name
my @insn_table; # Data for table inverter


########
# Begin an instruction table
sub begin_table($$)
{
    my ($name, $comment) = @_;
    $table_name = $name;
    @insn_table = ([], []);
    $insn_count = 0;
    $code_count = 0;
    print("\f\n",
          "$comment\n",
          "static const svn_vcdiff_insn_table_t $table_name =\n",
          " {\n");
}

########
# End an instruction table, and generate inverse table.
sub end_table()
{
    if ($code_count != 0) { print "\n"; }
    print " };\n\n";

    # Generate inv. table for first insns with noop second insn.
    my @insns = sort {
        # Sort by second insn's opcode first, so that the noops
        # stay at the front of the list.
        my $cmp = ($insn_table[1]->[$a->{index}]->{opcode}
                   <=> $insn_table[1]->[$b->{index}]->{opcode});
        # Now sort by opcode, mode and size.
        ($cmp ? $cmp
         : (($cmp = $a->{opcode} <=> $b->{opcode}) ? $cmp
            : (($cmp = $a->{mode} <=> $b->{mode}) ? $cmp
               : ($cmp = $a->{size} <=> $b->{size}))));
    } @{$insn_table[0]};

    my %inv_table = (add => [-1, -1, -1],
                     run => [-1, -1, -1],
                     copy => [[-1, -1, -1],
                              [-1, -1, -1],
                              [-1, -1, -1],
                              [-1, -1, -1],
                              [-1, -1, -1],
                              [-1, -1, -1],
                              [-1, -1, -1]]);

    my $index = 0;
    print("static const svn_vcdiff_inv_code_t ${table_name}_inv_codes[] =\n",
          " {\n");
    foreach (@insns)
    {
        die "Aargh, bad insn table!" unless $_->{opcode} != 0;
        last if $insn_table[1]->[$_->{index}]->{opcode} != 0;
        print ",\n" if $index > 0;
        print " {$_->{size}, $_->{index}}";

        my $ix = ($_->{opcode} == 1 ? $inv_table{add}
                  : ($_->{opcode} == 2 ? $inv_table{run}
                     : $inv_table{copy}->[$_->{mode}]));
        
        if ($_->{size} == 0)
        {
            $ix->[0] = $_->{index};
        }
        else
        {
            $ix->[1] = $index unless $ix->[1] >= 0;
            $ix->[2] = $index;
        }
        ++$index;
    }
    print "\n" if $index > 0;
    print " };\n\n";

    print("static const svn_vcdiff_inv_insn_table_t ${table_name}_inv =\n",
          " {\n");
    foreach ($inv_table{add}, $inv_table{run})
    {
        print " {$_->[0], ";
        if ($_->[1] < 0)
        {
            print "NULL, NULL},\n";
        }
        else
        {
            print("&${table_name}_inv_codes[$_->[1]], ",
                  "&${table_name}_inv_codes[$_->[2]]},\n");
        }
    }
    print " {\n";
    for (0..6)
    {
        my $ix = $inv_table{copy}->[$_];
        print ",\n" if $_ > 0;
        print " {$ix->[0], ";
        if ($ix->[1] < 0)
        {
            print "NULL, NULL}";
        }
        else
        {
            print("&${table_name}_inv_codes[$ix->[1]], ",
                  "&${table_name}_inv_codes[$ix->[2]]}");
        }
    }
    print "\n }\n };\n\n";
}


########
# Emit a pair of instructions
sub emit($$)
{
    my ($insn1, $insn2) = @_;
    my $comma = ', ';

    if ($code_count != 0) { print ",\n"; }
    print ' {';
    foreach ($insn1, $insn2)
    {
        my $opcode = $opcodes[$_->{'opcode'}];
        my $addrmode = ($_->{'mode'} == -1 ? $noaddrmode
                        : $addrmodes[$_->{'mode'}]);
        print "{$opcode, $addrmode, $_->{'size'}}$comma";
        $comma = '}';
    }
    ++$code_count;
}

########
# Single instruction generators
sub noop()
{
    my $insn = {index => $code_count,
                opcode => 0,
                mode => -1,
                size => 0};
    push @{$insn_table[$insn_count & 1]}, $insn;
    ++$insn_count;
    return $insn;
}

sub add($)
{
    my ($size) = @_;
    my $insn = {index => $code_count,
                opcode => 1,
                mode => -1,
                size => $size};
    push @{$insn_table[$insn_count & 1]}, $insn;
    ++$insn_count;
    return $insn;
}

sub run($)
{
    my ($size) = @_;
    my $insn = {index => $code_count,
                opcode => 2,
                mode => -1,
                size => $size};
    push @{$insn_table[$insn_count & 1]}, $insn;
    ++$insn_count;
    return $insn;
}

sub copy($$)
{
    my ($size, $mode) = @_;
    my $insn_mode;
    foreach ($mode)
    {
        m/^self$/i and do { $insn_mode = 0; last; };
        m/^here$/i and do { $insn_mode = 1; last; };
        m/^same$/i and do { $insn_mode = 2; last; };
        m/^near([0-3])$/i and do { $insn_mode = 3 + $1; last; };
        die "Invalid addressing mode \`$mode\'.";
    }
    my $insn = {index => $code_count,
                opcode => 3,
                mode => $insn_mode,
                size => $size};
    push @{$insn_table[$insn_count & 1]}, $insn;
    ++$insn_count;
    return $insn;
}


# Print the file header.
print '/* GENERATED FILE -- DO NOT EDIT! Make changes to vcdiff_tables.def.
 *
 * ================================================================
 * Copyright (c) 2000 CollabNet. All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are
 * met:
 *
 * 1. Redistributions of source code must retain the above copyright
 * notice, this list of conditions and the following disclaimer.
 *
 * 2. Redistributions in binary form must reproduce the above copyright
 * notice, this list of conditions and the following disclaimer in the
 * documentation and/or other materials provided with the distribution.
 *
 * 3. The end-user documentation included with the redistribution, if
 * any, must include the following acknowlegement: "This product includes
 * software developed by CollabNet (http://www.Collab.Net)."
 * Alternately, this acknowlegement may appear in the software itself, if
 * and wherever such third-party acknowlegements normally appear.
 *
 * 4. The hosted project names must not be used to endorse or promote
 * products derived from this software without prior written
 * permission. For written permission, please contact info@collab.net.
 *
 * 5. Products derived from this software may not use the "Tigris" name
 * nor may "Tigris" appear in their names without prior written
 * permission of CollabNet.
 *
 * THIS SOFTWARE IS PROVIDED ``AS IS\'\' AND ANY EXPRESSED OR IMPLIED
 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
 * IN NO EVENT SHALL COLLABNET OR ITS CONTRIBUTORS BE LIABLE FOR ANY
 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
 * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 *
 * ====================================================================
 *
 * This software may consist of voluntary contributions made by many
 * individuals on behalf of CollabNet.
 */

#include "vcdiff.h"
#include <stddef.h>

';

# Include the code table definitions.
eval `cat vcdiff_tables.def`;

# That's it.

- --------------8A24BE8C29DBEB9B8DB05FC7
Content-Type: text/plain; charset=iso-8859-2;
 name="vcdiff_tables.def"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="vcdiff_tables.def"

# -*- Perl -*-


begin_table('vcdiff_table_0',
            '/* Standard code table, index 0 -- 4-byte copies. */');
emit(run(0), noop());
emit(add(0), noop());
for (1..14) {
    emit(add($_), noop());
}
for (@all_modes) {
    emit(copy(0, $_), noop());
}
for my $s (4..14) {
    for my $m (@all_modes) {
        emit(copy($s, $m), noop());
    }
}
for my $m (@all_modes) {
    for my $s (1..4) {
        emit(copy(0, $m), add($s));
    }
}
for my $cs (4..7) {
    for my $m (@all_modes) {
        for my $as (1..4) {
            emit(copy($cs, $m), add($as));
        }
    }
}
for my $s1 (4..7) {
    for my $s2 (4..7) {
        emit(copy($s1, 'self'), copy($s2, 'self'));
    }
}
end_table();


begin_table('vcdiff_table_1',
            '/* Standard code table, index 1 -- 3-byte copies. */');
emit(run(0), noop());
emit(add(0), noop());
for (1..14) {
    emit(add($_), noop());
}
for (@all_modes) {
    emit(copy(0, $_), noop());
}
for my $s (3..13) {
    for my $m (@all_modes) {
        emit(copy($s, $m), noop());
    }
}
for my $m (@all_modes) {
    for my $s (1..4) {
        emit(copy(0, $m), add($s));
    }
}
for my $cs (3..6) {
    for my $m (@all_modes) {
        for my $as (1..4) {
            emit(copy($cs, $m), add($as));
        }
    }
}
for my $s1 (3..6) {
    for my $s2 (3..6) {
        emit(copy($s1, 'self'), copy($s2, 'self'));
    }
}
end_table();


# Standard instructin tables and inverse tables.
print ("\f\n",
       "/* Standard VCDIFF decoding tables. */\n",
       "const svn_vcdiff_insn_table_t *\n",
       "const svn_vcdiff_std_tables[SVN_VCDIFF_STD_TABLES_SIZE] = \n",
       " {\n",
       " &vcdiff_table_0,\n",
       " &vcdiff_table_1,\n",
       " NULL,\n",
       " NULL,\n",
       " NULL,\n",
       " NULL,\n",
       " NULL,\n",
       " NULL\n",
       " };\n\n",
       "/* Standard VCDIFF encoding tables. */\n",
       "const svn_vcdiff_inv_insn_table_t *\n",
       "const svn_vcdiff_std_inv_tables[SVN_VCDIFF_STD_TABLES_SIZE] = \n",
       " {\n",
       " &vcdiff_table_0_inv,\n",
       " &vcdiff_table_1_inv,\n",
       " NULL,\n",
       " NULL,\n",
       " NULL,\n",
       " NULL,\n",
       " NULL,\n",
       " NULL\n",
       " };\n\n",
       );

- --------------8A24BE8C29DBEB9B8DB05FC7--

------- End of Forwarded Message
Received on Sat Oct 21 14:36:10 2006

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.