1

我是新尝试阅读此类文档的新手,我对 VCDIFF 的说明如何工作感到困惑,这是原始文档:

https://www.rfc-editor.org/rfc/rfc3284

这部分:

  ADD:  This instruction has two arguments, a size x and a sequence
        of x bytes to be copied.
  COPY: This instruction has two arguments, a size x and an address
        p in the string U.  The arguments specify the substring of U
        that must be copied.  We shall assert that such a substring
        must be entirely contained in either S or T.
  RUN:  This instruction has two arguments, a size x and a byte b,
        that will be repeated x times.

现在文档举了一个例子:

     a b c d e f g h i j k l m n o p
     a b c d w x y z e f g h e f g h e f g h e f g h z z z z

     COPY  4, 0
     ADD   4, w x y z
     COPY  4, 4
     COPY 12, 24
     RUN   4, z

我不明白每个操作都做了什么,我认为第一个副本是第一个“abc d”,添加现在包括“wxy z”,现在我不太明白接下来的两个副本是如何工作的。

如果我认为如果有人可以显示该指令的用途会很有用,例如“此指令有这个字符串作为结果,下一个这个”,只是为了可以逐步比较:D

谢谢。

4

1 回答 1

2

看起来在您执行此操作时,您将知道输出的长度。在这种“语言”中,输入和输出在“内存”中是连续的。所以你开始:

abcdefghijklmnop----------------------------
|<-     S    ->||<-            T         ->|

组合字符串中从偏移量 0 开始的前COPY4 个字节:

ABCDefghijklmnopABCD------------------------
|<-     S    ->||<-            T         ->|

然后ADD是 4 个字节,字面意思是w x y z

abcdefghijklmnopabcdWXYZ--------------------
|<-     S    ->||<-            T         ->|

然后COPY是从偏移量 4 开始的 4 个字节:

abcdEFGHijklmnopabcdwxyzEFGH----------------
|<-     S    ->||<-            T         ->|

然后COPY是从偏移量 24 开始的 12 个字节。这有点棘手,因为偏移量 24 是我们刚刚写的“efgh”,我们还没有写最后 8 个字节,但是如果你一次写一个字节,重叠不会没关系:

                        |<- from ->|
                            |<-  to  ->|
abcdEFGHijklmnopabcdwxyzefghEFGHEFGHEFGH----
|<-     S    ->||<-            T         ->|

最后有一个RUN4 个连续字节全部为“z”:

abcdEFGHijklmnopabcdwxyzefghefghefghefghZZZZ
|<-     S    ->||<-            T         ->|
于 2018-07-21T00:17:03.520 回答