eXept Software AG Logo

Smalltalk/X Webserver

Documentation of class 'Diff':

Home

Documentation
www.exept.de
Everywhere
for:
[back]

Class: Diff


Inheritance:

   Object
   |
   +--Diff

Package:
stx:libtool
Category:
Collections-Support
Version:
rev: 1.7 date: 2019/07/07 17:44:59
user: cg
file: Diff.st directory: libtool
module: stx stc-classLibrary: libtool
Author:
Jakub Zelenka (zelenj7@fel.cvut.cz)
Vladislav Skoumal (skoumal@skoumal.net)
Jan Vrany (jan.vrany@fit.cvut.cz)

Description:


I'm standard diff implementation written purely in Smalltalk. I can
compute differences between two sequenceable collections, not necessarily
holding strings. Elements are compared using #=.

Result of comparison is an edit script, a linked list of Diff::Changes,
each keeping one difference: whether change is insert and/or delete,
and positions in A and B.

I'm a port of Java diff.


[instance variables:]

[class variables:]


Related information:



Class protocol:

diffing
o  between: a and: b

o  between: a and: b reverse: reverse

instance creation
o  new
return an initialized instance


Instance protocol:

diffing
o  a: gA b: gB
Prepare to find differences between two arrays. Each element of
the arrays is translated to an

o  diff

o  diff: reverse

o  diffUsingScript: bld
Get the results of comparison as an edit script. The script
is described by a list of changes. The standard ScriptBuilder
implementations provide for forward and reverse edit scripts.
Alternate implementations could, for instance, list common elements
instead of differences.
@param bld an object to build the script from change flags
@return the head of a list of changes
Some lines are obviously insertions or deletions
because they don't match anything. Detect them now,
and avoid even thinking about them in the main comparison algorithm.

initialization
o  initialize
konstruktor

private
o  compareseq: gXoff xlim: gXlim yoff: gYoff ylim: gYlim
Compare in detail contiguous subsequences of the two files
which are known, as a whole, to match each other.

The results are recorded in the vectors filevec[N].changedflag, by
storing a 1 in the element for each line that is an insertion or deletion.

The subsequence of file 0 is [XOFF, XLIM) and likewise for file 1.

Note that XLIM, YLIM are exclusive bounds.
All line numbers are origin-0 and discarded lines are not counted.

o  diag: anXoff xlim: anXlim yoff: aYoff ylim: aYlim
Give the compiler a chance.

o  discardConfusingLines
Discard lines from one file that have no matches in the other file.

o  equivMax

o  equivMax: something

o  filevec

o  nodiscards

o  nodiscards: something

o  shiftBoundaries
Adjust inserts/deletes of blank lines to join changes
as much as possible.


Private classes:

    Change
    Data
    ForwardScript
    ReverseScript

Examples:


|first second diff| first := #('prvni' 'druhy' 'treti' 'treti' 'paty' 'zeleny' 'ruzovy' ). second := #('prvni' 'treti' 'zeleny' 'ruzovy' 'treti' 'bbb' 'ccc' 'aaa' 'aaa' 'hhh' 'iii' 'mmm' 'nnn' 'ppp' 'aaa' 'aaa' ). diff := Diff between:first and:second

ST/X 7.2.0.0; WebServer 1.670 at bd0aa1f87cdd.unknown:8081; Sat, 20 Apr 2024 08:00:02 GMT