[ Index ]
 

Code source de Horde 3.1.3

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/lib/Text/ -> Diff.php (sommaire)

(pas de description)

Poids: 847 lignes (26 kb)
Inclus ou requis:0 fois
Référencé: 0 fois
Nécessite: 0 fichiers

Définit 9 classes

Text_Diff:: (9 méthodes):
  Text_Diff()
  getDiff()
  reverse()
  isEmpty()
  lcs()
  getOriginal()
  getFinal()
  _trimNewlines()
  _check()

Text_MappedDiff:: (1 méthode):
  Text_MappedDiff()

Text_Diff_Engine_xdiff:: (1 méthode):
  diff()

Text_Diff_Engine_native:: (5 méthodes):
  diff()
  _diag()
  _lcsPos()
  _compareseq()
  _shiftBoundaries()

Text_Diff_Op:: (3 méthodes):
  reverse()
  norig()
  nfinal()

Text_Diff_Op_copy:: (2 méthodes):
  Text_Diff_Op_copy()
  reverse()

Text_Diff_Op_delete:: (2 méthodes):
  Text_Diff_Op_delete()
  reverse()

Text_Diff_Op_add:: (2 méthodes):
  Text_Diff_Op_add()
  reverse()

Text_Diff_Op_change:: (2 méthodes):
  Text_Diff_Op_change()
  reverse()


Classe: Text_Diff  - X-Ref

Text_Diff

General API for generating and formatting diffs - the differences between
two sequences of strings.

The PHP diff code used in this package was originally written by Geoffrey
T. Dairiki and is used with his permission.

$Horde: framework/Text_Diff/Diff.php,v 1.11.2.7 2006/02/06 00:25:52 jan Exp $

Text_Diff($from_lines, $to_lines)   X-Ref
Computes diffs between sequences of strings.

param: array $from_lines  An array of strings.  Typically these are
param: array $to_lines    An array of strings.

getDiff()   X-Ref
Returns the array of differences.


reverse()   X-Ref
Computes a reversed diff.

Example:
<code>
$diff = &new Text_Diff($lines1, $lines2);
$rev = $diff->reverse();
</code>

return: Text_Diff  A Diff object representing the inverse of the

isEmpty()   X-Ref
Checks for an empty diff.

return: boolean  True if two sequences were identical.

lcs()   X-Ref
Computes the length of the Longest Common Subsequence (LCS).

This is mostly for diagnostic purposes.

return: integer  The length of the LCS.

getOriginal()   X-Ref
Gets the original set of lines.

This reconstructs the $from_lines parameter passed to the constructor.

return: array  The original sequence of strings.

getFinal()   X-Ref
Gets the final set of lines.

This reconstructs the $to_lines parameter passed to the constructor.

return: array  The sequence of strings.

_trimNewlines(&$line, $key)   X-Ref
Removes trailing newlines from a line of text. This is meant to be used
with array_walk().

param: string $line  The line to trim.
param: integer $key  The index of the line in the array. Not used.

_check($from_lines, $to_lines)   X-Ref
Checks a diff for validity.

This is here only for debugging purposes.

Classe: Text_MappedDiff  - X-Ref

$Horde: framework/Text_Diff/Diff.php,v 1.11.2.7 2006/02/06 00:25:52 jan Exp $

Text_MappedDiff($from_lines, $to_lines,$mapped_from_lines, $mapped_to_lines)   X-Ref
Computes a diff between sequences of strings.

This can be used to compute things like case-insensitve diffs, or diffs
which ignore changes in white-space.

param: array $from_lines         An array of strings.
param: array $to_lines           An array of strings.
param: array $mapped_from_lines  This array should have the same size
param: array $mapped_to_lines    This array should have the same number

Classe: Text_Diff_Engine_xdiff  - X-Ref

Class used internally by Diff to actually compute the diffs.  This class
uses the xdiff PECL package (http://pecl.php.net/package/xdiff) to compute
the differences between the two input arrays.

diff($from_lines, $to_lines)   X-Ref
Pas de description

Classe: Text_Diff_Engine_native  - X-Ref

Class used internally by Diff to actually compute the diffs.  This class is
implemented using native PHP code.

The algorithm used here is mostly lifted from the perl module
Algorithm::Diff (version 1.06) by Ned Konz, which is available at:
http://www.perl.com/CPAN/authors/id/N/NE/NEDKONZ/Algorithm-Diff-1.06.zip

More ideas are taken from:
http://www.ics.uci.edu/~eppstein/161/960229.html

Some ideas (and a bit of code) are taken from analyze.c, of GNU
diffutils-2.7, which can be found at:
ftp://gnudist.gnu.org/pub/gnu/diffutils/diffutils-2.7.tar.gz

Some ideas (subdivision by NCHUNKS > 2, and some optimizations) are from
Geoffrey T. Dairiki <dairiki@dairiki.org>. The original PHP version of this
code was written by him, and is used/adapted with his permission.

diff($from_lines, $to_lines)   X-Ref
Pas de description

_diag($xoff, $xlim, $yoff, $ylim, $nchunks)   X-Ref
Divides the Largest Common Subsequence (LCS) of the sequences (XOFF,
XLIM) and (YOFF, YLIM) into NCHUNKS approximately equally sized
segments.

Returns (LCS, PTS).  LCS is the length of the LCS. PTS is an array of
NCHUNKS+1 (X, Y) indexes giving the diving points between sub
sequences.  The first sub-sequence is contained in (X0, X1), (Y0, Y1),
the second in (X1, X2), (Y1, Y2) and so on.  Note that (X0, Y0) ==
(XOFF, YOFF) and (X[NCHUNKS], Y[NCHUNKS]) == (XLIM, YLIM).

This function assumes that the first lines of the specified portions of
the two files do not match, and likewise that the last lines do not
match.  The caller must trim matching lines from the beginning and end
of the portions it is going to specify.

_lcsPos($ypos)   X-Ref
Pas de description

_compareseq($xoff, $xlim, $yoff, $ylim)   X-Ref
Finds LCS of two sequences.

The results are recorded in the vectors $this->{x,y}changed[], by
storing a 1 in the element for each line that is an insertion or
deletion (ie. is not in the LCS).

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.

_shiftBoundaries($lines, &$changed, $other_changed)   X-Ref
Adjusts inserts/deletes of identical lines to join changes as much as
possible.

We do something when a run of changed lines include a line at one end
and has an excluded, identical line at the other.  We are free to
choose which identical line is included.  `compareseq' usually chooses
the one at the beginning, but usually it is cleaner to consider the
following identical line to be the "change".

This is extracted verbatim from analyze.c (GNU diffutils-2.7).

Classe: Text_Diff_Op  - X-Ref


reverse()   X-Ref
Pas de description

norig()   X-Ref
Pas de description

nfinal()   X-Ref
Pas de description

Classe: Text_Diff_Op_copy  - X-Ref


Text_Diff_Op_copy($orig, $final = false)   X-Ref
Pas de description

reverse()   X-Ref
Pas de description

Classe: Text_Diff_Op_delete  - X-Ref


Text_Diff_Op_delete($lines)   X-Ref
Pas de description

reverse()   X-Ref
Pas de description

Classe: Text_Diff_Op_add  - X-Ref


Text_Diff_Op_add($lines)   X-Ref
Pas de description

reverse()   X-Ref
Pas de description

Classe: Text_Diff_Op_change  - X-Ref


Text_Diff_Op_change($orig, $final)   X-Ref
Pas de description

reverse()   X-Ref
Pas de description



Généré le : Sun Feb 25 18:01:28 2007 par Balluche grâce à PHPXref 0.7