|
Class: Diff
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)
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:]
diffing
-
between: a and: b
-
-
between: a and: b reverse: reverse
-
instance creation
-
new
-
return an initialized instance
diffing
-
a: gA b: gB
-
Prepare to find differences between two arrays. Each element of
the arrays is translated to an
-
diff
-
-
diff: reverse
-
-
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
-
initialize
-
konstruktor
private
-
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.
-
diag: anXoff xlim: anXlim yoff: aYoff ylim: aYlim
-
Give the compiler a chance.
-
discardConfusingLines
-
Discard lines from one file that have no matches in the other file.
-
equivMax
-
-
equivMax: something
-
-
filevec
-
-
nodiscards
-
-
nodiscards: something
-
-
shiftBoundaries
-
Adjust inserts/deletes of blank lines to join changes
as much as possible.
Change
Data
ForwardScript
ReverseScript
|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
|